Loading tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java +16 −8 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertEquals; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading @@ -31,7 +31,6 @@ import android.provider.Settings; import android.service.notification.ZenModeConfig; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; Loading Loading @@ -189,7 +188,6 @@ public class ZenModeBackendTest { } } @Ignore @Test public void saveConversationSenders_importantToNone() { when(mNotificationManager.getNotificationPolicy()).thenReturn( Loading @@ -204,7 +202,11 @@ public class ZenModeBackendTest { mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture()); if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNotificationManager).setNotificationPolicy(captor.capture()); } Policy expected = new Policy( PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, Loading @@ -215,7 +217,6 @@ public class ZenModeBackendTest { assertEquals(expected, captor.getValue()); } @Ignore @Test public void saveConversationSenders_noneToAll() { when(mNotificationManager.getNotificationPolicy()).thenReturn(new Policy( Loading @@ -229,7 +230,11 @@ public class ZenModeBackendTest { mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture()); if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNotificationManager).setNotificationPolicy(captor.capture()); } Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, Loading @@ -240,7 +245,6 @@ public class ZenModeBackendTest { assertEquals(expected, captor.getValue()); } @Ignore @Test public void saveSenders_doesNotChangeConversations() { when(mNotificationManager.getNotificationPolicy()).thenReturn( Loading @@ -255,7 +259,11 @@ public class ZenModeBackendTest { mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture()); if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNotificationManager).setNotificationPolicy(captor.capture()); } Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, Loading tests/robotests/src/com/android/settings/notification/zen/ZenModeSliceBuilderTest.java +26 −11 Original line number Diff line number Diff line Loading @@ -17,13 +17,18 @@ package com.android.settings.notification.zen; import static android.app.slice.Slice.EXTRA_TOGGLE_STATE; import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; import static android.provider.Settings.Global.ZEN_MODE_OFF; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.provider.Settings; import androidx.slice.Slice; import androidx.slice.SliceMetadata; Loading @@ -37,12 +42,14 @@ import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowApplication; import java.util.List; Loading @@ -52,10 +59,17 @@ public class ZenModeSliceBuilderTest { private Context mContext; @Mock private NotificationManager mNm; @Before public void setUp() { mContext = RuntimeEnvironment.application; MockitoAnnotations.initMocks(this); ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm); // Set-up specs for SliceMetadata. SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS); } Loading Loading @@ -96,30 +110,31 @@ public class ZenModeSliceBuilderTest { assertThat(primaryAction.getIcon()).isNull(); } @Ignore @Test public void handleUriChange_turnOn_zenModeTurnsOn() { final Intent intent = new Intent(); intent.putExtra(EXTRA_TOGGLE_STATE, true); NotificationManager.from(mContext).setZenMode(Settings.Global.ZEN_MODE_OFF, null, ""); ZenModeSliceBuilder.handleUriChange(mContext, intent); final int zenMode = NotificationManager.from(mContext).getZenMode(); assertThat(zenMode).isEqualTo(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS); if (android.app.Flags.modesApi()) { verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true)); } else { verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any()); } } @Ignore @Test public void handleUriChange_turnOff_zenModeTurnsOff() { final Intent intent = new Intent(); intent.putExtra(EXTRA_TOGGLE_STATE, false); NotificationManager.from(mContext).setZenMode( Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, ""); ZenModeSliceBuilder.handleUriChange(mContext, intent); final int zenMode = NotificationManager.from(mContext).getZenMode(); assertThat(zenMode).isEqualTo(Settings.Global.ZEN_MODE_OFF); if (android.app.Flags.modesApi()) { verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true)); } else { verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any()); } } } tests/robotests/src/com/android/settings/notification/zen/ZenOnboardingActivityTest.java +13 −4 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ import static com.android.settings.notification.zen.ZenOnboardingActivity.isSugg import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.Flags; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.content.Context; Loading @@ -42,7 +45,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.testutils.FakeFeatureFactory; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; Loading Loading @@ -91,7 +93,6 @@ public class ZenOnboardingActivityTest { verify(mMetricsLogger).visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING); } @Ignore @Test public void saveNewSetting() { Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON); Loading @@ -103,7 +104,11 @@ public class ZenOnboardingActivityTest { verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); if (android.app.Flags.modesApi()) { verify(mNm).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNm).setNotificationPolicy(captor.capture()); } Policy actual = captor.getValue(); assertThat(actual.priorityCategories).isEqualTo(PRIORITY_CATEGORY_ALARMS Loading @@ -123,8 +128,12 @@ public class ZenOnboardingActivityTest { mActivity.save(null); verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS); if (Flags.modesApi()) { verify(mNm, never()).setNotificationPolicy(any(), anyBoolean()); } else { verify(mNm, never()).setNotificationPolicy(any()); } } @Test public void isSuggestionComplete_zenUpdated() { Loading Loading
tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java +16 −8 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertEquals; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading @@ -31,7 +31,6 @@ import android.provider.Settings; import android.service.notification.ZenModeConfig; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; Loading Loading @@ -189,7 +188,6 @@ public class ZenModeBackendTest { } } @Ignore @Test public void saveConversationSenders_importantToNone() { when(mNotificationManager.getNotificationPolicy()).thenReturn( Loading @@ -204,7 +202,11 @@ public class ZenModeBackendTest { mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture()); if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNotificationManager).setNotificationPolicy(captor.capture()); } Policy expected = new Policy( PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, Loading @@ -215,7 +217,6 @@ public class ZenModeBackendTest { assertEquals(expected, captor.getValue()); } @Ignore @Test public void saveConversationSenders_noneToAll() { when(mNotificationManager.getNotificationPolicy()).thenReturn(new Policy( Loading @@ -229,7 +230,11 @@ public class ZenModeBackendTest { mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture()); if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNotificationManager).setNotificationPolicy(captor.capture()); } Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, Loading @@ -240,7 +245,6 @@ public class ZenModeBackendTest { assertEquals(expected, captor.getValue()); } @Ignore @Test public void saveSenders_doesNotChangeConversations() { when(mNotificationManager.getNotificationPolicy()).thenReturn( Loading @@ -255,7 +259,11 @@ public class ZenModeBackendTest { mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture()); if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNotificationManager).setNotificationPolicy(captor.capture()); } Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, Loading
tests/robotests/src/com/android/settings/notification/zen/ZenModeSliceBuilderTest.java +26 −11 Original line number Diff line number Diff line Loading @@ -17,13 +17,18 @@ package com.android.settings.notification.zen; import static android.app.slice.Slice.EXTRA_TOGGLE_STATE; import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; import static android.provider.Settings.Global.ZEN_MODE_OFF; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.provider.Settings; import androidx.slice.Slice; import androidx.slice.SliceMetadata; Loading @@ -37,12 +42,14 @@ import com.android.settings.testutils.shadow.ShadowRestrictedLockUtilsInternal; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowApplication; import java.util.List; Loading @@ -52,10 +59,17 @@ public class ZenModeSliceBuilderTest { private Context mContext; @Mock private NotificationManager mNm; @Before public void setUp() { mContext = RuntimeEnvironment.application; MockitoAnnotations.initMocks(this); ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm); // Set-up specs for SliceMetadata. SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS); } Loading Loading @@ -96,30 +110,31 @@ public class ZenModeSliceBuilderTest { assertThat(primaryAction.getIcon()).isNull(); } @Ignore @Test public void handleUriChange_turnOn_zenModeTurnsOn() { final Intent intent = new Intent(); intent.putExtra(EXTRA_TOGGLE_STATE, true); NotificationManager.from(mContext).setZenMode(Settings.Global.ZEN_MODE_OFF, null, ""); ZenModeSliceBuilder.handleUriChange(mContext, intent); final int zenMode = NotificationManager.from(mContext).getZenMode(); assertThat(zenMode).isEqualTo(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS); if (android.app.Flags.modesApi()) { verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true)); } else { verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any()); } } @Ignore @Test public void handleUriChange_turnOff_zenModeTurnsOff() { final Intent intent = new Intent(); intent.putExtra(EXTRA_TOGGLE_STATE, false); NotificationManager.from(mContext).setZenMode( Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, ""); ZenModeSliceBuilder.handleUriChange(mContext, intent); final int zenMode = NotificationManager.from(mContext).getZenMode(); assertThat(zenMode).isEqualTo(Settings.Global.ZEN_MODE_OFF); if (android.app.Flags.modesApi()) { verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true)); } else { verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any()); } } }
tests/robotests/src/com/android/settings/notification/zen/ZenOnboardingActivityTest.java +13 −4 Original line number Diff line number Diff line Loading @@ -27,10 +27,13 @@ import static com.android.settings.notification.zen.ZenOnboardingActivity.isSugg import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.Flags; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.content.Context; Loading @@ -42,7 +45,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.testutils.FakeFeatureFactory; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; Loading Loading @@ -91,7 +93,6 @@ public class ZenOnboardingActivityTest { verify(mMetricsLogger).visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING); } @Ignore @Test public void saveNewSetting() { Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON); Loading @@ -103,7 +104,11 @@ public class ZenOnboardingActivityTest { verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); if (android.app.Flags.modesApi()) { verify(mNm).setNotificationPolicy(captor.capture(), eq(true)); } else { verify(mNm).setNotificationPolicy(captor.capture()); } Policy actual = captor.getValue(); assertThat(actual.priorityCategories).isEqualTo(PRIORITY_CATEGORY_ALARMS Loading @@ -123,8 +128,12 @@ public class ZenOnboardingActivityTest { mActivity.save(null); verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS); if (Flags.modesApi()) { verify(mNm, never()).setNotificationPolicy(any(), anyBoolean()); } else { verify(mNm, never()).setNotificationPolicy(any()); } } @Test public void isSuggestionComplete_zenUpdated() { Loading