Search in sources :

Example 36 with ActivityTile

use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.

the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent.

@Test
public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    tile.userHandle = new ArrayList<>();
    tile.userHandle.add(mock(UserHandle.class));
    when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
    preference.getOnPreferenceClickListener().onPreferenceClick(null);
    verify(mFeatureFactory.metricsFeatureProvider).logStartedIntent(any(Intent.class), eq(MetricsEvent.SETTINGS_GESTURES));
    verify(mActivity).startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) UserHandle(android.os.UserHandle) ActivityTile(com.android.settingslib.drawer.ActivityTile) ProviderTile(com.android.settingslib.drawer.ProviderTile) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 37 with ActivityTile

use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.

the class ProfileSelectDialogTest method updateUserHandlesIfNeeded_Normal.

@Test
public void updateUserHandlesIfNeeded_Normal() {
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    tile.userHandle.add(NORMAL_USER);
    ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
    assertThat(tile.userHandle).hasSize(1);
    assertThat(tile.userHandle.get(0).getIdentifier()).isEqualTo(NORMAL_USER.getIdentifier());
    verify(mUserManager, never()).getUserInfo(NORMAL_USER.getIdentifier());
}
Also used : ActivityTile(com.android.settingslib.drawer.ActivityTile) Tile(com.android.settingslib.drawer.Tile) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 38 with ActivityTile

use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.

the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent.

@Test
public void refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent() {
    final DashboardFeatureProviderImpl dashboardFeatureProvider = new DashboardFeatureProviderImpl(mContext);
    final PackageManager packageManager = mock(PackageManager.class);
    ReflectionHelpers.setField(dashboardFeatureProvider, "mPackageManager", packageManager);
    when(packageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(mock(ResolveInfo.class));
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
    mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
    mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_TITLE, "summary");
    mActivityInfo.metaData.putString("com.android.settings.intent.action", Intent.ACTION_ASSIST);
    tile.userHandle = null;
    mFragment.displayTile(tile);
    final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
    final Preference preference = new Preference(mContext);
    dashboardFeatureProvider.bindPreferenceToTileAndGetObservers(activity, false, /* forceRoundedIcon */
    MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, null, /* key */
    Preference.DEFAULT_ORDER);
    assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext));
    preference.performClick();
    final Intent intent = Shadows.shadowOf(activity).getNextStartedActivityForResult().intent;
    assertThat(intent.getStringExtra("extra.accountName")).isEqualTo("name1@abc.com");
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) FragmentActivity(androidx.fragment.app.FragmentActivity) PackageManager(android.content.pm.PackageManager) Preference(androidx.preference.Preference) DashboardFeatureProviderImpl(com.android.settings.dashboard.DashboardFeatureProviderImpl) ActivityTile(com.android.settingslib.drawer.ActivityTile) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 39 with ActivityTile

use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.

the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_NoAccountType_shouldNotDisplay.

@Test
public void refreshDashboardTiles_NoAccountType_shouldNotDisplay() {
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
    mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
    assertThat(mFragment.displayTile(tile)).isFalse();
}
Also used : ActivityTile(com.android.settingslib.drawer.ActivityTile) Tile(com.android.settingslib.drawer.Tile) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 40 with ActivityTile

use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.

the class CategoryManagerTest method backwardCompatCleanupForCategory_shouldNotChangeCategoryForNewKeys.

@Test
public void backwardCompatCleanupForCategory_shouldNotChangeCategoryForNewKeys() {
    final Tile tile1 = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
    final Tile tile2 = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
    final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_ACCOUNT);
    category.addTile(tile1);
    category.addTile(tile2);
    mCategoryByKeyMap.put(CategoryKey.CATEGORY_ACCOUNT, category);
    mTileByComponentCache.put(new Pair<>("PACKAGE", "1"), tile1);
    mTileByComponentCache.put(new Pair<>("PACKAGE", "2"), tile2);
    mCategoryManager.backwardCompatCleanupForCategory(mTileByComponentCache, mCategoryByKeyMap);
    assertThat(mCategoryByKeyMap.size()).isEqualTo(1);
    assertThat(mCategoryByKeyMap.get(CategoryKey.CATEGORY_ACCOUNT)).isNotNull();
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ActivityTile(com.android.settingslib.drawer.ActivityTile) ProviderTile(com.android.settingslib.drawer.ProviderTile) Tile(com.android.settingslib.drawer.Tile) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Aggregations

ActivityTile (com.android.settingslib.drawer.ActivityTile)41 Test (org.junit.Test)37 Tile (com.android.settingslib.drawer.Tile)35 ProviderTile (com.android.settingslib.drawer.ProviderTile)29 Preference (androidx.preference.Preference)20 SwitchPreference (androidx.preference.SwitchPreference)19 Intent (android.content.Intent)11 UserHandle (android.os.UserHandle)10 ArrayList (java.util.ArrayList)7 ActivityInfo (android.content.pm.ActivityInfo)5 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)5 Config (org.robolectric.annotation.Config)5 Bundle (android.os.Bundle)4 FragmentActivity (androidx.fragment.app.FragmentActivity)3 ProviderInfo (android.content.pm.ProviderInfo)2 ResolveInfo (android.content.pm.ResolveInfo)2 Bitmap (android.graphics.Bitmap)2 Drawable (android.graphics.drawable.Drawable)2 Before (org.junit.Before)2 ShadowActivity (org.robolectric.shadows.ShadowActivity)2