Search in sources :

Example 6 with ActivityTile

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

the class AccountDetailDashboardFragmentTest method displayTile_shouldAddUserHandleToTileIntent.

@Test
public void displayTile_shouldAddUserHandleToTileIntent() {
    mFragment.mUserHandle = new UserHandle(1);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
    mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
    mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
    mFragment.displayTile(tile);
    final UserHandle userHandle = tile.getIntent().getParcelableExtra(EXTRA_USER);
    assertThat(userHandle.getIdentifier()).isEqualTo(1);
}
Also used : UserHandle(android.os.UserHandle) ActivityTile(com.android.settingslib.drawer.ActivityTile) Tile(com.android.settingslib.drawer.Tile) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 7 with ActivityTile

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

the class SettingsSearchIndexablesProviderTest method isEligibleForIndexing_normalInjectedItem_shouldReturnTrue.

@Test
public void isEligibleForIndexing_normalInjectedItem_shouldReturnTrue() {
    final ActivityInfo activityInfo = new ActivityInfo();
    activityInfo.packageName = "pkg";
    activityInfo.name = "class";
    final ActivityTile activityTile = new ActivityTile(activityInfo, CategoryKey.CATEGORY_CONNECT);
    assertThat(mProvider.isEligibleForIndexing(PACKAGE_NAME, activityTile)).isTrue();
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 8 with ActivityTile

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

the class SettingsSearchIndexablesProviderTest method isEligibleForIndexing_isSettingsInjectedItem_shouldReturnFalse.

@Test
public void isEligibleForIndexing_isSettingsInjectedItem_shouldReturnFalse() {
    final ActivityInfo activityInfo = new ActivityInfo();
    activityInfo.packageName = PACKAGE_NAME;
    activityInfo.name = "class";
    final ActivityTile activityTile = new ActivityTile(activityInfo, CategoryKey.CATEGORY_SYSTEM);
    assertThat(mProvider.isEligibleForIndexing(PACKAGE_NAME, activityTile)).isFalse();
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) ActivityTile(com.android.settingslib.drawer.ActivityTile) Test(org.junit.Test)

Example 9 with ActivityTile

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

the class SettingsSearchIndexablesProviderTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mProvider = spy(new SettingsSearchIndexablesProvider());
    ProviderInfo info = new ProviderInfo();
    info.exported = true;
    info.grantUriPermissions = true;
    info.authority = PACKAGE_NAME;
    info.readPermission = Manifest.permission.READ_SEARCH_INDEXABLES;
    mProvider.attachInfo(RuntimeEnvironment.application, info);
    final SearchFeatureProvider featureProvider = new SearchFeatureProviderImpl();
    featureProvider.getSearchIndexableResources().getProviderValues().clear();
    featureProvider.getSearchIndexableResources().getProviderValues().add(new SearchIndexableData(FakeSettingsFragment.class, FakeSettingsFragment.SEARCH_INDEX_DATA_PROVIDER));
    mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mFakeFeatureFactory.searchFeatureProvider = featureProvider;
    final ActivityInfo activityInfo = new ActivityInfo();
    activityInfo.packageName = "pkg";
    activityInfo.name = "class";
    activityInfo.metaData = new Bundle();
    activityInfo.metaData.putString(META_DATA_PREFERENCE_TITLE, "title");
    final DashboardCategory category = new DashboardCategory("key");
    when(mFakeFeatureFactory.dashboardFeatureProvider.getAllCategories()).thenReturn(Arrays.asList(category));
    category.addTile(new ActivityTile(activityInfo, category.key));
    ShadowCategoryManager.setDashboardCategory(category);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ActivityInfo(android.content.pm.ActivityInfo) ProviderInfo(android.content.pm.ProviderInfo) Bundle(android.os.Bundle) SearchIndexableData(com.android.settingslib.search.SearchIndexableData) ActivityTile(com.android.settingslib.drawer.ActivityTile) Before(org.junit.Before)

Example 10 with ActivityTile

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

the class DashboardFeatureProviderImplTest method bindPreference_hasTitleUri_shouldLoadFromContentProviderAndHaveObserver.

@Test
@Config(shadows = { ShadowTileUtils.class })
public void bindPreference_hasTitleUri_shouldLoadFromContentProviderAndHaveObserver() {
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
    final String uriString = "content://com.android.settings/tile_title";
    mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_TITLE_URI, uriString);
    final List<DynamicDataObserver> observers = mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /*key */
    Preference.DEFAULT_ORDER);
    assertThat(preference.getTitle()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY);
    assertThat(observers.get(0).getUri().toString()).isEqualTo(uriString);
}
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)

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