[Audiosharing] Reset shadows after tests.
Test: atest Bug: 345686602 Change-Id: I311ba5c8d234240e61dffd17b4357452c12f4fb1
This commit is contained in:
@@ -72,7 +72,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
private static final String PREF_KEY = "calls_and_alarms";
|
private static final String PREF_KEY = "calls_and_alarms";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected enum ChangeCallAudioType {
|
enum ChangeCallAudioType {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
CONNECTED_EARLIER,
|
CONNECTED_EARLIER,
|
||||||
CONNECTED_LATER
|
CONNECTED_LATER
|
||||||
@@ -276,7 +276,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
|
|
||||||
/** Test only: set callback registration status in tests. */
|
/** Test only: set callback registration status in tests. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setCallbacksRegistered(boolean registered) {
|
void setCallbacksRegistered(boolean registered) {
|
||||||
mCallbacksRegistered.set(registered);
|
mCallbacksRegistered.set(registered);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected void logCallAudioDeviceChange(int currentGroupId, CachedBluetoothDevice target) {
|
void logCallAudioDeviceChange(int currentGroupId, CachedBluetoothDevice target) {
|
||||||
var unused =
|
var unused =
|
||||||
ThreadUtils.postOnBackgroundThread(
|
ThreadUtils.postOnBackgroundThread(
|
||||||
() -> {
|
() -> {
|
||||||
|
@@ -60,7 +60,7 @@ public class AudioSharingCompatibilityPreferenceController extends TogglePrefere
|
|||||||
private final AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false);
|
private final AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false);
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||||
new BluetoothLeBroadcast.Callback() {
|
new BluetoothLeBroadcast.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onBroadcastStarted(int reason, int broadcastId) {
|
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. */
|
/** Test only: set callbacks registration state for test setup. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setCallbacksRegistered(boolean registered) {
|
void setCallbacksRegistered(boolean registered) {
|
||||||
mCallbacksRegistered.set(registered);
|
mCallbacksRegistered.set(registered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -103,7 +103,7 @@ public class AudioSharingDashboardFragment extends DashboardFragment
|
|||||||
|
|
||||||
/** Test only: set mock controllers for the {@link AudioSharingDashboardFragment} */
|
/** Test only: set mock controllers for the {@link AudioSharingDashboardFragment} */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected void setControllers(
|
void setControllers(
|
||||||
AudioSharingDeviceVolumeGroupController volumeGroupController,
|
AudioSharingDeviceVolumeGroupController volumeGroupController,
|
||||||
AudioSharingCallAudioPreferenceController callAudioController,
|
AudioSharingCallAudioPreferenceController callAudioController,
|
||||||
AudioSharingPlaySoundPreferenceController playSoundController,
|
AudioSharingPlaySoundPreferenceController playSoundController,
|
||||||
|
@@ -323,26 +323,26 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setDeviceUpdater(@Nullable AudioSharingDeviceVolumeControlUpdater updater) {
|
void setDeviceUpdater(@Nullable AudioSharingDeviceVolumeControlUpdater updater) {
|
||||||
mBluetoothDeviceUpdater = updater;
|
mBluetoothDeviceUpdater = updater;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test only: set callback registration status in tests. */
|
/** Test only: set callback registration status in tests. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setCallbacksRegistered(boolean registered) {
|
void setCallbacksRegistered(boolean registered) {
|
||||||
mCallbacksRegistered.set(registered);
|
mCallbacksRegistered.set(registered);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test only: set volume map in tests. */
|
/** Test only: set volume map in tests. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setVolumeMap(@Nullable Map<Integer, Integer> map) {
|
void setVolumeMap(@Nullable Map<Integer, Integer> map) {
|
||||||
mValueMap.clear();
|
mValueMap.clear();
|
||||||
mValueMap.putAll(map);
|
mValueMap.putAll(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test only: set value for private preferenceGroup in tests. */
|
/** Test only: set value for private preferenceGroup in tests. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void setPreferenceGroup(@Nullable PreferenceGroup group) {
|
void setPreferenceGroup(@Nullable PreferenceGroup group) {
|
||||||
mPreferenceGroup = group;
|
mPreferenceGroup = group;
|
||||||
mPreference = group;
|
mPreference = group;
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,8 @@ public class AudioSharingDialogFragment extends InstrumentedDialogFragment {
|
|||||||
|
|
||||||
/** Test only: get the event data passed to the dialog. */
|
/** Test only: get the event data passed to the dialog. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected @NonNull Pair<Integer, Object>[] getEventData() {
|
@NonNull
|
||||||
|
Pair<Integer, Object>[] getEventData() {
|
||||||
return sEventData;
|
return sEventData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -147,7 +147,8 @@ public class AudioSharingDisconnectDialogFragment extends InstrumentedDialogFrag
|
|||||||
|
|
||||||
/** Test only: get the event data passed to the dialog. */
|
/** Test only: get the event data passed to the dialog. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected @NonNull Pair<Integer, Object>[] getEventData() {
|
@NonNull
|
||||||
|
Pair<Integer, Object>[] getEventData() {
|
||||||
return sEventData;
|
return sEventData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,7 +112,8 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
|
|||||||
|
|
||||||
/** Test only: get the event data passed to the dialog. */
|
/** Test only: get the event data passed to the dialog. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected @NonNull Pair<Integer, Object>[] getEventData() {
|
@NonNull
|
||||||
|
Pair<Integer, Object>[] getEventData() {
|
||||||
return sEventData;
|
return sEventData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ public class AudioSharingPlaySoundPreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected void setRingtone(Ringtone ringtone) {
|
void setRingtone(Ringtone ringtone) {
|
||||||
mRingtone = ringtone;
|
mRingtone = ringtone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ public class AudioSharingPreferenceController extends BasePreferenceController
|
|||||||
private final Executor mExecutor;
|
private final Executor mExecutor;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||||
new BluetoothLeBroadcast.Callback() {
|
new BluetoothLeBroadcast.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onBroadcastStarted(int reason, int broadcastId) {
|
public void onBroadcastStarted(int reason, int broadcastId) {
|
||||||
|
@@ -142,7 +142,8 @@ public class AudioSharingStopDialogFragment extends InstrumentedDialogFragment {
|
|||||||
|
|
||||||
/** Test only: get the event data passed to the dialog. */
|
/** Test only: get the event data passed to the dialog. */
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected @NonNull Pair<Integer, Object>[] getEventData() {
|
@NonNull
|
||||||
|
Pair<Integer, Object>[] getEventData() {
|
||||||
return sEventData;
|
return sEventData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,6 +58,7 @@ import com.android.settingslib.flags.Flags;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -143,6 +144,12 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
|||||||
mDeviceUpdater.setPrefContext(mContext);
|
mDeviceUpdater.setPrefContext(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowThreadUtils.reset();
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
@@ -33,6 +33,7 @@ import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
|||||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -66,16 +67,16 @@ public class AudioSharingCallAudioDialogFragmentTest {
|
|||||||
|
|
||||||
private Fragment mParent;
|
private Fragment mParent;
|
||||||
private AudioSharingCallAudioDialogFragment mFragment;
|
private AudioSharingCallAudioDialogFragment mFragment;
|
||||||
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ShadowAlertDialogCompat.reset();
|
ShadowAlertDialogCompat.reset();
|
||||||
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
||||||
mShadowBluetoothAdapter.setEnabled(true);
|
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||||
mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
|
shadowBluetoothAdapter.setEnabled(true);
|
||||||
|
shadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
|
||||||
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||||
mShadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
|
shadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
|
||||||
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
BluetoothStatusCodes.FEATURE_SUPPORTED);
|
||||||
mFragment = new AudioSharingCallAudioDialogFragment();
|
mFragment = new AudioSharingCallAudioDialogFragment();
|
||||||
mParent = new Fragment();
|
mParent = new Fragment();
|
||||||
@@ -83,6 +84,11 @@ public class AudioSharingCallAudioDialogFragmentTest {
|
|||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetricsCategory_correctValue() {
|
public void getMetricsCategory_correctValue() {
|
||||||
assertThat(mFragment.getMetricsCategory())
|
assertThat(mFragment.getMetricsCategory())
|
||||||
|
@@ -77,6 +77,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -142,6 +143,7 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||||
mShadowBluetoothAdapter.setEnabled(true);
|
mShadowBluetoothAdapter.setEnabled(true);
|
||||||
mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
|
mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
|
||||||
@@ -179,6 +181,13 @@ public class AudioSharingCallAudioPreferenceControllerTest {
|
|||||||
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
|
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
|
ShadowThreadUtils.reset();
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onStart_flagOff_doNothing() {
|
public void onStart_flagOff_doNothing() {
|
||||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
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.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -128,6 +129,12 @@ public class AudioSharingCompatibilityPreferenceControllerTest {
|
|||||||
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
|
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowThreadUtils.reset();
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onStart_flagOn_registerCallback() {
|
public void onStart_flagOn_registerCallback() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
|
@@ -61,7 +61,7 @@ public class AudioSharingConfirmDialogFragmentTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
cleanUpDialogs();
|
ShadowAlertDialogCompat.reset();
|
||||||
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
||||||
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||||
shadowBluetoothAdapter.setEnabled(true);
|
shadowBluetoothAdapter.setEnabled(true);
|
||||||
@@ -77,7 +77,7 @@ public class AudioSharingConfirmDialogFragmentTest {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
cleanUpDialogs();
|
ShadowAlertDialogCompat.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -118,12 +118,4 @@ public class AudioSharingConfirmDialogFragmentTest {
|
|||||||
shadowMainLooper().idle();
|
shadowMainLooper().idle();
|
||||||
assertThat(dialog.isShowing()).isFalse();
|
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 com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -173,6 +174,11 @@ public class AudioSharingDevicePreferenceControllerTest {
|
|||||||
mController.setHostFragment(mFragment);
|
mController.setHostFragment(mFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onStart_flagOff_doNothing() {
|
public void onStart_flagOff_doNothing() {
|
||||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
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.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -131,6 +132,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
|||||||
mDeviceUpdater.setPrefContext(mContext);
|
mDeviceUpdater.setPrefContext(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
|
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
|
||||||
setupPreferenceMapWithDevice();
|
setupPreferenceMapWithDevice();
|
||||||
|
@@ -69,6 +69,7 @@ import com.android.settingslib.flags.Flags;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -181,6 +182,12 @@ public class AudioSharingDeviceVolumeGroupControllerTest {
|
|||||||
mContentObserver = mController.getSettingsObserver();
|
mContentObserver = mController.getSettingsObserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowThreadUtils.reset();
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onStart_flagOff_doNothing() {
|
public void onStart_flagOff_doNothing() {
|
||||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
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.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -112,6 +113,11 @@ public class AudioSharingDialogFragmentTest {
|
|||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetricsCategory_correctValue() {
|
public void getMetricsCategory_correctValue() {
|
||||||
assertThat(mFragment.getMetricsCategory())
|
assertThat(mFragment.getMetricsCategory())
|
||||||
|
@@ -57,6 +57,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.truth.Correspondence;
|
import com.google.common.truth.Correspondence;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -167,6 +168,11 @@ public class AudioSharingDialogHandlerTest {
|
|||||||
mHandler = new AudioSharingDialogHandler(mContext, mParentFragment);
|
mHandler = new AudioSharingDialogHandler(mContext, mParentFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() {
|
public void handleUserTriggeredNonLeaDeviceConnected_noSharing_setActive() {
|
||||||
setUpBroadcast(false);
|
setUpBroadcast(false);
|
||||||
|
@@ -47,6 +47,7 @@ import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
|||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -104,11 +105,7 @@ public class AudioSharingDisconnectDialogFragmentTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
|
||||||
if (latestAlertDialog != null) {
|
|
||||||
latestAlertDialog.dismiss();
|
|
||||||
ShadowAlertDialogCompat.reset();
|
ShadowAlertDialogCompat.reset();
|
||||||
}
|
|
||||||
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
||||||
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||||
shadowBluetoothAdapter.setEnabled(true);
|
shadowBluetoothAdapter.setEnabled(true);
|
||||||
@@ -131,6 +128,11 @@ public class AudioSharingDisconnectDialogFragmentTest {
|
|||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetricsCategory_correctValue() {
|
public void getMetricsCategory_correctValue() {
|
||||||
assertThat(mFragment.getMetricsCategory())
|
assertThat(mFragment.getMetricsCategory())
|
||||||
|
@@ -48,6 +48,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
|||||||
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -104,11 +105,7 @@ public class AudioSharingJoinDialogFragmentTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
|
||||||
if (latestAlertDialog != null) {
|
|
||||||
latestAlertDialog.dismiss();
|
|
||||||
ShadowAlertDialogCompat.reset();
|
ShadowAlertDialogCompat.reset();
|
||||||
}
|
|
||||||
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
||||||
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||||
shadowBluetoothAdapter.setEnabled(true);
|
shadowBluetoothAdapter.setEnabled(true);
|
||||||
@@ -129,6 +126,12 @@ public class AudioSharingJoinDialogFragmentTest {
|
|||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetricsCategory_notInSharing_correctValue() {
|
public void getMetricsCategory_notInSharing_correctValue() {
|
||||||
when(mBroadcast.isEnabled(null)).thenReturn(false);
|
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.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -114,6 +115,12 @@ public class AudioSharingPreferenceControllerTest {
|
|||||||
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
|
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
ShadowThreadUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onStart_flagOn_registerCallback() {
|
public void onStart_flagOn_registerCallback() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
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.bluetooth.LocalBluetoothProfileManager;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -103,6 +104,11 @@ public class AudioSharingReceiverTest {
|
|||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void broadcastReceiver_isRegistered() {
|
public void broadcastReceiver_isRegistered() {
|
||||||
List<ShadowApplication.Wrapper> registeredReceivers =
|
List<ShadowApplication.Wrapper> registeredReceivers =
|
||||||
|
@@ -48,6 +48,7 @@ import com.android.settingslib.flags.Flags;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -101,11 +102,7 @@ public class AudioSharingStopDialogFragmentTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
|
||||||
if (latestAlertDialog != null) {
|
|
||||||
latestAlertDialog.dismiss();
|
|
||||||
ShadowAlertDialogCompat.reset();
|
ShadowAlertDialogCompat.reset();
|
||||||
}
|
|
||||||
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
ShadowBluetoothAdapter shadowBluetoothAdapter =
|
||||||
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||||
shadowBluetoothAdapter.setEnabled(true);
|
shadowBluetoothAdapter.setEnabled(true);
|
||||||
@@ -126,6 +123,11 @@ public class AudioSharingStopDialogFragmentTest {
|
|||||||
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
mParent, FragmentActivity.class, /* containerViewId= */ 0, /* bundle= */ null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowAlertDialogCompat.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMetricsCategory_correctValue() {
|
public void getMetricsCategory_correctValue() {
|
||||||
assertThat(mFragment.getMetricsCategory())
|
assertThat(mFragment.getMetricsCategory())
|
||||||
|
@@ -75,6 +75,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.truth.Correspondence;
|
import com.google.common.truth.Correspondence;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -207,6 +208,12 @@ public class AudioSharingSwitchBarControllerTest {
|
|||||||
mController.init(mParentFragment);
|
mController.init(mParentFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
ShadowThreadUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bluetoothOff_switchDisabled() {
|
public void bluetoothOff_switchDisabled() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
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.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.flags.Flags;
|
import com.android.settingslib.flags.Flags;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -117,6 +118,11 @@ public class StreamSettingsCategoryControllerTest {
|
|||||||
when(mScreen.findPreference(KEY)).thenReturn(mPreference);
|
when(mScreen.findPreference(KEY)).thenReturn(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
ShadowBluetoothUtils.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bluetoothOff_updateVisibility() {
|
public void bluetoothOff_updateVisibility() {
|
||||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||||
|
Reference in New Issue
Block a user