Merge "Get Tile#intent through getter"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fbc325a9aa
@@ -54,6 +54,8 @@ public class CategoryManagerTest {
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mActivityInfo.applicationInfo = new ApplicationInfo();
|
||||
mTileByComponentCache = new HashMap<>();
|
||||
mCategoryByKeyMap = new HashMap<>();
|
||||
@@ -130,18 +132,21 @@ public class CategoryManagerTest {
|
||||
// Create some fake tiles that are not sorted.
|
||||
final String testPackage = "com.android.test";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 50;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile3.priority = 200;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -163,18 +168,22 @@ public class CategoryManagerTest {
|
||||
final String testPackage1 = "com.android.test1";
|
||||
final String testPackage2 = "com.android.test2";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
|
||||
mActivityInfo.packageName = testPackage2;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage2, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage1;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage1, "class2"));
|
||||
tile2.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage1;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage1, "class3"));
|
||||
tile3.priority = 50;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -194,18 +203,22 @@ public class CategoryManagerTest {
|
||||
// Create some fake tiles that are not sorted.
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile3.priority = 50;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -226,17 +239,21 @@ public class CategoryManagerTest {
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final String testPackage2 = "com.google.test2";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent = new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 2;
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent = new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 1;
|
||||
mActivityInfo.packageName = testPackage2;
|
||||
mActivityInfo.name = "class0";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent = new Intent().setComponent(new ComponentName(testPackage2, "class0"));
|
||||
tile3.priority = 0;
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile4 = new Tile(mActivityInfo, category.key);
|
||||
tile4.intent = new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile4.priority = -1;
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
@@ -261,15 +278,21 @@ public class CategoryManagerTest {
|
||||
final String testPackage2 = "com.google.test2";
|
||||
final String testPackage3 = "com.abcde.test3";
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage2;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent = new Intent().setComponent(new ComponentName(testPackage2, "class1"));
|
||||
tile1.priority = 1;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent = new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 1;
|
||||
|
||||
mActivityInfo.packageName = testPackage3;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent = new Intent().setComponent(new ComponentName(testPackage3, "class3"));
|
||||
tile3.priority = 1;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -289,18 +312,21 @@ public class CategoryManagerTest {
|
||||
// Create some unique tiles
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class2";
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class2"));
|
||||
tile2.priority = 100;
|
||||
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class3";
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class3"));
|
||||
tile3.priority = 50;
|
||||
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
category.addTile(tile3);
|
||||
@@ -316,17 +342,13 @@ public class CategoryManagerTest {
|
||||
// Create tiles pointing to same intent.
|
||||
final String testPackage = mContext.getPackageName();
|
||||
final DashboardCategory category = new DashboardCategory(CATEGORY_HOMEPAGE);
|
||||
mActivityInfo.packageName = testPackage;
|
||||
mActivityInfo.name = "class1";
|
||||
final Tile tile1 = new Tile(mActivityInfo, category.key);
|
||||
tile1.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile1.priority = 100;
|
||||
final Tile tile2 = new Tile(mActivityInfo, category.key);
|
||||
tile2.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile2.priority = 100;
|
||||
final Tile tile3 = new Tile(mActivityInfo, category.key);
|
||||
tile3.intent =
|
||||
new Intent().setComponent(new ComponentName(testPackage, "class1"));
|
||||
tile3.priority = 50;
|
||||
category.addTile(tile1);
|
||||
category.addTile(tile2);
|
||||
|
@@ -92,6 +92,8 @@ public class DashboardAdapterTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFactory = FakeFeatureFactory.setupForTest();
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mActivityInfo.metaData = new Bundle();
|
||||
when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
|
||||
|
||||
|
@@ -34,7 +34,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
@@ -101,6 +100,8 @@ public class DashboardFeatureProviderImplTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mActivityInfo.metaData = new Bundle();
|
||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||
when(mPackageManager.resolveActivity(any(Intent.class), anyInt()))
|
||||
@@ -140,8 +141,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.priority = 10;
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
preference, tile, "123", Preference.DEFAULT_ORDER);
|
||||
@@ -158,8 +157,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.userHandle = new ArrayList<>();
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
when(mActivity.getApplicationContext().getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
@@ -177,8 +174,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle = new ArrayList<>();
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
@@ -198,12 +193,10 @@ public class DashboardFeatureProviderImplTest {
|
||||
@Test
|
||||
public void bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle = new ArrayList<>();
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(
|
||||
new ComponentName(RuntimeEnvironment.application.getPackageName(), "class"));
|
||||
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
@@ -234,8 +227,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -247,8 +238,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void bindPreference_noSummary_shouldSetSummaryToPlaceholder() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -261,8 +250,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.summary = "test";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /*key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -274,8 +261,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProvider() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI,
|
||||
"content://com.android.settings/tile_summary");
|
||||
|
||||
@@ -290,8 +275,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN,
|
||||
preference, tile, null /* key */, Preference.DEFAULT_ORDER);
|
||||
|
||||
@@ -302,11 +285,9 @@ public class DashboardFeatureProviderImplTest {
|
||||
@Config(shadows = {ShadowTileUtils.class, ShadowThreadUtils.class})
|
||||
public void bindPreference_withIconUri_shouldLoadIconFromContentProvider() {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(
|
||||
new ComponentName(RuntimeEnvironment.application.getPackageName(), "class"));
|
||||
mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI,
|
||||
"content://com.android.settings/tile_icon");
|
||||
mImpl.bindIcon(preference, tile);
|
||||
@@ -357,8 +338,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(RuntimeEnvironment.application);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
|
||||
tile.userHandle = null;
|
||||
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES,
|
||||
@@ -382,8 +361,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
final Preference preference = new Preference(application.getApplicationContext());
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.key = "key";
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
|
||||
tile.userHandle = null;
|
||||
|
||||
@@ -457,8 +434,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
@Test
|
||||
public void openTileIntent_profileSelectionDialog_shouldShow() {
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
@@ -474,8 +449,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void openTileIntent_profileSelectionDialog_explicitMetadataShouldShow() {
|
||||
mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
@@ -491,8 +464,6 @@ public class DashboardFeatureProviderImplTest {
|
||||
public void openTileIntent_profileSelectionDialog_shouldNotShow() {
|
||||
mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
tile.intent.setComponent(new ComponentName("pkg", "class"));
|
||||
final ArrayList<UserHandle> handles = new ArrayList<>();
|
||||
handles.add(new UserHandle(0));
|
||||
handles.add(new UserHandle(10));
|
||||
|
@@ -67,6 +67,8 @@ public class DashboardFragmentTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mDashboardCategory = new DashboardCategory("key");
|
||||
mDashboardCategory.addTile(new Tile(mActivityInfo, mDashboardCategory.key));
|
||||
|
@@ -43,7 +43,10 @@ public class DashboardItemAnimatorTest {
|
||||
public void SetUp() {
|
||||
mDashboardItemAnimator = new DashboardItemAnimator();
|
||||
mViewHolder = new ViewHolder(new TextView(RuntimeEnvironment.application));
|
||||
mViewHolder.itemView.setTag(new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE));
|
||||
final ActivityInfo activityInfo = new ActivityInfo();
|
||||
activityInfo.packageName = "pkg";
|
||||
activityInfo.name = "class";
|
||||
mViewHolder.itemView.setTag(new Tile(activityInfo, CategoryKey.CATEGORY_HOMEPAGE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
@@ -52,8 +51,10 @@ public class SummaryLoaderTest {
|
||||
public void SetUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
|
||||
mTile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
|
||||
final ActivityInfo activityInfo = new ActivityInfo();
|
||||
activityInfo.packageName = "pkg";
|
||||
activityInfo.name = "class";
|
||||
mTile = new Tile(activityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
mTile.summary = SUMMARY_1;
|
||||
mCallbackInvoked = false;
|
||||
|
||||
@@ -86,9 +87,11 @@ public class SummaryLoaderTest {
|
||||
public void testUpdateSummaryToCache_hasCache_shouldUpdate() {
|
||||
final String testSummary = "test_summary";
|
||||
final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_HOMEPAGE);
|
||||
final Tile tile = new Tile(new ActivityInfo(), category.key);
|
||||
final ActivityInfo activityInfo = new ActivityInfo();
|
||||
activityInfo.packageName = "pkg";
|
||||
activityInfo.name = "cls";
|
||||
final Tile tile = new Tile(activityInfo, category.key);
|
||||
tile.key = "123";
|
||||
tile.intent = new Intent();
|
||||
category.addTile(tile);
|
||||
when(mFeatureFactory.dashboardFeatureProvider.getDashboardKeyForTile(tile))
|
||||
.thenReturn(tile.key);
|
||||
|
@@ -24,7 +24,6 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
@@ -51,6 +50,8 @@ public class ProfileSelectDialogTest {
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
|
||||
private ActivityInfo mActivityInfo;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@@ -58,12 +59,15 @@ public class ProfileSelectDialogTest {
|
||||
final UserInfo userInfo = new UserInfo(
|
||||
NORMAL_USER.getIdentifier(), "test_user", UserInfo.FLAG_RESTRICTED);
|
||||
when(mUserManager.getUserInfo(NORMAL_USER.getIdentifier())).thenReturn(userInfo);
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "cls";
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateUserHandlesIfNeeded_Normal() {
|
||||
final Tile tile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle.add(NORMAL_USER);
|
||||
|
||||
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
|
||||
@@ -75,8 +79,7 @@ public class ProfileSelectDialogTest {
|
||||
|
||||
@Test
|
||||
public void updateUserHandlesIfNeeded_Remove() {
|
||||
final Tile tile = new Tile(new ActivityInfo(), CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.intent = new Intent();
|
||||
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
tile.userHandle.add(REMOVED_USER);
|
||||
tile.userHandle.add(NORMAL_USER);
|
||||
tile.userHandle.add(REMOVED_USER);
|
||||
|
@@ -78,6 +78,8 @@ public class SuggestionFeatureProviderImplTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mFactory = FakeFeatureFactory.setupForTest();
|
||||
mActivityInfo = new ActivityInfo();
|
||||
mActivityInfo.packageName = "pkg";
|
||||
mActivityInfo.name = "class";
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
// Explicit casting to object due to MockitoCast bug
|
||||
when((Object) mContext.getSystemService(FingerprintManager.class))
|
||||
|
Reference in New Issue
Block a user