Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b853891 authored by chelseahao's avatar chelseahao
Browse files

[Audiosharing] Increase test coverage for audio stream states.

Test: atest -c com.android.settings.connecteddevice.audiosharing.audiostreams
Flag: com.android.settingslib.flags.enable_le_audio_qr_code_private_broadcast_sharing
Bug: 345686602
Change-Id: I91d9a45abd4c9659c9d0ddeca5f5aaefed36f820
parent e626a77a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ class AddSourceWaitForResponseState extends AudioStreamStateHandler {

    @Nullable private static AddSourceWaitForResponseState sInstance = null;

    private AddSourceWaitForResponseState() {}
    @VisibleForTesting
    AddSourceWaitForResponseState() {}

    static AddSourceWaitForResponseState getInstance() {
        if (sInstance == null) {
+6 −1
Original line number Diff line number Diff line
@@ -35,10 +35,10 @@ class AudioStreamStateHandler {
    private static final boolean DEBUG = BluetoothUtils.D;
    @VisibleForTesting static final int EMPTY_STRING_RES = 0;

    final AudioStreamsRepository mAudioStreamsRepository = AudioStreamsRepository.getInstance();
    final Handler mHandler = new Handler(Looper.getMainLooper());
    final MetricsFeatureProvider mMetricsFeatureProvider =
            FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
    AudioStreamsRepository mAudioStreamsRepository = AudioStreamsRepository.getInstance();

    AudioStreamStateHandler() {}

@@ -112,4 +112,9 @@ class AudioStreamStateHandler {
    AudioStreamsProgressCategoryController.AudioStreamState getStateEnum() {
        return AudioStreamsProgressCategoryController.AudioStreamState.UNKNOWN;
    }

    @VisibleForTesting
    void setAudioStreamsRepositoryForTesting(AudioStreamsRepository repository) {
        mAudioStreamsRepository = repository;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ public class AudioStreamsHelper {
     *
     * @param source The LE broadcast metadata representing the audio source.
     */
    void addSource(BluetoothLeBroadcastMetadata source) {
    @VisibleForTesting
    public void addSource(BluetoothLeBroadcastMetadata source) {
        if (mLeBroadcastAssistant == null) {
            Log.w(TAG, "addSource(): LeBroadcastAssistant is null!");
            return;
@@ -97,7 +98,8 @@ public class AudioStreamsHelper {
    }

    /** Removes sources from LE broadcasts associated for all active sinks based on broadcast Id. */
    void removeSource(int broadcastId) {
    @VisibleForTesting
    public void removeSource(int broadcastId) {
        if (mLeBroadcastAssistant == null) {
            Log.w(TAG, "removeSource(): LeBroadcastAssistant is null!");
            return;
+3 −3
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ class SourceAddedState extends AudioStreamStateHandler {

    @Nullable private static SourceAddedState sInstance = null;

    private SourceAddedState() {}
    @VisibleForTesting
    SourceAddedState() {}

    static SourceAddedState getInstance() {
        if (sInstance == null) {
@@ -80,8 +81,7 @@ class SourceAddedState extends AudioStreamStateHandler {
                    AudioStreamDetailsFragment.BROADCAST_ID_ARG, p.getAudioStreamBroadcastId());

            new SubSettingLauncher(p.getContext())
                    .setTitleText(
                            p.getContext().getString(R.string.audio_streams_detail_page_title))
                    .setTitleRes(R.string.audio_streams_detail_page_title)
                    .setDestination(AudioStreamDetailsFragment.class.getName())
                    .setSourceMetricsCategory(
                            controller.getFragment() == null
+4 −2
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ class WaitForSyncState extends AudioStreamStateHandler {

    @Nullable private static WaitForSyncState sInstance = null;

    private WaitForSyncState() {}
    @VisibleForTesting
    WaitForSyncState() {}

    static WaitForSyncState getInstance() {
        if (sInstance == null) {
@@ -114,7 +115,8 @@ class WaitForSyncState extends AudioStreamStateHandler {
                SettingsEnums.DIALOG_AUDIO_STREAM_MAIN_WAIT_FOR_SYNC_TIMEOUT);
    }

    private void launchQrCodeScanFragment(Context context, Fragment fragment) {
    @VisibleForTesting
    void launchQrCodeScanFragment(Context context, Fragment fragment) {
        new SubSettingLauncher(context)
                .setTitleRes(R.string.audio_streams_main_page_scan_qr_code_title)
                .setDestination(AudioStreamsQrCodeScanFragment.class.getName())
Loading