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();
}
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);
}
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();
}
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());
}
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<>();
}
Aggregations