Fix BluetoothLeAudioDeviceDetailsPreferenceControllerTest faliure

Two failure case need to run under classic connection by default
situation. Add the precondition for those test case. Remove the ignore
to reland those test case.

Bug: 313589946
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothLeAudioDeviceDetailsPreferenceControllerTest
Change-Id: If2c9cd590151be043be52e0793d073be83cd0c21
This commit is contained in:
Alice Kuo
2023-11-30 01:55:57 +08:00
parent 07b2af4120
commit 18e16b1a6a

View File

@@ -37,7 +37,6 @@ import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
@@ -82,7 +81,6 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest {
mController.onPreferenceChange(mPreference, true /* new value */); mController.onPreferenceChange(mPreference, true /* new value */);
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, false); LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, false);
assertThat(isEnabled).isTrue(); assertThat(isEnabled).isTrue();
} }
@@ -92,26 +90,24 @@ public class BluetoothLeAudioDeviceDetailsPreferenceControllerTest {
mController.onPreferenceChange(mPreference, false /* new value */); mController.onPreferenceChange(mPreference, false /* new value */);
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, true); LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, true);
assertThat(isEnabled).isFalse(); assertThat(isEnabled).isFalse();
} }
@Ignore("b/313589946")
@Test @Test
public void updateState_settingEnabled_preferenceShouldBeChecked() { public void updateState_settingEnabled_preferenceShouldBeChecked() {
mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED;
SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "true"); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "true");
mController.mLeAudioEnabledByDefault = false;
mController.updateState(mPreference); mController.updateState(mPreference);
verify(mPreference).setChecked(true); verify(mPreference).setChecked(true);
} }
@Ignore("b/313589946")
@Test @Test
public void updateState_settingDisabled_preferenceShouldNotBeChecked() { public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED; mController.sLeAudioSupportedStateCache = BluetoothStatusCodes.FEATURE_SUPPORTED;
SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "false"); SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, "false");
mController.mLeAudioEnabledByDefault = false;
mController.updateState(mPreference); mController.updateState(mPreference);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }