Loading tests/robotests/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceControllerTest.java +30 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,10 @@ package com.android.settings.notification; import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM; import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS; import static com.android.settings.core.BasePreferenceController.AVAILABLE; import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; import static com.google.common.truth.Truth.assertThat; Loading @@ -34,6 +38,8 @@ import android.provider.Settings; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.server.notification.Flags; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading @@ -44,9 +50,15 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; /** * Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new * settings page. */ @RunWith(RobolectricTestRunner.class) @DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS) public class LockscreenNotificationMinimalismPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock(answer = Answers.RETURNS_DEEP_STUBS) Loading @@ -56,8 +68,6 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest { private Preference mPreference; static final int ON = 1; static final int OFF = 0; @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Before public void setUp() { Loading @@ -72,17 +82,33 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest { } @Test @DisableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM) @DisableFlags(Flags.FLAG_NOTIFICATION_MINIMALISM) public void display_featureFlagOff_shouldNotDisplay() { // Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is disabled Settings.Secure.putInt(mContext.getContentResolver(), LOCK_SCREEN_SHOW_NOTIFICATIONS, ON); // When: displayPreference mController.displayPreference(mScreen); // Then: The controller is CONDITIONALLY_UNAVAILABLE, preference is not visible assertThat(mPreference.isVisible()).isFalse(); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE); } @Test @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM) public void display_featureFlagOn_shouldDisplay() { // Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is enabled Settings.Secure.putInt(mContext.getContentResolver(), LOCK_SCREEN_SHOW_NOTIFICATIONS, ON); // When: displayPreference mController.displayPreference(mScreen); // Then: The controller is AVAILABLE, preference is visible assertThat(mPreference.isVisible()).isTrue(); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } @Test Loading tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java +11 −1 Original line number Diff line number Diff line Loading @@ -37,11 +37,14 @@ import android.content.Context; import android.content.pm.UserInfo; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.DisableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import androidx.preference.PreferenceScreen; import com.android.internal.widget.LockPatternUtils; import com.android.server.notification.Flags; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal; import com.android.settings.testutils.shadow.ShadowUtils; Loading @@ -49,6 +52,7 @@ import com.android.settingslib.RestrictedSwitchPreference; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; Loading @@ -59,13 +63,19 @@ import org.robolectric.annotation.Config; import java.util.Arrays; /** * Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new * settings page. */ @RunWith(RobolectricTestRunner.class) @Config(shadows = { ShadowUtils.class, ShadowRestrictedLockUtilsInternal.class, }) @DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS) public class RedactNotificationPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private DevicePolicyManager mDpm; @Mock Loading tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import android.provider.Settings; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.server.notification.Flags; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading @@ -47,9 +49,15 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; /** * Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new * settings page. */ @RunWith(RobolectricTestRunner.class) @DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS) public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock(answer = Answers.RETURNS_DEEP_STUBS) Loading @@ -57,8 +65,6 @@ public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest { private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController; private Preference mPreference; @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Before public void setUp() { Loading Loading
tests/robotests/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceControllerTest.java +30 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,10 @@ package com.android.settings.notification; import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM; import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS; import static com.android.settings.core.BasePreferenceController.AVAILABLE; import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; import static com.google.common.truth.Truth.assertThat; Loading @@ -34,6 +38,8 @@ import android.provider.Settings; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.server.notification.Flags; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading @@ -44,9 +50,15 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; /** * Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new * settings page. */ @RunWith(RobolectricTestRunner.class) @DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS) public class LockscreenNotificationMinimalismPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock(answer = Answers.RETURNS_DEEP_STUBS) Loading @@ -56,8 +68,6 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest { private Preference mPreference; static final int ON = 1; static final int OFF = 0; @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Before public void setUp() { Loading @@ -72,17 +82,33 @@ public class LockscreenNotificationMinimalismPreferenceControllerTest { } @Test @DisableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM) @DisableFlags(Flags.FLAG_NOTIFICATION_MINIMALISM) public void display_featureFlagOff_shouldNotDisplay() { // Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is disabled Settings.Secure.putInt(mContext.getContentResolver(), LOCK_SCREEN_SHOW_NOTIFICATIONS, ON); // When: displayPreference mController.displayPreference(mScreen); // Then: The controller is CONDITIONALLY_UNAVAILABLE, preference is not visible assertThat(mPreference.isVisible()).isFalse(); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE); } @Test @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM) public void display_featureFlagOn_shouldDisplay() { // Given: lockscreen show notifications, FLAG_NOTIFICATION_MINIMALISM is enabled Settings.Secure.putInt(mContext.getContentResolver(), LOCK_SCREEN_SHOW_NOTIFICATIONS, ON); // When: displayPreference mController.displayPreference(mScreen); // Then: The controller is AVAILABLE, preference is visible assertThat(mPreference.isVisible()).isTrue(); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } @Test Loading
tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java +11 −1 Original line number Diff line number Diff line Loading @@ -37,11 +37,14 @@ import android.content.Context; import android.content.pm.UserInfo; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.DisableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import androidx.preference.PreferenceScreen; import com.android.internal.widget.LockPatternUtils; import com.android.server.notification.Flags; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal; import com.android.settings.testutils.shadow.ShadowUtils; Loading @@ -49,6 +52,7 @@ import com.android.settingslib.RestrictedSwitchPreference; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; Loading @@ -59,13 +63,19 @@ import org.robolectric.annotation.Config; import java.util.Arrays; /** * Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new * settings page. */ @RunWith(RobolectricTestRunner.class) @Config(shadows = { ShadowUtils.class, ShadowRestrictedLockUtilsInternal.class, }) @DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS) public class RedactNotificationPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private DevicePolicyManager mDpm; @Mock Loading
tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ import android.provider.Settings; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.server.notification.Flags; import org.junit.Before; import org.junit.Rule; import org.junit.Test; Loading @@ -47,9 +49,15 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; /** * Disable FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS because this toggle will be replaced by the new * settings page. */ @RunWith(RobolectricTestRunner.class) @DisableFlags(Flags.FLAG_NOTIFICATION_LOCK_SCREEN_SETTINGS) public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock(answer = Answers.RETURNS_DEEP_STUBS) Loading @@ -57,8 +65,6 @@ public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest { private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController; private Preference mPreference; @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Before public void setUp() { Loading