Update Robolectric to 3.4.2

Bug: 66693279
Test: m RunSettingsRoboTests
      m RunSettingsRoboTests-jacoco
Change-Id: I9df619c3d68f0af2ee2ae944a15998275129f7c2
This commit is contained in:
Maurice Lam
2017-09-20 22:20:22 -07:00
parent d0b1297e84
commit e18902ec67
66 changed files with 297 additions and 273 deletions

View File

@@ -38,6 +38,7 @@ import com.android.settingslib.bluetooth.LocalBluetoothAdapter;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -62,8 +63,12 @@ import static org.mockito.Mockito.when;
})
public class BluetoothEnablerTest {
private static final EnforcedAdmin FAKE_ENFORCED_ADMIN =
new EnforcedAdmin(new ComponentName("test.package", "test.Class"), 10);
private static EnforcedAdmin sFakeEnforcedAdmin;
@BeforeClass
public static void beforeClass() {
sFakeEnforcedAdmin = new EnforcedAdmin(new ComponentName("test.package", "test.Class"), 10);
}
@Mock
private MetricsFeatureProvider mMetricsFeatureProvider;
@@ -130,7 +135,7 @@ public class BluetoothEnablerTest {
public void maybeEnforceRestrictions_disallowBluetoothRestrictionSet() {
// GIVEN Bluetooth has been disallowed...
when(mRestrictionUtils.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_BLUETOOTH)).thenReturn(FAKE_ENFORCED_ADMIN);
mContext, UserManager.DISALLOW_BLUETOOTH)).thenReturn(sFakeEnforcedAdmin);
when(mRestrictionUtils.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH)).thenReturn(null);
@@ -139,7 +144,7 @@ public class BluetoothEnablerTest {
assertThat(mBluetoothEnabler.maybeEnforceRestrictions()).isTrue();
// THEN the expected EnfoceAdmin is set.
verify(mMasterSwitchController).setDisabledByAdmin(FAKE_ENFORCED_ADMIN);
verify(mMasterSwitchController).setDisabledByAdmin(sFakeEnforcedAdmin);
// THEN the switch is unchecked.
verify(mMasterSwitchController).setChecked(false);
@@ -151,14 +156,14 @@ public class BluetoothEnablerTest {
when(mRestrictionUtils.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_BLUETOOTH)).thenReturn(null);
when(mRestrictionUtils.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH)).thenReturn(FAKE_ENFORCED_ADMIN);
mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH)).thenReturn(sFakeEnforcedAdmin);
// WHEN the maybeEnforceRestrictions is called...
// THEN true is returned to indicate there was a restriction to enforce.
assertThat(mBluetoothEnabler.maybeEnforceRestrictions()).isTrue();
// THEN the expected EnfoceAdmin is set.
verify(mMasterSwitchController).setDisabledByAdmin(FAKE_ENFORCED_ADMIN);
verify(mMasterSwitchController).setDisabledByAdmin(sFakeEnforcedAdmin);
// THEN the switch is unchecked.
verify(mMasterSwitchController).setChecked(false);
@@ -168,7 +173,7 @@ public class BluetoothEnablerTest {
public void maybeEnforceRestrictions_disallowBluetoothNotOverriden() {
// GIVEN Bluetooth has been disallowed...
when(mRestrictionUtils.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_BLUETOOTH)).thenReturn(FAKE_ENFORCED_ADMIN);
mContext, UserManager.DISALLOW_BLUETOOTH)).thenReturn(sFakeEnforcedAdmin);
when(mRestrictionUtils.checkIfRestrictionEnforced(
mContext, UserManager.DISALLOW_CONFIG_BLUETOOTH)).thenReturn(null);

View File

@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
@@ -35,8 +34,6 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class BluetoothFilesPreferenceControllerTest {

View File

@@ -21,7 +21,6 @@ import android.content.Context;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;

View File

@@ -33,7 +33,6 @@ import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import org.junit.Before;
import org.junit.Test;