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

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

Issue 2617133002: [Android NTP] Move more of the dismissal logic into the tree. (Closed)
Patch Set: annotation Created 3 years, 11 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/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());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698