Hide audio switcher entry-point in the volume slice when in call
- update test case Bug: 132385707 Test: make -j42 RunSettingsRoboTests Change-Id: Ibfd12e75f584b6884d1025018772ac9c19673156
This commit is contained in:
@@ -26,6 +26,7 @@ import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.SliceMetadata;
|
||||
@@ -47,12 +48,15 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowTelephonyManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowBluetoothUtils.class})
|
||||
@Config(shadows = {ShadowBluetoothUtils.class,
|
||||
ShadowTelephonyManager.class})
|
||||
public class MediaOutputIndicatorSliceTest {
|
||||
|
||||
private static final String TEST_A2DP_DEVICE_NAME = "Test_A2DP_BT_Device_NAME";
|
||||
@@ -76,11 +80,14 @@ public class MediaOutputIndicatorSliceTest {
|
||||
private Context mContext;
|
||||
private List<BluetoothDevice> mDevicesList;
|
||||
private MediaOutputIndicatorSlice mMediaOutputIndicatorSlice;
|
||||
private ShadowTelephonyManager mShadowTelephonyManager;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mShadowTelephonyManager = Shadow.extract(mContext.getSystemService(
|
||||
Context.TELEPHONY_SERVICE));
|
||||
// Set-up specs for SliceMetadata.
|
||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||
|
||||
@@ -151,4 +158,31 @@ public class MediaOutputIndicatorSliceTest {
|
||||
assertThat(metadata.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
|
||||
assertThat(metadata.getSubtitle()).isEqualTo(TEST_HAP_DEVICE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_callStateIdle_available() {
|
||||
mDevicesList.add(mA2dpDevice);
|
||||
when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
|
||||
mShadowTelephonyManager.setCallState(TelephonyManager.CALL_STATE_IDLE);
|
||||
|
||||
assertThat(mMediaOutputIndicatorSlice.getSlice()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_callStateRinging_returnNull() {
|
||||
mDevicesList.add(mA2dpDevice);
|
||||
when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
|
||||
mShadowTelephonyManager.setCallState(TelephonyManager.CALL_STATE_RINGING);
|
||||
|
||||
assertThat(mMediaOutputIndicatorSlice.getSlice()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_callStateOffHook_returnNull() {
|
||||
mDevicesList.add(mA2dpDevice);
|
||||
when(mA2dpProfile.getConnectedDevices()).thenReturn(mDevicesList);
|
||||
mShadowTelephonyManager.setCallState(TelephonyManager.CALL_STATE_OFFHOOK);
|
||||
|
||||
assertThat(mMediaOutputIndicatorSlice.getSlice()).isNull();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user