Use external/robolectric-shadows/run_robotests.mk
This allows Settings to test against the latest framework changes. Also replaced TestConfig with traditional robolectric.properties. Bug: 73173204 Bug: 73892008 Test: make -j56 RunSettingsRoboTests Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
This commit is contained in:
@@ -15,11 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static com.android.settings.accounts.AccountDashboardFragmentTest
|
||||
.ShadowAuthenticationHelper.LABELS;
|
||||
import static com.android.settings.accounts.AccountDashboardFragmentTest
|
||||
.ShadowAuthenticationHelper.TYPES;
|
||||
|
||||
import static com.android.settings.accounts.AccountDashboardFragmentTest.ShadowAuthenticationHelper.LABELS;
|
||||
import static com.android.settings.accounts.AccountDashboardFragmentTest.ShadowAuthenticationHelper.TYPES;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -31,7 +28,6 @@ import android.provider.SearchIndexableResource;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
@@ -40,137 +36,129 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.annotation.Resetter;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AccountDashboardFragmentTest {
|
||||
|
||||
private AccountDashboardFragment mFragment;
|
||||
private AccountDashboardFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFragment = new AccountDashboardFragment();
|
||||
@Before
|
||||
public void setUp() {
|
||||
mFragment = new AccountDashboardFragment();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowAuthenticationHelper.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCategory_isAccount() {
|
||||
assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {
|
||||
ShadowAuthenticationHelper.class
|
||||
})
|
||||
public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
|
||||
|
||||
final SummaryLoader.SummaryProvider provider =
|
||||
AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, loader);
|
||||
provider.setListening(true);
|
||||
|
||||
verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1] + ", " + LABELS[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowAuthenticationHelper.class)
|
||||
public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
|
||||
ShadowAuthenticationHelper.setEnabledAccount(null);
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
|
||||
|
||||
final SummaryLoader.SummaryProvider provider =
|
||||
AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, loader);
|
||||
provider.setListening(true);
|
||||
|
||||
verify(loader).setSummary(provider,
|
||||
activity.getString(R.string.account_dashboard_default_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowAuthenticationHelper.class)
|
||||
public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() {
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
|
||||
final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]};
|
||||
ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts);
|
||||
|
||||
final SummaryLoader.SummaryProvider provider =
|
||||
AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, loader);
|
||||
provider.setListening(true);
|
||||
|
||||
// should only show the 2 accounts with labels
|
||||
verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchIndexProvider_shouldIndexResource() {
|
||||
final List<SearchIndexableResource> indexRes =
|
||||
AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getXmlResourcesToIndex(RuntimeEnvironment.application, true /* enabled */);
|
||||
|
||||
assertThat(indexRes).isNotNull();
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
|
||||
}
|
||||
|
||||
@Implements(AuthenticatorHelper.class)
|
||||
public static class ShadowAuthenticationHelper {
|
||||
|
||||
static final String[] TYPES = {"type1", "type2", "type3", "type4"};
|
||||
static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"};
|
||||
private static String[] sEnabledAccount = TYPES;
|
||||
|
||||
public void __constructor__(Context context, UserHandle userHandle,
|
||||
AuthenticatorHelper.OnAccountsUpdateListener listener) {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowAuthenticationHelper.reset();
|
||||
private static void setEnabledAccount(String[] enabledAccount) {
|
||||
sEnabledAccount = enabledAccount;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCategory_isAccount() {
|
||||
assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sEnabledAccount = TYPES;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {
|
||||
ShadowAuthenticationHelper.class
|
||||
})
|
||||
public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
|
||||
|
||||
final SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
|
||||
.createSummaryProvider(activity, loader);
|
||||
provider.setListening(true);
|
||||
|
||||
verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1] + ", " + LABELS[2]);
|
||||
@Implementation
|
||||
public String[] getEnabledAccountTypes() {
|
||||
return sEnabledAccount;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {
|
||||
ShadowAuthenticationHelper.class
|
||||
})
|
||||
public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
|
||||
ShadowAuthenticationHelper.setEnabledAccount(null);
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
|
||||
|
||||
final SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
|
||||
.createSummaryProvider(activity, loader);
|
||||
provider.setListening(true);
|
||||
|
||||
verify(loader).setSummary(provider,
|
||||
activity.getString(R.string.account_dashboard_default_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {
|
||||
ShadowAuthenticationHelper.class
|
||||
})
|
||||
public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() {
|
||||
final SummaryLoader loader = mock(SummaryLoader.class);
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
|
||||
final String[] enabledAccounts = {TYPES[0], "unlabled_account_type", TYPES[1]};
|
||||
ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts);
|
||||
|
||||
final SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
|
||||
.createSummaryProvider(activity, loader);
|
||||
provider.setListening(true);
|
||||
|
||||
// should only show the 2 accounts with labels
|
||||
verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchIndexProvider_shouldIndexResource() {
|
||||
final List<SearchIndexableResource> indexRes =
|
||||
AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
||||
ShadowApplication.getInstance().getApplicationContext(),
|
||||
true /* enabled */);
|
||||
|
||||
assertThat(indexRes).isNotNull();
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
|
||||
}
|
||||
|
||||
@Implements(AuthenticatorHelper.class)
|
||||
public static class ShadowAuthenticationHelper {
|
||||
|
||||
static final String[] TYPES = new String[] {"type1", "type2", "type3", "type4"};
|
||||
static final String[] LABELS = new String[] {"LABEL1", "LABEL2", "LABEL3", "LABEL4"};
|
||||
private static String[] sEnabledAccount = TYPES;
|
||||
|
||||
public void __constructor__(Context context, UserHandle userHandle,
|
||||
AuthenticatorHelper.OnAccountsUpdateListener listener) {
|
||||
}
|
||||
|
||||
public static void setEnabledAccount(String[] enabledAccount) {
|
||||
sEnabledAccount = enabledAccount;
|
||||
}
|
||||
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sEnabledAccount = TYPES;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public String[] getEnabledAccountTypes() {
|
||||
return sEnabledAccount;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public CharSequence getLabelForType(Context context, final String accountType) {
|
||||
if (TextUtils.equals(accountType, TYPES[0])) {
|
||||
return LABELS[0];
|
||||
} else if (TextUtils.equals(accountType, TYPES[1])) {
|
||||
return LABELS[1];
|
||||
} else if (TextUtils.equals(accountType, TYPES[2])) {
|
||||
return LABELS[2];
|
||||
} else if (TextUtils.equals(accountType, TYPES[3])) {
|
||||
return LABELS[3];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Implementation
|
||||
public CharSequence getLabelForType(Context context, final String accountType) {
|
||||
if (TextUtils.equals(accountType, TYPES[0])) {
|
||||
return LABELS[0];
|
||||
} else if (TextUtils.equals(accountType, TYPES[1])) {
|
||||
return LABELS[1];
|
||||
} else if (TextUtils.equals(accountType, TYPES[2])) {
|
||||
return LABELS[2];
|
||||
} else if (TextUtils.equals(accountType, TYPES[3])) {
|
||||
return LABELS[3];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,13 @@
|
||||
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;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -34,10 +31,8 @@ import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
@@ -46,41 +41,28 @@ import com.android.settingslib.drawer.Tile;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AccountDetailDashboardFragmentTest {
|
||||
|
||||
private static final String METADATA_CATEGORY = "com.android.settings.category";
|
||||
private static final String METADATA_ACCOUNT_TYPE = "com.android.settings.ia.account";
|
||||
private static final String METADATA_USER_HANDLE = "user_handle";
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private AccountManager mAccountManager;
|
||||
@Mock
|
||||
private Preference mPreference;
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
|
||||
private AccountDetailDashboardFragment mFragment;
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowContext = ShadowApplication.getInstance();
|
||||
shadowContext.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
mContext = spy(shadowContext.getApplicationContext());
|
||||
mContext = RuntimeEnvironment.application;
|
||||
|
||||
mFragment = spy(new AccountDetailDashboardFragment());
|
||||
final Bundle args = new Bundle();
|
||||
args.putParcelable(METADATA_USER_HANDLE, UserHandle.CURRENT);
|
||||
|
||||
mFragment = new AccountDetailDashboardFragment();
|
||||
mFragment.setArguments(args);
|
||||
mFragment.mAccountType = "com.abc";
|
||||
mFragment.mAccount = new Account("name1@abc.com", "com.abc");
|
||||
@@ -89,7 +71,7 @@ public class AccountDetailDashboardFragmentTest {
|
||||
@Test
|
||||
public void testCategory_isAccountDetail() {
|
||||
assertThat(new AccountDetailDashboardFragment().getCategoryKey())
|
||||
.isEqualTo(CategoryKey.CATEGORY_ACCOUNT_DETAIL);
|
||||
.isEqualTo(CategoryKey.CATEGORY_ACCOUNT_DETAIL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -143,7 +125,7 @@ public class AccountDetailDashboardFragmentTest {
|
||||
tile.userHandle = null;
|
||||
mFragment.displayTile(tile);
|
||||
|
||||
final Activity activity = Robolectric.buildActivity(Activity.class).get();
|
||||
final Activity activity = Robolectric.setupActivity(Activity.class);
|
||||
final Preference preference = new Preference(mContext);
|
||||
dashboardFeatureProvider.bindPreferenceToTile(activity,
|
||||
MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, "key",
|
||||
@@ -153,7 +135,6 @@ public class AccountDetailDashboardFragmentTest {
|
||||
|
||||
final Intent intent = shadowOf(activity).getNextStartedActivityForResult().intent;
|
||||
|
||||
assertThat(intent.getStringExtra("extra.accountName"))
|
||||
.isEqualTo("name1@abc.com");
|
||||
assertThat(intent.getStringExtra("extra.accountName")).isEqualTo("name1@abc.com");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import static org.mockito.Mockito.when;
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.arch.lifecycle.LifecycleOwner;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
@@ -33,7 +32,6 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -43,7 +41,6 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
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,17 +48,10 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(
|
||||
manifest = TestConfig.MANIFEST_PATH,
|
||||
sdk = TestConfig.SDK_VERSION,
|
||||
shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class
|
||||
)
|
||||
@Config(shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class)
|
||||
public class AccountHeaderPreferenceControllerTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private Activity mActivity;
|
||||
@Mock
|
||||
@@ -82,7 +72,7 @@ public class AccountHeaderPreferenceControllerTest {
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mHeaderPreference = new LayoutPreference(
|
||||
RuntimeEnvironment.application, R.layout.settings_entity_header);
|
||||
doReturn(mContext).when(mActivity).getApplicationContext();
|
||||
doReturn(RuntimeEnvironment.application).when(mActivity).getApplicationContext();
|
||||
mLifecycleOwner = () -> mLifecycle;
|
||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||
}
|
||||
@@ -115,7 +105,6 @@ public class AccountHeaderPreferenceControllerTest {
|
||||
((TextView) mHeaderPreference.findViewById(R.id.entity_header_title)).getText();
|
||||
|
||||
assertThat(label).isEqualTo(account.name);
|
||||
|
||||
}
|
||||
|
||||
@Implements(AuthenticatorHelper.class)
|
||||
|
||||
@@ -15,6 +15,19 @@
|
||||
*/
|
||||
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.Matchers.argThat;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
@@ -33,9 +46,8 @@ import android.text.TextUtils;
|
||||
import com.android.settings.AccessiblePreferenceCategory;
|
||||
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.search.SearchIndexableRaw;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
||||
import com.android.settings.testutils.shadow.ShadowContentResolver;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
@@ -46,6 +58,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
@@ -54,22 +67,8 @@ import org.robolectric.shadows.ShadowApplication;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.argThat;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.reset;
|
||||
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,
|
||||
shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
|
||||
@Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
|
||||
public class AccountPreferenceControllerTest {
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
@@ -89,15 +88,15 @@ public class AccountPreferenceControllerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowContext = ShadowApplication.getInstance();
|
||||
shadowContext.setSystemService(Context.USER_SERVICE, mUserManager);
|
||||
shadowContext.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
mContext = shadowContext.getApplicationContext();
|
||||
mContext = RuntimeEnvironment.application;
|
||||
final ShadowApplication shadowApp = ShadowApplication.getInstance();
|
||||
shadowApp.setSystemService(Context.USER_SERVICE, mUserManager);
|
||||
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
|
||||
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
||||
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(
|
||||
new AuthenticatorDescription[0]);
|
||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
||||
.thenReturn(new AuthenticatorDescription[0]);
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
||||
mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper);
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class AccountPreferenceControllerTest {
|
||||
public void onResume_linkedUser_shouldAddOneAccountCategory() {
|
||||
final UserInfo info = new UserInfo(1, "user 1", 0);
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(true);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(true);
|
||||
when(mUserManager.getUserInfo(anyInt())).thenReturn(info);
|
||||
|
||||
mController.onResume();
|
||||
@@ -127,7 +126,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
|
||||
mController.onResume();
|
||||
@@ -141,7 +140,7 @@ public class AccountPreferenceControllerTest {
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
|
||||
mController.onResume();
|
||||
@@ -155,7 +154,7 @@ public class AccountPreferenceControllerTest {
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
// First time resume will build the UI
|
||||
mController.onResume();
|
||||
@@ -171,7 +170,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
// First time resume will build the UI
|
||||
mController.onResume();
|
||||
@@ -189,7 +188,7 @@ public class AccountPreferenceControllerTest {
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
// First time resume will build the UI
|
||||
mController.onResume();
|
||||
@@ -205,7 +204,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
|
||||
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn(
|
||||
@@ -223,7 +222,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
|
||||
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
|
||||
@@ -241,7 +240,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
mController.onResume();
|
||||
|
||||
@@ -332,7 +331,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
Account[] accounts = {new Account("Account1", "com.acct1")};
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
||||
@@ -367,7 +366,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
|
||||
final Account[] accountType1 = new Account[2];
|
||||
@@ -411,7 +410,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
Account[] accounts = {new Account("Acct1", "com.acct1")};
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
||||
@@ -446,7 +445,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
Account[] accounts = {new Account("Acct1", "com.acct1")};
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
||||
@@ -492,7 +491,7 @@ public class AccountPreferenceControllerTest {
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
|
||||
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
|
||||
@@ -526,7 +525,7 @@ public class AccountPreferenceControllerTest {
|
||||
final List<UserInfo> infos = new ArrayList<>();
|
||||
infos.add(new UserInfo(1, "user 1", 0));
|
||||
when(mUserManager.isManagedProfile()).thenReturn(false);
|
||||
when(mUserManager.isLinkedUser()).thenReturn(false);
|
||||
when(mUserManager.isRestrictedProfile()).thenReturn(false);
|
||||
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
|
||||
Account[] accounts = {new Account("Acct1", "com.acct1")};
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
||||
|
||||
@@ -16,42 +16,38 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AccountPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
private Account mAccount;
|
||||
private ArrayList<String> mAuthorities;
|
||||
private AccountPreference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ShadowApplication.getInstance().getApplicationContext();
|
||||
mAccount = new Account("name", "type");
|
||||
mAuthorities = new ArrayList<>();
|
||||
mAuthorities.add("authority");
|
||||
final ArrayList<String> authorities = new ArrayList<>();
|
||||
authorities.add("authority");
|
||||
|
||||
mPreference = spy(new AccountPreference(
|
||||
mContext, mAccount, null /* icon */, mAuthorities, false /* showTypeIcon */));
|
||||
RuntimeEnvironment.application,
|
||||
new Account("name", "type"),
|
||||
null /* icon */,
|
||||
authorities,
|
||||
false /* showTypeIcon */)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
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.anyInt;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -33,7 +32,6 @@ import android.support.v7.preference.Preference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
||||
import com.android.settings.testutils.shadow.ShadowContentResolver;
|
||||
|
||||
@@ -43,12 +41,13 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
|
||||
@Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
|
||||
public class AccountSyncPreferenceControllerTest {
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
@@ -61,9 +60,8 @@ public class AccountSyncPreferenceControllerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication application = ShadowApplication.getInstance();
|
||||
application.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
mContext = application.getApplicationContext();
|
||||
mContext = RuntimeEnvironment.application;
|
||||
ShadowApplication.getInstance().setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
|
||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(
|
||||
new AuthenticatorDescription[0]);
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
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.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
@@ -29,7 +36,6 @@ 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.testutils.shadow.ShadowAccountManager;
|
||||
import com.android.settings.testutils.shadow.ShadowContentResolver;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
@@ -39,18 +45,11 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
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)
|
||||
public class AccountTypePreferenceLoaderTest {
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
@@ -73,7 +72,7 @@ public class AccountTypePreferenceLoaderTest {
|
||||
new AuthenticatorDescription[0]);
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
||||
when(mPreferenceFragment.getActivity().getPackageManager()).thenReturn(mPackageManager);
|
||||
mContext = shadowContext.getApplicationContext();
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mAccount = new Account("name", "type");
|
||||
final AuthenticatorHelper helper = new AuthenticatorHelper(mContext, UserHandle.CURRENT,
|
||||
null /* OnAccountsUpdateListener */);
|
||||
|
||||
@@ -33,7 +33,6 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
||||
@@ -52,7 +51,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class EmergencyInfoPreferenceControllerTest {
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
@@ -142,7 +140,7 @@ public class EmergencyInfoPreferenceControllerTest {
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_shouldStartActivity() {
|
||||
final ShadowApplication application = ShadowApplication.getInstance();
|
||||
final Context context = application.getApplicationContext();
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final Preference preference = new Preference(context);
|
||||
preference.setKey("emergency_info");
|
||||
mController = new EmergencyInfoPreferenceController(context);
|
||||
|
||||
@@ -16,23 +16,19 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class ProviderPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@@ -22,7 +22,6 @@ 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.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -45,7 +44,6 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
||||
@@ -57,11 +55,11 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class RemoveAccountPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_REMOVE_ACCOUNT = "remove_account";
|
||||
@@ -84,26 +82,23 @@ public class RemoveAccountPreferenceControllerTest {
|
||||
@Mock
|
||||
private LayoutPreference mPreference;
|
||||
|
||||
private Context mContext;
|
||||
private RemoveAccountPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShadowApplication shadowContext = ShadowApplication.getInstance();
|
||||
shadowContext.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
mContext = spy(shadowContext.getApplicationContext());
|
||||
ShadowApplication.getInstance().setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
|
||||
|
||||
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
||||
when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
|
||||
when(mPreferenceManager.getContext()).thenReturn(mContext);
|
||||
when(mPreferenceManager.getContext()).thenReturn(RuntimeEnvironment.application);
|
||||
when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
|
||||
when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
|
||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(
|
||||
new AuthenticatorDescription[0]);
|
||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
||||
.thenReturn(new AuthenticatorDescription[0]);
|
||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
||||
mController = new RemoveAccountPreferenceController(mContext, mFragment,
|
||||
mDevicePolicyManager);
|
||||
mController = new RemoveAccountPreferenceController(RuntimeEnvironment.application,
|
||||
mFragment, mDevicePolicyManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,19 +16,16 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class RemoveUserFragmentTest {
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user