diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java index 581ad62bb31..42a90387714 100644 --- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java +++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java @@ -60,7 +60,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere private final AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false); @VisibleForTesting - protected final BluetoothLeBroadcast.Callback mBroadcastCallback = + final BluetoothLeBroadcast.Callback mBroadcastCallback = new BluetoothLeBroadcast.Callback() { @Override public void onBroadcastStarted(int reason, int broadcastId) { @@ -219,7 +219,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere /** Test only: set callbacks registration state for test setup. */ @VisibleForTesting - public void setCallbacksRegistered(boolean registered) { + void setCallbacksRegistered(boolean registered) { mCallbacksRegistered.set(registered); } diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java index c7d740740e7..ad41e8a2997 100644 --- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java +++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java @@ -103,7 +103,7 @@ public class AudioSharingDashboardFragment extends DashboardFragment /** Test only: set mock controllers for the {@link AudioSharingDashboardFragment} */ @VisibleForTesting - protected void setControllers( + void setControllers( AudioSharingDeviceVolumeGroupController volumeGroupController, AudioSharingCallAudioPreferenceController callAudioController, AudioSharingPlaySoundPreferenceController playSoundController, diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragment.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragment.java index 3d111fd8e3b..e787be30e03 100644 --- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragment.java +++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragment.java @@ -100,7 +100,8 @@ public class AudioSharingDialogFragment extends InstrumentedDialogFragment { /** Test only: get the event data passed to the dialog. */ @VisibleForTesting - protected @NonNull Pair[] getEventData() { + @NonNull + Pair[] getEventData() { return sEventData; } diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java index 46c7f9c63cc..11b195c47dd 100644 --- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java +++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java @@ -105,7 +105,7 @@ public class AudioSharingPlaySoundPreferenceController } @VisibleForTesting - protected void setRingtone(Ringtone ringtone) { + void setRingtone(Ringtone ringtone) { mRingtone = ringtone; } diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceController.java index d27d3a20d72..02448892243 100644 --- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceController.java +++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceController.java @@ -52,7 +52,7 @@ public class AudioSharingPreferenceController extends BasePreferenceController private final Executor mExecutor; @VisibleForTesting - protected final BluetoothLeBroadcast.Callback mBroadcastCallback = + final BluetoothLeBroadcast.Callback mBroadcastCallback = new BluetoothLeBroadcast.Callback() { @Override public void onBroadcastStarted(int reason, int broadcastId) { diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragment.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragment.java index beac4b0fd33..59593ba340f 100644 --- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragment.java +++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragment.java @@ -142,7 +142,8 @@ public class AudioSharingStopDialogFragment extends InstrumentedDialogFragment { /** Test only: get the event data passed to the dialog. */ @VisibleForTesting - protected @NonNull Pair[] getEventData() { + @NonNull + Pair[] getEventData() { return sEventData; } diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java index 23be20846fd..785b1dc9f9e 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java @@ -58,6 +58,7 @@ import com.android.settingslib.flags.Flags; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -143,6 +144,12 @@ public class AudioSharingBluetoothDeviceUpdaterTest { mDeviceUpdater.setPrefContext(mContext); } + @After + public void tearDown() { + ShadowThreadUtils.reset(); + ShadowBluetoothUtils.reset(); + } + @Test public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() { setupPreferenceMapWithDevice(); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioDialogFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioDialogFragmentTest.java index 979f149b8a6..7f0c1c97858 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioDialogFragmentTest.java @@ -33,6 +33,7 @@ import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -66,16 +67,16 @@ public class AudioSharingCallAudioDialogFragmentTest { private Fragment mParent; private AudioSharingCallAudioDialogFragment mFragment; - private ShadowBluetoothAdapter mShadowBluetoothAdapter; @Before public void setUp() { ShadowAlertDialogCompat.reset(); - mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter()); - mShadowBluetoothAdapter.setEnabled(true); - mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported( + ShadowBluetoothAdapter shadowBluetoothAdapter = + Shadow.extract(BluetoothAdapter.getDefaultAdapter()); + shadowBluetoothAdapter.setEnabled(true); + shadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported( BluetoothStatusCodes.FEATURE_SUPPORTED); - mShadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported( + shadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported( BluetoothStatusCodes.FEATURE_SUPPORTED); mFragment = new AudioSharingCallAudioDialogFragment(); mParent = new Fragment(); @@ -83,6 +84,11 @@ public class AudioSharingCallAudioDialogFragmentTest { mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null); } + @After + public void tearDown() { + ShadowAlertDialogCompat.reset(); + } + @Test public void getMetricsCategory_correctValue() { assertThat(mFragment.getMetricsCategory()) diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java index aba0a799068..c72b5a5138f 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java @@ -78,6 +78,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -144,6 +145,7 @@ public class AudioSharingCallAudioPreferenceControllerTest { @Before public void setUp() { + ShadowAlertDialogCompat.reset(); mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter()); mShadowBluetoothAdapter.setEnabled(true); mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported( @@ -181,6 +183,13 @@ public class AudioSharingCallAudioPreferenceControllerTest { when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference); } + @After + public void tearDown() { + ShadowAlertDialogCompat.reset(); + ShadowThreadUtils.reset(); + ShadowBluetoothUtils.reset(); + } + @Test public void onStart_flagOff_doNothing() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceControllerTest.java index 19221a65abe..74210cd0ea3 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceControllerTest.java @@ -61,6 +61,7 @@ import com.android.settingslib.bluetooth.VolumeControlProfile; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -128,6 +129,12 @@ public class AudioSharingCompatibilityPreferenceControllerTest { when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference); } + @After + public void tearDown() { + ShadowThreadUtils.reset(); + ShadowBluetoothUtils.reset(); + } + @Test public void onStart_flagOn_registerCallback() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingConfirmDialogFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingConfirmDialogFragmentTest.java index e5facc1d62d..32f666f05f4 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingConfirmDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingConfirmDialogFragmentTest.java @@ -61,7 +61,7 @@ public class AudioSharingConfirmDialogFragmentTest { @Before public void setUp() { - cleanUpDialogs(); + ShadowAlertDialogCompat.reset(); ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter()); shadowBluetoothAdapter.setEnabled(true); @@ -77,7 +77,7 @@ public class AudioSharingConfirmDialogFragmentTest { @After public void tearDown() { - cleanUpDialogs(); + ShadowAlertDialogCompat.reset(); } @Test @@ -118,12 +118,4 @@ public class AudioSharingConfirmDialogFragmentTest { shadowMainLooper().idle(); assertThat(dialog.isShowing()).isFalse(); } - - private void cleanUpDialogs() { - AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - if (latestAlertDialog != null) { - latestAlertDialog.dismiss(); - ShadowAlertDialogCompat.reset(); - } - } } diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java index eb29b50bb87..18f75ba2b85 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDevicePreferenceControllerTest.java @@ -77,6 +77,7 @@ import com.android.settingslib.flags.Flags; import com.google.common.collect.ImmutableList; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -180,6 +181,11 @@ public class AudioSharingDevicePreferenceControllerTest { mController.setHostFragment(mFragment); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + } + @Test public void onStart_flagOff_doNothing() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java index 65a0492cf5d..e7cfb859e74 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java @@ -58,6 +58,7 @@ import com.android.settingslib.bluetooth.VolumeControlProfile; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -136,6 +137,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest { mDeviceUpdater.setPrefContext(mContext); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + } + @Test public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() { setupPreferenceMapWithDevice(); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java index d5dfb50fd7b..f2f0a2f31f6 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java @@ -72,6 +72,7 @@ import com.android.settingslib.flags.Flags; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -189,6 +190,12 @@ public class AudioSharingDeviceVolumeGroupControllerTest { mContentObserver = mController.getSettingsObserver(); } + @After + public void tearDown() { + ShadowThreadUtils.reset(); + ShadowBluetoothUtils.reset(); + } + @Test public void onStart_flagOff_doNothing() { mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragmentTest.java index c63a1a971a4..39709c14931 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragmentTest.java @@ -45,6 +45,7 @@ import com.android.settings.testutils.shadow.ShadowAlertDialogCompat; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -112,6 +113,11 @@ public class AudioSharingDialogFragmentTest { mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null); } + @After + public void tearDown() { + ShadowAlertDialogCompat.reset(); + } + @Test public void getMetricsCategory_correctValue() { assertThat(mFragment.getMetricsCategory()) diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java index 00e210dec89..4c060d4356d 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogHandlerTest.java @@ -62,6 +62,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.truth.Correspondence; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -176,6 +177,11 @@ public class AudioSharingDialogHandlerTest { mHandler = new AudioSharingDialogHandler(mContext, mParentFragment); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + } + @Test public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() { setUpBroadcast(false); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDisconnectDialogFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDisconnectDialogFragmentTest.java index 481c78d2917..6b984af9939 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDisconnectDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDisconnectDialogFragmentTest.java @@ -47,6 +47,7 @@ import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -104,11 +105,7 @@ public class AudioSharingDisconnectDialogFragmentTest { @Before public void setUp() { - AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - if (latestAlertDialog != null) { - latestAlertDialog.dismiss(); - ShadowAlertDialogCompat.reset(); - } + ShadowAlertDialogCompat.reset(); ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter()); shadowBluetoothAdapter.setEnabled(true); @@ -131,6 +128,11 @@ public class AudioSharingDisconnectDialogFragmentTest { mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null); } + @After + public void tearDown() { + ShadowAlertDialogCompat.reset(); + } + @Test public void getMetricsCategory_correctValue() { assertThat(mFragment.getMetricsCategory()) diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingJoinDialogFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingJoinDialogFragmentTest.java index c7b21ade886..13ea965d3c5 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingJoinDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingJoinDialogFragmentTest.java @@ -48,6 +48,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -104,11 +105,7 @@ public class AudioSharingJoinDialogFragmentTest { @Before public void setUp() { - AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - if (latestAlertDialog != null) { - latestAlertDialog.dismiss(); - ShadowAlertDialogCompat.reset(); - } + ShadowAlertDialogCompat.reset(); ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter()); shadowBluetoothAdapter.setEnabled(true); @@ -129,6 +126,12 @@ public class AudioSharingJoinDialogFragmentTest { mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null); } + @After + public void tearDown() { + ShadowAlertDialogCompat.reset(); + ShadowBluetoothUtils.reset(); + } + @Test public void getMetricsCategory_notInSharing_correctValue() { when(mBroadcast.isEnabled(null)).thenReturn(false); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceControllerTest.java index 046a4ce8f67..d9c883e5b1f 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceControllerTest.java @@ -56,6 +56,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -114,6 +115,12 @@ public class AudioSharingPreferenceControllerTest { when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + ShadowThreadUtils.reset(); + } + @Test public void onStart_flagOn_registerCallback() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingReceiverTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingReceiverTest.java index d542b985bc2..deed229bbcb 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingReceiverTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingReceiverTest.java @@ -50,6 +50,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -103,6 +104,11 @@ public class AudioSharingReceiverTest { mFeatureFactory = FakeFeatureFactory.setupForTest(); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + } + @Test public void broadcastReceiver_isRegistered() { List registeredReceivers = diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragmentTest.java index 7d46a18a4f2..b6babfb8016 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragmentTest.java @@ -48,6 +48,7 @@ import com.android.settingslib.flags.Flags; import com.google.common.collect.ImmutableList; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -101,11 +102,7 @@ public class AudioSharingStopDialogFragmentTest { @Before public void setUp() { - AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - if (latestAlertDialog != null) { - latestAlertDialog.dismiss(); - ShadowAlertDialogCompat.reset(); - } + ShadowAlertDialogCompat.reset(); ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter()); shadowBluetoothAdapter.setEnabled(true); @@ -126,6 +123,11 @@ public class AudioSharingStopDialogFragmentTest { mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null); } + @After + public void tearDown() { + ShadowAlertDialogCompat.reset(); + } + @Test public void getMetricsCategory_correctValue() { assertThat(mFragment.getMetricsCategory()) diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarControllerTest.java index 012f88c29fc..45d99c7adde 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingSwitchBarControllerTest.java @@ -78,6 +78,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.truth.Correspondence; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -210,6 +211,12 @@ public class AudioSharingSwitchBarControllerTest { mController.init(mParentFragment); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + ShadowThreadUtils.reset(); + } + @Test public void bluetoothOff_switchDisabled() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING); diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/StreamSettingsCategoryControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/StreamSettingsCategoryControllerTest.java index 50dde0fcaab..ee92b3bc82f 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/StreamSettingsCategoryControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/StreamSettingsCategoryControllerTest.java @@ -54,6 +54,7 @@ import com.android.settingslib.bluetooth.VolumeControlProfile; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.flags.Flags; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -117,6 +118,11 @@ public class StreamSettingsCategoryControllerTest { when(mScreen.findPreference(KEY)).thenReturn(mPreference); } + @After + public void tearDown() { + ShadowBluetoothUtils.reset(); + } + @Test public void bluetoothOff_updateVisibility() { mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);