Clear connected Bluetooth device from preference when Bluetooth state is off
1. Clear connected Bluetooth device from preference when Bluetooth state is off. 2. Do not force to update the list of Bluetooth device when Bluetooth is disable. 3. Add test to verify following situations: 1. Do not force to update the list of Bluetooth device when Bluetooth is disable. 2. Force to update the list of Bluetooth device when Bluetooth is enable. 3. Force to update the list of Bluetooth device when Bluetooth state is on. 4. Clear the connected Bluetooth device from preference when Bluetooth state is off. Bug: 110178164 Test: make -j42 RunSettingsRoboTests Change-Id: I8b17c5d761e010e4eab620355c8b9185543e85ed
This commit is contained in:
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
@@ -32,6 +33,7 @@ import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowAudioManager;
|
||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
@@ -43,12 +45,13 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowAudioManager.class})
|
||||
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class})
|
||||
public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
@Mock
|
||||
private DashboardFragment mDashboardFragment;
|
||||
@@ -67,12 +70,15 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
private ConnectedBluetoothDeviceUpdater mBluetoothDeviceUpdater;
|
||||
private Collection<CachedBluetoothDevice> cachedDevices;
|
||||
private ShadowAudioManager mShadowAudioManager;
|
||||
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mShadowAudioManager = ShadowAudioManager.getShadow();
|
||||
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||
mShadowBluetoothAdapter.setEnabled(true);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||
cachedDevices =
|
||||
|
Reference in New Issue
Block a user