Search in sources :

Example 16 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 17 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 18 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 19 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 20 with Config

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

the class ShadowContentProviderClientTest method shouldDelegateToContentProvider.

@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void shouldDelegateToContentProvider() throws Exception {
    ContentProviderClient client = contentResolver.acquireContentProviderClient(AUTHORITY);
    client.query(URI, PROJECTION, SELECTION, SELECTION_ARGS, SORT_ORDER);
    verify(provider).query(URI, PROJECTION, SELECTION, SELECTION_ARGS, SORT_ORDER);
    CancellationSignal signal = new CancellationSignal();
    client.query(URI, PROJECTION, SELECTION, SELECTION_ARGS, SORT_ORDER, signal);
    verify(provider).query(URI, PROJECTION, SELECTION, SELECTION_ARGS, SORT_ORDER, signal);
    client.insert(URI, VALUES);
    verify(provider).insert(URI, VALUES);
    client.update(URI, VALUES, SELECTION, SELECTION_ARGS);
    verify(provider).update(URI, VALUES, SELECTION, SELECTION_ARGS);
    client.delete(URI, SELECTION, SELECTION_ARGS);
    verify(provider).delete(URI, SELECTION, SELECTION_ARGS);
    client.getType(URI);
    verify(provider).getType(URI);
    client.openFile(URI, "rw");
    verify(provider).openFile(URI, "rw");
    client.openAssetFile(URI, "r");
    verify(provider).openAssetFile(URI, "r");
    final Bundle opts = new Bundle();
    client.openTypedAssetFileDescriptor(URI, MIME_TYPE, opts);
    verify(provider).openTypedAssetFile(URI, MIME_TYPE, opts);
    client.getStreamTypes(URI, MIME_TYPE);
    verify(provider).getStreamTypes(URI, MIME_TYPE);
    final ArrayList<ContentProviderOperation> ops = new ArrayList<>();
    client.applyBatch(ops);
    verify(provider).applyBatch(ops);
    final ContentValues[] values = { VALUES };
    client.bulkInsert(URI, values);
    verify(provider).bulkInsert(URI, values);
    final String method = "method";
    final String arg = "arg";
    final Bundle extras = new Bundle();
    client.call(method, arg, extras);
    verify(provider).call(method, arg, extras);
}
Also used : ContentValues(android.content.ContentValues) ContentProviderOperation(android.content.ContentProviderOperation) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) CancellationSignal(android.os.CancellationSignal) ContentProviderClient(android.content.ContentProviderClient) 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