Search in sources :

Example 21 with Config

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();
}
Also used : AccessibilityManager(android.view.accessibility.AccessibilityManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 22 with Config

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 23 with Config

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 24 with Config

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);
}
Also used : Bitmap(android.graphics.Bitmap) DisplayMetrics(android.util.DisplayMetrics) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 25 with Config

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());
}
Also used : NetworkInfo(android.net.NetworkInfo) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

Config (org.robolectric.annotation.Config)158 Test (org.junit.Test)153 Intent (android.content.Intent)21 ComponentName (android.content.ComponentName)16 Bundle (android.os.Bundle)10 Activity (android.app.Activity)7 Bitmap (android.graphics.Bitmap)7 Notification (android.app.Notification)6 Button (android.widget.Button)6 TextView (android.widget.TextView)6 BuildConfig (com.firebase.ui.auth.BuildConfig)6 BuildConfig (com.onesignal.BuildConfig)6 ShadowRecyclerView (io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView)6 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)6 Properties (java.util.Properties)6 Account (android.accounts.Account)5 Network (android.net.Network)5 NetworkInfo (android.net.NetworkInfo)5 RecyclerView (android.support.v7.widget.RecyclerView)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4