summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryusukes <yusukes@chromium.org>2016-09-21 04:49:38 (GMT)
committerCommit bot <commit-bot@chromium.org>2016-09-21 04:51:26 (GMT)
commit1e98dc42d3ef1dfb35de77b10ecdbad1e0347130 (patch)
tree1cb0dd5ab908377bdd0cda9bbefc254e7e35dd59
parent7f747dc36f42f789a92e122cf0f7d1e5d6eeaee0 (diff)
downloadchromium-1e98dc42d3ef1dfb35de77b10ecdbad1e0347130.tar.gz
chromium-1e98dc42d3ef1dfb35de77b10ecdbad1e0347130.tar.xz
Add page_transition_util_unittest.cc
BUG=None TEST=try Review-Url: https://codereview.chromium.org/2356953003 Cr-Commit-Position: refs/heads/master@{#419975}
-rw-r--r--chrome/browser/chromeos/BUILD.gn1
-rw-r--r--chrome/browser/chromeos/arc/page_transition_util_unittest.cc69
2 files changed, 70 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn
index 5d676c7..16650f0 100644
--- a/chrome/browser/chromeos/BUILD.gn
+++ b/chrome/browser/chromeos/BUILD.gn
@@ -1353,6 +1353,7 @@ source_set("unit_tests") {
"arc/arc_auth_service_unittest.cc",
"arc/arc_navigation_throttle_unittest.cc",
"arc/arc_policy_bridge_unittest.cc",
+ "arc/page_transition_util_unittest.cc",
"attestation/attestation_ca_client_unittest.cc",
"attestation/attestation_policy_observer_unittest.cc",
"attestation/fake_certificate.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 0000000..3abc4af
--- /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