use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowApplicationTest method shouldCorrectlyInstantiatedAccessibilityService.
@Test
@Config(minSdk = KITKAT)
public void shouldCorrectlyInstantiatedAccessibilityService() throws Exception {
AccessibilityManager accessibilityManager = (AccessibilityManager) RuntimeEnvironment.application.getSystemService(Context.ACCESSIBILITY_SERVICE);
AccessibilityManager.TouchExplorationStateChangeListener listener = createTouchListener();
assertThat(accessibilityManager.addTouchExplorationStateChangeListener(listener)).isTrue();
assertThat(accessibilityManager.removeTouchExplorationStateChangeListener(listener)).isTrue();
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowAssetManagerTest method openNonAssetShouldOpenCorrectAssetBasedOnQualifierMdpi.
@Test
@Config(qualifiers = "mdpi")
public void openNonAssetShouldOpenCorrectAssetBasedOnQualifierMdpi() throws IOException {
InputStream inputStream = assetManager.openNonAsset(0, "./res/drawable/robolectric.png", 0);
ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) inputStream;
assertThat(byteArrayInputStream.available()).isEqualTo(8141);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowAssetManagerTest method openNonAssetShouldOpenCorrectAssetBasedOnQualifierHdpi.
@Test
@Config(qualifiers = "hdpi")
public void openNonAssetShouldOpenCorrectAssetBasedOnQualifierHdpi() throws IOException {
InputStream inputStream = assetManager.openNonAsset(0, "./res/drawable/robolectric.png", 0);
ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) inputStream;
assertThat(byteArrayInputStream.available()).isEqualTo(23447);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowBitmapTest method shouldSetDensity.
@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldSetDensity() {
final Bitmap bitmap = Bitmap.createBitmap(new DisplayMetrics(), 100, 100, Bitmap.Config.ARGB_8888);
bitmap.setDensity(1000);
assertThat(bitmap.getDensity()).isEqualTo(1000);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowConnectivityManagerTest method setActiveNetworkInfo_shouldSetActiveNetwork.
@Test
@Config(minSdk = M)
public void setActiveNetworkInfo_shouldSetActiveNetwork() throws Exception {
shadowConnectivityManager.setActiveNetworkInfo(null);
assertThat(connectivityManager.getActiveNetworkInfo()).isNull();
shadowConnectivityManager.setActiveNetworkInfo(ShadowNetworkInfo.newInstance(null, ConnectivityManager.TYPE_MOBILE_HIPRI, TelephonyManager.NETWORK_TYPE_EDGE, true, false));
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
assertThat(ConnectivityManager.TYPE_MOBILE_HIPRI).isEqualTo(info.getType());
assertThat(TelephonyManager.NETWORK_TYPE_EDGE).isEqualTo(info.getSubtype());
assertThat(info.isAvailable()).isTrue();
assertThat(info.isConnected()).isFalse();
assertThat(shadowOf(connectivityManager.getActiveNetwork()).getNetId()).isEqualTo(info.getType());
}
Aggregations