| Index: chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfoTest.java
|
| diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfoTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfoTest.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1c68a52e22ee1fb41b691d719af80e630d3bb485
|
| --- /dev/null
|
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/ntp/cards/SuggestionsCategoryInfoTest.java
|
| @@ -0,0 +1,79 @@
|
| +// 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.hamcrest.CoreMatchers.is;
|
| +import static org.hamcrest.CoreMatchers.nullValue;
|
| +import static org.junit.Assert.assertThat;
|
| +
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +import org.robolectric.annotation.Config;
|
| +
|
| +import org.chromium.chrome.browser.ntp.ContextMenuManager;
|
| +import org.chromium.chrome.browser.ntp.cards.ContentSuggestionsTestUtils.CategoryInfoBuilder;
|
| +import org.chromium.chrome.browser.ntp.snippets.KnownCategories;
|
| +import org.chromium.testing.local.LocalRobolectricTestRunner;
|
| +
|
| +/**
|
| + * Unit tests for {@link SuggestionsCategoryInfo}.
|
| + */
|
| +@RunWith(LocalRobolectricTestRunner.class)
|
| +@Config(manifest = Config.NONE)
|
| +public class SuggestionsCategoryInfoTest {
|
| + @Test
|
| + public void testDownloadContextMenu() {
|
| + SuggestionsCategoryInfo categoryInfo =
|
| + new CategoryInfoBuilder(KnownCategories.DOWNLOADS).build();
|
| + assertThat(
|
| + categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_OPEN_IN_NEW_WINDOW),
|
| + is(true));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_OPEN_IN_NEW_TAB),
|
| + is(true));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(
|
| + ContextMenuManager.ID_OPEN_IN_INCOGNITO_TAB),
|
| + is(false));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_SAVE_FOR_OFFLINE),
|
| + is(false));
|
| + assertThat(
|
| + categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_REMOVE), nullValue());
|
| + }
|
| +
|
| + @Test
|
| + public void testRecentTabContextMenu() {
|
| + SuggestionsCategoryInfo categoryInfo =
|
| + new CategoryInfoBuilder(KnownCategories.RECENT_TABS).build();
|
| + assertThat(
|
| + categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_OPEN_IN_NEW_WINDOW),
|
| + is(false));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_OPEN_IN_NEW_TAB),
|
| + is(false));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(
|
| + ContextMenuManager.ID_OPEN_IN_INCOGNITO_TAB),
|
| + is(false));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_SAVE_FOR_OFFLINE),
|
| + is(false));
|
| + assertThat(
|
| + categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_REMOVE), nullValue());
|
| + }
|
| +
|
| + @Test
|
| + public void testArticleContextMenu() {
|
| + SuggestionsCategoryInfo categoryInfo =
|
| + new CategoryInfoBuilder(KnownCategories.ARTICLES).build();
|
| + assertThat(
|
| + categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_OPEN_IN_NEW_WINDOW),
|
| + is(true));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_OPEN_IN_NEW_TAB),
|
| + is(true));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(
|
| + ContextMenuManager.ID_OPEN_IN_INCOGNITO_TAB),
|
| + is(true));
|
| + assertThat(categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_SAVE_FOR_OFFLINE),
|
| + is(true));
|
| + assertThat(
|
| + categoryInfo.isContextMenuItemSupported(ContextMenuManager.ID_REMOVE), nullValue());
|
| + }
|
| +}
|
|
|