Chromium Code Reviews| 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..6ac05aa9d1360dec0e2397b600eaa002b8eb68d2 |
| --- /dev/null |
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsTestUtils.java |
| @@ -0,0 +1,35 @@ |
| +// 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 class ContentSuggestionsTestUtils { |
|
Michael van Ouwerkerk
2016/09/28 09:36:23
This is a static utility class: make it final and
dgn
2016/09/28 21:31:19
Done.
|
| + 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); |
| + } |
| +} |