use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class SummaryLoaderTest method SetUp.
@Before
public void SetUp() {
MockitoAnnotations.initMocks(this);
mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
mTile = new Tile();
mTile.summary = SUMMARY_1;
mCallbackInvoked = false;
final Activity activity = Robolectric.buildActivity(Activity.class).get();
final List<DashboardCategory> categories = new ArrayList<>();
mSummaryLoader = new SummaryLoader(activity, categories);
mSummaryLoader.setSummaryConsumer(new SummaryLoader.SummaryConsumer() {
@Override
public void notifySummaryChanged(Tile tile) {
mCallbackInvoked = true;
}
});
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by omnirom.
the class SummaryLoaderTest method SetUp.
@Before
public void SetUp() {
MockitoAnnotations.initMocks(this);
mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
mTile = new Tile();
mTile.summary = SUMMARY_1;
mCallbackInvoked = false;
final Activity activity = Robolectric.buildActivity(Activity.class).get();
final List<DashboardCategory> categories = new ArrayList<>();
mSummaryLoader = new SummaryLoader(activity, categories);
mSummaryLoader.setSummaryConsumer(new SummaryLoader.SummaryConsumer() {
@Override
public void notifySummaryChanged(Tile tile) {
mCallbackInvoked = true;
}
});
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by omnirom.
the class SummaryLoaderTest method testUpdateSummaryToCache_hasCache_shouldUpdate.
@Test
public void testUpdateSummaryToCache_hasCache_shouldUpdate() {
final String testSummary = "test_summary";
final DashboardCategory category = new DashboardCategory();
final Tile tile = new Tile();
tile.key = "123";
tile.intent = new Intent();
category.addTile(tile);
when(mFeatureFactory.dashboardFeatureProvider.getDashboardKeyForTile(tile)).thenReturn(tile.key);
mSummaryLoader.updateSummaryIfNeeded(tile, testSummary);
tile.summary = null;
mSummaryLoader.updateSummaryToCache(category);
assertThat(tile.summary).isEqualTo(testSummary);
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by omnirom.
the class DashboardAdapterTest method testBindConditionAndSuggestion_shouldSetSuggestionAdapterAndNoCrash.
@Test
public void testBindConditionAndSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapter(mContext, null, null, null, null);
final List<Tile> suggestions = makeSuggestions("pkg1");
final DashboardCategory category = mock(DashboardCategory.class);
final List<Tile> tiles = new ArrayList<>();
tiles.add(mock(Tile.class));
category.tiles = tiles;
mDashboardAdapter.setCategoriesAndSuggestions(category, suggestions);
final RecyclerView data = mock(RecyclerView.class);
when(data.getResources()).thenReturn(mResources);
when(data.getContext()).thenReturn(mContext);
when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
final View itemView = mock(View.class);
when(itemView.findViewById(R.id.data)).thenReturn(data);
final DashboardAdapter.SuggestionAndConditionContainerHolder holder = new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
mDashboardAdapter.onBindConditionAndSuggestion(holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
verify(data).setAdapter(any(SuggestionAdapter.class));
// should not crash
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by omnirom.
the class SiteMapManagerTest method buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp.
@Test
public void buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp() {
final String iaClass = SystemDashboardFragment.class.getName();
final String iaTitle = "ia_title";
ContentValues index = new ContentValues();
index.put(IndexDatabaseHelper.IndexColumns.CLASS_NAME, iaClass);
index.put(IndexDatabaseHelper.IndexColumns.SCREEN_TITLE, iaTitle);
mDb.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_PREFS_INDEX, null, index);
final DashboardCategory category = new DashboardCategory();
category.key = CategoryKey.CATEGORY_SYSTEM;
category.tiles.add(new Tile());
category.tiles.get(0).title = TITLE_PREFIX + STATIC_DB_DEPTH;
category.tiles.get(0).metaData = new Bundle();
category.tiles.get(0).metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, CLASS_PREFIX + STATIC_DB_DEPTH);
when(mFeatureFactory.dashboardFeatureProvider.getAllCategories()).thenReturn(Arrays.asList(category));
final List<String> breadcrumb = mSiteMapManager.buildBreadCrumb(mContext, CLASS_PREFIX + 0, TITLE_PREFIX + 0);
assertThat(breadcrumb.size()).isEqualTo(STATIC_DB_DEPTH + 2);
assertThat(breadcrumb.get(0)).isEqualTo(iaTitle);
}
Aggregations