Prepare tests for impending robolectric merge
Some ShadowUserManager function moved into the basic shadow in robolectric proper and has been removed from the Settings ShadowUserManager. Test: make -j56 RunSettingsRoboTests Change-Id: I38647dae5d16bc79bc7925ca139c9362a2035393
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -64,7 +64,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
private Context mContext;
|
||||
private AvailableMediaBluetoothDeviceUpdater mBluetoothDeviceUpdater;
|
||||
private Collection<CachedBluetoothDevice> mCachedDevices;
|
||||
private ShadowAudioManager mShadowAudioManager;
|
||||
private AudioManager mAudioManager;
|
||||
private BluetoothDevicePreference mPreference;
|
||||
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
|
||||
private ShadowCachedBluetoothDeviceManager mShadowCachedBluetoothDeviceManager;
|
||||
@@ -73,14 +73,13 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mShadowAudioManager = ShadowAudioManager.getShadow();
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mAudioManager = mContext.getSystemService(AudioManager.class);
|
||||
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
|
||||
mShadowBluetoothAdapter.setEnabled(true);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mShadowCachedBluetoothDeviceManager = Shadow.extract(
|
||||
Utils.getLocalBtManager(mContext).getCachedDeviceManager());
|
||||
mCachedDevices =
|
||||
new ArrayList<CachedBluetoothDevice>(new ArrayList<CachedBluetoothDevice>());
|
||||
mCachedDevices = new ArrayList<>();
|
||||
mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
|
||||
|
||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||
@@ -96,7 +95,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onAudioModeChanged_hfpDeviceConnected_inCall_addPreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
|
||||
@@ -109,7 +108,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onAudioModeChanged_hfpDeviceConnected_notInCall_removePreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
|
||||
@@ -122,7 +121,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onAudioModeChanged_a2dpDeviceConnected_inCall_removePreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true);
|
||||
@@ -135,7 +134,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onAudioModeChanged_a2dpDeviceConnected_notInCall_addPreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true);
|
||||
@@ -148,7 +147,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_a2dpDeviceConnected_notInCall_addPreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true);
|
||||
@@ -161,7 +160,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_a2dpDeviceConnected_inCall_removePreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true);
|
||||
@@ -174,7 +173,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hfpDeviceConnected_notInCall_removePreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
|
||||
@@ -187,7 +186,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hfpDeviceConnected_inCall_addPreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
|
||||
@@ -201,7 +200,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hearingAidDeviceConnected_notInCall_addPreference()
|
||||
{
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
|
||||
@@ -214,7 +213,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hearingAidDeviceConnected_inCall_addPreference() {
|
||||
mShadowAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
|
||||
when(mBluetoothDeviceUpdater.
|
||||
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
|
||||
|
Reference in New Issue
Block a user