Chromium Code Reviews| Index: content/browser/frame_host/navigation_handle_impl_unittest.cc |
| diff --git a/content/browser/frame_host/navigation_handle_impl_unittest.cc b/content/browser/frame_host/navigation_handle_impl_unittest.cc |
| index 7776eacaeb3c59c4ac703d139894607b1471957b..550f000cbc8db7b2122d7d02ab17db902aad0594 100644 |
| --- a/content/browser/frame_host/navigation_handle_impl_unittest.cc |
| +++ b/content/browser/frame_host/navigation_handle_impl_unittest.cc |
| @@ -1,16 +1,20 @@ |
| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <memory> |
| + |
| #include "base/macros.h" |
| +#include "base/memory/ptr_util.h" |
| #include "content/browser/frame_host/navigation_handle_impl.h" |
| +#include "content/public/browser/navigation_data.h" |
| #include "content/public/browser/navigation_throttle.h" |
| #include "content/test/test_render_frame_host.h" |
| namespace content { |
| // Test version of a NavigationThrottle. It will always return the current |
| // NavigationThrottle::ThrottleCheckResult |result_|, It also monitors the |
| // number of times WillStartRequest, WillRedirectRequest, and |
| // WillProcessResponse were called. |
| class TestNavigationThrottle : public NavigationThrottle { |
| @@ -49,20 +53,29 @@ class TestNavigationThrottle : public NavigationThrottle { |
| private: |
| // The result returned by the TestNavigationThrottle. |
| NavigationThrottle::ThrottleCheckResult result_; |
| // The number of times each handler was called. |
| int will_start_calls_; |
| int will_redirect_calls_; |
| int will_process_response_calls_; |
| }; |
| +class TestNavigationData : public NavigationData { |
| + public: |
| + TestNavigationData() {} |
| + ~TestNavigationData() override {} |
| + std::unique_ptr<NavigationData> Clone() const override { |
| + return base::WrapUnique(new TestNavigationData()); |
| + } |
| +}; |
| + |
| class NavigationHandleImplTest : public RenderViewHostImplTestHarness { |
| public: |
| NavigationHandleImplTest() |
| : was_callback_called_(false), |
| callback_result_(NavigationThrottle::DEFER) {} |
| void SetUp() override { |
| RenderViewHostImplTestHarness::SetUp(); |
| test_handle_ = |
| NavigationHandleImpl::Create(GURL(), main_test_rfh()->frame_tree_node(), |
| @@ -638,11 +651,17 @@ TEST_F(NavigationHandleImplTest, CancelThenProceedWillProcessResponse) { |
| EXPECT_TRUE(was_callback_called()); |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| } |
| +TEST_F(NavigationHandleImplTest, NavigationData) { |
| + TestNavigationData* test_data = new TestNavigationData(); |
| + test_handle()->SetNavigationData(base::WrapUnique(test_data)); |
| + EXPECT_EQ(test_data, test_handle()->GetNavigationData()); |
|
nasko
2016/05/02 22:02:49
This test case doesn't test much, what's the goal
RyanSturm
2016/05/02 23:02:56
I like to unittest everything individually, but th
|
| +} |
| + |
| } // namespace content |