| 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 addPendingItem:GURL(url_spec) | 40 web_state_->GetNavigationManagerImpl().AddPendingItem( |
| 41 referrer:web::Referrer() | 41 GURL(url_spec), web::Referrer(), transition, |
| 42 transition:transition | 42 web::NavigationInitiationType::USER_INITIATED); |
| 43 rendererInitiated:NO]; | |
| 44 [session_controller commitPendingItem]; | 43 [session_controller commitPendingItem]; |
| 45 } | 44 } |
| 46 | 45 |
| 47 private: | 46 private: |
| 48 std::unique_ptr<web::WebStateImpl> web_state_; | 47 std::unique_ptr<web::WebStateImpl> web_state_; |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 // Tests that default state is not a link click. | 50 // Tests that default state is not a link click. |
| 52 TEST_F(NativeAppNavigationUtilsTest, TestEmpty) { | 51 TEST_F(NativeAppNavigationUtilsTest, TestEmpty) { |
| 53 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); | 52 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 90 |
| 92 // The first non-redirect entry is tested. Earlier redirects do not matter. | 91 // The first non-redirect entry is tested. Earlier redirects do not matter. |
| 93 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { | 92 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { |
| 94 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); | 93 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); |
| 95 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_SERVER_REDIRECT); | 94 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_SERVER_REDIRECT); |
| 96 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); | 95 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); |
| 97 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); | 96 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); |
| 98 } | 97 } |
| 99 | 98 |
| 100 } // namespace | 99 } // namespace |
| OLD | NEW |