Loading src/com/android/settings/notification/ZenModeVisEffectPreferenceController.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings.notification; import android.app.NotificationManager; import android.content.Context; import android.support.v7.preference.CheckBoxPreference; import android.support.v7.preference.Preference; Loading Loading @@ -51,6 +52,10 @@ public class ZenModeVisEffectPreferenceController @Override public boolean isAvailable() { if (mEffect == NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS) { return mContext.getResources() .getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed); } return true; } Loading tests/robotests/src/com/android/settings/notification/ZenModeVisEffectPreferenceControllerTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -17,9 +17,14 @@ package com.android.settings.notification; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.mock; Loading @@ -30,6 +35,7 @@ import static org.mockito.Mockito.when; import android.app.NotificationManager; import android.content.Context; import android.content.res.Resources; import android.support.v7.preference.CheckBoxPreference; import android.support.v7.preference.PreferenceScreen; Loading Loading @@ -81,6 +87,27 @@ public class ZenModeVisEffectPreferenceControllerTest { mController.displayPreference(mScreen); } @Test public void isAvailable() { // SUPPRESSED_EFFECT_PEEK is always available: assertTrue(mController.isAvailable()); // SUPPRESSED_EFFECT_LIGHTS is only available if the device has an LED: Context mockContext = mock(Context.class); mController = new ZenModeVisEffectPreferenceController(mockContext, mock(Lifecycle.class), PREF_KEY, SUPPRESSED_EFFECT_LIGHTS, PREF_METRICS, null); Resources mockResources = mock(Resources.class); when(mockContext.getResources()).thenReturn(mockResources); when(mockResources.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) .thenReturn(false); // no light assertFalse(mController.isAvailable()); when(mockResources.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) .thenReturn(true); // has light assertTrue(mController.isAvailable()); } @Test public void updateState_notChecked() { when(mBackend.isVisualEffectSuppressed(SUPPRESSED_EFFECT_PEEK)).thenReturn(false); Loading Loading
src/com/android/settings/notification/ZenModeVisEffectPreferenceController.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.settings.notification; import android.app.NotificationManager; import android.content.Context; import android.support.v7.preference.CheckBoxPreference; import android.support.v7.preference.Preference; Loading Loading @@ -51,6 +52,10 @@ public class ZenModeVisEffectPreferenceController @Override public boolean isAvailable() { if (mEffect == NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS) { return mContext.getResources() .getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed); } return true; } Loading
tests/robotests/src/com/android/settings/notification/ZenModeVisEffectPreferenceControllerTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -17,9 +17,14 @@ package com.android.settings.notification; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.mock; Loading @@ -30,6 +35,7 @@ import static org.mockito.Mockito.when; import android.app.NotificationManager; import android.content.Context; import android.content.res.Resources; import android.support.v7.preference.CheckBoxPreference; import android.support.v7.preference.PreferenceScreen; Loading Loading @@ -81,6 +87,27 @@ public class ZenModeVisEffectPreferenceControllerTest { mController.displayPreference(mScreen); } @Test public void isAvailable() { // SUPPRESSED_EFFECT_PEEK is always available: assertTrue(mController.isAvailable()); // SUPPRESSED_EFFECT_LIGHTS is only available if the device has an LED: Context mockContext = mock(Context.class); mController = new ZenModeVisEffectPreferenceController(mockContext, mock(Lifecycle.class), PREF_KEY, SUPPRESSED_EFFECT_LIGHTS, PREF_METRICS, null); Resources mockResources = mock(Resources.class); when(mockContext.getResources()).thenReturn(mockResources); when(mockResources.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) .thenReturn(false); // no light assertFalse(mController.isAvailable()); when(mockResources.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) .thenReturn(true); // has light assertTrue(mController.isAvailable()); } @Test public void updateState_notChecked() { when(mBackend.isVisualEffectSuppressed(SUPPRESSED_EFFECT_PEEK)).thenReturn(false); Loading