Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2183)

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java

Issue 2582793002: 📰 Make NewTabPageAdapterTest failures more explicit (Closed)
Patch Set: address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java
index 4dc63a2670fd85051f29cdc3498ee92ca5828deb..476100c8f8f19d8b3b168369207c41e9b06fc56d 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java
@@ -5,8 +5,10 @@
package org.chromium.chrome.browser.ntp.cards;
import org.chromium.chrome.browser.ntp.snippets.CategoryInt;
+import org.chromium.chrome.browser.ntp.snippets.CategoryStatus;
import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsCardLayout;
import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsCardLayout.ContentSuggestionsCardLayoutEnum;
+import org.chromium.chrome.browser.ntp.snippets.FakeSuggestionsSource;
import org.chromium.chrome.browser.ntp.snippets.KnownCategories;
import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
@@ -27,6 +29,45 @@ private ContentSuggestionsTestUtils() {}
return suggestions;
}
+ /** Registers a category that has a reload action and is shown if empty. */
+ public static void registerCategory(FakeSuggestionsSource suggestionsSource,
+ @CategoryInt int category, int suggestionCount) {
+ // FakeSuggestionSource does not provide suggestions if the category's status is not
+ // AVAILABLE.
+ suggestionsSource.setStatusForCategory(category, CategoryStatus.AVAILABLE);
+ // Important: showIfEmpty flag to true.
+ suggestionsSource.setInfoForCategory(category,
+ new CategoryInfoBuilder(category).withReloadAction().showIfEmpty().build());
+ suggestionsSource.setSuggestionsForCategory(
+ category, createDummySuggestions(suggestionCount));
+ }
+
+ public static String viewTypeToString(@ItemViewType int viewType) {
+ switch (viewType) {
+ case ItemViewType.ABOVE_THE_FOLD:
+ return "ABOVE_THE_FOLD";
+ case ItemViewType.HEADER:
+ return "HEADER";
+ case ItemViewType.SNIPPET:
+ return "SNIPPET";
+ case ItemViewType.SPACING:
+ return "SPACING";
+ case ItemViewType.STATUS:
+ return "STATUS";
+ case ItemViewType.PROGRESS:
+ return "PROGRESS";
+ case ItemViewType.ACTION:
+ return "ACTION";
+ case ItemViewType.FOOTER:
+ return "FOOTER";
+ case ItemViewType.PROMO:
+ return "PROMO";
+ case ItemViewType.ALL_DISMISSED:
+ return "ALL_DISMISSED";
+ }
+ throw new AssertionError();
+ }
+
/**
* Uses the builder pattern to simplify constructing category info objects for tests.
*/
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapterTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698