Fix issues in BT detail header
1. Update isAvailable() in controller 2. Update method to get fast pair icon Bug: 124455912 Test: RunSettingsRoboTests Change-Id: I24a04c8c91d74e9b8b7e8746ad6279fafa37f0a9
This commit is contained in:
@@ -18,13 +18,16 @@ package com.android.settings.bluetooth;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -50,12 +53,17 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
|
||||
private static final int BATTERY_LEVEL_MAIN = 30;
|
||||
private static final int BATTERY_LEVEL_LEFT = 25;
|
||||
private static final int BATTERY_LEVEL_RIGHT = 45;
|
||||
private static final String ICON_URI = "content://test.provider/icon.png";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Mock
|
||||
private BluetoothDevice mBluetoothDevice;
|
||||
@Mock
|
||||
private Bitmap mBitmap;
|
||||
@Mock
|
||||
private ImageView mImageView;
|
||||
@Mock
|
||||
private CachedBluetoothDevice mCachedDevice;
|
||||
private AdvancedBluetoothDetailsHeaderController mController;
|
||||
private LayoutPreference mLayoutPreference;
|
||||
@@ -142,6 +150,15 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
|
||||
BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateIcon_existInCache_setImageBitmap() {
|
||||
mController.mIconCache.put(ICON_URI, mBitmap);
|
||||
|
||||
mController.updateIcon(mImageView, ICON_URI);
|
||||
|
||||
verify(mImageView).setImageBitmap(mBitmap);
|
||||
}
|
||||
|
||||
private void assertBatteryLevel(LinearLayout linearLayout, int batteryLevel) {
|
||||
final TextView textView = linearLayout.findViewById(R.id.bt_battery_summary);
|
||||
assertThat(textView.getText().toString()).isEqualTo(
|
||||
|
@@ -19,18 +19,12 @@ package com.android.settings.bluetooth;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -62,6 +56,8 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro
|
||||
private LocalBluetoothManager mBluetoothManager;
|
||||
@Mock
|
||||
private CachedBluetoothDeviceManager mCachedDeviceManager;
|
||||
@Mock
|
||||
private BluetoothDevice mBluetoothDevice;
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
@@ -77,6 +73,7 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro
|
||||
mPreference.setKey(mController.getPreferenceKey());
|
||||
mScreen.addPreference(mPreference);
|
||||
setupDevice(mDeviceConfig);
|
||||
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -124,4 +121,12 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro
|
||||
inOrder.verify(mHeaderController)
|
||||
.setSummary(mContext.getString(R.string.bluetooth_connecting));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_unthetheredHeadset_returnFalse() {
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_IS_UNTHETHERED_HEADSET)).thenReturn("true");
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user