Merge "Fix broken settings tests"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a2cd3a32e3
@@ -26,7 +26,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -75,13 +74,13 @@ public class AlwaysDiscoverableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void startSetsModeAndRegistersReceiver() {
|
||||
mBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_NONE);
|
||||
mAlwaysDiscoverable.start();
|
||||
assertThat(mBluetoothAdapter.getScanMode())
|
||||
.isEqualTo(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
|
||||
verify(mContext).registerReceiver(eq(mAlwaysDiscoverable), any());
|
||||
verify(mContext).registerReceiver(eq(mAlwaysDiscoverable), any(),
|
||||
eq(Context.RECEIVER_EXPORTED_UNAUDITED));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -47,7 +48,6 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -206,11 +206,11 @@ public class BluetoothEnablerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void bluetoothTurnsOff_switchTurnsOff() {
|
||||
// Start up with bluetooth turned on. The switch should get turned on.
|
||||
ArgumentCaptor<BroadcastReceiver> captor = ArgumentCaptor.forClass(BroadcastReceiver.class);
|
||||
when(mContext.registerReceiver(captor.capture(), any(IntentFilter.class))).thenReturn(null);
|
||||
when(mContext.registerReceiver(captor.capture(), any(IntentFilter.class),
|
||||
eq(Context.RECEIVER_EXPORTED_UNAUDITED))).thenReturn(null);
|
||||
mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_ON);
|
||||
verify(mSwitchController, never()).setChecked(anyBoolean());
|
||||
mBluetoothEnabler.resume(mContext);
|
||||
@@ -231,11 +231,11 @@ public class BluetoothEnablerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void bluetoothTurnsOn_switchTurnsOn() {
|
||||
// Start up with bluetooth turned on. The switch should be left off.
|
||||
ArgumentCaptor<BroadcastReceiver> captor = ArgumentCaptor.forClass(BroadcastReceiver.class);
|
||||
when(mContext.registerReceiver(captor.capture(), any(IntentFilter.class))).thenReturn(null);
|
||||
when(mContext.registerReceiver(captor.capture(), any(IntentFilter.class),
|
||||
eq(Context.RECEIVER_EXPORTED_UNAUDITED))).thenReturn(null);
|
||||
mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_OFF);
|
||||
verify(mSwitchController, never()).setChecked(anyBoolean());
|
||||
mBluetoothEnabler.resume(mContext);
|
||||
|
@@ -47,7 +47,6 @@ import com.android.settings.widget.SingleTargetGearPreference;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -155,16 +154,21 @@ public class PreviouslyConnectedDevicePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void callbackCanRegisterAndUnregister() {
|
||||
public void onStart_registerCallback() {
|
||||
// register the callback in onStart()
|
||||
mPreConnectedDeviceController.onStart();
|
||||
|
||||
verify(mBluetoothDeviceUpdater).registerCallback();
|
||||
verify(mDockUpdater).registerCallback();
|
||||
verify(mContext).registerReceiver(mPreConnectedDeviceController.mReceiver,
|
||||
mPreConnectedDeviceController.mIntentFilter);
|
||||
mPreConnectedDeviceController.mIntentFilter, Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||
verify(mBluetoothDeviceUpdater).refreshPreference();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStop_unregisterCallback() {
|
||||
// register it first
|
||||
mContext.registerReceiver(mPreConnectedDeviceController.mReceiver, null);
|
||||
|
||||
// unregister the callback in onStop()
|
||||
mPreConnectedDeviceController.onStop();
|
||||
|
Reference in New Issue
Block a user