Merge "[Audiosharing] Reset shadows after tests." into main
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java
index 581ad62..42a9038 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCompatibilityPreferenceController.java
@@ -60,7 +60,7 @@
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 @@
/** 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 c7d7407..ad41e8a 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDashboardFragment.java
@@ -103,7 +103,7 @@
/** 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 3d111fd..e787be3 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragment.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDialogFragment.java
@@ -100,7 +100,8 @@
/** Test only: get the event data passed to the dialog. */
@VisibleForTesting
- protected @NonNull Pair<Integer, Object>[] getEventData() {
+ @NonNull
+ Pair<Integer, Object>[] getEventData() {
return sEventData;
}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java
index 46c7f9c..11b195c 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPlaySoundPreferenceController.java
@@ -105,7 +105,7 @@
}
@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 d27d3a2..0244889 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingPreferenceController.java
@@ -52,7 +52,7 @@
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 beac4b0..59593ba 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragment.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingStopDialogFragment.java
@@ -142,7 +142,8 @@
/** Test only: get the event data passed to the dialog. */
@VisibleForTesting
- protected @NonNull Pair<Integer, Object>[] getEventData() {
+ @NonNull
+ Pair<Integer, Object>[] 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 23be208..785b1dc 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.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 @@
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 979f149..7f0c1c9 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.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 @@
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 @@
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 aba0a79..c72b5a5 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.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 @@
@Before
public void setUp() {
+ ShadowAlertDialogCompat.reset();
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
mShadowBluetoothAdapter.setEnabled(true);
mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
@@ -181,6 +183,13 @@
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 19221a6..74210cd 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.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 @@
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 e5facc1..32f666f 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 @@
@Before
public void setUp() {
- cleanUpDialogs();
+ ShadowAlertDialogCompat.reset();
ShadowBluetoothAdapter shadowBluetoothAdapter =
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
shadowBluetoothAdapter.setEnabled(true);
@@ -77,7 +77,7 @@
@After
public void tearDown() {
- cleanUpDialogs();
+ ShadowAlertDialogCompat.reset();
}
@Test
@@ -118,12 +118,4 @@
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 eb29b50..18f75ba 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.google.common.collect.ImmutableList;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -180,6 +181,11 @@
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 65a0492..e7cfb85 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.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 @@
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 d5dfb50..f2f0a2f 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.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 @@
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 c63a1a9..39709c1 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.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 @@
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 00e210d..4c060d4 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.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 @@
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 481c78d..6b984af 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.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 @@
@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 @@
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 c7b21ad..13ea965 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.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 @@
@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 @@
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 046a4ce..d9c883e 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.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 @@
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 d542b98..deed229 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.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 @@
mFeatureFactory = FakeFeatureFactory.setupForTest();
}
+ @After
+ public void tearDown() {
+ ShadowBluetoothUtils.reset();
+ }
+
@Test
public void broadcastReceiver_isRegistered() {
List<ShadowApplication.Wrapper> 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 7d46a18..b6babfb 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.google.common.collect.ImmutableList;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -101,11 +102,7 @@
@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 @@
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 012f88c..45d99c7 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.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 @@
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 50dde0f..ee92b3b 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.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 @@
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);