Search in sources :

Example 76 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowDrawableTest method drawableShouldLoadImageOfCorrectSizeWithHdpiQualifier.

@Test
@Config(qualifiers = "hdpi")
public void drawableShouldLoadImageOfCorrectSizeWithHdpiQualifier() {
    final Drawable anImage = RuntimeEnvironment.application.getResources().getDrawable(R.drawable.robolectric);
    assertThat(anImage.getIntrinsicHeight()).isEqualTo(251);
    assertThat(anImage.getIntrinsicWidth()).isEqualTo(297);
}
Also used : BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) VectorDrawable(android.graphics.drawable.VectorDrawable) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 77 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowEnvironmentTest method isExternalStorageRemovable_shouldReturnSavedValue.

@Test
@Config(minSdk = LOLLIPOP)
public void isExternalStorageRemovable_shouldReturnSavedValue() {
    final File file = new File("/mnt/media/file");
    assertThat(Environment.isExternalStorageRemovable(file)).isFalse();
    ShadowEnvironment.setExternalStorageRemovable(file, true);
    assertThat(Environment.isExternalStorageRemovable(file)).isTrue();
}
Also used : File(java.io.File) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 78 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowEnvironmentTest method reset_shouldClearEmulatedFiles.

@Test
@Config(minSdk = LOLLIPOP)
public void reset_shouldClearEmulatedFiles() {
    final File file = new File("foo");
    ShadowEnvironment.setExternalStorageEmulated(file, true);
    assertThat(Environment.isExternalStorageEmulated(file)).isTrue();
    ShadowEnvironment.reset();
    assertThat(Environment.isExternalStorageEmulated(file)).isFalse();
}
Also used : File(java.io.File) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 79 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowEnvironmentTest method isExternalStorageEmulated_shouldReturnSavedValue.

@Test
@Config(minSdk = LOLLIPOP)
public void isExternalStorageEmulated_shouldReturnSavedValue() {
    final File file = new File("/mnt/media/file");
    assertThat(Environment.isExternalStorageEmulated(file)).isFalse();
    ShadowEnvironment.setExternalStorageEmulated(file, true);
    assertThat(Environment.isExternalStorageEmulated(file)).isTrue();
}
Also used : File(java.io.File) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 80 with Config

use of org.robolectric.annotation.Config in project robolectric by robolectric.

the class ShadowIntentTest method resolveActivityInfo_shouldReturnActivityInfoForExistingActivity.

@Test
@Config(manifest = "src/test/resources/TestAndroidManifestForActivities.xml")
public void resolveActivityInfo_shouldReturnActivityInfoForExistingActivity() {
    Context context = RuntimeEnvironment.application;
    PackageManager packageManager = context.getPackageManager();
    Intent intent = new Intent();
    intent.setClassName(context, TEST_ACTIVITY_CLASS_NAME);
    ActivityInfo activityInfo = intent.resolveActivityInfo(packageManager, PackageManager.GET_ACTIVITIES);
    assertThat(activityInfo).isNotNull();
}
Also used : Context(android.content.Context) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) 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