Merge "Remove fake package name from MediaOutputControllerTest" into main

This commit is contained in:
Iván Budnik
2023-07-28 11:59:24 +00:00
committed by Android (Google) Code Review

View File

@@ -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";
@@ -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<>();
@@ -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(),
@@ -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,
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);