Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputControllerTest.java +14 −13 Original line number Diff line number Diff line Loading @@ -98,8 +98,6 @@ import java.util.List; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper(setAsMainLooper = true) public class MediaOutputControllerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "com.test.package.name"; private static final String TEST_DEVICE_1_ID = "test_device_1_id"; private static final String TEST_DEVICE_2_ID = "test_device_2_id"; private static final String TEST_DEVICE_3_ID = "test_device_3_id"; Loading Loading @@ -167,6 +165,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { final Notification mNotification = mock(Notification.class); private Context mSpyContext; private String mPackageName = null; private MediaOutputController mMediaOutputController; private LocalMediaManager mLocalMediaManager; private List<MediaController> mMediaControllers = new ArrayList<>(); Loading @@ -177,12 +176,14 @@ public class MediaOutputControllerTest extends SysuiTestCase { @Before public void setUp() { mPackageName = mContext.getPackageName(); MockitoAnnotations.initMocks(this); mContext.setMockPackageManager(mPackageManager); mSpyContext = spy(mContext); final UserHandle userHandle = mock(UserHandle.class); when(mUserTracker.getUserHandle()).thenReturn(userHandle); when(mSessionMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(mSessionMediaController.getPackageName()).thenReturn(mPackageName); when(mSessionMediaController.getPlaybackState()).thenReturn(mPlaybackState); mMediaControllers.add(mSessionMediaController); when(mMediaSessionManager.getActiveSessionsForUser(any(), Loading @@ -193,7 +194,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn( mCachedBluetoothDeviceManager); mMediaOutputController = new MediaOutputController(mSpyContext, TEST_PACKAGE_NAME, mMediaOutputController = new MediaOutputController(mSpyContext, mPackageName, mMediaSessionManager, mLocalBluetoothManager, mStarter, mNotifCollection, mDialogLaunchAnimator, mNearbyMediaDevicesManager, mAudioManager, mPowerExemptionManager, Loading Loading @@ -231,7 +232,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(mNotification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); mNotification.extras = bundle; when(bundle.getParcelable(Notification.EXTRA_MEDIA_SESSION, MediaSession.Token.class)).thenReturn(token); Loading Loading @@ -339,8 +340,8 @@ public class MediaOutputControllerTest extends SysuiTestCase { public void tryToLaunchMediaApplication_intentNotNull_startActivity() { when(mDialogLaunchAnimator.createActivityLaunchController(any(View.class))).thenReturn( mController); Intent intent = new Intent(TEST_PACKAGE_NAME); doReturn(intent).when(mPackageManager).getLaunchIntentForPackage(TEST_PACKAGE_NAME); Intent intent = new Intent(mPackageName); doReturn(intent).when(mPackageManager).getLaunchIntentForPackage(mPackageName); mMediaOutputController.start(mCallback); mMediaOutputController.tryToLaunchMediaApplication(mDialogLaunchView); Loading @@ -355,7 +356,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { mController); mMediaOutputController.start(mCallback); when(mLocalMediaManager.getLinkedItemComponentName()).thenReturn( new ComponentName(TEST_PACKAGE_NAME, "")); new ComponentName(mPackageName, "")); mMediaOutputController.tryToLaunchInAppRoutingIntent(TEST_DEVICE_1_ID, mDialogLaunchView); Loading Loading @@ -891,7 +892,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getLargeIcon()).thenReturn(null); Loading @@ -910,7 +911,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getLargeIcon()).thenReturn(icon); Loading @@ -929,7 +930,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(false); when(notification.getLargeIcon()).thenReturn(icon); Loading @@ -947,7 +948,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getSmallIcon()).thenReturn(null); Loading @@ -966,7 +967,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getSmallIcon()).thenReturn(icon); Loading Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputControllerTest.java +14 −13 Original line number Diff line number Diff line Loading @@ -98,8 +98,6 @@ import java.util.List; @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper(setAsMainLooper = true) public class MediaOutputControllerTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "com.test.package.name"; private static final String TEST_DEVICE_1_ID = "test_device_1_id"; private static final String TEST_DEVICE_2_ID = "test_device_2_id"; private static final String TEST_DEVICE_3_ID = "test_device_3_id"; Loading Loading @@ -167,6 +165,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { final Notification mNotification = mock(Notification.class); private Context mSpyContext; private String mPackageName = null; private MediaOutputController mMediaOutputController; private LocalMediaManager mLocalMediaManager; private List<MediaController> mMediaControllers = new ArrayList<>(); Loading @@ -177,12 +176,14 @@ public class MediaOutputControllerTest extends SysuiTestCase { @Before public void setUp() { mPackageName = mContext.getPackageName(); MockitoAnnotations.initMocks(this); mContext.setMockPackageManager(mPackageManager); mSpyContext = spy(mContext); final UserHandle userHandle = mock(UserHandle.class); when(mUserTracker.getUserHandle()).thenReturn(userHandle); when(mSessionMediaController.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(mSessionMediaController.getPackageName()).thenReturn(mPackageName); when(mSessionMediaController.getPlaybackState()).thenReturn(mPlaybackState); mMediaControllers.add(mSessionMediaController); when(mMediaSessionManager.getActiveSessionsForUser(any(), Loading @@ -193,7 +194,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn( mCachedBluetoothDeviceManager); mMediaOutputController = new MediaOutputController(mSpyContext, TEST_PACKAGE_NAME, mMediaOutputController = new MediaOutputController(mSpyContext, mPackageName, mMediaSessionManager, mLocalBluetoothManager, mStarter, mNotifCollection, mDialogLaunchAnimator, mNearbyMediaDevicesManager, mAudioManager, mPowerExemptionManager, Loading Loading @@ -231,7 +232,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(mNotification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); mNotification.extras = bundle; when(bundle.getParcelable(Notification.EXTRA_MEDIA_SESSION, MediaSession.Token.class)).thenReturn(token); Loading Loading @@ -339,8 +340,8 @@ public class MediaOutputControllerTest extends SysuiTestCase { public void tryToLaunchMediaApplication_intentNotNull_startActivity() { when(mDialogLaunchAnimator.createActivityLaunchController(any(View.class))).thenReturn( mController); Intent intent = new Intent(TEST_PACKAGE_NAME); doReturn(intent).when(mPackageManager).getLaunchIntentForPackage(TEST_PACKAGE_NAME); Intent intent = new Intent(mPackageName); doReturn(intent).when(mPackageManager).getLaunchIntentForPackage(mPackageName); mMediaOutputController.start(mCallback); mMediaOutputController.tryToLaunchMediaApplication(mDialogLaunchView); Loading @@ -355,7 +356,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { mController); mMediaOutputController.start(mCallback); when(mLocalMediaManager.getLinkedItemComponentName()).thenReturn( new ComponentName(TEST_PACKAGE_NAME, "")); new ComponentName(mPackageName, "")); mMediaOutputController.tryToLaunchInAppRoutingIntent(TEST_DEVICE_1_ID, mDialogLaunchView); Loading Loading @@ -891,7 +892,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getLargeIcon()).thenReturn(null); Loading @@ -910,7 +911,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getLargeIcon()).thenReturn(icon); Loading @@ -929,7 +930,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(false); when(notification.getLargeIcon()).thenReturn(icon); Loading @@ -947,7 +948,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getSmallIcon()).thenReturn(null); Loading @@ -966,7 +967,7 @@ public class MediaOutputControllerTest extends SysuiTestCase { when(mNotifCollection.getAllNotifs()).thenReturn(entryList); when(entry.getSbn()).thenReturn(sbn); when(sbn.getNotification()).thenReturn(notification); when(sbn.getPackageName()).thenReturn(TEST_PACKAGE_NAME); when(sbn.getPackageName()).thenReturn(mPackageName); when(notification.isMediaNotification()).thenReturn(true); when(notification.getSmallIcon()).thenReturn(icon); Loading