From 0851843bed622e96047094b54089484477a7c2e6 Mon Sep 17 00:00:00 2001 From: Santiago Seifert Date: Tue, 26 Jul 2022 15:37:20 +0000 Subject: [PATCH] Merge tests calling onStart and onStop Allows MediaOutputBaseDialog to manage resources properly during test runs. Bug: 232812007 Test: atest MediaOutputBaseDialogTest Change-Id: I4d6aa4d7afd87c10a226800185695b6b3f8cf3e2 --- .../dialog/MediaOutputBaseDialogTest.java | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java index 9eaa20c2afedb..1b25c1105b0c0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBaseDialogTest.java @@ -203,46 +203,29 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase { } @Test - public void onStart_isBroadcasting_verifyRegisterLeBroadcastServiceCallBack() { + public void whenBroadcasting_verifyLeBroadcastServiceCallBackIsRegisteredAndUnregistered() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); mIsBroadcasting = true; mMediaOutputBaseDialogImpl.onStart(); - verify(mLocalBluetoothLeBroadcast).registerServiceCallBack(any(), any()); - } - - @Test - public void onStart_notBroadcasting_noRegisterLeBroadcastServiceCallBack() { - when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( - mLocalBluetoothLeBroadcast); - mIsBroadcasting = false; - - mMediaOutputBaseDialogImpl.onStart(); - - verify(mLocalBluetoothLeBroadcast, never()).registerServiceCallBack(any(), any()); - } - - @Test - public void onStart_isBroadcasting_verifyUnregisterLeBroadcastServiceCallBack() { - when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( - mLocalBluetoothLeBroadcast); - mIsBroadcasting = true; mMediaOutputBaseDialogImpl.onStop(); - verify(mLocalBluetoothLeBroadcast).unregisterServiceCallBack(any()); } @Test - public void onStop_notBroadcasting_noUnregisterLeBroadcastServiceCallBack() { + public void + whenNotBroadcasting_verifyLeBroadcastServiceCallBackIsNotRegisteredOrUnregistered() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); mIsBroadcasting = false; + mMediaOutputBaseDialogImpl.onStart(); mMediaOutputBaseDialogImpl.onStop(); + verify(mLocalBluetoothLeBroadcast, never()).registerServiceCallBack(any(), any()); verify(mLocalBluetoothLeBroadcast, never()).unregisterServiceCallBack(any()); }