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

Unified Diff: chrome/browser/chromeos/arc/page_transition_util_unittest.cc

Issue 2356953003: Add page_transition_util_unittest.cc (Closed)
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « chrome/browser/chromeos/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/page_transition_util_unittest.cc
diff --git a/chrome/browser/chromeos/arc/page_transition_util_unittest.cc b/chrome/browser/chromeos/arc/page_transition_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3abc4af3c6825f81fc8cb965effeb953da1849ad
--- /dev/null
+++ b/chrome/browser/chromeos/arc/page_transition_util_unittest.cc
@@ -0,0 +1,69 @@
+// 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.
+
+#include "chrome/browser/chromeos/arc/page_transition_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/page_transition_types.h"
+
+namespace arc {
+
+// Tests that ShouldIgnoreNavigation returns false only for
+// PAGE_TRANSITION_LINK.
+TEST(PageTransitionUtilTest, TestShouldIgnoreNavigationWithCoreTypes) {
+ EXPECT_FALSE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_LINK));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_TYPED));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_AUTO_BOOKMARK));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_AUTO_SUBFRAME));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_GENERATED));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_AUTO_TOPLEVEL));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_FORM_SUBMIT));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_RELOAD));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD_GENERATED));
+
+ static_assert(
+ ui::PAGE_TRANSITION_KEYWORD_GENERATED == ui::PAGE_TRANSITION_LAST_CORE,
+ "Not all core transition types are covered here");
+}
+
+// Tests that ShouldIgnoreNavigation returns true when no qualifiers are
+// provided.
+TEST(PageTransitionUtilTest, TestShouldIgnoreNavigationWithLinkWithQualifiers) {
+ // The navigation is triggered by Forward or Back button.
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FORWARD_BACK)));
+ // The user used the address bar to triger the navigation.
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
+ // The user pressed the Home button.
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_HOME_PAGE)));
+ // ARC (for example) opened the link in Chrome.
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FROM_API)));
+
+ // Also tests the case with 2+ qualifiers.
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR |
+ ui::PAGE_TRANSITION_CLIENT_REDIRECT)));
+}
+
+// Just in case, does the same with ui::PAGE_TRANSITION_TYPED.
+TEST(PageTransitionUtilTest,
+ TestShouldIgnoreNavigationWithTypedWithQualifiers) {
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FORWARD_BACK)));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_HOME_PAGE)));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API)));
+ EXPECT_TRUE(ShouldIgnoreNavigation(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR |
+ ui::PAGE_TRANSITION_CLIENT_REDIRECT)));
+}
+
+} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698