Loading tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java +7 −8 Original line number Diff line number Diff line Loading @@ -44,26 +44,27 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.google.common.base.Strings; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.mockito.stubbing.Answer; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowApplication; import org.robolectric.shadows.ShadowLooper; import java.util.ArrayList; @RunWith(RobolectricTestRunner.class) @LooperMode(LooperMode.Mode.LEGACY) @Config(shadows = {ShadowBluetoothUtils.class}) public class NotificationAccessSettingsTest { @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); private Context mContext; private NotificationAccessSettings mAccessSettings; @Mock private NotificationManager mNotificationManager; Loading @@ -72,9 +73,6 @@ public class NotificationAccessSettingsTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; ShadowApplication shadowApp = ShadowApplication.getInstance(); shadowApp.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager); Loading @@ -92,6 +90,7 @@ public class NotificationAccessSettingsTest { mAccessSettings.mNm = mNotificationManager; mAccessSettings.mPm = mPackageManager; ShadowBluetoothUtils.sLocalBluetoothManager = mock(LocalBluetoothManager.class); ShadowLooper.idleMainLooper(); } @Test Loading tests/robotests/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceControllerTest.java +22 −10 Original line number Diff line number Diff line Loading @@ -42,21 +42,25 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowApplication; import org.robolectric.android.util.concurrent.PausedExecutorService; import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowPausedAsyncTask; import java.util.ArrayList; import java.util.Collections; @RunWith(RobolectricTestRunner.class) @LooperMode(LooperMode.Mode.LEGACY) public class AppChannelsBypassingDndPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); @Mock private NotificationBackend mBackend; Loading @@ -65,11 +69,13 @@ public class AppChannelsBypassingDndPreferenceControllerTest { private PreferenceScreen mPreferenceScreen; private PreferenceCategory mCategory; private PausedExecutorService mExecutorService; @Before public void setUp() { MockitoAnnotations.initMocks(this); Context context = ApplicationProvider.getApplicationContext(); mExecutorService = new PausedExecutorService(); ShadowPausedAsyncTask.overrideExecutor(mExecutorService); mAppRow = new NotificationBackend.AppRow(); mAppRow.uid = 42; Loading @@ -91,7 +97,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, true, false)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mCategory.getPreferenceCount()).isEqualTo(4); // "All" + 3 channels assertThat(mCategory.getPreference(0).getTitle().toString()).isEqualTo( Loading @@ -107,7 +114,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, true, false)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mCategory.getPreference(0).isEnabled()).isTrue(); } Loading @@ -118,7 +126,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, false, true)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(((PrimarySwitchPreference) mCategory.getPreference( 1)).isSwitchEnabled()).isTrue(); Loading @@ -135,7 +144,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, false, true)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mCategory.getPreference(0).isEnabled()).isFalse(); assertThat(((PrimarySwitchPreference) mCategory.getPreference( Loading Loading @@ -185,7 +195,9 @@ public class AppChannelsBypassingDndPreferenceControllerTest { when(mBackend.getGroups(eq(mAppRow.pkg), eq(mAppRow.uid))).thenReturn(groups); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); // Check that we've added the group name as a summary to channels that have identical names. // Channels are also alphabetized. assertThat(mCategory.getPreference(1).getTitle().toString()).isEqualTo("Mail"); Loading tests/robotests/src/com/android/settings/notification/app/AppConversationListPreferenceControllerTest.java +26 −7 Original line number Diff line number Diff line Loading @@ -37,20 +37,24 @@ import androidx.test.core.app.ApplicationProvider; import com.android.settings.notification.NotificationBackend; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowApplication; import org.robolectric.android.util.concurrent.PausedExecutorService; import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowPausedAsyncTask; import java.util.ArrayList; import java.util.Arrays; @RunWith(RobolectricTestRunner.class) @LooperMode(LooperMode.Mode.LEGACY) public class AppConversationListPreferenceControllerTest { @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); private Context mContext; Loading @@ -60,11 +64,13 @@ public class AppConversationListPreferenceControllerTest { private AppConversationListPreferenceController mController; private NotificationBackend.AppRow mAppRow; private PreferenceCategory mPreference; private PausedExecutorService mExecutorService; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = ApplicationProvider.getApplicationContext(); mExecutorService = new PausedExecutorService(); ShadowPausedAsyncTask.overrideExecutor(mExecutorService); mAppRow = new NotificationBackend.AppRow(); mAppRow.uid = 42; Loading @@ -88,7 +94,8 @@ public class AppConversationListPreferenceControllerTest { )); mController.updateState(mPreference); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.getPreferenceCount()).isEqualTo(2); Loading @@ -107,7 +114,8 @@ public class AppConversationListPreferenceControllerTest { )); mController.updateState(mPreference); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.getPreferenceCount()).isEqualTo(1); Loading @@ -120,6 +128,8 @@ public class AppConversationListPreferenceControllerTest { .thenReturn(conversationList()); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isFalse(); assertThat(mPreference.getPreferenceCount()).isEqualTo(0); Loading @@ -130,6 +140,9 @@ public class AppConversationListPreferenceControllerTest { when(mBackend.getConversations(eq(mAppRow.pkg), eq(mAppRow.uid))) .thenReturn(conversationList()); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isFalse(); // Empty -> present Loading @@ -138,6 +151,9 @@ public class AppConversationListPreferenceControllerTest { conversationChannel("1", "msg", "Mario", "Messages", "M", false) )); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.getPreferenceCount()).isEqualTo(1); Loading @@ -145,6 +161,9 @@ public class AppConversationListPreferenceControllerTest { when(mBackend.getConversations(eq(mAppRow.pkg), eq(mAppRow.uid))) .thenReturn(conversationList()); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isFalse(); assertThat(mPreference.getPreferenceCount()).isEqualTo(0); } Loading Loading
tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java +7 −8 Original line number Diff line number Diff line Loading @@ -44,26 +44,27 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.google.common.base.Strings; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.mockito.stubbing.Answer; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowApplication; import org.robolectric.shadows.ShadowLooper; import java.util.ArrayList; @RunWith(RobolectricTestRunner.class) @LooperMode(LooperMode.Mode.LEGACY) @Config(shadows = {ShadowBluetoothUtils.class}) public class NotificationAccessSettingsTest { @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); private Context mContext; private NotificationAccessSettings mAccessSettings; @Mock private NotificationManager mNotificationManager; Loading @@ -72,9 +73,6 @@ public class NotificationAccessSettingsTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; ShadowApplication shadowApp = ShadowApplication.getInstance(); shadowApp.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager); Loading @@ -92,6 +90,7 @@ public class NotificationAccessSettingsTest { mAccessSettings.mNm = mNotificationManager; mAccessSettings.mPm = mPackageManager; ShadowBluetoothUtils.sLocalBluetoothManager = mock(LocalBluetoothManager.class); ShadowLooper.idleMainLooper(); } @Test Loading
tests/robotests/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceControllerTest.java +22 −10 Original line number Diff line number Diff line Loading @@ -42,21 +42,25 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowApplication; import org.robolectric.android.util.concurrent.PausedExecutorService; import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowPausedAsyncTask; import java.util.ArrayList; import java.util.Collections; @RunWith(RobolectricTestRunner.class) @LooperMode(LooperMode.Mode.LEGACY) public class AppChannelsBypassingDndPreferenceControllerTest { @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); @Mock private NotificationBackend mBackend; Loading @@ -65,11 +69,13 @@ public class AppChannelsBypassingDndPreferenceControllerTest { private PreferenceScreen mPreferenceScreen; private PreferenceCategory mCategory; private PausedExecutorService mExecutorService; @Before public void setUp() { MockitoAnnotations.initMocks(this); Context context = ApplicationProvider.getApplicationContext(); mExecutorService = new PausedExecutorService(); ShadowPausedAsyncTask.overrideExecutor(mExecutorService); mAppRow = new NotificationBackend.AppRow(); mAppRow.uid = 42; Loading @@ -91,7 +97,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, true, false)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mCategory.getPreferenceCount()).isEqualTo(4); // "All" + 3 channels assertThat(mCategory.getPreference(0).getTitle().toString()).isEqualTo( Loading @@ -107,7 +114,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, true, false)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mCategory.getPreference(0).isEnabled()).isTrue(); } Loading @@ -118,7 +126,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, false, true)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(((PrimarySwitchPreference) mCategory.getPreference( 1)).isSwitchEnabled()).isTrue(); Loading @@ -135,7 +144,8 @@ public class AppChannelsBypassingDndPreferenceControllerTest { buildGroupList(true, false, true)); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mCategory.getPreference(0).isEnabled()).isFalse(); assertThat(((PrimarySwitchPreference) mCategory.getPreference( Loading Loading @@ -185,7 +195,9 @@ public class AppChannelsBypassingDndPreferenceControllerTest { when(mBackend.getGroups(eq(mAppRow.pkg), eq(mAppRow.uid))).thenReturn(groups); mController.displayPreference(mPreferenceScreen); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); // Check that we've added the group name as a summary to channels that have identical names. // Channels are also alphabetized. assertThat(mCategory.getPreference(1).getTitle().toString()).isEqualTo("Mail"); Loading
tests/robotests/src/com/android/settings/notification/app/AppConversationListPreferenceControllerTest.java +26 −7 Original line number Diff line number Diff line Loading @@ -37,20 +37,24 @@ import androidx.test.core.app.ApplicationProvider; import com.android.settings.notification.NotificationBackend; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.LooperMode; import org.robolectric.shadows.ShadowApplication; import org.robolectric.android.util.concurrent.PausedExecutorService; import org.robolectric.shadows.ShadowLooper; import org.robolectric.shadows.ShadowPausedAsyncTask; import java.util.ArrayList; import java.util.Arrays; @RunWith(RobolectricTestRunner.class) @LooperMode(LooperMode.Mode.LEGACY) public class AppConversationListPreferenceControllerTest { @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); private Context mContext; Loading @@ -60,11 +64,13 @@ public class AppConversationListPreferenceControllerTest { private AppConversationListPreferenceController mController; private NotificationBackend.AppRow mAppRow; private PreferenceCategory mPreference; private PausedExecutorService mExecutorService; @Before public void setUp() { MockitoAnnotations.initMocks(this); mContext = ApplicationProvider.getApplicationContext(); mExecutorService = new PausedExecutorService(); ShadowPausedAsyncTask.overrideExecutor(mExecutorService); mAppRow = new NotificationBackend.AppRow(); mAppRow.uid = 42; Loading @@ -88,7 +94,8 @@ public class AppConversationListPreferenceControllerTest { )); mController.updateState(mPreference); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.getPreferenceCount()).isEqualTo(2); Loading @@ -107,7 +114,8 @@ public class AppConversationListPreferenceControllerTest { )); mController.updateState(mPreference); ShadowApplication.runBackgroundTasks(); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.getPreferenceCount()).isEqualTo(1); Loading @@ -120,6 +128,8 @@ public class AppConversationListPreferenceControllerTest { .thenReturn(conversationList()); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isFalse(); assertThat(mPreference.getPreferenceCount()).isEqualTo(0); Loading @@ -130,6 +140,9 @@ public class AppConversationListPreferenceControllerTest { when(mBackend.getConversations(eq(mAppRow.pkg), eq(mAppRow.uid))) .thenReturn(conversationList()); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isFalse(); // Empty -> present Loading @@ -138,6 +151,9 @@ public class AppConversationListPreferenceControllerTest { conversationChannel("1", "msg", "Mario", "Messages", "M", false) )); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isTrue(); assertThat(mPreference.getPreferenceCount()).isEqualTo(1); Loading @@ -145,6 +161,9 @@ public class AppConversationListPreferenceControllerTest { when(mBackend.getConversations(eq(mAppRow.pkg), eq(mAppRow.uid))) .thenReturn(conversationList()); mController.updateState(mPreference); mExecutorService.runAll(); ShadowLooper.idleMainLooper(); assertThat(mPreference.isVisible()).isFalse(); assertThat(mPreference.getPreferenceCount()).isEqualTo(0); } Loading