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 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #import "ios/web/public/test/fakes/test_navigation_manager.h" | 8 #import "ios/web/public/test/fakes/test_navigation_manager.h" |
9 #import "ios/web/public/test/fakes/test_web_state.h" | 9 #import "ios/web/public/test/fakes/test_web_state.h" |
10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
11 #include "ui/base/page_transition_types.h" | 11 #include "ui/base/page_transition_types.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." |
| 16 #endif |
| 17 |
14 // Tests the implementation of IsLinkNavigation(). The function being tested | 18 // Tests the implementation of IsLinkNavigation(). The function being tested |
15 // uses public NavigationManager interfaces and can be tested by using | 19 // uses public NavigationManager interfaces and can be tested by using |
16 // TestNavigationManager that implements the same interface. | 20 // TestNavigationManager that implements the same interface. |
17 class NativeAppNavigationUtilsTest : public PlatformTest { | 21 class NativeAppNavigationUtilsTest : public PlatformTest { |
18 protected: | 22 protected: |
19 void SetUp() override { | 23 void SetUp() override { |
20 PlatformTest::SetUp(); | 24 PlatformTest::SetUp(); |
21 std::unique_ptr<web::TestNavigationManager> test_navigation_manager = | 25 std::unique_ptr<web::TestNavigationManager> test_navigation_manager = |
22 base::MakeUnique<web::TestNavigationManager>(); | 26 base::MakeUnique<web::TestNavigationManager>(); |
23 test_navigation_manager_ = test_navigation_manager.get(); | 27 test_navigation_manager_ = test_navigation_manager.get(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 EXPECT_TRUE(native_app_launcher::IsLinkNavigation(web_state())); | 81 EXPECT_TRUE(native_app_launcher::IsLinkNavigation(web_state())); |
78 } | 82 } |
79 | 83 |
80 // The first non-redirect entry is tested. Earlier redirects do not matter. | 84 // The first non-redirect entry is tested. Earlier redirects do not matter. |
81 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { | 85 TEST_F(NativeAppNavigationUtilsTest, TestTypedUrlWithRedirectEarlier) { |
82 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); | 86 AddItem("http://foo.com/page0", ui::PAGE_TRANSITION_LINK); |
83 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 87 AddItem("http://bar.com/page1", ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
84 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); | 88 AddItem("http://blah.com/page2", ui::PAGE_TRANSITION_TYPED); |
85 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); | 89 EXPECT_FALSE(native_app_launcher::IsLinkNavigation(web_state())); |
86 } | 90 } |
OLD | NEW |