Commit a9efb918 authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

[Explore sites]: Clean up code and remove unneeded header to ESP.

Also fixes a number of issues:
1. Re-reinforce the max 2 rows of sites on categories
2. Update tests to account for the 4-sites-per-row rule

Change-Id: I27b232466314ce0398c6f5ba31ebdb340e6dbdfc
Reviewed-on: https://chromium-review.googlesource.com/c/1377141Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Cathy Li <chili@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619598}
parent 2d3f8519
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/BlackHeadline"
android:text="@string/explore_sites_title"
android:paddingBottom="@dimen/explore_sites_category_padding"
android:paddingTop="@dimen/explore_sites_page_padding"/>
...@@ -12,9 +12,8 @@ import android.text.SpannableString; ...@@ -12,9 +12,8 @@ import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.modelutil.ListObservable; import org.chromium.chrome.browser.modelutil.ForwardingListObservable;
import org.chromium.chrome.browser.modelutil.ListObservable.ListObserver; import org.chromium.chrome.browser.modelutil.ListObservable.ListObserver;
import org.chromium.chrome.browser.modelutil.ListObservableImpl;
import org.chromium.chrome.browser.modelutil.PropertyKey; import org.chromium.chrome.browser.modelutil.PropertyKey;
import org.chromium.chrome.browser.modelutil.PropertyModel; import org.chromium.chrome.browser.modelutil.PropertyModel;
import org.chromium.chrome.browser.modelutil.PropertyObservable; import org.chromium.chrome.browser.modelutil.PropertyObservable;
...@@ -33,17 +32,16 @@ import java.lang.annotation.RetentionPolicy; ...@@ -33,17 +32,16 @@ import java.lang.annotation.RetentionPolicy;
/** /**
* Recycler view adapter delegate for a model containing a list of category cards and an error code. * Recycler view adapter delegate for a model containing a list of category cards and an error code.
*/ */
class CategoryCardAdapter extends ListObservableImpl<Void> class CategoryCardAdapter extends ForwardingListObservable<Void>
implements RecyclerViewAdapter implements RecyclerViewAdapter
.Delegate<CategoryCardViewHolderFactory.CategoryCardViewHolder, Void>, .Delegate<CategoryCardViewHolderFactory.CategoryCardViewHolder, Void>,
PropertyObservable.PropertyObserver<PropertyKey>, ListObserver<Void> { PropertyObservable.PropertyObserver<PropertyKey>, ListObserver<Void> {
@IntDef({ViewType.HEADER, ViewType.CATEGORY, ViewType.LOADING, ViewType.ERROR}) @IntDef({ViewType.CATEGORY, ViewType.LOADING, ViewType.ERROR})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface ViewType { public @interface ViewType {
int HEADER = 0; int CATEGORY = 0;
int CATEGORY = 1; int LOADING = 1;
int LOADING = 2; int ERROR = 2;
int ERROR = 3;
} }
private final RoundedIconGenerator mIconGenerator; private final RoundedIconGenerator mIconGenerator;
...@@ -75,8 +73,7 @@ class CategoryCardAdapter extends ListObservableImpl<Void> ...@@ -75,8 +73,7 @@ class CategoryCardAdapter extends ListObservableImpl<Void>
!= ExploreSitesPage.CatalogLoadingState.SUCCESS) { != ExploreSitesPage.CatalogLoadingState.SUCCESS) {
return 1; return 1;
} }
// Add 1 for title. return mCategoryModel.get(ExploreSitesPage.CATEGORY_LIST_KEY).size();
return mCategoryModel.get(ExploreSitesPage.CATEGORY_LIST_KEY).size() + 1;
} }
@Override @Override
...@@ -89,7 +86,6 @@ class CategoryCardAdapter extends ListObservableImpl<Void> ...@@ -89,7 +86,6 @@ class CategoryCardAdapter extends ListObservableImpl<Void>
case ExploreSitesPage.CatalogLoadingState.LOADING_NET: case ExploreSitesPage.CatalogLoadingState.LOADING_NET:
return ViewType.LOADING; return ViewType.LOADING;
case ExploreSitesPage.CatalogLoadingState.SUCCESS: case ExploreSitesPage.CatalogLoadingState.SUCCESS:
if (position == 0) return ViewType.HEADER;
return ViewType.CATEGORY; return ViewType.CATEGORY;
default: default:
assert(false); assert(false);
...@@ -102,10 +98,8 @@ class CategoryCardAdapter extends ListObservableImpl<Void> ...@@ -102,10 +98,8 @@ class CategoryCardAdapter extends ListObservableImpl<Void>
int position, @Nullable Void payload) { int position, @Nullable Void payload) {
if (holder.getItemViewType() == ViewType.CATEGORY) { if (holder.getItemViewType() == ViewType.CATEGORY) {
ExploreSitesCategoryCardView view = (ExploreSitesCategoryCardView) holder.itemView; ExploreSitesCategoryCardView view = (ExploreSitesCategoryCardView) holder.itemView;
// Position - 1 because there is always title. view.setCategory(mCategoryModel.get(ExploreSitesPage.CATEGORY_LIST_KEY).get(position),
view.setCategory( position, mIconGenerator, mContextMenuManager, mNavDelegate, mProfile);
mCategoryModel.get(ExploreSitesPage.CATEGORY_LIST_KEY).get(position - 1),
position - 1, mIconGenerator, mContextMenuManager, mNavDelegate, mProfile);
} else if (holder.getItemViewType() == ViewType.LOADING) { } else if (holder.getItemViewType() == ViewType.LOADING) {
// Start spinner. // Start spinner.
LoadingView spinner = holder.itemView.findViewById(R.id.loading); LoadingView spinner = holder.itemView.findViewById(R.id.loading);
...@@ -139,28 +133,8 @@ class CategoryCardAdapter extends ListObservableImpl<Void> ...@@ -139,28 +133,8 @@ class CategoryCardAdapter extends ListObservableImpl<Void>
} }
} }
if (key == ExploreSitesPage.SCROLL_TO_CATEGORY_KEY) { if (key == ExploreSitesPage.SCROLL_TO_CATEGORY_KEY) {
int pos = mCategoryModel.get(ExploreSitesPage.SCROLL_TO_CATEGORY_KEY); mLayoutManager.scrollToPosition(
// Add 1 for title. mCategoryModel.get(ExploreSitesPage.SCROLL_TO_CATEGORY_KEY));
mLayoutManager.scrollToPosition(pos + 1);
} }
} }
@Override
public void onItemRangeInserted(ListObservable source, int index, int count) {
// Add 1 because of title.
notifyItemRangeInserted(index + 1, count);
}
@Override
public void onItemRangeRemoved(ListObservable source, int index, int count) {
// Add 1 because of title.
notifyItemRangeRemoved(index + 1, count);
}
@Override
public void onItemRangeChanged(
ListObservable<Void> source, int index, int count, @Nullable Void payload) {
// Add 1 because of title.
notifyItemRangeChanged(index + 1, count, payload);
}
} }
...@@ -27,11 +27,6 @@ class CategoryCardViewHolderFactory implements RecyclerViewAdapter.ViewHolderFac ...@@ -27,11 +27,6 @@ class CategoryCardViewHolderFactory implements RecyclerViewAdapter.ViewHolderFac
ViewGroup parent, @CategoryCardAdapter.ViewType int viewType) { ViewGroup parent, @CategoryCardAdapter.ViewType int viewType) {
View view; View view;
switch (viewType) { switch (viewType) {
case CategoryCardAdapter.ViewType.HEADER:
view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.explore_sites_title_card, parent,
/* attachToRoot = */ false);
break;
case CategoryCardAdapter.ViewType.CATEGORY: case CategoryCardAdapter.ViewType.CATEGORY:
view = LayoutInflater.from(parent.getContext()) view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.explore_sites_category_card_view, parent, .inflate(R.layout.explore_sites_category_card_view, parent,
......
...@@ -23,21 +23,24 @@ import java.util.List; ...@@ -23,21 +23,24 @@ import java.util.List;
*/ */
public class ExploreSitesCategory { public class ExploreSitesCategory {
private static final String TAG = "ExploreSitesCategory"; private static final String TAG = "ExploreSitesCategory";
// The ID to use when creating the More button, that should not scroll the ESP when clicked. // The ID to use when creating placeholder icons on the NTP when there is no data or the More
public static final int MORE_BUTTON_ID = -1; // button.
private static final int PLACEHOLDER_ID = -1;
static final int MAX_COLUMNS = 4; static final int MAX_COLUMNS = 4;
// This enum must match the numbering for ExploreSites.CategoryClick in histograms.xml. Do not // This enum must match the numbering for ExploreSites.CategoryClick in histograms.xml. Do not
// reorder or remove items, only add new items before COUNT. // reorder or remove items, only add new items before COUNT.
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({CategoryType.DEFAULT, CategoryType.SOCIAL, CategoryType.ENTERTAINMENT, @IntDef({CategoryType.MORE_BUTTON, CategoryType.DEFAULT, CategoryType.SOCIAL,
CategoryType.SPORT, CategoryType.NEWS, CategoryType.SHOPPING, CategoryType.REFERENCE, CategoryType.ENTERTAINMENT, CategoryType.SPORT, CategoryType.NEWS,
CategoryType.BANKING, CategoryType.GOVERNMENT, CategoryType.TRAVEL, CategoryType.SHOPPING, CategoryType.REFERENCE, CategoryType.BANKING,
CategoryType.EDUCATION, CategoryType.JOBS, CategoryType.APPS_GAMES, CategoryType.GOVERNMENT, CategoryType.TRAVEL, CategoryType.EDUCATION, CategoryType.JOBS,
CategoryType.FAVORITE, CategoryType.GOOGLE, CategoryType.FOOD, CategoryType.HEALTH, CategoryType.APPS_GAMES, CategoryType.FAVORITE, CategoryType.GOOGLE, CategoryType.FOOD,
CategoryType.BOOKS, CategoryType.TECHNOLOGY, CategoryType.SCIENCE, CategoryType.COUNT}) CategoryType.HEALTH, CategoryType.BOOKS, CategoryType.TECHNOLOGY, CategoryType.SCIENCE,
CategoryType.COUNT})
public @interface CategoryType { public @interface CategoryType {
int MORE_BUTTON = -1; // This is not included in histograms.xml.
int DEFAULT = 0; int DEFAULT = 0;
int SOCIAL = 1; int SOCIAL = 1;
int ENTERTAINMENT = 2; int ENTERTAINMENT = 2;
...@@ -62,6 +65,11 @@ public class ExploreSitesCategory { ...@@ -62,6 +65,11 @@ public class ExploreSitesCategory {
int COUNT = 20; int COUNT = 20;
} }
public static ExploreSitesCategory createPlaceholder(
@CategoryType int categoryType, String title) {
return new ExploreSitesCategory(PLACEHOLDER_ID, categoryType, title);
}
private int mCategoryId; private int mCategoryId;
private @CategoryType int mCategoryType; private @CategoryType int mCategoryType;
...@@ -95,7 +103,11 @@ public class ExploreSitesCategory { ...@@ -95,7 +103,11 @@ public class ExploreSitesCategory {
} }
public boolean isPlaceholder() { public boolean isPlaceholder() {
return mCategoryId == -1; return mCategoryId == PLACEHOLDER_ID;
}
public boolean isMoreButton() {
return mCategoryType == CategoryType.MORE_BUTTON;
} }
public String getTitle() { public String getTitle() {
......
...@@ -89,10 +89,9 @@ public class ExploreSitesCategoryCardView extends LinearLayout { ...@@ -89,10 +89,9 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
// Remove from model (category). // Remove from model (category).
mCategory.removeSite(mTileIndex); mCategory.removeSite(mTileIndex);
// Update the view This may add any sites that we didn't have room for before. It // Update the view. This may add sites that we didn't have room for before. It
// should reset the tile indexeds for views we keep. // should reset the tile indexes for views we keep.
updateTileViews( updateTileViews(mCategory);
mCategory.getSites(), mCategory.getNumDisplayed(), mCategory.getMaxRows());
} }
@Override @Override
public String getUrl() { public String getUrl() {
...@@ -160,14 +159,14 @@ public class ExploreSitesCategoryCardView extends LinearLayout { ...@@ -160,14 +159,14 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
mCategory = category; mCategory = category;
updateTitle(category.getTitle()); updateTitle(category.getTitle());
updateTileViews(category.getSites(), category.getNumDisplayed(), category.getMaxRows()); updateTileViews(category);
} }
public void updateTitle(String categoryTitle) { public void updateTitle(String categoryTitle) {
mTitleView.setText(categoryTitle); mTitleView.setText(categoryTitle);
} }
public void updateTileViews(List<ExploreSitesSite> sites, int numSitesToShow, int maxRows) { public void updateTileViews(ExploreSitesCategory category) {
// Clear observers. // Clear observers.
for (PropertyModelChangeProcessor<PropertyModel, ExploreSitesTileView, PropertyKey> for (PropertyModelChangeProcessor<PropertyModel, ExploreSitesTileView, PropertyKey>
observer : mModelChangeProcessors) { observer : mModelChangeProcessors) {
...@@ -177,11 +176,12 @@ public class ExploreSitesCategoryCardView extends LinearLayout { ...@@ -177,11 +176,12 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
// Only show rows that would be fully populated by original list of sites. This is // Only show rows that would be fully populated by original list of sites. This is
// calculated within the category. // calculated within the category.
mTileView.setMaxRows(maxRows); mTileView.setMaxRows(Math.min(category.getMaxRows(), MAX_ROWS));
// Maximum number of sites that can be shown, defined as min of // Maximum number of sites that can be shown, defined as min of
// numSitesToShow and maxRows * maxCols. // numSitesToShow and maxRows * maxCols.
int tileMax = Math.min(maxRows * ExploreSitesCategory.MAX_COLUMNS, numSitesToShow); int tileMax = Math.min(category.getMaxRows() * ExploreSitesCategory.MAX_COLUMNS,
category.getNumDisplayed());
// Remove extra tiles if too many. // Remove extra tiles if too many.
if (mTileView.getChildCount() > tileMax) { if (mTileView.getChildCount() > tileMax) {
...@@ -199,7 +199,7 @@ public class ExploreSitesCategoryCardView extends LinearLayout { ...@@ -199,7 +199,7 @@ public class ExploreSitesCategoryCardView extends LinearLayout {
// Initialize all the non-empty tiles again to update. // Initialize all the non-empty tiles again to update.
int tileIndex = 0; int tileIndex = 0;
for (ExploreSitesSite site : sites) { for (ExploreSitesSite site : category.getSites()) {
if (tileIndex >= tileMax) break; if (tileIndex >= tileMax) break;
final PropertyModel siteModel = site.getModel(); final PropertyModel siteModel = site.getModel();
// Skip blacklisted sites. // Skip blacklisted sites.
......
...@@ -33,7 +33,6 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -33,7 +33,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabObserver; import org.chromium.chrome.browser.tab.TabObserver;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.widget.RoundedIconGenerator; import org.chromium.chrome.browser.widget.RoundedIconGenerator;
import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.NavigationEntry; import org.chromium.content_public.browser.NavigationEntry;
...@@ -70,7 +69,6 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -70,7 +69,6 @@ public class ExploreSitesPage extends BasicNativePage {
int LOADING_NET = 4; // Retrieving catalog resources from internet. int LOADING_NET = 4; // Retrieving catalog resources from internet.
} }
private TabModelSelector mTabModelSelector;
private NativePageHost mHost; private NativePageHost mHost;
private Tab mTab; private Tab mTab;
private TabObserver mTabObserver; private TabObserver mTabObserver;
...@@ -97,7 +95,6 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -97,7 +95,6 @@ public class ExploreSitesPage extends BasicNativePage {
mHost = host; mHost = host;
mTab = mHost.getActiveTab(); mTab = mHost.getActiveTab();
mTabModelSelector = activity.getTabModelSelector();
mTitle = activity.getString(R.string.explore_sites_title); mTitle = activity.getString(R.string.explore_sites_title);
mView = (ViewGroup) activity.getLayoutInflater().inflate( mView = (ViewGroup) activity.getLayoutInflater().inflate(
R.layout.explore_sites_page_layout, null); R.layout.explore_sites_page_layout, null);
...@@ -118,8 +115,9 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -118,8 +115,9 @@ public class ExploreSitesPage extends BasicNativePage {
context.getResources(), R.color.default_favicon_background_color), context.getResources(), R.color.default_favicon_background_color),
context.getResources().getDimensionPixelSize(R.dimen.tile_view_icon_text_size)); context.getResources().getDimensionPixelSize(R.dimen.tile_view_icon_text_size));
NativePageNavigationDelegateImpl navDelegate = NativePageNavigationDelegateImpl navDelegate = new NativePageNavigationDelegateImpl(
new NativePageNavigationDelegateImpl(activity, mProfile, host, mTabModelSelector); activity, mProfile, host, activity.getTabModelSelector());
// Don't direct reference activity because it might change if tab is reparented. // Don't direct reference activity because it might change if tab is reparented.
Runnable closeContextMenuCallback = Runnable closeContextMenuCallback =
() -> host.getActiveTab().getActivity().closeContextMenu(); () -> host.getActiveTab().getActivity().closeContextMenu();
...@@ -139,8 +137,6 @@ public class ExploreSitesPage extends BasicNativePage { ...@@ -139,8 +137,6 @@ public class ExploreSitesPage extends BasicNativePage {
ExploreSitesBridge.getEspCatalog(mProfile, this::translateToModel); ExploreSitesBridge.getEspCatalog(mProfile, this::translateToModel);
RecordUserAction.record("Android.ExploreSitesPage.Open"); RecordUserAction.record("Android.ExploreSitesPage.Open");
// TODO(chili): Set layout to be an observer of list model
} }
void translateToModel(@Nullable List<ExploreSitesCategory> categoryList) { void translateToModel(@Nullable List<ExploreSitesCategory> categoryList) {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.explore_sites;
import android.view.View;
import org.chromium.chrome.browser.profiles.Profile;
/**
* Class to manage layout of explore sites page.
*/
public class ExploreSitesPageLayout {
private View mParent;
private Profile mProfile;
public ExploreSitesPageLayout(View parent, Profile profile) {
mParent = parent;
mProfile = profile;
}
}
...@@ -76,20 +76,19 @@ public class ExploreSitesSection { ...@@ -76,20 +76,19 @@ public class ExploreSitesSection {
List<ExploreSitesCategory> categoryList = new ArrayList<>(); List<ExploreSitesCategory> categoryList = new ArrayList<>();
// News category. // News category.
ExploreSitesCategory category = ExploreSitesCategory category = ExploreSitesCategory.createPlaceholder(CategoryType.NEWS,
new ExploreSitesCategory(-1 /* category_id */, CategoryType.NEWS, getContext().getString(R.string.explore_sites_default_category_news));
getContext().getString(R.string.explore_sites_default_category_news));
category.setDrawable(getVectorDrawable(R.drawable.ic_article_blue_24dp)); category.setDrawable(getVectorDrawable(R.drawable.ic_article_blue_24dp));
categoryList.add(category); categoryList.add(category);
// Shopping category. // Shopping category.
category = new ExploreSitesCategory(-1 /* category_id */, CategoryType.SHOPPING, category = ExploreSitesCategory.createPlaceholder(CategoryType.SHOPPING,
getContext().getString(R.string.explore_sites_default_category_shopping)); getContext().getString(R.string.explore_sites_default_category_shopping));
category.setDrawable(getVectorDrawable(R.drawable.ic_shopping_basket_blue_24dp)); category.setDrawable(getVectorDrawable(R.drawable.ic_shopping_basket_blue_24dp));
categoryList.add(category); categoryList.add(category);
// Sport category. // Sport category.
category = new ExploreSitesCategory(-1 /* category_id */, CategoryType.SPORT, category = ExploreSitesCategory.createPlaceholder(CategoryType.SPORT,
getContext().getString(R.string.explore_sites_default_category_sports)); getContext().getString(R.string.explore_sites_default_category_sports));
category.setDrawable(getVectorDrawable(R.drawable.ic_directions_run_blue_24dp)); category.setDrawable(getVectorDrawable(R.drawable.ic_directions_run_blue_24dp));
categoryList.add(category); categoryList.add(category);
...@@ -98,8 +97,8 @@ public class ExploreSitesSection { ...@@ -98,8 +97,8 @@ public class ExploreSitesSection {
} }
private ExploreSitesCategory createMoreTileCategory() { private ExploreSitesCategory createMoreTileCategory() {
ExploreSitesCategory category = new ExploreSitesCategory(-1 /* category_id */, ExploreSitesCategory category = ExploreSitesCategory.createPlaceholder(
ExploreSitesCategory.MORE_BUTTON_ID, getContext().getString(R.string.more)); CategoryType.MORE_BUTTON, getContext().getString(R.string.more));
category.setDrawable(getVectorDrawable(R.drawable.ic_arrow_forward_blue_24dp)); category.setDrawable(getVectorDrawable(R.drawable.ic_arrow_forward_blue_24dp));
return category; return category;
} }
...@@ -147,8 +146,7 @@ public class ExploreSitesSection { ...@@ -147,8 +146,7 @@ public class ExploreSitesSection {
ExploreSitesCategoryTileView v = ExploreSitesCategoryTileView v =
(ExploreSitesCategoryTileView) mExploreSection.getChildAt(i); (ExploreSitesCategoryTileView) mExploreSection.getChildAt(i);
ExploreSitesCategory category = v.getCategory(); ExploreSitesCategory category = v.getCategory();
if (category == null || category.getType() == ExploreSitesCategory.MORE_BUTTON_ID) if (category == null || category.isMoreButton()) continue;
continue;
viewTypes.put(category.getType(), v); viewTypes.put(category.getType(), v);
} }
......
...@@ -648,7 +648,6 @@ chrome_java_sources = [ ...@@ -648,7 +648,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTileView.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesCategoryTileView.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesEnums.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesEnums.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPage.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesPageLayout.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSection.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSection.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSite.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesSite.java",
"java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesTileView.java", "java/src/org/chromium/chrome/browser/explore_sites/ExploreSitesTileView.java",
......
...@@ -52,10 +52,12 @@ public class ExploreSitesPageTest { ...@@ -52,10 +52,12 @@ public class ExploreSitesPageTest {
ArrayList<ExploreSitesCategory> getTestingCatalog() { ArrayList<ExploreSitesCategory> getTestingCatalog() {
final ArrayList<ExploreSitesCategory> categoryList = new ArrayList<>(); final ArrayList<ExploreSitesCategory> categoryList = new ArrayList<>();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 5; i++) {
ExploreSitesCategory category = ExploreSitesCategory category =
new ExploreSitesCategory(i, i, "Category #" + Integer.toString(i)); new ExploreSitesCategory(i, i, "Category #" + Integer.toString(i));
for (int j = 0; j < 8; j++) { // 0th category would be filtered out. Tests that row maximums are obeyed.
int numSites = 4 * i + 1;
for (int j = 0; j < numSites; j++) {
ExploreSitesSite site = new ExploreSitesSite( ExploreSitesSite site = new ExploreSitesSite(
i * 8 + j, "Site #" + Integer.toString(j), "https://example.com/", false); i * 8 + j, "Site #" + Integer.toString(j), "https://example.com/", false);
category.addSite(site); category.addSite(site);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment