Search in sources :

Example 11 with ShadowContentResolver

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

the class BrightnessLevelPreferenceControllerTest method onStop_shouldUnregisterObserver.

@Test
public void onStop_shouldUnregisterObserver() {
    Context context = RuntimeEnvironment.application;
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(context, null, mPowerManager);
    ShadowContentResolver shadowContentResolver = (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
    controller.displayPreference(mScreen);
    controller.onStart();
    controller.onStop();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isEmpty();
}
Also used : Context(android.content.Context) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 12 with ShadowContentResolver

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

the class BrightnessLevelPreferenceControllerTest method onStop_shouldUnregisterObserver.

@Test
public void onStop_shouldUnregisterObserver() {
    Context context = RuntimeEnvironment.application;
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(context, null, mPowerManager);
    ShadowContentResolver shadowContentResolver = (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
    controller.displayPreference(mScreen);
    controller.onStart();
    controller.onStop();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isEmpty();
}
Also used : Context(android.content.Context) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 13 with ShadowContentResolver

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

the class BrightnessLevelPreferenceControllerTest method onStart_shouldRegisterObserver.

@Test
public void onStart_shouldRegisterObserver() {
    Context context = RuntimeEnvironment.application;
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(context, null, mPowerManager);
    ShadowContentResolver shadowContentResolver = (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
    controller.onStart();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isNotEmpty();
}
Also used : Context(android.content.Context) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 14 with ShadowContentResolver

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

the class BrightnessLevelPreferenceControllerTest method onStop_shouldUnregisterObserver.

@Test
public void onStop_shouldUnregisterObserver() {
    Context context = RuntimeEnvironment.application;
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(context, null, mPowerManager);
    ShadowContentResolver shadowContentResolver = (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
    controller.displayPreference(mScreen);
    controller.onStart();
    controller.onStop();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isEmpty();
}
Also used : Context(android.content.Context) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 15 with ShadowContentResolver

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

the class BrightnessLevelPreferenceControllerTest method onStart_shouldRegisterObserver.

@Test
public void onStart_shouldRegisterObserver() {
    Context context = RuntimeEnvironment.application;
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(context, null, mPowerManager);
    ShadowContentResolver shadowContentResolver = (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
    controller.onStart();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isNotEmpty();
    assertThat(shadowContentResolver.getContentObservers(System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isNotEmpty();
}
Also used : Context(android.content.Context) ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

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