Search in sources :

Example 16 with ActivityTile

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

the class DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_explicitMetadataShouldShow.

@Test
public void openTileIntent_profileSelectionDialog_explicitMetadataShouldShow() {
    ShadowUserManager.getShadow().addUser(10, "Someone", 0);
    mActivityInfo.metaData.putString(META_DATA_KEY_PROFILE, PROFILE_ALL);
    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 17 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_withBaseOrder_shouldOffsetOrder.

@Test
public void bindPreference_withBaseOrder_shouldOffsetOrder() {
    final int baseOrder = 100;
    final Preference preference = new Preference(RuntimeEnvironment.application);
    mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, "123", baseOrder);
    assertThat(preference.getOrder()).isEqualTo(tile.getOrder() + baseOrder);
}
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 18 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadata_shouldBindToProfileSelector.

@Test
public void bindPreference_noFragmentMetadata_shouldBindToProfileSelector() {
    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));
    tile.userHandle.add(mock(UserHandle.class));
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
    preference.getOnPreferenceClickListener().onPreferenceClick(null);
    verify(mActivity).getSupportFragmentManager();
}
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) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 19 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadata_shouldBindIntent.

@Test
public void bindPreference_noFragmentMetadata_shouldBindIntent() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
    assertThat(preference.getFragment()).isNull();
    assertThat(preference.getOnPreferenceClickListener()).isNotNull();
    assertThat(preference.getOrder()).isEqualTo(tile.getOrder());
}
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 20 with ActivityTile

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

the class DashboardFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    final ActivityInfo activityInfo = new ActivityInfo();
    activityInfo.packageName = "pkg";
    activityInfo.name = "class";
    activityInfo.metaData = new Bundle();
    activityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "injected_tile_key");
    mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mDashboardCategory = new DashboardCategory("key");
    mActivityTile = new ActivityTile(activityInfo, mDashboardCategory.key);
    mDashboardCategory.addTile(mActivityTile);
    final ProviderInfo providerInfo = new ProviderInfo();
    providerInfo.packageName = "pkg";
    providerInfo.name = "provider";
    providerInfo.authority = "authority";
    final Bundle metaData = new Bundle();
    metaData.putString(META_DATA_PREFERENCE_KEYHINT, "injected_tile_key2");
    metaData.putString(META_DATA_PREFERENCE_SWITCH_URI, "uri");
    mProviderTile = new ProviderTile(providerInfo, mDashboardCategory.key, metaData);
    mDashboardCategory.addTile(mProviderTile);
    mTestFragment = new TestFragment(RuntimeEnvironment.application);
    when(mFakeFeatureFactory.dashboardFeatureProvider.getTilesForCategory(nullable(String.class))).thenReturn(mDashboardCategory);
    mTestFragment.onAttach(RuntimeEnvironment.application);
    when(mContext.getPackageName()).thenReturn("TestPackage");
    mControllers = new ArrayList<>();
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ActivityInfo(android.content.pm.ActivityInfo) ProviderInfo(android.content.pm.ProviderInfo) Bundle(android.os.Bundle) ActivityTile(com.android.settingslib.drawer.ActivityTile) ProviderTile(com.android.settingslib.drawer.ProviderTile) Before(org.junit.Before)

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