Fix the section below "Pair new device" moves up a few pixels

This CL add new controller that used to show the summary when
bluetooth is off. It can prevent a jank since the UI is decided
before render.

Bug: 182232469
Test: make RunSettingsRoboTests -j56
Change-Id: I78eb757cd1b636fbb18028fb2294861467bc6eba
This commit is contained in:
Hugh Chen
2021-04-27 14:37:29 +08:00
parent 9246f6f8b0
commit 139ff59346
5 changed files with 223 additions and 4 deletions

View File

@@ -79,6 +79,7 @@ public class AddDevicePreferenceControllerTest {
String key = mAddDevicePreferenceController.getPreferenceKey();
mAddDevicePreference = new RestrictedPreference(mContext);
mAddDevicePreference.setKey(key);
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
when(mScreen.findPreference(key)).thenReturn(mAddDevicePreference);
mAddDevicePreferenceController.displayPreference(mScreen);
}
@@ -128,4 +129,13 @@ public class AddDevicePreferenceControllerTest {
assertThat(mAddDevicePreferenceController.getAvailabilityStatus())
.isEqualTo(AVAILABLE);
}
@Test
public void getAvailabilityStatus_bluetoothIsDisabled_unSupported() {
mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
when(mBluetoothAdapter.isEnabled()).thenReturn(false);
assertThat(mAddDevicePreferenceController.getAvailabilityStatus())
.isEqualTo(UNSUPPORTED_ON_DEVICE);
}
}