[Audiosharing] Increase audio sharing test coverage
Bug: 345686602 Test: atest Change-Id: Iec196fc884c3b7ddd580eb8dd13b445d59e3b1b7
This commit is contained in:
@@ -72,7 +72,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
||||
private static final String PREF_KEY = "calls_and_alarms";
|
||||
|
||||
@VisibleForTesting
|
||||
protected enum ChangeCallAudioType {
|
||||
enum ChangeCallAudioType {
|
||||
UNKNOWN,
|
||||
CONNECTED_EARLIER,
|
||||
CONNECTED_LATER
|
||||
@@ -90,7 +90,9 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
||||
Map<Integer, List<CachedBluetoothDevice>> mGroupedConnectedDevices = new HashMap<>();
|
||||
private List<AudioSharingDeviceItem> mDeviceItemsInSharingSession = new ArrayList<>();
|
||||
private final AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false);
|
||||
private final BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
|
||||
|
||||
@VisibleForTesting
|
||||
final BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
|
||||
new BluetoothLeBroadcastAssistant.Callback() {
|
||||
@Override
|
||||
public void onSearchStarted(int reason) {}
|
||||
@@ -276,7 +278,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
||||
|
||||
/** Test only: set callback registration status in tests. */
|
||||
@VisibleForTesting
|
||||
public void setCallbacksRegistered(boolean registered) {
|
||||
void setCallbacksRegistered(boolean registered) {
|
||||
mCallbacksRegistered.set(registered);
|
||||
}
|
||||
|
||||
@@ -385,7 +387,7 @@ public class AudioSharingCallAudioPreferenceController extends AudioSharingBaseP
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void logCallAudioDeviceChange(int currentGroupId, CachedBluetoothDevice target) {
|
||||
void logCallAudioDeviceChange(int currentGroupId, CachedBluetoothDevice target) {
|
||||
var unused =
|
||||
ThreadUtils.postOnBackgroundThread(
|
||||
() -> {
|
||||
|
||||
@@ -87,7 +87,8 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
|
||||
@Nullable private AudioSharingDialogHandler mDialogHandler;
|
||||
private AtomicBoolean mIntentHandled = new AtomicBoolean(false);
|
||||
|
||||
private BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
|
||||
@VisibleForTesting
|
||||
BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
|
||||
new BluetoothLeBroadcastAssistant.Callback() {
|
||||
@Override
|
||||
public void onSearchStarted(int reason) {}
|
||||
@@ -368,23 +369,23 @@ public class AudioSharingDevicePreferenceController extends BasePreferenceContro
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setBluetoothDeviceUpdater(@Nullable BluetoothDeviceUpdater bluetoothDeviceUpdater) {
|
||||
void setBluetoothDeviceUpdater(@Nullable BluetoothDeviceUpdater bluetoothDeviceUpdater) {
|
||||
mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setDialogHandler(@Nullable AudioSharingDialogHandler dialogHandler) {
|
||||
void setDialogHandler(@Nullable AudioSharingDialogHandler dialogHandler) {
|
||||
mDialogHandler = dialogHandler;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setHostFragment(@Nullable DashboardFragment fragment) {
|
||||
void setHostFragment(@Nullable DashboardFragment fragment) {
|
||||
mFragment = fragment;
|
||||
}
|
||||
|
||||
/** Test only: set intent handle state for test. */
|
||||
@VisibleForTesting
|
||||
public void setIntentHandled(boolean handled) {
|
||||
void setIntentHandled(boolean handled) {
|
||||
mIntentHandled.set(handled);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +79,9 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
||||
private Map<Integer, Integer> mValueMap = new HashMap<Integer, Integer>();
|
||||
private AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false);
|
||||
|
||||
private BluetoothVolumeControl.Callback mVolumeControlCallback =
|
||||
@VisibleForTesting
|
||||
BluetoothVolumeControl.Callback mVolumeControlCallback =
|
||||
new BluetoothVolumeControl.Callback() {
|
||||
@Override
|
||||
public void onVolumeOffsetChanged(
|
||||
@NonNull BluetoothDevice device, int volumeOffset) {}
|
||||
|
||||
@Override
|
||||
public void onDeviceVolumeChanged(
|
||||
@NonNull BluetoothDevice device,
|
||||
@@ -117,7 +114,8 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
||||
}
|
||||
};
|
||||
|
||||
private BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
|
||||
@VisibleForTesting
|
||||
BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
|
||||
new BluetoothLeBroadcastAssistant.Callback() {
|
||||
@Override
|
||||
public void onSearchStarted(int reason) {}
|
||||
@@ -323,26 +321,26 @@ public class AudioSharingDeviceVolumeGroupController extends AudioSharingBasePre
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setDeviceUpdater(@Nullable AudioSharingDeviceVolumeControlUpdater updater) {
|
||||
void setDeviceUpdater(@Nullable AudioSharingDeviceVolumeControlUpdater updater) {
|
||||
mBluetoothDeviceUpdater = updater;
|
||||
}
|
||||
|
||||
/** Test only: set callback registration status in tests. */
|
||||
@VisibleForTesting
|
||||
public void setCallbacksRegistered(boolean registered) {
|
||||
void setCallbacksRegistered(boolean registered) {
|
||||
mCallbacksRegistered.set(registered);
|
||||
}
|
||||
|
||||
/** Test only: set volume map in tests. */
|
||||
@VisibleForTesting
|
||||
public void setVolumeMap(@Nullable Map<Integer, Integer> map) {
|
||||
void setVolumeMap(@Nullable Map<Integer, Integer> map) {
|
||||
mValueMap.clear();
|
||||
mValueMap.putAll(map);
|
||||
}
|
||||
|
||||
/** Test only: set value for private preferenceGroup in tests. */
|
||||
@VisibleForTesting
|
||||
public void setPreferenceGroup(@Nullable PreferenceGroup group) {
|
||||
void setPreferenceGroup(@Nullable PreferenceGroup group) {
|
||||
mPreferenceGroup = group;
|
||||
mPreference = group;
|
||||
}
|
||||
|
||||
@@ -345,4 +345,6 @@ public class AudioSharingDialogFactory {
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
|
||||
private AudioSharingDialogFactory() {}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.util.Pair;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
@@ -61,7 +62,8 @@ public class AudioSharingDialogHandler {
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private List<BluetoothDevice> mTargetSinks = new ArrayList<>();
|
||||
|
||||
private final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||
@VisibleForTesting
|
||||
final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||
new BluetoothLeBroadcast.Callback() {
|
||||
@Override
|
||||
public void onBroadcastStarted(int reason, int broadcastId) {
|
||||
|
||||
@@ -145,9 +145,17 @@ public class AudioSharingDisconnectDialogFragment extends InstrumentedDialogFrag
|
||||
return sNewDevice;
|
||||
}
|
||||
|
||||
/** Test only: get the {@link DialogEventListener} passed to the dialog. */
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
DialogEventListener getListener() {
|
||||
return sListener;
|
||||
}
|
||||
|
||||
/** Test only: get the event data passed to the dialog. */
|
||||
@VisibleForTesting
|
||||
protected @NonNull Pair<Integer, Object>[] getEventData() {
|
||||
@NonNull
|
||||
Pair<Integer, Object>[] getEventData() {
|
||||
return sEventData;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,9 +110,17 @@ public class AudioSharingJoinDialogFragment extends InstrumentedDialogFragment {
|
||||
return sNewDevice;
|
||||
}
|
||||
|
||||
/** Test only: get the {@link DialogEventListener} passed to the dialog. */
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
DialogEventListener getListener() {
|
||||
return sListener;
|
||||
}
|
||||
|
||||
/** Test only: get the event data passed to the dialog. */
|
||||
@VisibleForTesting
|
||||
protected @NonNull Pair<Integer, Object>[] getEventData() {
|
||||
@NonNull
|
||||
Pair<Integer, Object>[] getEventData() {
|
||||
return sEventData;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
protected final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||
final BluetoothLeBroadcast.Callback mBroadcastCallback =
|
||||
new BluetoothLeBroadcast.Callback() {
|
||||
@Override
|
||||
public void onBroadcastStarted(int reason, int broadcastId) {
|
||||
@@ -392,7 +392,7 @@ public class AudioSharingSwitchBarController extends BasePreferenceController
|
||||
|
||||
/** Test only: set callback registration status in tests. */
|
||||
@VisibleForTesting
|
||||
public void setCallbacksRegistered(boolean registered) {
|
||||
void setCallbacksRegistered(boolean registered) {
|
||||
mCallbacksRegistered.set(registered);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user