diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java index 11fef7eb2d7..d9f96cf7a92 100644 --- a/src/com/android/settings/dashboard/DashboardAdapter.java +++ b/src/com/android/settings/dashboard/DashboardAdapter.java @@ -396,6 +396,7 @@ public class DashboardAdapter extends RecyclerView.Adapter packages = makeSuggestions("pkg1"); + RemoteViews remoteViews = mock(RemoteViews.class); + FrameLayout layout = new FrameLayout(context); + Button primary = new Button(context); + primary.setId(android.R.id.primary); + layout.addView(primary); + doReturn(layout).when(remoteViews).apply(any(Context.class), any(ViewGroup.class)); + packages.get(0).remoteViews = remoteViews; + mDashboardAdapter.setCategoriesAndSuggestions(Collections.emptyList(), packages); + mSuggestionHolder = mDashboardAdapter.onCreateViewHolder( + new FrameLayout(context), + R.layout.suggestion_tile_card); + + mDashboardAdapter.onBindViewHolder(mSuggestionHolder, 1); + mDashboardAdapter.onBindViewHolder(mSuggestionHolder, 1); + + ViewGroup itemView = (ViewGroup) mSuggestionHolder.itemView; + assertThat(itemView.getChildCount()).isEqualTo(1); + } + private List makeSuggestions(String... pkgNames) { final List suggestions = new ArrayList<>(); for (String pkgName : pkgNames) {