Search in sources :

Example 76 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardDataTest method testGetPositionByTile_notExisted_returnNotFound.

@Test
public void testGetPositionByTile_notExisted_returnNotFound() {
    final Tile tile = mock(Tile.class);
    tile.title = "";
    final int position = mDashboardDataWithOneConditions.getPositionByTile(tile);
    assertThat(position).isEqualTo(DashboardData.POSITION_NOT_FOUND);
}
Also used : Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 77 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyTileKey_shouldUseTileKey.

@Test
public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new Tile();
    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);
    assertThat(preference.getKey()).isEqualTo(tile.key);
}
Also used : Preference(android.support.v7.preference.Preference) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 78 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadata_shouldBindIntent.

@Test
public void bindPreference_noFragmentMetadata_shouldBindIntent() {
    final Preference preference = new Preference(ShadowApplication.getInstance().getApplicationContext());
    final Tile tile = new Tile();
    tile.metaData = new Bundle();
    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);
    assertThat(preference.getFragment()).isNull();
    assertThat(preference.getOnPreferenceClickListener()).isNotNull();
    assertThat(preference.getOrder()).isEqualTo(-tile.priority);
}
Also used : Preference(android.support.v7.preference.Preference) Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 79 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority.

@Test
public void bindPreference_withNullKeyNullPriority_shouldGenerateKeyAndPriority() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new Tile();
    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);
    assertThat(preference.getKey()).isNotNull();
    assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
}
Also used : Preference(android.support.v7.preference.Preference) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Test(org.junit.Test)

Example 80 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFeatureProviderImplTest method clickPreference_withUnresolvableIntent_shouldNotLaunchAnything.

@Test
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
    ReflectionHelpers.setField(mImpl, "mPackageManager", RuntimeEnvironment.getPackageManager());
    Activity activity = Robolectric.buildActivity(Activity.class).get();
    final ShadowApplication application = ShadowApplication.getInstance();
    final Preference preference = new Preference(application.getApplicationContext());
    final Tile tile = new Tile();
    tile.key = "key";
    tile.intent = new Intent();
    tile.intent.setComponent(new ComponentName("pkg", "class"));
    tile.metaData = new Bundle();
    tile.metaData.putString("com.android.settings.intent.action", "TestAction");
    tile.userHandle = null;
    mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
    preference.performClick();
    final ShadowActivity.IntentForResult launchIntent = shadowOf(activity).getNextStartedActivityForResult();
    assertThat(launchIntent).isNull();
}
Also used : Preference(android.support.v7.preference.Preference) Bundle(android.os.Bundle) ShadowActivity(org.robolectric.shadows.ShadowActivity) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) Tile(com.android.settingslib.drawer.Tile) ShadowActivity(org.robolectric.shadows.ShadowActivity) Intent(android.content.Intent) ComponentName(android.content.ComponentName) ShadowApplication(org.robolectric.shadows.ShadowApplication) Test(org.junit.Test)

Aggregations

Tile (com.android.settingslib.drawer.Tile)506 Test (org.junit.Test)345 Intent (android.content.Intent)160 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)117 Bundle (android.os.Bundle)108 Preference (android.support.v7.preference.Preference)98 ComponentName (android.content.ComponentName)93 ArrayList (java.util.ArrayList)87 Context (android.content.Context)70 ActivityTile (com.android.settingslib.drawer.ActivityTile)50 ProviderTile (com.android.settingslib.drawer.ProviderTile)45 UserHandle (android.os.UserHandle)39 Preference (androidx.preference.Preference)39 RecyclerView (android.support.v7.widget.RecyclerView)31 View (android.view.View)31 Icon (android.graphics.drawable.Icon)30 Activity (android.app.Activity)29 VisibleForTesting (android.support.annotation.VisibleForTesting)29 PackageManager (android.content.pm.PackageManager)25 ViewGroup (android.view.ViewGroup)24