OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ios/chrome/browser/native_app_launcher/native_app_navigation_util.h" | 5 #include "ios/chrome/browser/native_app_launcher/native_app_navigation_util.h" |
6 | 6 |
7 #import "ios/web/navigation/crw_session_controller.h" | 7 #import "ios/web/navigation/crw_session_controller.h" |
8 #import "ios/web/navigation/navigation_manager_impl.h" | 8 #import "ios/web/navigation/navigation_manager_impl.h" |
9 #include "ios/web/public/referrer.h" | 9 #include "ios/web/public/referrer.h" |
10 #include "ios/web/public/test/web_test.h" | 10 #include "ios/web/public/test/web_test.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 void TearDown() override { | 30 void TearDown() override { |
31 web_state_.reset(); | 31 web_state_.reset(); |
32 web::WebTest::TearDown(); | 32 web::WebTest::TearDown(); |
33 } | 33 } |
34 | 34 |
35 web::WebState* web_state() { return web_state_->GetWebState(); } | 35 web::WebState* web_state() { return web_state_->GetWebState(); } |
36 | 36 |
37 void AddItem(const std::string& url_spec, ui::PageTransition transition) { | 37 void AddItem(const std::string& url_spec, ui::PageTransition transition) { |
38 CRWSessionController* session_controller = | 38 CRWSessionController* session_controller = |
39 web_state_->GetNavigationManagerImpl().GetSessionController(); | 39 web_state_->GetNavigationManagerImpl().GetSessionController(); |
40 [session_controller addPendingEntry:GURL(url_spec) | 40 [session_controller addPendingItem:GURL(url_spec) |
41 referrer:web::Referrer() | 41 referrer:web::Referrer() |
42 transition:transition | 42 transition:transition |
43 rendererInitiated:NO]; | 43 rendererInitiated:NO]; |
44 [session_controller commitPendingEntry]; | 44 [session_controller commitPendingItem]; |
45 } | 45 } |
46 | 46 |
47 private: | 47 private: |
48 std::unique_ptr<web::WebStateImpl> web_state_; | 48 std::unique_ptr<web::WebStateImpl> web_state_; |
49 }; | 49 }; |
50 | 50 |
51 // Tests that default state is not a link click. | 51 // Tests that default state is not a link click. |
52 TEST_F(NativeAppNavigationUtilsTest, TestEmpty) { | 52 TEST_F(NativeAppNavigationUtilsTest, TestEmpty) { |
53 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); | 53 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); |
54 } | 54 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // The first non-redirect entry is tested. Earlier redirects do not matter. | 92 // The first non-redirect entry is tested. Earlier redirects do not matter. |
93 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { | 93 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { |
94 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); | 94 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); |
95 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_SERVER_REDIRECT); | 95 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_SERVER_REDIRECT); |
96 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); | 96 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); |
97 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); | 97 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
OLD | NEW |