| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "content/browser/frame_host/navigation_handle_impl.h" | 6 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 7 #include "content/browser/frame_host/navigator_impl.h" |
| 7 #include "content/public/browser/navigation_throttle.h" | 8 #include "content/public/browser/navigation_throttle.h" |
| 8 #include "content/test/test_render_frame_host.h" | 9 #include "content/test/test_render_frame_host.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 // Test version of a NavigationThrottle. It will always return the current | 13 // Test version of a NavigationThrottle. It will always return the current |
| 13 // NavigationThrottle::ThrottleCheckResult |result_|, It also monitors the | 14 // NavigationThrottle::ThrottleCheckResult |result_|, It also monitors the |
| 14 // number of times WillStartRequest, WillRedirectRequest, and | 15 // number of times WillStartRequest, WillRedirectRequest, and |
| 15 // WillProcessResponse were called. | 16 // WillProcessResponse were called. |
| 16 class TestNavigationThrottle : public NavigationThrottle { | 17 class TestNavigationThrottle : public NavigationThrottle { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 class NavigationHandleImplTest : public RenderViewHostImplTestHarness { | 60 class NavigationHandleImplTest : public RenderViewHostImplTestHarness { |
| 60 public: | 61 public: |
| 61 NavigationHandleImplTest() | 62 NavigationHandleImplTest() |
| 62 : was_callback_called_(false), | 63 : was_callback_called_(false), |
| 63 callback_result_(NavigationThrottle::DEFER) {} | 64 callback_result_(NavigationThrottle::DEFER) {} |
| 64 | 65 |
| 65 void SetUp() override { | 66 void SetUp() override { |
| 66 RenderViewHostImplTestHarness::SetUp(); | 67 RenderViewHostImplTestHarness::SetUp(); |
| 67 test_handle_ = NavigationHandleImpl::Create( | 68 test_handle_ = |
| 68 GURL(), main_test_rfh()->frame_tree_node(), base::TimeTicks::Now()); | 69 NavigationHandleImpl::Create(GURL(), main_test_rfh()->frame_tree_node(), |
| 70 base::TimeTicks::Now(), nullptr); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void TearDown() override { | 73 void TearDown() override { |
| 72 // Release the |test_handle_| before destroying the WebContents, to match | 74 // Release the |test_handle_| before destroying the WebContents, to match |
| 73 // the WebContentsObserverSanityChecker expectations. | 75 // the WebContentsObserverSanityChecker expectations. |
| 74 test_handle_.reset(); | 76 test_handle_.reset(); |
| 75 RenderViewHostImplTestHarness::TearDown(); | 77 RenderViewHostImplTestHarness::TearDown(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool IsDeferringStart() { | 80 bool IsDeferringStart() { |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); | 640 EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| 639 EXPECT_EQ(0, cancel_throttle->will_start_calls()); | 641 EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| 640 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); | 642 EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| 641 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); | 643 EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
| 642 EXPECT_EQ(0, proceed_throttle->will_start_calls()); | 644 EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| 643 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); | 645 EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| 644 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); | 646 EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| 645 } | 647 } |
| 646 | 648 |
| 647 } // namespace content | 649 } // namespace content |
| OLD | NEW |