Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "content/browser/child_process_security_policy_impl.h" | 6 #include "content/browser/child_process_security_policy_impl.h" |
| 7 #include "content/browser/renderer_host/test_render_view_host.h" | 7 #include "content/browser/renderer_host/test_render_view_host.h" |
| 8 #include "content/browser/web_contents/navigation_controller_impl.h" | 8 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 9 #include "content/browser/web_contents/test_web_contents.h" | 9 #include "content/browser/web_contents/test_web_contents.h" |
| 10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| 11 #include "content/port/browser/render_view_host_delegate_view.h" | 11 #include "content/port/browser/render_view_host_delegate_view.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/common/bindings_policy.h" | 13 #include "content/public/common/bindings_policy.h" |
| 14 #include "content/public/common/page_transition_types.h" | 14 #include "content/public/common/page_transition_types.h" |
| 15 #include "content/public/common/url_constants.h" | |
| 15 #include "content/public/test/mock_render_process_host.h" | 16 #include "content/public/test/mock_render_process_host.h" |
| 17 #include "content/test/test_content_browser_client.h" | |
| 16 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
| 18 #include "webkit/glue/webdropdata.h" | 20 #include "webkit/glue/webdropdata.h" |
| 19 | 21 |
| 20 namespace content { | 22 namespace content { |
| 21 | 23 |
| 24 class RenderViewHostTestBrowserClient : public TestContentBrowserClient { | |
| 25 public: | |
| 26 RenderViewHostTestBrowserClient() {} | |
| 27 virtual ~RenderViewHostTestBrowserClient() {} | |
| 28 | |
| 29 virtual bool IsHandledURL(const GURL& url) OVERRIDE { | |
| 30 return url.scheme() == chrome::kFileScheme; | |
| 31 } | |
| 32 | |
| 33 private: | |
| 34 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestBrowserClient); | |
| 35 }; | |
| 36 | |
| 22 class RenderViewHostTest : public RenderViewHostImplTestHarness { | 37 class RenderViewHostTest : public RenderViewHostImplTestHarness { |
| 38 public: | |
| 39 RenderViewHostTest() : old_browser_client_(NULL) {} | |
| 40 virtual ~RenderViewHostTest() {} | |
| 41 | |
| 42 virtual void SetUp() OVERRIDE { | |
| 43 RenderViewHostImplTestHarness::SetUp(); | |
| 44 old_browser_client_ = GetContentClient()->browser(); | |
| 45 GetContentClient()->set_browser_for_testing(&test_browser_client_); | |
| 46 } | |
| 47 | |
| 48 virtual void TearDown() OVERRIDE { | |
| 49 RenderViewHostImplTestHarness::TearDown(); | |
| 50 GetContentClient()->set_browser_for_testing(old_browser_client_); | |
|
mmenke
2013/02/19 17:26:15
This should be first, so cleanup order is the reve
pauljensen
2013/02/20 15:13:27
Done.
| |
| 51 } | |
| 52 | |
| 53 private: | |
| 54 RenderViewHostTestBrowserClient test_browser_client_; | |
| 55 ContentBrowserClient* old_browser_client_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTest); | |
| 23 }; | 58 }; |
| 24 | 59 |
| 25 // All about URLs reported by the renderer should get rewritten to about:blank. | 60 // All about URLs reported by the renderer should get rewritten to about:blank. |
| 26 // See RenderViewHost::OnNavigate for a discussion. | 61 // See RenderViewHost::OnNavigate for a discussion. |
| 27 TEST_F(RenderViewHostTest, FilterAbout) { | 62 TEST_F(RenderViewHostTest, FilterAbout) { |
| 28 test_rvh()->SendNavigate(1, GURL("about:cache")); | 63 test_rvh()->SendNavigate(1, GURL("about:cache")); |
| 29 ASSERT_TRUE(controller().GetActiveEntry()); | 64 ASSERT_TRUE(controller().GetActiveEntry()); |
| 30 EXPECT_EQ(GURL("about:blank"), controller().GetActiveEntry()->GetURL()); | 65 EXPECT_EQ(GURL("about:blank"), controller().GetActiveEntry()->GetURL()); |
| 31 } | 66 } |
| 32 | 67 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 // OnInputEventAck() processing. | 255 // OnInputEventAck() processing. |
| 221 IPC::Message message(0, ViewHostMsg_HandleInputEvent_ACK::ID, | 256 IPC::Message message(0, ViewHostMsg_HandleInputEvent_ACK::ID, |
| 222 IPC::Message::PRIORITY_NORMAL); | 257 IPC::Message::PRIORITY_NORMAL); |
| 223 test_rvh()->OnMessageReceived(message); | 258 test_rvh()->OnMessageReceived(message); |
| 224 EXPECT_EQ(1, process()->bad_msg_count()); | 259 EXPECT_EQ(1, process()->bad_msg_count()); |
| 225 } | 260 } |
| 226 | 261 |
| 227 #endif | 262 #endif |
| 228 | 263 |
| 229 } // namespace content | 264 } // namespace content |
| OLD | NEW |