Merge "Fix broken test cases" into rvc-dev am: 15254e3b5e
am: 13f57006fd
am: 1bef15bae0
Change-Id: Ia34a119272fa43075f38104853ab7a05ec1e86dc
This commit is contained in:
@@ -49,6 +49,7 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
||||||
import com.android.settings.testutils.shadow.ShadowContentResolver;
|
import com.android.settings.testutils.shadow.ShadowContentResolver;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowSettingsLibUtils;
|
||||||
import com.android.settingslib.search.SearchIndexableRaw;
|
import com.android.settingslib.search.SearchIndexableRaw;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -67,7 +68,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
|
@Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class,
|
||||||
|
ShadowSettingsLibUtils.class})
|
||||||
public class AccountPreferenceControllerTest {
|
public class AccountPreferenceControllerTest {
|
||||||
|
|
||||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||||
@@ -95,7 +97,7 @@ public class AccountPreferenceControllerTest {
|
|||||||
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
|
||||||
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
|
||||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
|
||||||
.thenReturn(new AuthenticatorDescription[0]);
|
.thenReturn(new AuthenticatorDescription[0]);
|
||||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
|
||||||
mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
|
mController = new AccountPreferenceController(mContext, mFragment, null, mAccountHelper,
|
||||||
ProfileSelectFragment.ProfileType.ALL);
|
ProfileSelectFragment.ProfileType.ALL);
|
||||||
@@ -341,8 +343,8 @@ public class AccountPreferenceControllerTest {
|
|||||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
||||||
|
|
||||||
Account[] accountType1 = {
|
Account[] accountType1 = {
|
||||||
new Account("Account11", "com.acct1"),
|
new Account("Account11", "com.acct1"),
|
||||||
new Account("Account12", "com.acct1")
|
new Account("Account12", "com.acct1")
|
||||||
};
|
};
|
||||||
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
||||||
.thenReturn(accountType1);
|
.thenReturn(accountType1);
|
||||||
@@ -535,8 +537,8 @@ public class AccountPreferenceControllerTest {
|
|||||||
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(accounts);
|
||||||
|
|
||||||
Account[] accountType1 = {
|
Account[] accountType1 = {
|
||||||
new Account("Acct11", "com.acct1"),
|
new Account("Acct11", "com.acct1"),
|
||||||
new Account("Acct12", "com.acct1")
|
new Account("Acct12", "com.acct1")
|
||||||
};
|
};
|
||||||
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
||||||
.thenReturn(accountType1);
|
.thenReturn(accountType1);
|
||||||
@@ -555,7 +557,7 @@ public class AccountPreferenceControllerTest {
|
|||||||
mController.onResume();
|
mController.onResume();
|
||||||
|
|
||||||
// remove an account
|
// remove an account
|
||||||
accountType1 = new Account[] {new Account("Acct11", "com.acct1")};
|
accountType1 = new Account[]{new Account("Acct11", "com.acct1")};
|
||||||
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
||||||
.thenReturn(accountType1);
|
.thenReturn(accountType1);
|
||||||
|
|
||||||
@@ -577,19 +579,19 @@ public class AccountPreferenceControllerTest {
|
|||||||
Account[] accounts = {new Account("Acct1", "com.acct1")};
|
Account[] accounts = {new Account("Acct1", "com.acct1")};
|
||||||
when(mAccountManager.getAccountsAsUser(1)).thenReturn(accounts);
|
when(mAccountManager.getAccountsAsUser(1)).thenReturn(accounts);
|
||||||
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
when(mAccountManager.getAccountsByTypeAsUser(eq("com.acct1"), any(UserHandle.class)))
|
||||||
.thenReturn(accounts);
|
.thenReturn(accounts);
|
||||||
|
|
||||||
AuthenticatorDescription[] authDescs = {
|
AuthenticatorDescription[] authDescs = {
|
||||||
new AuthenticatorDescription("com.acct1", "com.android.settings",
|
new AuthenticatorDescription("com.acct1", "com.android.settings",
|
||||||
R.string.account_settings_title, 0 /* iconId */, 0 /* smallIconId */,
|
R.string.account_settings_title, 0 /* iconId */, 0 /* smallIconId */,
|
||||||
0 /* prefId */, false /* customTokens */)
|
0 /* prefId */, false /* customTokens */)
|
||||||
};
|
};
|
||||||
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(authDescs);
|
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(authDescs);
|
||||||
|
|
||||||
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
|
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
|
||||||
when(preferenceGroup.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
|
when(preferenceGroup.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
|
||||||
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class)))
|
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class)))
|
||||||
.thenReturn(preferenceGroup);
|
.thenReturn(preferenceGroup);
|
||||||
|
|
||||||
// First time resume will build the UI with no account
|
// First time resume will build the UI with no account
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
|
|
||||||
@@ -29,6 +30,11 @@ import org.robolectric.annotation.Implements;
|
|||||||
@Implements(Utils.class)
|
@Implements(Utils.class)
|
||||||
public class ShadowSettingsLibUtils {
|
public class ShadowSettingsLibUtils {
|
||||||
|
|
||||||
|
@Implementation
|
||||||
|
protected static Drawable getBadgedIcon(Context context, Drawable icon, UserHandle user) {
|
||||||
|
return new ColorDrawable(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Implementation
|
@Implementation
|
||||||
protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
|
protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
|
||||||
return new ColorDrawable(0);
|
return new ColorDrawable(0);
|
||||||
|
Reference in New Issue
Block a user