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);
}
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();
}
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();
}
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();
}
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);
}
Aggregations