diff --git a/tests/robotests/src/com/android/settings/notification/modes/ManualDurationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ManualDurationPreferenceControllerTest.java index 29fdfdd6bd3..4edb0d510e1 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ManualDurationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ManualDurationPreferenceControllerTest.java @@ -18,11 +18,9 @@ package com.android.settings.notification.modes; import static com.google.common.truth.Truth.assertThat; -import android.app.AutomaticZenRule; import android.app.Flags; import android.content.ContentResolver; import android.content.Context; -import android.net.Uri; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; @@ -31,7 +29,6 @@ import androidx.fragment.app.Fragment; import androidx.preference.Preference; import com.android.settingslib.notification.modes.TestModeBuilder; -import com.android.settingslib.notification.modes.ZenMode; import com.android.settingslib.notification.modes.ZenModesBackend; import org.junit.Before; @@ -73,10 +70,8 @@ public class ManualDurationPreferenceControllerTest { @Test public void testIsAvailable_onlyForManualDnd() { assertThat(mPrefController.isAvailable(TestModeBuilder.EXAMPLE)).isFalse(); - - ZenMode manualDnd = ZenMode.manualDndMode( - new AutomaticZenRule.Builder("id", Uri.EMPTY).build(), false); - assertThat(mPrefController.isAvailable(manualDnd)).isTrue(); + assertThat(mPrefController.isAvailable(TestModeBuilder.MANUAL_DND_ACTIVE)).isTrue(); + assertThat(mPrefController.isAvailable(TestModeBuilder.MANUAL_DND_INACTIVE)).isTrue(); } @Test diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeButtonPreferenceControllerTest.java index 47078b08697..159dadae273 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeButtonPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeButtonPreferenceControllerTest.java @@ -23,11 +23,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import android.app.AutomaticZenRule; import android.app.Flags; import android.content.ContentResolver; import android.content.Context; -import android.net.Uri; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; @@ -192,8 +190,7 @@ public final class ZenModeButtonPreferenceControllerTest { Button button = new Button(mContext); LayoutPreference pref = mock(LayoutPreference.class); when(pref.findViewById(anyInt())).thenReturn(button); - ZenMode zenMode = ZenMode.manualDndMode( - new AutomaticZenRule.Builder("manual", Uri.EMPTY).build(), false); + ZenMode zenMode = TestModeBuilder.MANUAL_DND_INACTIVE; mController.updateZenMode(pref, zenMode); button.callOnClick(); @@ -207,8 +204,7 @@ public final class ZenModeButtonPreferenceControllerTest { Button button = new Button(mContext); LayoutPreference pref = mock(LayoutPreference.class); when(pref.findViewById(anyInt())).thenReturn(button); - ZenMode zenMode = ZenMode.manualDndMode( - new AutomaticZenRule.Builder("manual", Uri.EMPTY).build(), false); + ZenMode zenMode = TestModeBuilder.MANUAL_DND_INACTIVE; mController.updateZenMode(pref, zenMode); button.callOnClick(); diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerAddPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerAddPreferenceControllerTest.java index a56e7230bde..0d20b190844 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerAddPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerAddPreferenceControllerTest.java @@ -19,7 +19,6 @@ package com.android.settings.notification.modes; import static android.app.AutomaticZenRule.TYPE_OTHER; import static android.app.AutomaticZenRule.TYPE_SCHEDULE_CALENDAR; import static android.app.AutomaticZenRule.TYPE_SCHEDULE_TIME; -import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT; import static com.android.settings.notification.modes.CharSequenceTruth.assertThat; @@ -28,7 +27,6 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.verify; -import android.app.AutomaticZenRule; import android.app.Flags; import android.content.Context; import android.net.Uri; @@ -125,12 +123,7 @@ public class ZenModeTriggerAddPreferenceControllerTest { @Test public void isAvailable_manualDND_false() { - ZenMode manualMode = ZenMode.manualDndMode(new AutomaticZenRule.Builder("Do Not Disturb", - Uri.parse("manual")) - .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) - .build(), /* isActive= */ false); - - mController.setZenMode(manualMode); + mController.setZenMode(TestModeBuilder.MANUAL_DND_INACTIVE); assertThat(mController.isAvailable()).isFalse(); } diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerCategoryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerCategoryPreferenceControllerTest.java index 4510e2048f5..bcafe47f9c7 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerCategoryPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerCategoryPreferenceControllerTest.java @@ -18,15 +18,12 @@ package com.android.settings.notification.modes; import static android.app.AutomaticZenRule.TYPE_OTHER; import static android.app.AutomaticZenRule.TYPE_SCHEDULE_CALENDAR; -import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT; import static com.google.common.truth.Truth.assertThat; -import android.app.AutomaticZenRule; import android.app.Flags; import android.content.Context; -import android.net.Uri; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.service.notification.SystemZenRules; @@ -116,12 +113,7 @@ public class ZenModeTriggerCategoryPreferenceControllerTest { @Test public void isAvailable_manualDND_false() { - ZenMode manualMode = ZenMode.manualDndMode(new AutomaticZenRule.Builder("Do Not Disturb", - Uri.parse("manual")) - .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) - .build(), /* isActive= */ false); - - mController.setZenMode(manualMode); + mController.setZenMode(TestModeBuilder.MANUAL_DND_INACTIVE); assertThat(mController.isAvailable()).isFalse(); } } diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerUpdatePreferenceControllerTest.java index 80d314c3dc0..b7af71b50fd 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerUpdatePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeTriggerUpdatePreferenceControllerTest.java @@ -19,7 +19,6 @@ package com.android.settings.notification.modes; import static android.app.AutomaticZenRule.TYPE_OTHER; import static android.app.AutomaticZenRule.TYPE_SCHEDULE_CALENDAR; import static android.app.AutomaticZenRule.TYPE_SCHEDULE_TIME; -import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT; import static com.android.settings.notification.modes.CharSequenceTruth.assertThat; @@ -35,13 +34,11 @@ import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import android.app.AlertDialog; -import android.app.AutomaticZenRule; import android.app.Flags; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.net.Uri; import android.os.Looper; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; @@ -149,12 +146,7 @@ public class ZenModeTriggerUpdatePreferenceControllerTest { @Test public void isAvailable_manualDND_false() { - ZenMode manualMode = ZenMode.manualDndMode(new AutomaticZenRule.Builder("Do Not Disturb", - Uri.parse("manual")) - .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) - .build(), /* isActive= */ false); - - mController.setZenMode(manualMode); + mController.setZenMode(TestModeBuilder.MANUAL_DND_INACTIVE); assertThat(mController.isAvailable()).isFalse(); } diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModesListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModesListPreferenceControllerTest.java index 4c16f2616bf..4fa8b8ac6c4 100644 --- a/tests/robotests/src/com/android/settings/notification/modes/ZenModesListPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModesListPreferenceControllerTest.java @@ -18,6 +18,8 @@ package com.android.settings.notification.modes; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; +import static com.android.settingslib.notification.modes.TestModeBuilder.MANUAL_DND_INACTIVE; + import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.when; @@ -71,13 +73,6 @@ public class ZenModesListPreferenceControllerTest { .build()) .build(); - private static final ZenMode TEST_MANUAL_MODE = ZenMode.manualDndMode( - new AutomaticZenRule.Builder("Do Not Disturb", Uri.EMPTY) - .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) - .setZenPolicy(new ZenPolicy.Builder().allowAllSounds().build()) - .build(), - false); - @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule( SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT); @@ -152,7 +147,7 @@ public class ZenModesListPreferenceControllerTest { @DisableFlags(Flags.FLAG_MODES_UI) public void testModesUiOff_notAvailableAndNoSearchData() { // There exist modes - when(mBackend.getModes()).thenReturn(List.of(TEST_MANUAL_MODE, TEST_MODE)); + when(mBackend.getModes()).thenReturn(List.of(MANUAL_DND_INACTIVE, TEST_MODE)); assertThat(mPrefController.isAvailable()).isFalse(); List data = new ArrayList<>(); @@ -187,20 +182,20 @@ public class ZenModesListPreferenceControllerTest { // Changing mode data so there's a different one mode doesn't keep any previous data // (and setting that state up in the caller) - when(mBackend.getModes()).thenReturn(List.of(TEST_MANUAL_MODE)); + when(mBackend.getModes()).thenReturn(List.of(MANUAL_DND_INACTIVE)); List newData = new ArrayList<>(); mPrefController.updateDynamicRawDataToIndex(newData); assertThat(newData).hasSize(1); SearchIndexableRaw newItem = newData.get(0); - assertThat(newItem.key).isEqualTo(TEST_MANUAL_MODE.getId()); + assertThat(newItem.key).isEqualTo(MANUAL_DND_INACTIVE.getId()); assertThat(newItem.title).isEqualTo("Do Not Disturb"); // set above } @Test @EnableFlags(Flags.FLAG_MODES_UI) public void testUpdateDynamicRawDataToIndex_multipleModes() { - when(mBackend.getModes()).thenReturn(List.of(TEST_MANUAL_MODE, TEST_MODE)); + when(mBackend.getModes()).thenReturn(List.of(MANUAL_DND_INACTIVE, TEST_MODE)); List data = new ArrayList<>(); mPrefController.updateDynamicRawDataToIndex(data); @@ -208,7 +203,7 @@ public class ZenModesListPreferenceControllerTest { // Should keep the order presented by getModes() SearchIndexableRaw item0 = data.get(0); - assertThat(item0.key).isEqualTo(TEST_MANUAL_MODE.getId()); + assertThat(item0.key).isEqualTo(MANUAL_DND_INACTIVE.getId()); assertThat(item0.title).isEqualTo("Do Not Disturb"); // set above SearchIndexableRaw item1 = data.get(1);