Search in sources :

Example 1 with ShadowContentResolver

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

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 2 with ShadowContentResolver

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

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 3 with ShadowContentResolver

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

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 4 with ShadowContentResolver

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

the class BrightnessLevelPreferenceControllerTest method onStop_shouldUnregisterObserver.

@Test
public void onStop_shouldUnregisterObserver() {
    BrightnessLevelPreferenceController controller = new BrightnessLevelPreferenceController(mContext, null);
    ShadowContentResolver shadowContentResolver = Shadow.extract(mContext.getContentResolver());
    controller.displayPreference(mScreen);
    controller.onStart();
    controller.onStop();
    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 : ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Example 5 with ShadowContentResolver

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

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))).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 : ShadowContentResolver(org.robolectric.shadows.ShadowContentResolver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 ShadowContentResolver (org.robolectric.shadows.ShadowContentResolver)16 Context (android.content.Context)10