Move away from deprecated FakeFeatureFactory.setupForTest()
Test: rerun
Change-Id: I896ba414315ddb1664c0499264f4992f0554ef98
diff --git a/tests/robotests/src/com/android/settings/DeviceAdminAddTest.java b/tests/robotests/src/com/android/settings/DeviceAdminAddTest.java
index 82b8e1b..ccd0485 100644
--- a/tests/robotests/src/com/android/settings/DeviceAdminAddTest.java
+++ b/tests/robotests/src/com/android/settings/DeviceAdminAddTest.java
@@ -16,6 +16,10 @@
package com.android.settings;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
@@ -25,30 +29,22 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DeviceAdminAddTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
private FakeFeatureFactory mFeatureFactory;
private DeviceAdminAdd mDeviceAdminAdd;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mDeviceAdminAdd = Robolectric.buildActivity(DeviceAdminAdd.class).get();
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java
index 2e95c73..b2eb5b4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ShortcutServicePickerFragmentTest.java
@@ -17,7 +17,6 @@
package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -29,7 +28,6 @@
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.wrapper.PackageManagerWrapper;
import org.junit.Before;
import org.junit.Test;
@@ -54,15 +52,13 @@
private Activity mActivity;
@Mock
private UserManager mUserManager;
- @Mock
- private PackageManagerWrapper mPackageManager;
private ShortcutServicePickerFragment mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mFragment = spy(new ShortcutServicePickerFragment());
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
index 8924551..323a624 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDetailDashboardFragmentTest.java
@@ -15,6 +15,15 @@
*/
package com.android.settings.accounts;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Activity;
@@ -30,7 +39,6 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.TestConfig;
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
-import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.Tile;
@@ -45,15 +53,6 @@
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Answers.RETURNS_DEEP_STUBS;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import static org.robolectric.Shadows.shadowOf;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AccountDetailDashboardFragmentTest {
@@ -127,9 +126,6 @@
@Test
public void refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent() {
- FakeFeatureFactory.setupForTest(mContext);
- final FakeFeatureFactory featureFactory =
- (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
final DashboardFeatureProviderImpl dashboardFeatureProvider =
new DashboardFeatureProviderImpl(mContext);
final PackageManager packageManager = mock(PackageManager.class);
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java
index 1b20e96..0c15339 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountHeaderPreferenceControllerTest.java
@@ -80,7 +80,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
mHeaderPreference = new LayoutPreference(
RuntimeEnvironment.application, R.layout.settings_entity_header);
doReturn(mContext).when(mActivity).getApplicationContext();
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java
index 97c4df0..3314a21 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoDashboardFragmentTest.java
@@ -100,7 +100,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mShadowContext = RuntimeEnvironment.application;
mAppDetail = spy(new AppInfoDashboardFragment());
doReturn(mActivity).when(mAppDetail).getActivity();
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index 75ae458..7c9e81c 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -17,7 +17,6 @@
package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -61,8 +60,6 @@
shadows = ShadowEntityHeaderController.class)
public class AppInfoWithHeaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private EntityHeaderController mHeaderController;
private FakeFeatureFactory mFactory;
@@ -71,9 +68,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
-
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class)))
.thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY);
mAppInfoWithHeader = new TestFragment();
diff --git a/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java b/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
index 38c0128..bc7738c 100644
--- a/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/DrawOverlayDetailsTest.java
@@ -63,8 +63,8 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mActivity);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index b8a27b9..b6f75d4 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -130,7 +130,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mShadowContext = RuntimeEnvironment.application;
mAppDetail = spy(new InstalledAppDetails());
mAppDetail.mBatteryUtils = mBatteryUtils;
diff --git a/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java b/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
index b998b81e..0291392 100644
--- a/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PictureInPictureDetailsTest.java
@@ -17,7 +17,6 @@
package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
@@ -25,16 +24,14 @@
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.wrapper.ActivityInfoWrapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -42,17 +39,13 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PictureInPictureDetailsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private PictureInPictureDetails mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new PictureInPictureDetails();
}
diff --git a/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java b/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
index 85b398a..81df422 100644
--- a/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PictureInPictureSettingsTest.java
@@ -17,22 +17,16 @@
package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.UserInfo;
import android.util.Pair;
-import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -42,7 +36,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -57,9 +50,6 @@
private static final int PRIMARY_USER_ID = 0;
private static final int PROFILE_USER_ID = 10;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private PictureInPictureSettings mFragment;
@Mock
@@ -73,8 +63,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new PictureInPictureSettings(mPackageManager, mUserManager);
mPrimaryUserPackages = new ArrayList<>();
mProfileUserPackages = new ArrayList<>();
diff --git a/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java b/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java
index dedb61d..32a11f4 100644
--- a/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java
+++ b/tests/robotests/src/com/android/settings/applications/PremiumSmsAccessTest.java
@@ -41,17 +41,13 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PremiumSmsAccessTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private PremiumSmsAccess mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new PremiumSmsAccess();
mFragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
}
diff --git a/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java b/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java
index 64ef4ff..44b54a8 100644
--- a/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/UsageAccessDetailsTest.java
@@ -34,8 +34,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
@@ -44,17 +42,13 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsageAccessDetailsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private UsageAccessDetails mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new UsageAccessDetails();
mFragment.onAttach(ShadowApplication.getInstance().getApplicationContext());
}
diff --git a/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java b/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java
index 5f9ec95..ed14879 100644
--- a/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/VrListenerSettingsTest.java
@@ -23,15 +23,13 @@
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -39,17 +37,13 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class VrListenerSettingsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private VrListenerSettings mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new VrListenerSettings();
}
diff --git a/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java b/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java
index 6cd07e3..746bcf5 100644
--- a/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/WriteSettingsDetailsTest.java
@@ -23,15 +23,13 @@
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -39,17 +37,14 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WriteSettingsDetailsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private WriteSettingsDetails mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new WriteSettingsDetails();
}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
index 804df51..1afc12a 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
@@ -67,7 +67,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mActivity);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = spy(new TestFragment());
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
index 61d7f34..448da81 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAutofillPickerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.applications.defaultapps;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -59,7 +58,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mPicker = spy(new DefaultAutofillPicker());
mPicker.onAttach((Context) mActivity);
diff --git a/tests/robotests/src/com/android/settings/applications/instantapps/InstantAppButtonsControllerTest.java b/tests/robotests/src/com/android/settings/applications/instantapps/InstantAppButtonsControllerTest.java
index c7ca133..5c0badc 100644
--- a/tests/robotests/src/com/android/settings/applications/instantapps/InstantAppButtonsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/instantapps/InstantAppButtonsControllerTest.java
@@ -18,13 +18,10 @@
import static com.android.settings.applications.instantapps.InstantAppButtonsController
.ShowDialogDelegate;
-
import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.isNull;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -44,10 +41,10 @@
import android.widget.Button;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import org.junit.Before;
@@ -124,7 +121,7 @@
controller.setPackageName(TEST_AIA_PACKAGE_NAME);
ReflectionHelpers.setField(
controller, "mPackageManagerWrapper", mockPackageManagerWrapper);
- FakeFeatureFactory.setupForTest(mockContext);
+ FakeFeatureFactory.setupForTest();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
index 2dc411c..b45a743 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
@@ -17,20 +17,18 @@
package com.android.settings.bluetooth;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.graphics.drawable.Drawable;
import com.android.settings.R;
-import com.android.settings.applications.LayoutPreference;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.applications.LayoutPreference;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowBluetoothDevice;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
@@ -46,7 +44,7 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
- shadows={SettingsShadowBluetoothDevice.class, ShadowEntityHeaderController.class,
+ shadows = {SettingsShadowBluetoothDevice.class, ShadowEntityHeaderController.class,
SettingsShadowResources.class})
public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsControllerTestBase {
private BluetoothDetailsHeaderController mController;
@@ -58,7 +56,7 @@
@Override
public void setUp() {
super.setUp();
- FakeFeatureFactory.setupForTest(spy(mContext));
+ FakeFeatureFactory.setupForTest();
ShadowEntityHeaderController.setUseMock(mHeaderController);
mController = new BluetoothDetailsHeaderController(mContext, mFragment, mCachedDevice,
mLifecycle);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
index cd07a90..5d18c85 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragmentTest.java
@@ -68,7 +68,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
String deviceAddress = "55:66:77:88:99:AA";
mFragment = spy(BluetoothDeviceDetailsFragment.newInstance(deviceAddress));
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
index 3dd97bb..dcf0296 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDevicePreferenceTest.java
@@ -15,6 +15,14 @@
*/
package com.android.settings.bluetooth;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
@@ -22,10 +30,10 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -38,16 +46,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = SettingsShadowResources.class)
@@ -68,8 +66,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
SHOW_DEVICES_WITHOUT_NAMES);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
index 534cace..27cf3ca 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothMasterSwitchPreferenceControllerTest.java
@@ -16,15 +16,21 @@
package com.android.settings.bluetooth;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Fragment;
import android.content.Context;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.SettingsActivity;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.bluetooth.BluetoothCallback;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -38,14 +44,6 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothMasterSwitchPreferenceControllerTest {
@@ -71,8 +69,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new BluetoothMasterSwitchPreferenceController(
mContext, mBluetoothManager, mRestrictionUtils, mFragment, mActivity);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
index b177729..dc318c2 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSettingsTest.java
@@ -52,11 +52,10 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothSettingsTest {
+
private static final String FOOTAGE_MAC_STRING = "Bluetooth mac: xxxx";
@Mock
- private UserManager mUserManager;
- @Mock
private Resources mResource;
@Mock
private LocalBluetoothAdapter mLocalAdapter;
@@ -78,8 +77,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = spy(new BluetoothSettings());
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
index 71e9933..6e1e1bc 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ForgetDeviceDialogFragmentTest.java
@@ -17,7 +17,6 @@
package com.android.settings.bluetooth;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
@@ -27,7 +26,6 @@
import android.app.Activity;
import android.app.AlertDialog;
-import android.content.Context;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -41,7 +39,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
@@ -53,15 +50,13 @@
private CachedBluetoothDevice mCachedDevice;
private ForgetDeviceDialogFragment mFragment;
- private Context mContext;
private Activity mActivity;
private AlertDialog mDialog;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
String deviceAddress = "55:66:77:88:99:AA";
when(mCachedDevice.getAddress()).thenReturn(deviceAddress);
mFragment = spy(ForgetDeviceDialogFragment.newInstance(deviceAddress));
diff --git a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
index 65fe46c..254de63 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/RemoteDeviceNameDialogFragmentTest.java
@@ -17,7 +17,6 @@
package com.android.settings.bluetooth;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
@@ -27,7 +26,6 @@
import static org.mockito.Mockito.when;
import android.app.AlertDialog;
-import android.content.Context;
import android.content.DialogInterface;
import android.widget.Button;
import android.widget.EditText;
@@ -44,7 +42,6 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowDialog;
import org.robolectric.util.FragmentTestUtil;
@@ -57,13 +54,11 @@
private CachedBluetoothDevice mCachedDevice;
private RemoteDeviceNameDialogFragment mFragment;
- private Context mContext;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
String deviceAddress = "55:66:77:88:99:AA";
when(mCachedDevice.getAddress()).thenReturn(deviceAddress);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
index 43583ed..2008c81 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
@@ -15,13 +15,20 @@
*/
package com.android.settings.bluetooth;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -33,13 +40,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = SettingsShadowResources.class)
@@ -47,8 +47,6 @@
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
- @Mock
- private LocalBluetoothManager mLocalBluetoothManager;
private FakeFeatureFactory mFakeFeatureFactory;
private MetricsFeatureProvider mMetricsFeatureProvider;
@@ -56,8 +54,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
index bb35911..31d0ec5 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
@@ -47,7 +47,7 @@
public class AdvancedConnectedDeviceDashboardFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- Context mContext;
+ private Context mContext;
@Mock
private PackageManager mManager;
@@ -75,8 +75,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFeatureProvider = mFeatureFactory.smsMirroringFeatureProvider;
mFragment = new AdvancedConnectedDeviceDashboardFragment();
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
index 4bcb299..ada8944 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
@@ -15,6 +15,13 @@
*/
package com.android.settings.connecteddevice;
+import static android.content.Context.NFC_SERVICE;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.content.pm.PackageManager;
import android.nfc.NfcAdapter;
@@ -22,12 +29,12 @@
import android.provider.SearchIndexableResource;
import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.nfc.NfcPreferenceController;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.nfc.NfcPreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.XmlTestUtils;
import com.android.settingslib.drawer.CategoryKey;
@@ -42,13 +49,6 @@
import java.util.List;
-import static android.content.Context.NFC_SERVICE;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConnectedDeviceDashboardFragment2Test {
@@ -82,8 +82,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFeatureProvider = mFeatureFactory.smsMirroringFeatureProvider;
mFragment = new ConnectedDeviceDashboardFragmentOld();
diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java
index 3ad70ab..49556f2 100644
--- a/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java
+++ b/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java
@@ -63,8 +63,7 @@
@Before
public void init() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
mMetricsFeature = mFactory.metricsFeatureProvider;
mSharedPrefLogger = new SharedPreferencesLogger(mContext, TEST_TAG);
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index fdb1470..1c72863 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -92,8 +92,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
when(mFactory.suggestionsFeatureProvider
.getSuggestionIdentifier(any(Context.class), any(Tile.class)))
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index 3d36e6f..45038aa 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -98,8 +98,7 @@
doReturn(mPackageManager).when(mContext).getPackageManager();
when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
new ResolveInfo());
- FakeFeatureFactory.setupForTest(mActivity);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mImpl = new DashboardFeatureProviderImpl(mContext);
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
index 14f3078..372d3c5 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
@@ -16,9 +16,7 @@
package com.android.settings.dashboard;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -33,12 +31,11 @@
import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.instrumentation.VisibilityLoggerMixin;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
@@ -71,8 +68,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mDashboardCategory = new DashboardCategory();
mDashboardCategory.addTile(new Tile());
mTestFragment = new TestFragment(ShadowApplication.getInstance().getApplicationContext());
diff --git a/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java b/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java
index 92ed7b4..f6a32dc 100644
--- a/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/SummaryLoaderTest.java
@@ -21,7 +21,6 @@
import static org.mockito.Mockito.when;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import com.android.settings.TestConfig;
@@ -34,8 +33,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
@@ -47,8 +44,6 @@
private static final String SUMMARY_1 = "summary1";
private static final String SUMMARY_2 = "summary2";
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
private SummaryLoader mSummaryLoader;
private boolean mCallbackInvoked;
private Tile mTile;
@@ -57,7 +52,7 @@
@Before
public void SetUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mTile = new Tile();
mTile.summary = SUMMARY_1;
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index b052527..b77f8a4 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -82,7 +82,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mFeatureFactory = FakeFeatureFactory.setupForTest(mActivity);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
final Tile suggestion1 = new Tile();
final Tile suggestion2 = new Tile();
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
index c94f200..7a4ff15 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.dashboard.suggestions;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
@@ -31,9 +30,9 @@
import android.support.v7.widget.helper.ItemTouchHelper;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.suggestions.SuggestionParser;
@@ -66,8 +65,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
when(mRecyclerView.getResources().getDimension(anyInt())).thenReturn(50F);
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
index b74453c..fa53e06 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
@@ -98,8 +98,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
when(mContext.getPackageManager()).thenReturn(mPackageManager);
// Explicit casting to object due to MockitoCast bug
when((Object) mContext.getSystemService(FingerprintManager.class))
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java
index 6ddba03..2ce3769 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionStateProviderTest.java
@@ -31,8 +31,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
@@ -41,16 +39,13 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionStateProviderTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private SuggestionStateProvider mProvider;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mProvider = Robolectric.setupContentProvider(SuggestionStateProvider.class);
}
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index 75fec68..509e7cc 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -28,7 +28,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v14.preference.SwitchPreference;
@@ -62,8 +61,6 @@
public class AppDataUsageTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private EntityHeaderController mHeaderController;
@Mock
private PackageManagerWrapper mPackageManagerWrapper;
@@ -73,7 +70,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
}
@After
diff --git a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
index 081337f..5ff273e 100644
--- a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
@@ -16,7 +16,6 @@
package com.android.settings.datausage;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
@@ -26,15 +25,14 @@
import android.os.Process;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.applications.ApplicationsState;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -43,9 +41,6 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UnrestrictedDataAccessTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
@Mock
private ApplicationsState.AppEntry mAppEntry;
private UnrestrictedDataAccess mFragment;
@@ -54,8 +49,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new UnrestrictedDataAccess();
}
diff --git a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
index 3b98063..c9c3e24 100644
--- a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
@@ -17,11 +17,8 @@
package com.android.settings.deletionhelper;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -33,11 +30,10 @@
import android.support.v7.preference.Preference;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
import com.android.settings.widget.SwitchBar;
@@ -70,10 +66,7 @@
mContext = spy(RuntimeEnvironment.application);
mSwitchBar = new SwitchBar(mContext);
- Context fakeContextForFakeProvider = mock(Context.class, RETURNS_DEEP_STUBS);
- FakeFeatureFactory.setupForTest(fakeContextForFakeProvider);
- FeatureFactory featureFactory = FakeFeatureFactory.getFactory(fakeContextForFakeProvider);
- mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider();
+ mMetricsFeatureProvider = FakeFeatureFactory.setupForTest().getMetricsFeatureProvider();
mPreference = new Preference(mContext);
mController =
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index 8312673..66d397e 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.deviceinfo;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@@ -83,7 +82,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
mLifecycle = new Lifecycle(() -> mLifecycle);
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mController = new BuildNumberPreferenceController(
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
index fe640d2..23d42da 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
@@ -131,9 +131,7 @@
public void togglingShouldCauseMetricsEvent() {
// FakeFeatureFactory uses mock contexts, so this test scaffolds itself rather than using
// the instance variables.
- FakeFeatureFactory.setupForTest(mMockContext);
- final FakeFeatureFactory factory =
- (FakeFeatureFactory) FakeFeatureFactory.getFactory(mMockContext);
+ final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest();
final AutomaticStorageManagementSwitchPreferenceController controller =
new AutomaticStorageManagementSwitchPreferenceController(
mMockContext, factory.metricsFeatureProvider, mFragmentManager);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index a1a48ae..4828769 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -17,7 +17,8 @@
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ID;
-import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ONLY;
+import static com.android.settings.applications.manageapplications.ManageApplications
+ .EXTRA_WORK_ONLY;
import static com.android.settings.utils.FileSizeFormatter.MEGABYTE_IN_BYTES;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.nullable;
@@ -96,8 +97,7 @@
when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
mVolume = spy(new VolumeInfo("id", 0, null, "id"));
// Note: null is passed as the Lifecycle because we are handling it outside of the normal
@@ -203,12 +203,12 @@
assertThat(intent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
.isEqualTo(R.string.apps_storage);
assertThat(
- intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
- .getBoolean(EXTRA_WORK_ONLY))
+ intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getBoolean(EXTRA_WORK_ONLY))
.isTrue();
assertThat(
- intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
- .getInt(EXTRA_WORK_ID))
+ intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS)
+ .getInt(EXTRA_WORK_ID))
.isEqualTo(0);
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
index 1c1824d..b9a4963 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceControllerTest.java
@@ -16,8 +16,9 @@
package com.android.settings.deviceinfo.storage;
+import static com.android.settings.TestUtils.GIGABYTE;
+import static com.android.settings.TestUtils.KILOBYTE;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.spy;
@@ -36,10 +37,10 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -53,9 +54,6 @@
import java.io.File;
-import static com.android.settings.TestUtils.KILOBYTE;
-import static com.android.settings.TestUtils.GIGABYTE;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
@@ -75,8 +73,7 @@
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_headlineFontFamily, "");
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
mController = new StorageSummaryDonutPreferenceController(mContext);
mPreference = new StorageSummaryDonutPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
index febbaf1..e193b94 100644
--- a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.display;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
@@ -65,7 +64,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
mContentResolver = RuntimeEnvironment.application.getContentResolver();
mLifecycle = new Lifecycle(() -> mLifecycle);
mPreference = new SwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
index 289b8c1..751fa40 100644
--- a/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
@@ -16,6 +16,15 @@
package com.android.settings.display;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -23,10 +32,10 @@
import android.support.v7.preference.ListPreference;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.display.ThemePreferenceController.OverlayManager;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -37,15 +46,6 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ThemePreferenceControllerTest {
@@ -64,7 +64,7 @@
@Before
public void setUp() throws NameNotFoundException {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
when(mPackageManager.getApplicationInfo(any(), anyInt())).thenReturn(mApplicationInfo);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mContext.getString(R.string.default_theme))
diff --git a/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java b/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java
index e0a59b5..93403fe 100644
--- a/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/CurrentDreamPickerTest.java
@@ -16,17 +16,22 @@
package com.android.settings.dream;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.os.UserManager;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.dream.DreamBackend;
import com.android.settingslib.dream.DreamBackend.DreamInfo;
-import java.util.ArrayList;
-import java.util.Arrays;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,10 +41,8 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Arrays;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
@@ -58,10 +61,10 @@
public void setup() {
MockitoAnnotations.initMocks(this);
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
mPicker = new CurrentDreamPicker();
- mPicker.onAttach((Context)mActivity);
+ mPicker.onAttach((Context) mActivity);
ReflectionHelpers.setField(mPicker, "mBackend", mBackend);
}
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
index 542e0b7..94d6853 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
@@ -16,13 +16,19 @@
package com.android.settings.dream;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Activity;
import android.content.Context;
import android.os.UserManager;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.dream.DreamBackend;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,10 +38,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WhenToDreamPickerTest {
@@ -51,10 +53,10 @@
public void setup() {
MockitoAnnotations.initMocks(this);
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
mPicker = new WhenToDreamPicker();
- mPicker.onAttach((Context)mActivity);
+ mPicker.onAttach((Context) mActivity);
ReflectionHelpers.setField(mPicker, "mBackend", mBackend);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java
index e9b9d86..83b7198 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminActionPreferenceControllerTestBase.java
@@ -16,6 +16,9 @@
package com.android.settings.enterprise;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.Preference;
@@ -33,9 +36,6 @@
import java.util.Date;
import java.util.GregorianCalendar;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
/**
* Common base for testing subclasses of {@link AdminActionPreferenceControllerBase}.
*/
@@ -50,8 +50,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
public abstract void setDate(Date date);
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
index 421fb0f..03dc9f1 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
@@ -58,8 +58,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = createController(true /* async */);
}
@@ -69,9 +68,10 @@
((ApplicationFeatureProvider.NumberOfAppsCallback)
invocation.getArguments()[2]).onNumberOfAppsResult(number);
return null;
- }}).when(mFeatureFactory.applicationFeatureProvider)
- .calculateNumberOfAppsWithAdminGrantedPermissions(eq(mPermissions),
- eq(async), anyObject());
+ }
+ }).when(mFeatureFactory.applicationFeatureProvider)
+ .calculateNumberOfAppsWithAdminGrantedPermissions(eq(mPermissions),
+ eq(async), anyObject());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
index 17649bb..3c6b4c0 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnCurrentUserPreferenceControllerTest.java
@@ -55,8 +55,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new AlwaysOnVpnCurrentUserPreferenceController(mContext);
when(mContext.getString(R.string.enterprise_privacy_always_on_vpn_device))
.thenReturn(VPN_SET_DEVICE);
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
index d54505b..662b984 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
@@ -52,8 +52,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new AlwaysOnVpnManagedProfilePreferenceController(mContext);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java
index c2fb4da..fe7f4e1 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java
@@ -44,8 +44,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = createController();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index 7ecd0e3..19349a7 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -60,8 +60,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new EnterpriseInstalledPackagesPreferenceController(mContext,
true /* async */);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
index dd97cc0..8cbddb9 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
@@ -56,8 +56,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new EnterprisePrivacyPreferenceController(mContext);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 1a37e63..845fd61 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -55,8 +55,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mSettings = new EnterprisePrivacySettings();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
index cf66967..da26ba3 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsListPreferenceControllerTest.java
@@ -16,6 +16,16 @@
package com.android.settings.enterprise;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -28,13 +38,12 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.applications.EnterpriseDefaultApps;
import com.android.settings.applications.UserAppInfo;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.testutils.ApplicationTestUtils;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -48,16 +57,6 @@
import java.util.Arrays;
import java.util.Collections;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Answers.RETURNS_DEEP_STUBS;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EnterpriseSetDefaultAppsListPreferenceControllerTest {
@@ -86,8 +85,7 @@
MockitoAnnotations.initMocks(this);
ShadowApplication shadowContext = ShadowApplication.getInstance();
mContext = spy(shadowContext.getApplicationContext());
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
when(mPrefenceManager.getContext()).thenReturn(mContext);
when(mFragment.getPreferenceManager()).thenReturn(mPrefenceManager);
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
index 1223558..9d980cc 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
@@ -67,8 +67,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new EnterpriseSetDefaultAppsPreferenceController(mContext);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
index fe4fb6b..4b85b78 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
@@ -51,8 +51,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
public abstract void setMaximumFailedPasswordsBeforeWipe(int maximum);
diff --git a/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
index e31b40f..9bcda9a 100644
--- a/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/GlobalHttpProxyPreferenceControllerTest.java
@@ -52,8 +52,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new GlobalHttpProxyPreferenceController(mContext);
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
index caa5121..a56d9d3 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
@@ -55,8 +55,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new ImePreferenceController(mContext);
when(mContext.getResources().getString(R.string.enterprise_privacy_input_method_name,
DEFAULT_IME_LABEL)).thenReturn(DEFAULT_IME_TEXT);
diff --git a/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
index f46ecce..f656f10 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceControllerTest.java
@@ -16,13 +16,16 @@
package com.android.settings.enterprise;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.support.v7.preference.Preference;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -32,9 +35,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
/**
* Tests for {@link ManageDeviceAdminPreferenceController}.
*/
@@ -51,8 +51,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new ManageDeviceAdminPreferenceController(mContext);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index 99b0945..338373b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -17,7 +17,6 @@
package com.android.settings.fuelgauge;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
@@ -45,14 +44,14 @@
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsHelper;
+import com.android.settings.R;
import com.android.settings.SettingsActivity;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.applications.LayoutPreference;
-import com.android.settings.R;
+import com.android.settings.fuelgauge.anomaly.Anomaly;
+import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowActivityManager;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
import com.android.settings.widget.EntityHeaderController;
@@ -148,8 +147,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = spy(new AdvancedPowerUsageDetail());
doReturn(mContext).when(mFragment).getContext();
@@ -387,7 +385,7 @@
@Test
public void testStartBatteryDetailPage_batteryEntryNotExisted_extractUidFromPackageName() throws
- PackageManager.NameNotFoundException{
+ PackageManager.NameNotFoundException {
doReturn(UID).when(mPackageManager).getPackageUid(PACKAGE_NAME[0], 0 /* no flag */);
AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, PACKAGE_NAME[0]);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
index 5c28a06..acd9b97 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
@@ -108,7 +108,7 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mSettingsActivity);
+ FakeFeatureFactory.setupForTest();
doReturn(mUserManager).when(mSettingsActivity).getSystemService(Context.USER_SERVICE);
doReturn(mPackageManger).when(mSettingsActivity).getPackageManager();
doReturn(mAm).when(mSettingsActivity).getSystemService(Context.ACTIVITY_SERVICE);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java
index 5029897..ea0e6e5 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoLoaderTest.java
@@ -19,7 +19,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -27,11 +26,13 @@
import android.content.Context;
import android.content.Intent;
import android.os.BatteryStats;
+
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.TestConfig;
import com.android.settings.testutils.BatteryTestUtils;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,7 +62,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mProvider = FakeFeatureFactory
- .setupForTest(mContext)
+ .setupForTest()
.getPowerUsageFeatureProvider(mContext);
mDisChargingBatteryBroadcast = BatteryTestUtils.getDischargingIntent();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index dd6b709..4842b4e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -87,7 +87,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mDisChargingBatteryBroadcast = BatteryTestUtils.getDischargingIntent();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
index 56abf48..285ebc0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryUtilsTest.java
@@ -15,13 +15,32 @@
*/
package com.android.settings.fuelgauge;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_BACKGROUND;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_FOREGROUND;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_FOREGROUND_SERVICE;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_TOP;
+import static android.os.BatteryStats.Uid.PROCESS_STATE_TOP_SLEEPING;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.BatteryStats;
-import android.os.Bundle;
import android.os.Build;
+import android.os.Bundle;
import android.os.Process;
import android.os.SystemClock;
import android.os.UserManager;
@@ -30,10 +49,10 @@
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.R;
-import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -47,27 +66,6 @@
import java.util.ArrayList;
import java.util.List;
-import static android.os.BatteryStats.Uid.PROCESS_STATE_BACKGROUND;
-import static android.os.BatteryStats.Uid.PROCESS_STATE_FOREGROUND;
-import static android.os.BatteryStats.Uid.PROCESS_STATE_FOREGROUND_SERVICE;
-import static android.os.BatteryStats.Uid.PROCESS_STATE_TOP;
-import static android.os.BatteryStats.Uid.PROCESS_STATE_TOP_SLEEPING;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.spy;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BatteryUtilsTest {
@@ -148,8 +146,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mProvider = mFeatureFactory.powerUsageFeatureProvider;
doReturn(TIME_STATE_TOP).when(mUid).getProcessStateTime(eq(PROCESS_STATE_TOP), anyLong(),
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
index fe3cd29..0b8832f 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/HighPowerDetailTest.java
@@ -16,39 +16,35 @@
package com.android.settings.fuelgauge;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class HighPowerDetailTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mContext = RuntimeEnvironment.application;
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 5be2fe6..5ab7496 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -175,8 +175,7 @@
MockitoAnnotations.initMocks(this);
mRealContext = RuntimeEnvironment.application;
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mContext.getSystemService(Context.POWER_SERVICE)).thenReturn(mPowerManager);
mPreference = new PowerGaugePreference(mRealContext);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
index ccce08f..eea2256 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyDialogFragmentTest.java
@@ -99,7 +99,7 @@
.setPackageName(PACKAGE_NAME)
.setDisplayName(DISPLAY_NAME)
.build();
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
ShadowRuntimePermissionPresenter.setRuntimePermissionPresenter(mRuntimePermissionPresenter);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
index dfb7d21..7193cca 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/AnomalyLoaderTest.java
@@ -81,7 +81,7 @@
public void setUp() throws PackageManager.NameNotFoundException {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
doReturn(true).when(mAnomalyDetectionPolicy).isAnomalyDetectorEnabled(anyInt());
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
when(mContext.getPackageManager().getPackageUid(anyString(), anyInt())).thenReturn(UID);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
index 6f3e9b4..3f65a4c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/AnomalyActionTest.java
@@ -57,8 +57,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
doReturn(mAppOpsManagerr).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
mAnomaly = new Anomaly.Builder()
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
index e72039a..27f1b65 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/BackgroundCheckActionTest.java
@@ -17,7 +17,6 @@
package com.android.settings.fuelgauge.anomaly.action;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
@@ -25,11 +24,11 @@
import android.content.Context;
import android.os.Build;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -59,7 +58,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
mAnomaly = new Anomaly.Builder()
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
index fcb029c..351350a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/ForceStopActionTest.java
@@ -17,7 +17,6 @@
package com.android.settings.fuelgauge.anomaly.action;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
@@ -26,10 +25,10 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.fuelgauge.anomaly.Anomaly;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -59,7 +58,7 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
doReturn(mActivityManager).when(mContext).getSystemService(Context.ACTIVITY_SERVICE);
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(PACKAGE_NAME,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
index d2b6fcb..7b76261 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/LocationCheckActionTest.java
@@ -51,7 +51,7 @@
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
mLocationCheckAction = new LocationCheckAction(mContext, null);
mAnomaly = new Anomaly.Builder()
.setType(Anomaly.AnomalyType.BLUETOOTH_SCAN)
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
index de7402b..544b54e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/anomaly/action/StopAndBackgroundActionTest.java
@@ -59,7 +59,7 @@
.setPackageName(PACKAGE_NAME)
.build();
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
mStopAndBackgroundCheckAction = new StopAndBackgroundCheckAction(mContext, mForceStopAction,
mBackgroundCheckAction);
}
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
index 40c4af3..e2429c9 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.gestures;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
@@ -44,9 +43,9 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
- manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION_O,
- shadows = ShadowSecureSettings.class
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION_O,
+ shadows = ShadowSecureSettings.class
)
public class AssistGestureSettingsPreferenceControllerTest {
@@ -60,8 +59,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
mController = new AssistGestureSettingsPreferenceController(mContext, null, KEY_ASSIST,
false);
}
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
index b2bd27e..50cb611 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
@@ -31,8 +31,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@@ -43,16 +41,14 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AssistGestureSettingsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
+
private FakeFeatureFactory mFakeFeatureFactory;
private AssistGestureSettings mSettings;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mSettings = new AssistGestureSettings();
}
diff --git a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
index dcc06af..f0e1063 100644
--- a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
@@ -61,7 +61,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
mController = new GesturesSettingPreferenceController(mActivity);
}
diff --git a/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java
index 485efbe..137bba4 100644
--- a/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/language/PhoneLanguagePreferenceControllerTest.java
@@ -52,21 +52,20 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new PhoneLanguagePreferenceController(mContext);
}
@Test
public void testIsAvailable_hasMultipleLocales_shouldReturnTrue() {
- when(mContext.getAssets().getLocales()).thenReturn(new String[]{"en", "de"});
+ when(mContext.getAssets().getLocales()).thenReturn(new String[] {"en", "de"});
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void testIsAvailable_hasSingleLocales_shouldReturnFalse() {
- when(mContext.getAssets().getLocales()).thenReturn(new String[]{"en"});
+ when(mContext.getAssets().getLocales()).thenReturn(new String[] {"en"});
assertThat(mController.isAvailable()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
index 77d60cb..fd6a9c4 100644
--- a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
@@ -50,7 +50,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
mController = new TestController(mContext);
mPreference = new Preference(ShadowApplication.getInstance().getApplicationContext());
}
diff --git a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
index 48c26f3..9dea6f5 100644
--- a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
@@ -17,7 +17,6 @@
package com.android.settings.network;
import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -25,7 +24,6 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.TestConfig;
@@ -38,7 +36,6 @@
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -65,7 +62,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
doReturn(mResources).when(mContext).getResources();
doReturn(mPackageManager).when(mContext).getPackageManager();
mController = spy(new AirplaneModePreferenceController(mContext, null));
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java b/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java
index 8e74e79..9709504 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationAccessSettingsTest.java
@@ -23,15 +23,13 @@
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@@ -39,17 +37,13 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationAccessSettingsTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
private FakeFeatureFactory mFeatureFactory;
private NotificationAccessSettings mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mFragment = new NotificationAccessSettings();
}
diff --git a/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java
index f65752f..5fe3154 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenAccessSettingsTest.java
@@ -16,12 +16,16 @@
package com.android.settings.notification;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.verify;
+
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -31,10 +35,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ZenAccessSettingsTest {
@@ -47,8 +47,8 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java
index c495759..b7c122c 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeCallsTest.java
@@ -59,7 +59,7 @@
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
when(mActivity.getSystemService(Context.NOTIFICATION_SERVICE))
.thenReturn(mNotificationManager);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
mCalls = new ZenModeCallsSettings();
mCalls.onAttach((Context)mActivity);
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java
index 03226f9..e924487 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeMessagesTest.java
@@ -59,7 +59,7 @@
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
when(mActivity.getSystemService(Context.NOTIFICATION_SERVICE))
.thenReturn(mNotificationManager);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
mMessages = new ZenModeMessagesSettings();
mMessages.onAttach((Context)mActivity);
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java b/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java
index 7b5f474..b02543b 100644
--- a/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java
+++ b/tests/robotests/src/com/android/settings/search/DatabaseIndexingManagerTest.java
@@ -19,10 +19,10 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyList;
import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -69,11 +69,11 @@
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
- manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION_O,
- shadows = {
- ShadowRunnableAsyncTask.class,
- }
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION_O,
+ shadows = {
+ ShadowRunnableAsyncTask.class,
+ }
)
public class DatabaseIndexingManagerTest {
private final String localeStr = "en_US";
@@ -128,7 +128,7 @@
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(FAKE_PROVIDER_LIST).when(mPackageManager)
.queryIntentContentProviders(any(Intent.class), anyInt());
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
}
@After
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
index a2319f3..2ab24e2 100644
--- a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
@@ -33,7 +33,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
@@ -49,8 +48,6 @@
private static final String TITLE = "title";
private static final String SUMMARY = "summary";
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
@Mock
private SearchFragment mFragment;
@@ -66,8 +63,7 @@
MockitoAnnotations.initMocks(this);
final Context context = RuntimeEnvironment.application;
mIcon = context.getDrawable(R.drawable.ic_search_24dp);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mHolder = new InlineSwitchViewHolder(
LayoutInflater.from(context).inflate(R.layout.search_inline_switch_item, null),
diff --git a/tests/robotests/src/com/android/settings/search/InstalledAppResultLoaderTest.java b/tests/robotests/src/com/android/settings/search/InstalledAppResultLoaderTest.java
index 1ed483d..4dcd9b2 100644
--- a/tests/robotests/src/com/android/settings/search/InstalledAppResultLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/search/InstalledAppResultLoaderTest.java
@@ -19,9 +19,7 @@
import static android.content.pm.ApplicationInfo.FLAG_SYSTEM;
import static android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
-
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyList;
@@ -83,7 +81,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest(mContext);
+ final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest();
when(factory.searchFeatureProvider.getSiteMapManager())
.thenReturn(mSiteMapManager);
final List<UserInfo> infos = new ArrayList<>();
@@ -127,7 +125,7 @@
mPackageManagerWrapper, query,
mSiteMapManager));
when(mSiteMapManager.buildBreadCrumb(eq(mContext), anyString(), anyString()))
- .thenReturn(Arrays.asList(new String[]{"123"}));
+ .thenReturn(Arrays.asList(new String[] {"123"}));
assertThat(mCallable.call()).hasSize(3);
verify(mSiteMapManager)
diff --git a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
index 14fe63a..f19da83 100644
--- a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
@@ -18,7 +18,6 @@
package com.android.settings.search;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@@ -37,7 +36,6 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
-import android.os.UserManager;
import android.view.LayoutInflater;
import android.view.View;
@@ -76,25 +74,20 @@
private SearchFragment mFragment;
@Mock
private PackageManager mPackageManager;
- @Mock
- private UserManager mUserManager;
private FakeFeatureFactory mFeatureFactory;
private IntentSearchViewHolder mHolder;
private Drawable mIcon;
- private Drawable mBadgedIcon;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
final Context context = RuntimeEnvironment.application;
final View view = LayoutInflater.from(context).inflate(R.layout.search_intent_item, null);
mHolder = new IntentSearchViewHolder(view);
mIcon = context.getDrawable(R.drawable.ic_search_24dp);
- mBadgedIcon = context.getDrawable(R.drawable.ic_add);
when(mFragment.getActivity().getPackageManager()).thenReturn(mPackageManager);
}
diff --git a/tests/robotests/src/com/android/settings/search/SearchFragmentTest.java b/tests/robotests/src/com/android/settings/search/SearchFragmentTest.java
index f1f633c..014ca7c 100644
--- a/tests/robotests/src/com/android/settings/search/SearchFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchFragmentTest.java
@@ -18,7 +18,6 @@
package com.android.settings.search;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
@@ -28,14 +27,12 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.LoaderManager;
import android.content.Context;
import android.content.Intent;
-import android.content.Loader;
import android.os.Bundle;
import android.util.Pair;
import android.view.View;
@@ -54,7 +51,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -64,8 +60,6 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
-import java.util.List;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION_O,
@@ -74,9 +68,6 @@
SettingsShadowResources.SettingsShadowTheme.class,
})
public class SearchFragmentTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
@Mock
private SearchResultLoader mSearchResultLoader;
@Mock
@@ -92,7 +83,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
}
@After
diff --git a/tests/robotests/src/com/android/settings/search/SearchResultAggregatorTest.java b/tests/robotests/src/com/android/settings/search/SearchResultAggregatorTest.java
index 4dc0589..babb6e4 100644
--- a/tests/robotests/src/com/android/settings/search/SearchResultAggregatorTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchResultAggregatorTest.java
@@ -1,7 +1,6 @@
package com.android.settings.search;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
@@ -63,8 +62,7 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mAggregator = spy(SearchResultAggregator.getInstance());
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
// Return mock loaders from feature provider
when(mFeatureFactory.searchFeatureProvider.getStaticSearchResultTask(any(Context.class),
diff --git a/tests/robotests/src/com/android/settings/search/StaticSearchResultFutureTaskTest.java b/tests/robotests/src/com/android/settings/search/StaticSearchResultFutureTaskTest.java
index 31026fc..69795e7 100644
--- a/tests/robotests/src/com/android/settings/search/StaticSearchResultFutureTaskTest.java
+++ b/tests/robotests/src/com/android/settings/search/StaticSearchResultFutureTaskTest.java
@@ -17,6 +17,16 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
@@ -35,7 +45,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
@@ -51,23 +60,10 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class StaticSearchResultFutureTaskTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mMockContext;
@Mock
private SiteMapManager mSiteMapManager;
@Mock
@@ -86,7 +82,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mFeatureFactory = FakeFeatureFactory.setupForTest(mMockContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
when(mFeatureFactory.searchFeatureProvider.getExecutorService()).thenReturn(mService);
when(mFeatureFactory.searchFeatureProvider.getSiteMapManager())
.thenReturn(mSiteMapManager);
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
index 827dd64..a1e264d 100644
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
@@ -75,7 +75,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
+ FakeFeatureFactory.setupForTest();
mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
}
diff --git a/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java
index 19d6aa9..92e1384 100644
--- a/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/support/NewDeviceIntroSuggestionActivityTest.java
@@ -65,7 +65,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mMockContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mContext = application;
mShadowPackageManager = Shadows.shadowOf(application.getPackageManager());
diff --git a/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java b/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java
index cc025fb..8aacb52 100644
--- a/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/support/SupportDisclaimerDialogFragmentTest.java
@@ -1,5 +1,13 @@
package com.android.settings.support;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.robolectric.shadow.api.Shadow.directlyOn;
+
import android.accounts.Account;
import android.annotation.NonNull;
import android.annotation.StringRes;
@@ -10,16 +18,18 @@
import android.text.Spannable;
import android.text.style.URLSpan;
import android.widget.CheckBox;
+
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.overlay.SupportFeatureProvider.SupportType;
import com.android.settings.support.SupportDisclaimerDialogFragmentTest.SupportDisclaimerShadowResources;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,14 +41,6 @@
import org.robolectric.annotation.Implements;
import org.robolectric.util.FragmentTestUtil;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.robolectric.shadow.api.Shadow.directlyOn;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {SupportDisclaimerShadowResources.class})
@@ -57,8 +59,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
mSupportFeatureProvider = mFakeFeatureFactory.getSupportFeatureProvider(mContext);
when(mSupportFeatureProvider.getDisclaimerStringResId())
diff --git a/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java b/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
index 3dbd1e6..f8c7247 100644
--- a/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
+++ b/tests/robotests/src/com/android/settings/survey/SurveyMixinTest.java
@@ -14,13 +14,13 @@
import android.content.Context;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import com.android.settings.TestConfig;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.overlay.SurveyFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,6 +31,9 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
+import java.util.ArrayList;
+import java.util.HashMap;
+
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SurveyMixinTest {
@@ -51,8 +54,7 @@
// set up the fakefeature factory to mock out the survey provider
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
- FakeFeatureFactory.setupForTest(mContext);
- mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ mFactory = FakeFeatureFactory.setupForTest();
mProvider = mFactory.getSurveyFeatureProvider(mContext);
when(mProvider.getSurveyId(any(), eq(FAKE_KEY))).thenReturn(FAKE_SURVEY_ID);
}
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index dd5c76a..5430e9b 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -66,11 +66,9 @@
/**
* Call this in {@code @Before} method of the test class to use fake factory.
- *
- * @param context The context must be a deep mock.
*/
- @Deprecated
- public static FakeFeatureFactory setupForTest(Context context) {
+ public static FakeFeatureFactory setupForTest() {
+ final Context context = mock(Context.class, Answers.RETURNS_DEEP_STUBS);
sFactory = null;
when(context.getString(com.android.settings.R.string.config_featureFactory))
.thenReturn(FakeFeatureFactory.class.getName());
@@ -84,14 +82,6 @@
}
/**
- * Call this in {@code @Before} method of the test class to use fake factory.
- */
- public static FakeFeatureFactory setupForTest() {
- final Context context = mock(Context.class, Answers.RETURNS_DEEP_STUBS);
- return setupForTest(context);
- }
-
- /**
* Used by reflection. Do not call directly.
*/
public FakeFeatureFactory() {
diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
index af30e4f..842f53c 100644
--- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
@@ -16,6 +16,15 @@
package com.android.settings.widget;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
@@ -48,15 +57,6 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EntityHeaderControllerTest {
@@ -77,7 +77,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mShadowContext = RuntimeEnvironment.application;
when(mActivity.getApplicationContext()).thenReturn(mShadowContext);
when(mContext.getApplicationContext()).thenReturn(mContext);
diff --git a/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java b/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java
index 9fc5b2e..b4b86f6 100644
--- a/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RadioButtonPickerFragmentTest.java
@@ -61,7 +61,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mActivity);
+ FakeFeatureFactory.setupForTest();
mFragment = spy(new TestFragment());
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiMasterSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiMasterSwitchPreferenceControllerTest.java
index 8523cea..425f17d 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiMasterSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiMasterSwitchPreferenceControllerTest.java
@@ -16,6 +16,12 @@
package com.android.settings.wifi;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
@@ -23,33 +29,24 @@
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
import android.support.v7.preference.PreferenceScreen;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.MasterSwitchPreference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class WifiMasterSwitchPreferenceControllerTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- Context mMockContext;
@Mock
private WifiManager mWifiManager;
@Mock
@@ -65,8 +62,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mMockContext);
- mFakeFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mMockContext);
+ mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
mController = new WifiMasterSwitchPreferenceController(mContext, mMetricsFeatureProvider);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPreferenceControllerTest.java
index 44c70f6..48b5379 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPreferenceControllerTest.java
@@ -18,9 +18,7 @@
import static android.arch.lifecycle.Lifecycle.Event.ON_START;
import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
-
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
@@ -50,7 +48,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
@@ -70,8 +67,6 @@
})
public class WifiTetherPreferenceControllerTest {
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mFeatureFactoryContext;
@Mock
private Context mContext;
@Mock
@@ -89,14 +84,14 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mLifecycle = new Lifecycle(() -> mLifecycle);
- FakeFeatureFactory.setupForTest(mFeatureFactoryContext);
+ FakeFeatureFactory.setupForTest();
mPreference = new MasterSwitchPreference(RuntimeEnvironment.application);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
.thenReturn(mConnectivityManager);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
- when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
+ when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] {"1", "2"});
mController = new WifiTetherPreferenceController(mContext, mLifecycle);
}
@@ -107,7 +102,7 @@
@Test
public void isAvailable_noTetherRegex_shouldReturnFalse() {
- when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{});
+ when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] {});
mController = new WifiTetherPreferenceController(mContext, mLifecycle);
assertThat(mController.isAvailable()).isFalse();
@@ -272,6 +267,7 @@
/**
* Helper to cause the controller to receive a WIFI_AP_STATE_CHANGED_ACTION with a specific
* state.
+ *
* @param state - the state, as specified by one of the WifiManager.WIFI_AP_STATE_* values
*/
private void receiveApStateChangedBroadcast(int state) {