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

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

Issue 2670863004: 🏠 Add instrumentation test for Suggestions BottomSheet (Closed)
Patch Set: Wait for recyclerview to stabilise and check view type Created 3 years, 10 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/ContentSuggestionsJUnitTestUtils.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsJUnitTestUtils.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsJUnitTestUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..4787f02afbc3bd75c76eb02eeaddb7e9fc677cb3
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/ContentSuggestionsJUnitTestUtils.java
@@ -0,0 +1,45 @@
+// Copyright 2017 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 static org.mockito.Mockito.mock;
+
+import org.chromium.chrome.browser.ntp.snippets.CategoryInt;
+import org.chromium.chrome.browser.ntp.snippets.SectionHeaderViewHolder;
+import org.chromium.chrome.browser.ntp.snippets.SnippetArticleViewHolder;
+import org.chromium.chrome.test.util.browser.suggestions.ContentSuggestionsTestUtils;
+
+/**
+ * JUnit specific utility classes for testing suggestions code. Other utility code is in
+ * {@link ContentSuggestionsTestUtils}
Michael van Ouwerkerk 2017/02/07 11:12:41 nit: close with a period.
dgn 2017/02/13 14:25:39 Done.
+ */
+public class ContentSuggestionsJUnitTestUtils {
Michael van Ouwerkerk 2017/02/07 11:12:41 nit: Please make this static util class final and
dgn 2017/02/13 14:25:39 Done.
+ public static void bindViewHolders(InnerNode node) {
+ bindViewHolders(node, 0, node.getItemCount());
+ }
+
+ public static void bindViewHolders(InnerNode node, int startIndex, int endIndex) {
+ for (int i = startIndex; i < endIndex; ++i) {
+ node.onBindViewHolder(makeViewHolder(node.getItemViewType(i)), i);
+ }
+ }
+
+ private static NewTabPageViewHolder makeViewHolder(@CategoryInt int viewType) {
+ switch (viewType) {
+ case ItemViewType.SNIPPET:
+ return mock(SnippetArticleViewHolder.class);
+ case ItemViewType.HEADER:
+ return mock(SectionHeaderViewHolder.class);
+ case ItemViewType.STATUS:
+ return mock(StatusCardViewHolder.class);
+ case ItemViewType.ACTION:
+ return mock(ActionItem.ViewHolder.class);
+ case ItemViewType.PROGRESS:
+ return mock(ProgressViewHolder.class);
+ default:
+ return mock(NewTabPageViewHolder.class);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698