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

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

Issue 2360813004: 📰 Stop refreshing the whole NTP for every adapter change (Closed)
Patch Set: rebase again -_- Created 4 years, 3 months 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..24e9d2ebda15fec810b04bf1cad4b1137fe6b39b
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java
@@ -0,0 +1,37 @@
+// Copyright 2016 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.ntp.cards;
+
+import org.chromium.chrome.browser.ntp.snippets.ContentSuggestionsCardLayout;
+import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** Utilities to make testing content suggestions code easier. */
+public final class ContentSuggestionsTestUtils {
+ private ContentSuggestionsTestUtils() {}
+
+ public static List<SnippetArticle> createDummySuggestions(int count) {
+ List<SnippetArticle> suggestions = new ArrayList<>();
+ for (int index = 0; index < count; index++) {
+ suggestions.add(new SnippetArticle(0, "https://site.com/url" + index, "title" + index,
+ "pub" + index, "txt" + index, "https://site.com/url" + index,
+ "https://amp.site.com/url" + index, 0, 0, 0,
+ ContentSuggestionsCardLayout.FULL_CARD));
+ }
+ return suggestions;
+ }
+
+ public static SuggestionsCategoryInfo createInfo(boolean moreButton, boolean showIfEmpty) {
+ return new SuggestionsCategoryInfo(
+ "", ContentSuggestionsCardLayout.FULL_CARD, moreButton, showIfEmpty);
+ }
+
+ public static SuggestionsSection createSection(
+ boolean moreButton, boolean showIfEmpty, ItemGroup.Observer observer) {
+ return new SuggestionsSection(42, createInfo(moreButton, showIfEmpty), observer, null);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698