Add zero state in output switcher

-Update visibility of switcher preference in SoundSetting
-Update visibility of indicator slice in Volume Panel
-Add test case

Bug: 152357002
Test: make -j50 RunSettingsRoboTests
Change-Id: I8aa4e960b72f2c3c26ced78153c4ff620a123f40
This commit is contained in:
Tim Peng
2020-03-27 20:24:06 +08:00
committed by tim peng
parent df8b9acc69
commit 9d3092cb7f
6 changed files with 126 additions and 91 deletions

View File

@@ -166,47 +166,6 @@ public class MediaOutputPreferenceControllerTest {
ShadowBluetoothUtils.reset();
}
/**
* A2DP Bluetooth device(s) are not connected nor previously connected
* Preference should be invisible
*/
@Test
public void updateState_withoutConnectedBtDevice_preferenceInvisible() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_EARPIECE);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mProfileConnectedDevices.clear();
when(mA2dpProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
mPreference.setVisible(true);
assertThat(mPreference.isVisible()).isTrue();
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isFalse();
}
/**
* A2DP Bluetooth device(s) are connected, no matter active or inactive
* Preference should be visible
*/
@Test
public void updateState_withConnectedBtDevice_preferenceVisible() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_BLUETOOTH_A2DP);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mProfileConnectedDevices.clear();
mProfileConnectedDevices.add(mBluetoothDevice);
when(mA2dpProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
assertThat(mPreference.isVisible()).isFalse();
// Without Active Bluetooth Device
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isTrue();
// With Active Bluetooth Device
when(mA2dpProfile.getActiveDevice()).thenReturn(mBluetoothDevice);
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isTrue();
}
/**
* A2DP Bluetooth device(s) are connected, but no device is set as activated
* Preference summary should be "This device"
@@ -247,30 +206,6 @@ public class MediaOutputPreferenceControllerTest {
assertThat(mPreference.getSummary()).isEqualTo(TEST_DEVICE_NAME_1);
}
/**
* Hearing Aid device(s) are connected, no matter active or inactive
* Preference should be visible
*/
@Test
public void updateState_withConnectedHADevice_preferenceVisible() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_HEARING_AID);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mHearingAidActiveDevices.clear();
mHearingAidActiveDevices.add(mLeftBluetoothHapDevice);
when(mHearingAidProfile.getConnectedDevices()).thenReturn(mHearingAidActiveDevices);
assertThat(mPreference.isVisible()).isFalse();
// Without Active Hearing Aid Device
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isTrue();
// With Active Hearing Aid Device
when(mHearingAidProfile.getActiveDevices()).thenReturn(mHearingAidActiveDevices);
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isTrue();
}
/**
* Hearing Aid device(s) are connected and active
* Preference summary should be device's name
@@ -310,12 +245,12 @@ public class MediaOutputPreferenceControllerTest {
* Summary should be default summary
*/
@Test
public void updateState_shouldSetSummary() {
public void updateState_notInCall_preferenceVisible() {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isFalse();
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getText(R.string.media_output_default_summary));
assertThat(mPreference.isVisible()).isTrue();
}
/**
@@ -324,14 +259,12 @@ public class MediaOutputPreferenceControllerTest {
* Default string should be "Unavailable during calls"
*/
@Test
public void updateState_duringACall_shouldSetDefaultSummary() {
public void updateState_inCall_preferenceInvisible() {
mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isFalse();
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getText(R.string.media_out_summary_ongoing_call_state));
}
@Test