Search in sources :

Example 11 with ActivityTile

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

the class DashboardFeatureProviderImplTest method clickPreference_withUnresolvableIntent_shouldNotLaunchAnything.

@Test
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
    ReflectionHelpers.setField(mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager());
    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();
    final ShadowActivity.IntentForResult launchIntent = Shadows.shadowOf(activity).getNextStartedActivityForResult();
    assertThat(launchIntent).isNull();
}
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) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 12 with ActivityTile

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

the class DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_shouldShow.

@Test
public void openTileIntent_profileSelectionDialog_shouldShow() {
    ShadowUserManager.getShadow().addUser(10, "Someone", 0);
    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, never()).startActivityForResult(any(Intent.class), eq(0));
    verify(mActivity).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 13 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_noSummary_shouldSetNullSummary.

@Test
public void bindPreference_noSummary_shouldSetNullSummary() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    mActivityInfo.metaData.remove(META_DATA_PREFERENCE_SUMMARY);
    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.getSummary()).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)

Example 14 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyTileKey_shouldUseTileKey.

@Test
public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
    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()).isEqualTo(tile.getKey(mContext));
}
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 15 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_invalidOrderMetadata_shouldIgnore.

@Test
public void bindPreference_invalidOrderMetadata_shouldIgnore() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mActivityInfo.metaData.putString(META_DATA_KEY_ORDER, "hello");
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, "123", Preference.DEFAULT_ORDER);
    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)

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