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" |
11 #import "ios/web/web_state/web_state_impl.h" | 11 #import "ios/web/web_state/web_state_impl.h" |
12 #include "ui/base/page_transition_types.h" | 12 #include "ui/base/page_transition_types.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class NativeAppNavigationUtilsTest : public web::WebTest { | 17 class NativeAppNavigationUtilsTest : public web::WebTest { |
18 protected: | 18 protected: |
19 void SetUp() override { | 19 void SetUp() override { |
20 web::WebTest::SetUp(); | 20 web::WebTest::SetUp(); |
21 // WebStateImpl object is needed here to have access to CRWSessionController | 21 // WebStateImpl object is needed here to have access to CRWSessionController |
22 // for setting up NavigationManager entries. | 22 // for setting up NavigationManager entries. |
23 std::unique_ptr<web::WebStateImpl> web_state( | 23 std::unique_ptr<web::WebStateImpl> web_state( |
24 new web::WebStateImpl(GetBrowserState())); | 24 new web::WebStateImpl(GetBrowserState())); |
25 web_state->GetNavigationManagerImpl().InitializeSession(nil, NO); | 25 web_state->GetNavigationManagerImpl().InitializeSession(NO); |
26 web_state->SetWebUsageEnabled(true); | 26 web_state->SetWebUsageEnabled(true); |
27 web_state_.reset(web_state.release()); | 27 web_state_.reset(web_state.release()); |
28 } | 28 } |
29 | 29 |
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(); } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // 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. |
92 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { | 92 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { |
93 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); | 93 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); |
94 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_SERVER_REDIRECT); | 94 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_SERVER_REDIRECT); |
95 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); | 95 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); |
96 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); | 96 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); |
97 } | 97 } |
98 | 98 |
99 } // namespace | 99 } // namespace |
OLD | NEW |