| 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 "content/public/test/render_view_test.h" | 5 #include "content/public/test/render_view_test.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cctype> | 9 #include <cctype> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 namespace { | 72 namespace { |
| 73 | 73 |
| 74 const int32_t kRouteId = 5; | 74 const int32_t kRouteId = 5; |
| 75 const int32_t kMainFrameRouteId = 6; | 75 const int32_t kMainFrameRouteId = 6; |
| 76 // TODO(avi): Widget routing IDs should be distinct from the view routing IDs, | 76 // TODO(avi): Widget routing IDs should be distinct from the view routing IDs, |
| 77 // once RenderWidgetHost is distilled from RenderViewHostImpl. | 77 // once RenderWidgetHost is distilled from RenderViewHostImpl. |
| 78 // https://crbug.com/545684 | 78 // https://crbug.com/545684 |
| 79 const int32_t kMainFrameWidgetRouteId = 5; | 79 const int32_t kMainFrameWidgetRouteId = 5; |
| 80 const int32_t kNewWindowRouteId = 7; | 80 const int32_t kNewWindowRouteId = 7; |
| 81 const int32_t kNewWindowMainFrameRouteId = 8; |
| 81 const int32_t kNewFrameRouteId = 10; | 82 const int32_t kNewFrameRouteId = 10; |
| 82 const int32_t kNewFrameWidgetRouteId = 7; | 83 const int32_t kNewFrameWidgetRouteId = 7; |
| 83 | 84 |
| 84 // Converts |ascii_character| into |key_code| and returns true on success. | 85 // Converts |ascii_character| into |key_code| and returns true on success. |
| 85 // Handles only the characters needed by tests. | 86 // Handles only the characters needed by tests. |
| 86 bool GetWindowsKeyCode(char ascii_character, int* key_code) { | 87 bool GetWindowsKeyCode(char ascii_character, int* key_code) { |
| 87 if (isalnum(ascii_character)) { | 88 if (isalnum(ascii_character)) { |
| 88 *key_code = base::ToUpperASCII(ascii_character); | 89 *key_code = base::ToUpperASCII(ascii_character); |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 107 } | 108 } |
| 108 } | 109 } |
| 109 | 110 |
| 110 } // namespace | 111 } // namespace |
| 111 | 112 |
| 112 namespace content { | 113 namespace content { |
| 113 | 114 |
| 114 class RendererBlinkPlatformImplTestOverrideImpl | 115 class RendererBlinkPlatformImplTestOverrideImpl |
| 115 : public RendererBlinkPlatformImpl { | 116 : public RendererBlinkPlatformImpl { |
| 116 public: | 117 public: |
| 118 using WebURLLoaderFactory = RenderViewTest:: |
| 119 RendererBlinkPlatformImplTestOverride::WebURLLoaderFactory; |
| 120 |
| 117 RendererBlinkPlatformImplTestOverrideImpl( | 121 RendererBlinkPlatformImplTestOverrideImpl( |
| 118 scheduler::RendererScheduler* scheduler) | 122 scheduler::RendererScheduler* scheduler) |
| 119 : RendererBlinkPlatformImpl(scheduler, nullptr) { | 123 : RendererBlinkPlatformImpl(scheduler, nullptr) { |
| 120 } | 124 } |
| 121 | 125 |
| 122 // Get rid of the dependency to the sandbox, which is not available in | 126 // Get rid of the dependency to the sandbox, which is not available in |
| 123 // RenderViewTest. | 127 // RenderViewTest. |
| 124 blink::WebSandboxSupport* sandboxSupport() override { return NULL; } | 128 blink::WebSandboxSupport* sandboxSupport() override { return NULL; } |
| 129 |
| 130 blink::WebURLLoader* createURLLoader() override { |
| 131 if (!url_loader_factory_.is_null()) |
| 132 return url_loader_factory_.Run(); |
| 133 return RendererBlinkPlatformImpl::createURLLoader(); |
| 134 } |
| 135 |
| 136 void SetWebURLLoaderFactory(const WebURLLoaderFactory& factory) { |
| 137 url_loader_factory_ = factory; |
| 138 } |
| 139 |
| 140 private: |
| 141 WebURLLoaderFactory url_loader_factory_; |
| 125 }; | 142 }; |
| 126 | 143 |
| 127 RenderViewTest::RendererBlinkPlatformImplTestOverride:: | 144 RenderViewTest::RendererBlinkPlatformImplTestOverride:: |
| 128 RendererBlinkPlatformImplTestOverride() { | 145 RendererBlinkPlatformImplTestOverride() { |
| 129 renderer_scheduler_ = scheduler::RendererScheduler::Create(); | 146 renderer_scheduler_ = scheduler::RendererScheduler::Create(); |
| 130 blink_platform_impl_.reset( | 147 blink_platform_impl_.reset( |
| 131 new RendererBlinkPlatformImplTestOverrideImpl(renderer_scheduler_.get())); | 148 new RendererBlinkPlatformImplTestOverrideImpl(renderer_scheduler_.get())); |
| 132 } | 149 } |
| 133 | 150 |
| 134 RenderViewTest::RendererBlinkPlatformImplTestOverride:: | 151 RenderViewTest::RendererBlinkPlatformImplTestOverride:: |
| 135 ~RendererBlinkPlatformImplTestOverride() { | 152 ~RendererBlinkPlatformImplTestOverride() { |
| 136 } | 153 } |
| 137 | 154 |
| 138 blink::Platform* | 155 blink::Platform* |
| 139 RenderViewTest::RendererBlinkPlatformImplTestOverride::Get() const { | 156 RenderViewTest::RendererBlinkPlatformImplTestOverride::Get() const { |
| 140 return blink_platform_impl_.get(); | 157 return blink_platform_impl_.get(); |
| 141 } | 158 } |
| 142 | 159 |
| 143 void RenderViewTest::RendererBlinkPlatformImplTestOverride::Shutdown() { | 160 void RenderViewTest::RendererBlinkPlatformImplTestOverride::Shutdown() { |
| 144 renderer_scheduler_->Shutdown(); | 161 renderer_scheduler_->Shutdown(); |
| 145 blink_platform_impl_->Shutdown(); | 162 blink_platform_impl_->Shutdown(); |
| 146 } | 163 } |
| 147 | 164 |
| 165 void RenderViewTest::RendererBlinkPlatformImplTestOverride:: |
| 166 SetWebURLLoaderFactory(const WebURLLoaderFactory& factory) { |
| 167 blink_platform_impl_->SetWebURLLoaderFactory(factory); |
| 168 } |
| 169 |
| 148 RenderViewTest::RenderViewTest() | 170 RenderViewTest::RenderViewTest() |
| 149 : view_(NULL) { | 171 : view_(NULL) { |
| 150 RenderFrameImpl::InstallCreateHook(&TestRenderFrame::CreateTestRenderFrame); | 172 RenderFrameImpl::InstallCreateHook(&TestRenderFrame::CreateTestRenderFrame); |
| 151 } | 173 } |
| 152 | 174 |
| 153 RenderViewTest::~RenderViewTest() { | 175 RenderViewTest::~RenderViewTest() { |
| 154 } | 176 } |
| 155 | 177 |
| 156 void RenderViewTest::ProcessPendingMessages() { | 178 void RenderViewTest::ProcessPendingMessages() { |
| 157 msg_loop_.task_runner()->PostTask(FROM_HERE, | 179 msg_loop_.task_runner()->PostTask(FROM_HERE, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // font IPCs, causing all font loading to fail. | 272 // font IPCs, causing all font loading to fail. |
| 251 SetDWriteFontProxySenderForTesting(CreateFakeCollectionSender()); | 273 SetDWriteFontProxySenderForTesting(CreateFakeCollectionSender()); |
| 252 #endif | 274 #endif |
| 253 | 275 |
| 254 // Subclasses can set render_thread_ with their own implementation before | 276 // Subclasses can set render_thread_ with their own implementation before |
| 255 // calling RenderViewTest::SetUp(). | 277 // calling RenderViewTest::SetUp(). |
| 256 if (!render_thread_) | 278 if (!render_thread_) |
| 257 render_thread_.reset(new MockRenderThread()); | 279 render_thread_.reset(new MockRenderThread()); |
| 258 render_thread_->set_routing_id(kRouteId); | 280 render_thread_->set_routing_id(kRouteId); |
| 259 render_thread_->set_new_window_routing_id(kNewWindowRouteId); | 281 render_thread_->set_new_window_routing_id(kNewWindowRouteId); |
| 282 render_thread_->set_new_window_main_frame_routing_id( |
| 283 kNewWindowMainFrameRouteId); |
| 260 render_thread_->set_new_window_main_frame_widget_routing_id( | 284 render_thread_->set_new_window_main_frame_widget_routing_id( |
| 261 kNewFrameWidgetRouteId); | 285 kNewFrameWidgetRouteId); |
| 262 render_thread_->set_new_frame_routing_id(kNewFrameRouteId); | 286 render_thread_->set_new_frame_routing_id(kNewFrameRouteId); |
| 263 | 287 |
| 264 #if defined(OS_MACOSX) | 288 #if defined(OS_MACOSX) |
| 265 autorelease_pool_.reset(new base::mac::ScopedNSAutoreleasePool()); | 289 autorelease_pool_.reset(new base::mac::ScopedNSAutoreleasePool()); |
| 266 #endif | 290 #endif |
| 267 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 291 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 268 params_.reset(new MainFunctionParams(*command_line_)); | 292 params_.reset(new MainFunctionParams(*command_line_)); |
| 269 platform_.reset(new RendererMainPlatformDelegate(*params_)); | 293 platform_.reset(new RendererMainPlatformDelegate(*params_)); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); | 692 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); |
| 669 frame->Navigate(common_params, StartNavigationParams(), request_params); | 693 frame->Navigate(common_params, StartNavigationParams(), request_params); |
| 670 | 694 |
| 671 // The load actually happens asynchronously, so we pump messages to process | 695 // The load actually happens asynchronously, so we pump messages to process |
| 672 // the pending continuation. | 696 // the pending continuation. |
| 673 FrameLoadWaiter(frame).Wait(); | 697 FrameLoadWaiter(frame).Wait(); |
| 674 view_->GetWebView()->updateAllLifecyclePhases(); | 698 view_->GetWebView()->updateAllLifecyclePhases(); |
| 675 } | 699 } |
| 676 | 700 |
| 677 } // namespace content | 701 } // namespace content |
| OLD | NEW |