Chromium Code Reviews| 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); |
| + } |
| + } |
| +} |