[Audiosharing] Reset shadows after tests.
Test: atest Bug: 345686602 Change-Id: I311ba5c8d234240e61dffd17b4357452c12f4fb1
This commit is contained in:
@@ -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();
|
||||
|
@@ -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())
|
||||
|
@@ -77,6 +77,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;
|
||||
@@ -142,6 +143,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ShadowAlertDialogCompat.reset();
|
||||
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||
mShadowBluetoothAdapter.setEnabled(true);
|
||||
mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
|
||||
@@ -179,6 +181,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);
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,6 +74,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;
|
||||
@@ -173,6 +174,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);
|
||||
|
@@ -56,6 +56,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;
|
||||
@@ -131,6 +132,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
mDeviceUpdater.setPrefContext(mContext);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowBluetoothUtils.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
|
||||
setupPreferenceMapWithDevice();
|
||||
|
@@ -69,6 +69,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;
|
||||
@@ -181,6 +182,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);
|
||||
|
@@ -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())
|
||||
|
@@ -57,6 +57,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;
|
||||
@@ -167,6 +168,11 @@ public class AudioSharingDialogHandlerTest {
|
||||
mHandler = new AudioSharingDialogHandler(mContext, mParentFragment);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowBluetoothUtils.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() {
|
||||
setUpBroadcast(false);
|
||||
|
@@ -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())
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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<ShadowApplication.Wrapper> registeredReceivers =
|
||||
|
@@ -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())
|
||||
|
@@ -75,6 +75,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;
|
||||
@@ -207,6 +208,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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user