Merge "[Rohan]The battery level show up "-1%", not sync with Rohan." into sc-dev
This commit is contained in:
@@ -41,6 +41,7 @@ import com.android.settings.core.SettingsUIDeviceConfig;
|
||||
import com.android.settings.fuelgauge.BatteryMeterView;
|
||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
@@ -135,6 +136,32 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
||||
assertBatteryLevel(mLayoutPreference.findViewById(R.id.layout_middle), BATTERY_LEVEL_MAIN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refresh_connectedWatch_unknownBatteryLevel_shouldNotShowBatteryLevel() {
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
|
||||
BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)).thenReturn(
|
||||
String.valueOf(false).getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
|
||||
String.valueOf(BluetoothUtils.META_INT_ERROR).getBytes());
|
||||
when(mBluetoothDevice.getBatteryLevel()).thenReturn(BluetoothDevice.BATTERY_LEVEL_UNKNOWN);
|
||||
when(mCachedDevice.isConnected()).thenReturn(true);
|
||||
|
||||
mController.refresh();
|
||||
|
||||
assertThat(mLayoutPreference.findViewById(R.id.layout_left).getVisibility()).isEqualTo(
|
||||
View.GONE);
|
||||
assertThat(mLayoutPreference.findViewById(R.id.layout_right).getVisibility()).isEqualTo(
|
||||
View.GONE);
|
||||
assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
|
||||
View.VISIBLE);
|
||||
assertThat(mLayoutPreference.findViewById(R.id.layout_middle)
|
||||
.requireViewById(R.id.bt_battery_summary).getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refresh_connectedUntetheredHeadset_behaveAsExpected() {
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
|
Reference in New Issue
Block a user