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

Commit a9deae30 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Fix spatial audio tests when flag is enabled" into main

parents 0380864e bb2ad3cb
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.volume.panel.component.spatial.domain

import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothProfile
import android.media.AudioDeviceAttributes
import android.media.AudioDeviceInfo
import android.media.session.MediaSession
@@ -24,12 +26,14 @@ import android.testing.TestableLooper.RunWithLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LeAudioProfile
import com.android.settingslib.media.BluetoothMediaDevice
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.testScope
import com.android.systemui.media.spatializerRepository
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.android.systemui.volume.localMediaController
@@ -56,8 +60,15 @@ class SpatialAudioAvailabilityCriteriaTest : SysuiTestCase() {
    @Before
    fun setup() {
        with(kosmos) {
            val leAudioProfile =
                mock<LeAudioProfile> {
                    whenever(profileId).thenReturn(BluetoothProfile.LE_AUDIO)
                    whenever(isEnabled(any())).thenReturn(true)
                }
            val cachedBluetoothDevice: CachedBluetoothDevice = mock {
                whenever(address).thenReturn("test_address")
                whenever(profiles).thenReturn(listOf(leAudioProfile))
                whenever(device).thenReturn(mock<BluetoothDevice> {})
            }
            localMediaRepository.updateCurrentConnectedDevice(
                mock<BluetoothMediaDevice> {
+5 −1
Original line number Diff line number Diff line
@@ -65,16 +65,20 @@ class SpatialAudioComponentInteractorTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private lateinit var underTest: SpatialAudioComponentInteractor

    private val bluetoothDevice: BluetoothDevice = mock {}
    private val a2dpProfile: A2dpProfile = mock {
        whenever(profileId).thenReturn(BluetoothProfile.A2DP)
        whenever(isEnabled(bluetoothDevice)).thenReturn(false)
    }
    private val leAudioProfile: LeAudioProfile = mock {
        whenever(profileId).thenReturn(BluetoothProfile.LE_AUDIO)
        whenever(isEnabled(bluetoothDevice)).thenReturn(true)
    }
    private val hearingAidProfile: HearingAidProfile = mock {
        whenever(profileId).thenReturn(BluetoothProfile.HEARING_AID)
        whenever(isEnabled(bluetoothDevice)).thenReturn(false)
    }
    private val bluetoothDevice: BluetoothDevice = mock {}

    @Before
    fun setup() {
+8 −0
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@ package com.android.systemui.volume.panel.component.mediaoutput.domain.interacto

import android.annotation.SuppressLint
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothProfile
import android.graphics.drawable.Drawable
import android.graphics.drawable.TestStubDrawable
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.LeAudioProfile
import com.android.settingslib.media.BluetoothMediaDevice
import com.android.settingslib.media.MediaDevice
import com.android.settingslib.media.PhoneMediaDevice
@@ -59,11 +61,17 @@ object TestMediaDevicesFactory {
                whenever(name).thenReturn(deviceName)
                whenever(address).thenReturn(deviceAddress)
            }
        val leAudioProfile =
            mock<LeAudioProfile> {
                whenever(profileId).thenReturn(BluetoothProfile.LE_AUDIO)
                whenever(isEnabled(bluetoothDevice)).thenReturn(true)
            }
        val cachedBluetoothDevice: CachedBluetoothDevice = mock {
            whenever(isHearingAidDevice).thenReturn(true)
            whenever(address).thenReturn(deviceAddress)
            whenever(device).thenReturn(bluetoothDevice)
            whenever(name).thenReturn(deviceName)
            whenever(profiles).thenReturn(listOf(leAudioProfile))
        }
        return mock<BluetoothMediaDevice> {
            whenever(name).thenReturn(deviceName)