Search in sources :

Example 26 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority.

@Test
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /*key */
    Preference.DEFAULT_ORDER);
    assertThat(preference.getKey()).isNotNull();
    assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) 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)

Example 27 with ActivityTile

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

the class DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_shouldNotShow.

@Test
public void openTileIntent_profileSelectionDialog_shouldNotShow() {
    ShadowUserManager.getShadow().addUser(10, "Someone", 0);
    mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_PRIMARY);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    final ArrayList<UserHandle> handles = new ArrayList<>();
    handles.add(new UserHandle(0));
    handles.add(new UserHandle(10));
    tile.userHandle = handles;
    mImpl.openTileIntent(mActivity, tile);
    verify(mActivity).startActivityForResult(any(Intent.class), eq(0));
    verify(mActivity, never()).getSupportFragmentManager();
}
Also used : UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) 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 28 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindIcon_noIcon_shouldNotLoadIcon.

@Test
@Config(shadows = { ShadowTileUtils.class })
public void bindIcon_noIcon_shouldNotLoadIcon() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
    mImpl.bindIcon(preference, tile, false);
    assertThat(preference.getIcon()).isNull();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) 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) Config(org.robolectric.annotation.Config)

Example 29 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindIcon_withIconUri_shouldLoadIconFromContentProvider.

@Test
@Config(shadows = { ShadowTileUtils.class })
public void bindIcon_withIconUri_shouldLoadIconFromContentProvider() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_ICON_URI, "content://com.android.settings/tile_icon");
    mImpl.bindIcon(preference, tile, false);
    assertThat(preference.getIcon()).isNotNull();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) 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) Config(org.robolectric.annotation.Config)

Example 30 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_withIntentActionMetadata_shouldSetLaunchAction.

@Test
public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
    FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
    mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
    tile.userHandle = null;
    mImpl.bindPreferenceToTileAndGetObservers(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
    preference.performClick();
    ShadowActivity shadowActivity = Shadows.shadowOf(activity);
    final Intent launchIntent = shadowActivity.getNextStartedActivityForResult().intent;
    assertThat(launchIntent.getAction()).isEqualTo("TestAction");
    assertThat(launchIntent.getIntExtra(MetricsFeatureProvider.EXTRA_SOURCE_METRICS_CATEGORY, 0)).isEqualTo(MetricsEvent.SETTINGS_GESTURES);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) ActivityTile(com.android.settingslib.drawer.ActivityTile) ProviderTile(com.android.settingslib.drawer.ProviderTile) Tile(com.android.settingslib.drawer.Tile) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) 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