Search in sources :

Example 6 with ShadowContentResolver

use of org.robolectric.shadows.ShadowContentResolver in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VibrateWhenRingPreferenceControllerTest method testObserver_onPause_shouldUnregisterObserver.

@Test
public void testObserver_onPause_shouldUnregisterObserver() {
    final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
    mController.displayPreference(mScreen);
    mController.onResume();
    mController.onPause();
    assertThat(shadowContentResolver.getContentObservers(Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isEmpty();
}
Also used : ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 7 with ShadowContentResolver

use of org.robolectric.shadows.ShadowContentResolver in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VibrateWhenRingPreferenceControllerTest method testObserver_onResume_shouldRegisterObserver.

@Test
public void testObserver_onResume_shouldRegisterObserver() {
    final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
    mController.displayPreference(mScreen);
    mController.onResume();
    assertThat(shadowContentResolver.getContentObservers(Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isNotEmpty();
}
Also used : ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 8 with ShadowContentResolver

use of org.robolectric.shadows.ShadowContentResolver in project android_packages_apps_Settings by omnirom.

the class BrightnessLevelPreferenceControllerTest method onStart_shouldRegisterObserver.

@Test
public void onStart_shouldRegisterObserver() {
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(mContext, null);
    ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
    controller.onStart();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isNotEmpty();
}
Also used : ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 9 with ShadowContentResolver

use of org.robolectric.shadows.ShadowContentResolver in project AmazeFileManager by TeamAmaze.

the class TextEditorActivityTest method testOpenContentUri.

@Test
public void testOpenContentUri() throws Exception {
    Uri uri = Uri.parse("content://foo.bar.test.streamprovider/temp/thisisatest.txt");
    ContentResolver contentResolver = ApplicationProvider.getApplicationContext().getContentResolver();
    ShadowContentResolver shadowContentResolver = Shadows.shadowOf(contentResolver);
    shadowContentResolver.registerInputStream(uri, new ByteArrayInputStream(fileContents.getBytes("UTF-8")));
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType("text/plain");
    intent.setData(uri);
    generateActivity(intent);
    assertEquals(fileContents, text.getText().toString().trim());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Intent(android.content.Intent) Uri(android.net.Uri) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) ContentResolver(android.content.ContentResolver) Test(org.junit.Test)

Example 10 with ShadowContentResolver

use of org.robolectric.shadows.ShadowContentResolver in project AmazeFileManager by TeamAmaze.

the class TestArchives method readArchive.

private static void readArchive(Context context, String type) {
    try {
        Uri uri = Uri.parse("content://foo.bar.test.streamprovider/temp/test-archive." + type);
        ContentResolver contentResolver = context.getContentResolver();
        ShadowContentResolver shadowContentResolver = Shadows.shadowOf(contentResolver);
        shadowContentResolver.registerInputStream(uri, new ByteArrayInputStream(readArchive(type)));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) IOException(java.io.IOException) Uri(android.net.Uri) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) ContentResolver(android.content.ContentResolver)

Aggregations

ShadowContentResolver (org.robolectric.shadows.ShadowContentResolver)18 Test (org.junit.Test)17 Context (android.content.Context)10 ContentResolver (android.content.ContentResolver)2 Uri (android.net.Uri)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Intent (android.content.Intent)1 IOException (java.io.IOException)1