OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/arc/intent_helper/page_transition_util.h" | 5 #include "components/arc/intent_helper/page_transition_util.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "ui/base/page_transition_types.h" | 7 #include "ui/base/page_transition_types.h" |
8 | 8 |
9 namespace arc { | 9 namespace arc { |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_RELOAD, false, false)); | 42 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_RELOAD, false, false)); |
43 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_RELOAD, true, true)); | 43 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_RELOAD, true, true)); |
44 EXPECT_TRUE( | 44 EXPECT_TRUE( |
45 ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD, false, false)); | 45 ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD, false, false)); |
46 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD, true, true)); | 46 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD, true, true)); |
47 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD_GENERATED, | 47 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD_GENERATED, |
48 false, false)); | 48 false, false)); |
49 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD_GENERATED, | 49 EXPECT_TRUE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_KEYWORD_GENERATED, |
50 true, true)); | 50 true, true)); |
51 | 51 |
52 static_assert( | 52 static_assert(static_cast<int32_t>(ui::PAGE_TRANSITION_KEYWORD_GENERATED) == |
53 ui::PAGE_TRANSITION_KEYWORD_GENERATED == ui::PAGE_TRANSITION_LAST_CORE, | 53 static_cast<int32_t>(ui::PAGE_TRANSITION_LAST_CORE), |
54 "Not all core transition types are covered here"); | 54 "Not all core transition types are covered here"); |
55 } | 55 } |
56 | 56 |
57 // Tests that ShouldIgnoreNavigation returns true when no qualifiers except | 57 // Tests that ShouldIgnoreNavigation returns true when no qualifiers except |
58 // server redirect are provided. | 58 // server redirect are provided. |
59 TEST(PageTransitionUtilTest, TestShouldIgnoreNavigationWithLinkWithQualifiers) { | 59 TEST(PageTransitionUtilTest, TestShouldIgnoreNavigationWithLinkWithQualifiers) { |
60 // The navigation is triggered by Forward or Back button. | 60 // The navigation is triggered by Forward or Back button. |
61 EXPECT_TRUE(ShouldIgnoreNavigation( | 61 EXPECT_TRUE(ShouldIgnoreNavigation( |
62 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | | 62 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | |
63 ui::PAGE_TRANSITION_FORWARD_BACK), | 63 ui::PAGE_TRANSITION_FORWARD_BACK), |
64 false, false)); | 64 false, false)); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | | 166 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | |
167 ui::PAGE_TRANSITION_HOME_PAGE), | 167 ui::PAGE_TRANSITION_HOME_PAGE), |
168 true, true)); | 168 true, true)); |
169 } | 169 } |
170 | 170 |
171 // Test that MaskOutPageTransition correctly remove a qualifier from a given | 171 // Test that MaskOutPageTransition correctly remove a qualifier from a given |
172 // |page_transition|. | 172 // |page_transition|. |
173 TEST(PageTransitionUtilTest, TestMaskOutPageTransition) { | 173 TEST(PageTransitionUtilTest, TestMaskOutPageTransition) { |
174 ui::PageTransition page_transition = ui::PageTransitionFromInt( | 174 ui::PageTransition page_transition = ui::PageTransitionFromInt( |
175 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 175 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
176 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, | 176 EXPECT_EQ(static_cast<int>(ui::PAGE_TRANSITION_LINK), |
177 MaskOutPageTransition(page_transition, | 177 static_cast<int>(MaskOutPageTransition( |
178 ui::PAGE_TRANSITION_CLIENT_REDIRECT)); | 178 page_transition, ui::PAGE_TRANSITION_CLIENT_REDIRECT))); |
179 | 179 |
180 page_transition = ui::PageTransitionFromInt( | 180 page_transition = ui::PageTransitionFromInt( |
181 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_SERVER_REDIRECT); | 181 ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_SERVER_REDIRECT); |
182 EXPECT_EQ(ui::PAGE_TRANSITION_LINK, | 182 EXPECT_EQ(static_cast<int>(ui::PAGE_TRANSITION_LINK), |
183 MaskOutPageTransition(page_transition, | 183 static_cast<int>(MaskOutPageTransition( |
184 ui::PAGE_TRANSITION_SERVER_REDIRECT)); | 184 page_transition, ui::PAGE_TRANSITION_SERVER_REDIRECT))); |
185 } | 185 } |
186 | 186 |
187 // Test mixed variants between |allow_form_submit| and |allow_client_redirect|. | 187 // Test mixed variants between |allow_form_submit| and |allow_client_redirect|. |
188 TEST(PageTransitionUtilTest, TestShouldIgnoreNavigationWithNonProdScenarios) { | 188 TEST(PageTransitionUtilTest, TestShouldIgnoreNavigationWithNonProdScenarios) { |
189 EXPECT_FALSE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_LINK, true, false)); | 189 EXPECT_FALSE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_LINK, true, false)); |
190 EXPECT_FALSE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_LINK, false, true)); | 190 EXPECT_FALSE(ShouldIgnoreNavigation(ui::PAGE_TRANSITION_LINK, false, true)); |
191 | 191 |
192 EXPECT_TRUE(ShouldIgnoreNavigation( | 192 EXPECT_TRUE(ShouldIgnoreNavigation( |
193 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | | 193 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK | |
194 ui::PAGE_TRANSITION_CLIENT_REDIRECT), | 194 ui::PAGE_TRANSITION_CLIENT_REDIRECT), |
(...skipping 12 matching lines...) Expand all Loading... |
207 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT | | 207 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT | |
208 ui::PAGE_TRANSITION_CLIENT_REDIRECT), | 208 ui::PAGE_TRANSITION_CLIENT_REDIRECT), |
209 true, false)); | 209 true, false)); |
210 EXPECT_TRUE(ShouldIgnoreNavigation( | 210 EXPECT_TRUE(ShouldIgnoreNavigation( |
211 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT | | 211 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT | |
212 ui::PAGE_TRANSITION_CLIENT_REDIRECT), | 212 ui::PAGE_TRANSITION_CLIENT_REDIRECT), |
213 false, true)); | 213 false, true)); |
214 } | 214 } |
215 | 215 |
216 } // namespace arc | 216 } // namespace arc |
OLD | NEW |