| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/layouttest_support.h" | 5 #include "ui/gfx/test/icc_profiles.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 namespace gfx { |
| 8 #include <utility> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/lazy_instance.h" | |
| 12 #include "base/memory/ptr_util.h" | |
| 13 #include "base/strings/string_util.h" | |
| 14 #include "base/threading/thread_task_runner_handle.h" | |
| 15 #include "build/build_config.h" | |
| 16 #include "cc/output/copy_output_request.h" | |
| 17 #include "cc/test/pixel_test_output_surface.h" | |
| 18 #include "cc/test/test_compositor_frame_sink.h" | |
| 19 #include "components/test_runner/test_common.h" | |
| 20 #include "components/test_runner/web_frame_test_proxy.h" | |
| 21 #include "components/test_runner/web_view_test_proxy.h" | |
| 22 #include "components/test_runner/web_widget_test_proxy.h" | |
| 23 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" | |
| 24 #include "content/browser/renderer_host/render_process_host_impl.h" | |
| 25 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
| 26 #include "content/common/renderer.mojom.h" | |
| 27 #include "content/common/site_isolation_policy.h" | |
| 28 #include "content/public/common/page_state.h" | |
| 29 #include "content/public/renderer/renderer_gamepad_provider.h" | |
| 30 #include "content/renderer/fetchers/manifest_fetcher.h" | |
| 31 #include "content/renderer/gpu/render_widget_compositor.h" | |
| 32 #include "content/renderer/history_entry.h" | |
| 33 #include "content/renderer/history_serialization.h" | |
| 34 #include "content/renderer/input/render_widget_input_handler_delegate.h" | |
| 35 #include "content/renderer/layout_test_dependencies.h" | |
| 36 #include "content/renderer/render_frame_impl.h" | |
| 37 #include "content/renderer/render_thread_impl.h" | |
| 38 #include "content/renderer/render_view_impl.h" | |
| 39 #include "content/renderer/render_widget.h" | |
| 40 #include "content/renderer/renderer_blink_platform_impl.h" | |
| 41 #include "content/shell/common/shell_switches.h" | |
| 42 #include "gpu/ipc/service/image_transport_surface.h" | |
| 43 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | |
| 44 #include "third_party/WebKit/public/platform/WebFloatRect.h" | |
| 45 #include "third_party/WebKit/public/platform/WebGamepads.h" | |
| 46 #include "third_party/WebKit/public/platform/WebInputEvent.h" | |
| 47 #include "third_party/WebKit/public/platform/WebRect.h" | |
| 48 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionData.h" | |
| 49 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationData.h" | |
| 50 #include "third_party/WebKit/public/platform/scheduler/test/renderer_scheduler_t
est_support.h" | |
| 51 #include "third_party/WebKit/public/web/WebHistoryItem.h" | |
| 52 #include "third_party/WebKit/public/web/WebView.h" | |
| 53 #include "ui/events/blink/blink_event_util.h" | |
| 54 #include "ui/gfx/geometry/vector2d.h" | |
| 55 #include "ui/gfx/icc_profile.h" | |
| 56 | |
| 57 #if defined(OS_MACOSX) | |
| 58 #include "content/browser/frame_host/popup_menu_helper_mac.h" | |
| 59 #elif defined(OS_WIN) | |
| 60 #include "content/child/font_warmup_win.h" | |
| 61 #include "third_party/WebKit/public/web/win/WebFontRendering.h" | |
| 62 #include "third_party/skia/include/ports/SkFontMgr.h" | |
| 63 #include "third_party/skia/include/ports/SkTypeface_win.h" | |
| 64 #include "ui/gfx/win/direct_write.h" | |
| 65 #endif | |
| 66 | |
| 67 using blink::WebDeviceMotionData; | |
| 68 using blink::WebDeviceOrientationData; | |
| 69 using blink::WebGamepad; | |
| 70 using blink::WebGamepads; | |
| 71 using blink::WebRect; | |
| 72 using blink::WebSize; | |
| 73 | |
| 74 namespace content { | |
| 75 | 8 |
| 76 namespace { | 9 namespace { |
| 77 | 10 |
| 78 base::LazyInstance<ViewProxyCreationCallback>::Leaky | 11 const unsigned char generic_rgb_profile_data[] = { |
| 79 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; | |
| 80 | |
| 81 base::LazyInstance<WidgetProxyCreationCallback>::Leaky | |
| 82 g_widget_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; | |
| 83 | |
| 84 base::LazyInstance<FrameProxyCreationCallback>::Leaky | |
| 85 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; | |
| 86 | |
| 87 using WebViewTestProxyType = | |
| 88 test_runner::WebViewTestProxy<RenderViewImpl, | |
| 89 CompositorDependencies*, | |
| 90 const mojom::CreateViewParams&>; | |
| 91 using WebWidgetTestProxyType = | |
| 92 test_runner::WebWidgetTestProxy<RenderWidget, | |
| 93 int32_t, | |
| 94 CompositorDependencies*, | |
| 95 blink::WebPopupType, | |
| 96 const ScreenInfo&, | |
| 97 bool, | |
| 98 bool, | |
| 99 bool>; | |
| 100 using WebFrameTestProxyType = | |
| 101 test_runner::WebFrameTestProxy<RenderFrameImpl, | |
| 102 const RenderFrameImpl::CreateParams&>; | |
| 103 | |
| 104 RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps, | |
| 105 const mojom::CreateViewParams& params) { | |
| 106 WebViewTestProxyType* render_view_proxy = | |
| 107 new WebViewTestProxyType(compositor_deps, params); | |
| 108 if (g_view_test_proxy_callback == 0) | |
| 109 return render_view_proxy; | |
| 110 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy); | |
| 111 return render_view_proxy; | |
| 112 } | |
| 113 | |
| 114 RenderWidget* CreateWebWidgetTestProxy(int32_t routing_id, | |
| 115 CompositorDependencies* compositor_deps, | |
| 116 blink::WebPopupType popup_type, | |
| 117 const ScreenInfo& screen_info, | |
| 118 bool swapped_out, | |
| 119 bool hidden, | |
| 120 bool never_visible) { | |
| 121 WebWidgetTestProxyType* render_widget_proxy = new WebWidgetTestProxyType( | |
| 122 routing_id, compositor_deps, popup_type, screen_info, swapped_out, hidden, | |
| 123 never_visible); | |
| 124 return render_widget_proxy; | |
| 125 } | |
| 126 | |
| 127 void RenderWidgetInitialized(RenderWidget* render_widget) { | |
| 128 WebWidgetTestProxyType* render_widget_proxy = | |
| 129 static_cast<WebWidgetTestProxyType*>(render_widget); | |
| 130 if (!g_widget_test_proxy_callback.Get().is_null()) { | |
| 131 g_widget_test_proxy_callback.Get().Run(render_widget->GetWebWidget(), | |
| 132 render_widget_proxy); | |
| 133 } | |
| 134 } | |
| 135 | |
| 136 RenderFrameImpl* CreateWebFrameTestProxy( | |
| 137 const RenderFrameImpl::CreateParams& params) { | |
| 138 WebFrameTestProxyType* render_frame_proxy = new WebFrameTestProxyType(params); | |
| 139 if (g_frame_test_proxy_callback == 0) | |
| 140 return render_frame_proxy; | |
| 141 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy); | |
| 142 return render_frame_proxy; | |
| 143 } | |
| 144 | |
| 145 float GetWindowToViewportScale(RenderWidget* render_widget) { | |
| 146 blink::WebFloatRect rect(0, 0, 1.0f, 0.0); | |
| 147 render_widget->convertWindowToViewport(&rect); | |
| 148 return rect.width; | |
| 149 } | |
| 150 | |
| 151 #if defined(OS_WIN) | |
| 152 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer | |
| 153 // side-loading, support kRegisterFontFiles to allow access to additional fonts. | |
| 154 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { | |
| 155 std::vector<std::string> files = switches::GetSideloadFontFiles(); | |
| 156 for (std::vector<std::string>::const_iterator i(files.begin()); | |
| 157 i != files.end(); | |
| 158 ++i) { | |
| 159 SkTypeface* typeface = fontmgr->createFromFile(i->c_str()); | |
| 160 blink::WebFontRendering::addSideloadedFontForTesting(typeface); | |
| 161 } | |
| 162 } | |
| 163 #endif // OS_WIN | |
| 164 | |
| 165 } // namespace | |
| 166 | |
| 167 test_runner::WebViewTestProxyBase* GetWebViewTestProxyBase( | |
| 168 RenderView* render_view) { | |
| 169 WebViewTestProxyType* render_view_proxy = | |
| 170 static_cast<WebViewTestProxyType*>(render_view); | |
| 171 return static_cast<test_runner::WebViewTestProxyBase*>(render_view_proxy); | |
| 172 } | |
| 173 | |
| 174 test_runner::WebFrameTestProxyBase* GetWebFrameTestProxyBase( | |
| 175 RenderFrame* render_frame) { | |
| 176 WebFrameTestProxyType* render_frame_proxy = | |
| 177 static_cast<WebFrameTestProxyType*>(render_frame); | |
| 178 return static_cast<test_runner::WebFrameTestProxyBase*>(render_frame_proxy); | |
| 179 } | |
| 180 | |
| 181 test_runner::WebWidgetTestProxyBase* GetWebWidgetTestProxyBase( | |
| 182 blink::WebLocalFrame* frame) { | |
| 183 DCHECK(frame); | |
| 184 RenderFrame* local_root = RenderFrame::FromWebFrame(frame->localRoot()); | |
| 185 DCHECK(local_root); | |
| 186 // TODO(lfg): Simplify once RenderView no longer inherits from RenderWidget. | |
| 187 if (local_root->IsMainFrame()) { | |
| 188 test_runner::WebViewTestProxyBase* web_view_test_proxy_base = | |
| 189 GetWebViewTestProxyBase(local_root->GetRenderView()); | |
| 190 auto* web_widget_test_proxy_base = | |
| 191 static_cast<test_runner::WebWidgetTestProxyBase*>( | |
| 192 web_view_test_proxy_base); | |
| 193 DCHECK(web_widget_test_proxy_base->web_widget()->isWebView()); | |
| 194 return web_widget_test_proxy_base; | |
| 195 } else { | |
| 196 RenderWidget* render_widget = | |
| 197 static_cast<RenderFrameImpl*>(local_root)->GetRenderWidget(); | |
| 198 DCHECK(render_widget); | |
| 199 WebWidgetTestProxyType* render_widget_proxy = | |
| 200 static_cast<WebWidgetTestProxyType*>(render_widget); | |
| 201 auto* web_widget_test_proxy_base = | |
| 202 static_cast<test_runner::WebWidgetTestProxyBase*>(render_widget_proxy); | |
| 203 DCHECK(web_widget_test_proxy_base->web_widget()->isWebFrameWidget()); | |
| 204 return web_widget_test_proxy_base; | |
| 205 } | |
| 206 } | |
| 207 | |
| 208 RenderWidget* GetRenderWidget( | |
| 209 test_runner::WebWidgetTestProxyBase* web_widget_test_proxy_base) { | |
| 210 DCHECK(web_widget_test_proxy_base); | |
| 211 | |
| 212 blink::WebWidget* widget = web_widget_test_proxy_base->web_widget(); | |
| 213 // TODO(lfg): Simplify once RenderView no longer inherits from RenderWidget. | |
| 214 if (widget->isWebView()) { | |
| 215 WebViewTestProxyType* render_view_proxy = | |
| 216 static_cast<WebViewTestProxyType*>(web_widget_test_proxy_base); | |
| 217 RenderViewImpl* render_view_impl = | |
| 218 static_cast<RenderViewImpl*>(render_view_proxy); | |
| 219 return render_view_impl; | |
| 220 } else if (widget->isWebFrameWidget()) { | |
| 221 WebWidgetTestProxyType* render_widget_proxy = | |
| 222 static_cast<WebWidgetTestProxyType*>(web_widget_test_proxy_base); | |
| 223 return static_cast<RenderWidget*>(render_widget_proxy); | |
| 224 } else { | |
| 225 NOTREACHED(); | |
| 226 return nullptr; | |
| 227 } | |
| 228 } | |
| 229 | |
| 230 void EnableWebTestProxyCreation( | |
| 231 const ViewProxyCreationCallback& view_proxy_creation_callback, | |
| 232 const WidgetProxyCreationCallback& widget_proxy_creation_callback, | |
| 233 const FrameProxyCreationCallback& frame_proxy_creation_callback) { | |
| 234 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; | |
| 235 g_widget_test_proxy_callback.Get() = widget_proxy_creation_callback; | |
| 236 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback; | |
| 237 RenderViewImpl::InstallCreateHook(CreateWebViewTestProxy); | |
| 238 RenderWidget::InstallCreateHook(CreateWebWidgetTestProxy, | |
| 239 RenderWidgetInitialized); | |
| 240 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); | |
| 241 } | |
| 242 | |
| 243 void FetchManifestDoneCallback(std::unique_ptr<ManifestFetcher> fetcher, | |
| 244 const FetchManifestCallback& callback, | |
| 245 const blink::WebURLResponse& response, | |
| 246 const std::string& data) { | |
| 247 // |fetcher| will be autodeleted here as it is going out of scope. | |
| 248 callback.Run(response, data); | |
| 249 } | |
| 250 | |
| 251 void FetchManifest(blink::WebView* view, const GURL& url, | |
| 252 const FetchManifestCallback& callback) { | |
| 253 ManifestFetcher* fetcher = new ManifestFetcher(url); | |
| 254 std::unique_ptr<ManifestFetcher> autodeleter(fetcher); | |
| 255 | |
| 256 // Start is called on fetcher which is also bound to the callback. | |
| 257 // A raw pointer is used instead of a scoped_ptr as base::Passes passes | |
| 258 // ownership and thus nulls the scoped_ptr. On MSVS this happens before | |
| 259 // the call to Start, resulting in a crash. | |
| 260 fetcher->Start(view->mainFrame(), | |
| 261 false, | |
| 262 base::Bind(&FetchManifestDoneCallback, | |
| 263 base::Passed(&autodeleter), | |
| 264 callback)); | |
| 265 } | |
| 266 | |
| 267 void SetMockGamepadProvider(std::unique_ptr<RendererGamepadProvider> provider) { | |
| 268 RenderThreadImpl::current() | |
| 269 ->blink_platform_impl() | |
| 270 ->SetPlatformEventObserverForTesting(blink::WebPlatformEventTypeGamepad, | |
| 271 std::move(provider)); | |
| 272 } | |
| 273 | |
| 274 void SetMockDeviceLightData(const double data) { | |
| 275 RendererBlinkPlatformImpl::SetMockDeviceLightDataForTesting(data); | |
| 276 } | |
| 277 | |
| 278 void SetMockDeviceMotionData(const WebDeviceMotionData& data) { | |
| 279 RendererBlinkPlatformImpl::SetMockDeviceMotionDataForTesting(data); | |
| 280 } | |
| 281 | |
| 282 void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) { | |
| 283 RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting(data); | |
| 284 } | |
| 285 | |
| 286 namespace { | |
| 287 | |
| 288 // Invokes a callback on commit (on the main thread) to obtain the output | |
| 289 // surface that should be used, then asks that output surface to submit the copy | |
| 290 // request at SwapBuffers time. | |
| 291 class CopyRequestSwapPromise : public cc::SwapPromise { | |
| 292 public: | |
| 293 using FindCompositorFrameSinkCallback = | |
| 294 base::Callback<cc::TestCompositorFrameSink*()>; | |
| 295 CopyRequestSwapPromise( | |
| 296 std::unique_ptr<cc::CopyOutputRequest> request, | |
| 297 FindCompositorFrameSinkCallback find_compositor_frame_sink_callback) | |
| 298 : copy_request_(std::move(request)), | |
| 299 find_compositor_frame_sink_callback_( | |
| 300 std::move(find_compositor_frame_sink_callback)) {} | |
| 301 | |
| 302 // cc::SwapPromise implementation. | |
| 303 void OnCommit() override { | |
| 304 compositor_frame_sink_from_commit_ = | |
| 305 find_compositor_frame_sink_callback_.Run(); | |
| 306 DCHECK(compositor_frame_sink_from_commit_); | |
| 307 } | |
| 308 void DidActivate() override {} | |
| 309 void WillSwap(cc::CompositorFrameMetadata*) override { | |
| 310 compositor_frame_sink_from_commit_->RequestCopyOfOutput( | |
| 311 std::move(copy_request_)); | |
| 312 } | |
| 313 void DidSwap() override {} | |
| 314 DidNotSwapAction DidNotSwap(DidNotSwapReason r) override { | |
| 315 // The compositor should always swap in layout test mode. | |
| 316 NOTREACHED() << "did not swap for reason " << r; | |
| 317 return DidNotSwapAction::BREAK_PROMISE; | |
| 318 } | |
| 319 int64_t TraceId() const override { return 0; } | |
| 320 | |
| 321 private: | |
| 322 std::unique_ptr<cc::CopyOutputRequest> copy_request_; | |
| 323 FindCompositorFrameSinkCallback find_compositor_frame_sink_callback_; | |
| 324 cc::TestCompositorFrameSink* compositor_frame_sink_from_commit_ = nullptr; | |
| 325 }; | |
| 326 | |
| 327 } // namespace | |
| 328 | |
| 329 class LayoutTestDependenciesImpl : public LayoutTestDependencies, | |
| 330 public cc::TestCompositorFrameSinkClient { | |
| 331 public: | |
| 332 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( | |
| 333 int32_t routing_id, | |
| 334 scoped_refptr<gpu::GpuChannelHost> gpu_channel, | |
| 335 scoped_refptr<cc::ContextProvider> compositor_context_provider, | |
| 336 scoped_refptr<cc::ContextProvider> worker_context_provider, | |
| 337 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | |
| 338 CompositorDependencies* deps) override { | |
| 339 // This could override the GpuChannel for a CompositorFrameSink that was | |
| 340 // previously being created but in that case the old GpuChannel would be | |
| 341 // lost as would the CompositorFrameSink. | |
| 342 gpu_channel_ = gpu_channel; | |
| 343 | |
| 344 auto* task_runner = deps->GetCompositorImplThreadTaskRunner().get(); | |
| 345 bool synchronous_composite = !task_runner; | |
| 346 if (!task_runner) | |
| 347 task_runner = base::ThreadTaskRunnerHandle::Get().get(); | |
| 348 | |
| 349 cc::LayerTreeSettings settings = | |
| 350 RenderWidgetCompositor::GenerateLayerTreeSettings( | |
| 351 *base::CommandLine::ForCurrentProcess(), deps, 1.f); | |
| 352 | |
| 353 auto compositor_frame_sink = base::MakeUnique<cc::TestCompositorFrameSink>( | |
| 354 std::move(compositor_context_provider), | |
| 355 std::move(worker_context_provider), nullptr /* shared_bitmap_manager */, | |
| 356 gpu_memory_buffer_manager, settings.renderer_settings, task_runner, | |
| 357 synchronous_composite, false /* force_disable_reclaim_resources */); | |
| 358 compositor_frame_sink->SetClient(this); | |
| 359 compositor_frame_sinks_[routing_id] = compositor_frame_sink.get(); | |
| 360 return std::move(compositor_frame_sink); | |
| 361 } | |
| 362 | |
| 363 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutput( | |
| 364 int32_t routing_id, | |
| 365 std::unique_ptr<cc::CopyOutputRequest> request) override { | |
| 366 // Note that we can't immediately check compositor_frame_sinks_, since it | |
| 367 // may not have been created yet. Instead, we wait until OnCommit to find | |
| 368 // the currently active CompositorFrameSink for the given RenderWidget | |
| 369 // routing_id. | |
| 370 return base::MakeUnique<CopyRequestSwapPromise>( | |
| 371 std::move(request), | |
| 372 base::Bind( | |
| 373 &LayoutTestDependenciesImpl::FindCompositorFrameSink, | |
| 374 // |this| will still be valid, because its lifetime is tied to | |
| 375 // RenderThreadImpl, which outlives layout test execution. | |
| 376 base::Unretained(this), routing_id)); | |
| 377 } | |
| 378 | |
| 379 // TestCompositorFrameSinkClient implementation. | |
| 380 std::unique_ptr<cc::OutputSurface> CreateDisplayOutputSurface( | |
| 381 scoped_refptr<cc::ContextProvider> compositor_context_provider) override { | |
| 382 // This is for an offscreen context for the compositor. So the default | |
| 383 // framebuffer doesn't need alpha, depth, stencil, antialiasing. | |
| 384 gpu::gles2::ContextCreationAttribHelper attributes; | |
| 385 attributes.alpha_size = -1; | |
| 386 attributes.depth_size = 0; | |
| 387 attributes.stencil_size = 0; | |
| 388 attributes.samples = 0; | |
| 389 attributes.sample_buffers = 0; | |
| 390 attributes.bind_generates_resource = false; | |
| 391 attributes.lose_context_when_out_of_memory = true; | |
| 392 const bool automatic_flushes = false; | |
| 393 const bool support_locking = false; | |
| 394 | |
| 395 auto context_provider = | |
| 396 make_scoped_refptr(new ui::ContextProviderCommandBuffer( | |
| 397 gpu_channel_, gpu::GPU_STREAM_DEFAULT, | |
| 398 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | |
| 399 GURL("chrome://gpu/" | |
| 400 "LayoutTestDependenciesImpl::CreateOutputSurface"), | |
| 401 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), | |
| 402 attributes, nullptr, | |
| 403 ui::command_buffer_metrics::OFFSCREEN_CONTEXT_FOR_TESTING)); | |
| 404 context_provider->BindToCurrentThread(); | |
| 405 | |
| 406 bool flipped_output_surface = false; | |
| 407 return base::MakeUnique<cc::PixelTestOutputSurface>( | |
| 408 std::move(context_provider), flipped_output_surface); | |
| 409 } | |
| 410 void DisplayReceivedCompositorFrame( | |
| 411 const cc::CompositorFrame& frame) override {} | |
| 412 void DisplayWillDrawAndSwap( | |
| 413 bool will_draw_and_swap, | |
| 414 const cc::RenderPassList& render_passes) override {} | |
| 415 void DisplayDidDrawAndSwap() override {} | |
| 416 | |
| 417 private: | |
| 418 cc::TestCompositorFrameSink* FindCompositorFrameSink(int32_t routing_id) { | |
| 419 auto it = compositor_frame_sinks_.find(routing_id); | |
| 420 return it == compositor_frame_sinks_.end() ? nullptr : it->second; | |
| 421 } | |
| 422 | |
| 423 // Entries are not removed, so this map can grow. However, it is only used in | |
| 424 // layout tests, so this memory usage does not occur in production. | |
| 425 // Entries in this map will outlive the output surface, because this object is | |
| 426 // owned by RenderThreadImpl, which outlives layout test execution. | |
| 427 std::unordered_map<int32_t, cc::TestCompositorFrameSink*> | |
| 428 compositor_frame_sinks_; | |
| 429 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | |
| 430 }; | |
| 431 | |
| 432 void EnableRendererLayoutTestMode() { | |
| 433 RenderThreadImpl::current()->set_layout_test_dependencies( | |
| 434 base::MakeUnique<LayoutTestDependenciesImpl>()); | |
| 435 | |
| 436 #if defined(OS_WIN) | |
| 437 RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite()); | |
| 438 #endif | |
| 439 } | |
| 440 | |
| 441 void EnableBrowserLayoutTestMode() { | |
| 442 #if defined(OS_MACOSX) | |
| 443 gpu::ImageTransportSurface::SetAllowOSMesaForTesting(true); | |
| 444 PopupMenuHelper::DontShowPopupMenuForTesting(); | |
| 445 #endif | |
| 446 RenderWidgetHostImpl::DisableResizeAckCheckForTesting(); | |
| 447 } | |
| 448 | |
| 449 int GetLocalSessionHistoryLength(RenderView* render_view) { | |
| 450 return static_cast<RenderViewImpl*>(render_view)-> | |
| 451 GetLocalSessionHistoryLengthForTesting(); | |
| 452 } | |
| 453 | |
| 454 void SyncNavigationState(RenderView* render_view) { | |
| 455 // TODO(creis): Add support for testing in OOPIF-enabled modes. | |
| 456 // See https://crbug.com/477150. | |
| 457 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
| 458 return; | |
| 459 static_cast<RenderViewImpl*>(render_view)->SendUpdateState(); | |
| 460 } | |
| 461 | |
| 462 void SetFocusAndActivate(RenderView* render_view, bool enable) { | |
| 463 static_cast<RenderViewImpl*>(render_view)-> | |
| 464 SetFocusAndActivateForTesting(enable); | |
| 465 } | |
| 466 | |
| 467 void ForceResizeRenderView(RenderView* render_view, | |
| 468 const WebSize& new_size) { | |
| 469 RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view); | |
| 470 render_view_impl->ForceResizeForTesting(new_size); | |
| 471 } | |
| 472 | |
| 473 void SetDeviceScaleFactor(RenderView* render_view, float factor) { | |
| 474 static_cast<RenderViewImpl*>(render_view)-> | |
| 475 SetDeviceScaleFactorForTesting(factor); | |
| 476 } | |
| 477 | |
| 478 float GetWindowToViewportScale(RenderView* render_view) { | |
| 479 return GetWindowToViewportScale( | |
| 480 static_cast<RenderViewImpl*>(render_view)->GetWidget()); | |
| 481 } | |
| 482 | |
| 483 std::unique_ptr<blink::WebInputEvent> TransformScreenToWidgetCoordinates( | |
| 484 test_runner::WebWidgetTestProxyBase* web_widget_test_proxy_base, | |
| 485 const blink::WebInputEvent& event) { | |
| 486 DCHECK(web_widget_test_proxy_base); | |
| 487 RenderWidget* render_widget = GetRenderWidget(web_widget_test_proxy_base); | |
| 488 | |
| 489 blink::WebRect view_rect = render_widget->viewRect(); | |
| 490 float scale = GetWindowToViewportScale(render_widget); | |
| 491 gfx::Vector2d delta(-view_rect.x, -view_rect.y); | |
| 492 return ui::TranslateAndScaleWebInputEvent(event, delta, scale); | |
| 493 } | |
| 494 | |
| 495 gfx::ICCProfile GetTestingICCProfile(const std::string& name) { | |
| 496 const unsigned char rgb_profile_data[] = { | |
| 497 0x00, 0x00, 0x07, 0xd8, 0x61, 0x70, 0x70, 0x6c, 0x02, 0x20, 0x00, 0x00, | 12 0x00, 0x00, 0x07, 0xd8, 0x61, 0x70, 0x70, 0x6c, 0x02, 0x20, 0x00, 0x00, |
| 498 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, | 13 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, |
| 499 0x07, 0xd9, 0x00, 0x02, 0x00, 0x19, 0x00, 0x0b, 0x00, 0x1a, 0x00, 0x0b, | 14 0x07, 0xd9, 0x00, 0x02, 0x00, 0x19, 0x00, 0x0b, 0x00, 0x1a, 0x00, 0x0b, |
| 500 0x61, 0x63, 0x73, 0x70, 0x41, 0x50, 0x50, 0x4c, 0x00, 0x00, 0x00, 0x00, | 15 0x61, 0x63, 0x73, 0x70, 0x41, 0x50, 0x50, 0x4c, 0x00, 0x00, 0x00, 0x00, |
| 501 0x61, 0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 16 0x61, 0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 502 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, | 17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, |
| 503 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x70, 0x70, 0x6c, | 18 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x61, 0x70, 0x70, 0x6c, |
| 504 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 505 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 506 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 0x00, 0x01, 0x16, 0xcf, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, | 169 0x00, 0x01, 0x16, 0xcf, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, |
| 655 0x00, 0x00, 0x74, 0x4d, 0x00, 0x00, 0x3d, 0xee, 0x00, 0x00, 0x03, 0xd0, | 170 0x00, 0x00, 0x74, 0x4d, 0x00, 0x00, 0x3d, 0xee, 0x00, 0x00, 0x03, 0xd0, |
| 656 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x75, | 171 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x75, |
| 657 0x00, 0x00, 0xac, 0x73, 0x00, 0x00, 0x17, 0x34, 0x58, 0x59, 0x5a, 0x20, | 172 0x00, 0x00, 0xac, 0x73, 0x00, 0x00, 0x17, 0x34, 0x58, 0x59, 0x5a, 0x20, |
| 658 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x1a, 0x00, 0x00, 0x15, 0x9f, | 173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x1a, 0x00, 0x00, 0x15, 0x9f, |
| 659 0x00, 0x00, 0xb8, 0x36, 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, | 174 0x00, 0x00, 0xb8, 0x36, 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, |
| 660 0x00, 0x00, 0x00, 0x01, 0x01, 0xcd, 0x00, 0x00, 0x73, 0x66, 0x33, 0x32, | 175 0x00, 0x00, 0x00, 0x01, 0x01, 0xcd, 0x00, 0x00, 0x73, 0x66, 0x33, 0x32, |
| 661 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x42, 0x00, 0x00, 0x05, 0xde, | 176 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x42, 0x00, 0x00, 0x05, 0xde, |
| 662 0xff, 0xff, 0xf3, 0x26, 0x00, 0x00, 0x07, 0x92, 0x00, 0x00, 0xfd, 0x91, | 177 0xff, 0xff, 0xf3, 0x26, 0x00, 0x00, 0x07, 0x92, 0x00, 0x00, 0xfd, 0x91, |
| 663 0xff, 0xff, 0xfb, 0xa2, 0xff, 0xff, 0xfd, 0xa3, 0x00, 0x00, 0x03, 0xdc, | 178 0xff, 0xff, 0xfb, 0xa2, 0xff, 0xff, 0xfd, 0xa3, 0x00, 0x00, 0x03, 0xdc, |
| 664 0x00, 0x00, 0xc0, 0x6c | 179 0x00, 0x00, 0xc0, 0x6c}; |
| 665 }; | |
| 666 | 180 |
| 667 const unsigned char srgb_profile_data[] = { | 181 const unsigned char srgb_profile_data[] = { |
| 668 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00, 0x00, | 182 0x00, 0x00, 0x0c, 0x48, 0x4c, 0x69, 0x6e, 0x6f, 0x02, 0x10, 0x00, 0x00, |
| 669 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, | 183 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, |
| 670 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00, 0x31, 0x00, 0x00, | 184 0x07, 0xce, 0x00, 0x02, 0x00, 0x09, 0x00, 0x06, 0x00, 0x31, 0x00, 0x00, |
| 671 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, | 185 0x61, 0x63, 0x73, 0x70, 0x4d, 0x53, 0x46, 0x54, 0x00, 0x00, 0x00, 0x00, |
| 672 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, | 186 0x49, 0x45, 0x43, 0x20, 0x73, 0x52, 0x47, 0x42, 0x00, 0x00, 0x00, 0x00, |
| 673 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, | 187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, |
| 674 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20, | 188 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x48, 0x50, 0x20, 0x20, |
| 675 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 676 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 677 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 191 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 0xdc, 0x8a, 0xdd, 0x10, 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, | 433 0xdc, 0x8a, 0xdd, 0x10, 0xdd, 0x96, 0xde, 0x1c, 0xde, 0xa2, 0xdf, 0x29, |
| 920 0xdf, 0xaf, 0xe0, 0x36, 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, | 434 0xdf, 0xaf, 0xe0, 0x36, 0xe0, 0xbd, 0xe1, 0x44, 0xe1, 0xcc, 0xe2, 0x53, |
| 921 0xe2, 0xdb, 0xe3, 0x63, 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, | 435 0xe2, 0xdb, 0xe3, 0x63, 0xe3, 0xeb, 0xe4, 0x73, 0xe4, 0xfc, 0xe5, 0x84, |
| 922 0xe6, 0x0d, 0xe6, 0x96, 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, | 436 0xe6, 0x0d, 0xe6, 0x96, 0xe7, 0x1f, 0xe7, 0xa9, 0xe8, 0x32, 0xe8, 0xbc, |
| 923 0xe9, 0x46, 0xe9, 0xd0, 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, | 437 0xe9, 0x46, 0xe9, 0xd0, 0xea, 0x5b, 0xea, 0xe5, 0xeb, 0x70, 0xeb, 0xfb, |
| 924 0xec, 0x86, 0xed, 0x11, 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, | 438 0xec, 0x86, 0xed, 0x11, 0xed, 0x9c, 0xee, 0x28, 0xee, 0xb4, 0xef, 0x40, |
| 925 0xef, 0xcc, 0xf0, 0x58, 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, | 439 0xef, 0xcc, 0xf0, 0x58, 0xf0, 0xe5, 0xf1, 0x72, 0xf1, 0xff, 0xf2, 0x8c, |
| 926 0xf3, 0x19, 0xf3, 0xa7, 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, | 440 0xf3, 0x19, 0xf3, 0xa7, 0xf4, 0x34, 0xf4, 0xc2, 0xf5, 0x50, 0xf5, 0xde, |
| 927 0xf6, 0x6d, 0xf6, 0xfb, 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, | 441 0xf6, 0x6d, 0xf6, 0xfb, 0xf7, 0x8a, 0xf8, 0x19, 0xf8, 0xa8, 0xf9, 0x38, |
| 928 0xf9, 0xc7, 0xfa, 0x57, 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, | 442 0xf9, 0xc7, 0xfa, 0x57, 0xfa, 0xe7, 0xfb, 0x77, 0xfc, 0x07, 0xfc, 0x98, |
| 929 0xfd, 0x29, 0xfd, 0xba, 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff | 443 0xfd, 0x29, 0xfd, 0xba, 0xfe, 0x4b, 0xfe, 0xdc, 0xff, 0x6d, 0xff, 0xff}; |
| 930 }; | |
| 931 | 444 |
| 932 const unsigned char colorspin_profile_data[] = { | 445 const unsigned char colorspin_profile_data[] = { |
| 933 0x00, 0x00, 0x01, 0xea, 0x54, 0x45, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, | 446 0x00, 0x00, 0x01, 0xea, 0x54, 0x45, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00, |
| 934 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, | 447 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, |
| 935 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 448 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 936 0x61, 0x63, 0x73, 0x70, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, | 449 0x61, 0x63, 0x73, 0x70, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, |
| 937 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 450 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 938 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, | 451 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, |
| 939 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x74, 0x65, 0x73, 0x74, | 452 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x74, 0x65, 0x73, 0x74, |
| 940 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 453 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 941 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 942 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 455 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 963 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 476 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 964 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 477 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 965 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 966 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x52, | 479 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x52, |
| 967 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, | 480 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20, |
| 968 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x8d, 0x00, 0x00, 0xa0, 0x2c, | 481 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x8d, 0x00, 0x00, 0xa0, 0x2c, |
| 969 0x00, 0x00, 0x0f, 0x95, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, | 482 0x00, 0x00, 0x0f, 0x95, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, |
| 970 0x00, 0x00, 0x26, 0x31, 0x00, 0x00, 0x10, 0x2f, 0x00, 0x00, 0xbe, 0x9b, | 483 0x00, 0x00, 0x26, 0x31, 0x00, 0x00, 0x10, 0x2f, 0x00, 0x00, 0xbe, 0x9b, |
| 971 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x18, | 484 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x18, |
| 972 0x00, 0x00, 0x4f, 0xa5, 0x00, 0x00, 0x04, 0xfc, 0x63, 0x75, 0x72, 0x76, | 485 0x00, 0x00, 0x4f, 0xa5, 0x00, 0x00, 0x04, 0xfc, 0x63, 0x75, 0x72, 0x76, |
| 973 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x33 | 486 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x33}; |
| 974 }; | |
| 975 | 487 |
| 976 const unsigned char adobe_rgb_profile_data[] = { | 488 const unsigned char adobe_rgb_profile_data[] = { |
| 977 0x00, 0x00, 0x02, 0x30, 0x41, 0x44, 0x42, 0x45, 0x02, 0x10, 0x00, 0x00, | 489 0x00, 0x00, 0x02, 0x30, 0x41, 0x44, 0x42, 0x45, 0x02, 0x10, 0x00, 0x00, |
| 978 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, | 490 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20, |
| 979 0x07, 0xd0, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x13, 0x00, 0x33, 0x00, 0x3b, | 491 0x07, 0xd0, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x13, 0x00, 0x33, 0x00, 0x3b, |
| 980 0x61, 0x63, 0x73, 0x70, 0x41, 0x50, 0x50, 0x4c, 0x00, 0x00, 0x00, 0x00, | 492 0x61, 0x63, 0x73, 0x70, 0x41, 0x50, 0x50, 0x4c, 0x00, 0x00, 0x00, 0x00, |
| 981 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 493 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 982 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, | 494 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6, |
| 983 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x41, 0x44, 0x42, 0x45, | 495 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x41, 0x44, 0x42, 0x45, |
| 984 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 496 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 985 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 497 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 986 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 498 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1013 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 525 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1014 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x75, 0x72, 0x76, | 526 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x75, 0x72, 0x76, |
| 1015 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x33, 0x00, 0x00, | 527 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x33, 0x00, 0x00, |
| 1016 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, | 528 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, |
| 1017 0x02, 0x33, 0x00, 0x00, 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, | 529 0x02, 0x33, 0x00, 0x00, 0x63, 0x75, 0x72, 0x76, 0x00, 0x00, 0x00, 0x00, |
| 1018 0x00, 0x00, 0x00, 0x01, 0x02, 0x33, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, | 530 0x00, 0x00, 0x00, 0x01, 0x02, 0x33, 0x00, 0x00, 0x58, 0x59, 0x5a, 0x20, |
| 1019 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x18, 0x00, 0x00, 0x4f, 0xa5, | 531 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x18, 0x00, 0x00, 0x4f, 0xa5, |
| 1020 0x00, 0x00, 0x04, 0xfc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, | 532 0x00, 0x00, 0x04, 0xfc, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, |
| 1021 0x00, 0x00, 0x34, 0x8d, 0x00, 0x00, 0xa0, 0x2c, 0x00, 0x00, 0x0f, 0x95, | 533 0x00, 0x00, 0x34, 0x8d, 0x00, 0x00, 0xa0, 0x2c, 0x00, 0x00, 0x0f, 0x95, |
| 1022 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x31, | 534 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x31, |
| 1023 0x00, 0x00, 0x10, 0x2f, 0x00, 0x00, 0xbe, 0x9c | 535 0x00, 0x00, 0x10, 0x2f, 0x00, 0x00, 0xbe, 0x9c}; |
| 1024 }; | |
| 1025 | |
| 1026 const unsigned char* data = nullptr; | |
| 1027 size_t size = 0; | |
| 1028 if (name == "genericRGB") { | |
| 1029 data = rgb_profile_data; | |
| 1030 size = sizeof(rgb_profile_data); | |
| 1031 } else if (name == "sRGB") { | |
| 1032 data = srgb_profile_data; | |
| 1033 size = sizeof(srgb_profile_data); | |
| 1034 } else if (name == "test" || name == "colorSpin") { | |
| 1035 data = colorspin_profile_data; | |
| 1036 size = sizeof(colorspin_profile_data); | |
| 1037 } else if (name == "adobeRGB") { | |
| 1038 data = adobe_rgb_profile_data; | |
| 1039 size = sizeof(adobe_rgb_profile_data); | |
| 1040 } | |
| 1041 | |
| 1042 if (data) | |
| 1043 return gfx::ICCProfile::FromData(reinterpret_cast<const char*>(data), size); | |
| 1044 return gfx::ICCProfile(); | |
| 1045 } | 536 } |
| 1046 | 537 |
| 1047 void SetDeviceColorProfile( | 538 ICCProfile ICCProfileForTestingAdobeRGB() { |
| 1048 RenderView* render_view, const gfx::ICCProfile& icc_profile) { | 539 return ICCProfile::FromData( |
| 1049 static_cast<RenderViewImpl*>(render_view) | 540 reinterpret_cast<const char*>(adobe_rgb_profile_data), |
| 1050 ->GetWidget() | 541 arraysize(adobe_rgb_profile_data)); |
| 1051 ->SetDeviceColorProfileForTesting(icc_profile.GetData()); | |
| 1052 } | 542 } |
| 1053 | 543 |
| 1054 void SetTestBluetoothScanDuration() { | 544 ICCProfile ICCProfileForTestingGenericRGB() { |
| 1055 BluetoothDeviceChooserController::SetTestScanDurationForTesting(); | 545 return ICCProfile::FromData( |
| 546 reinterpret_cast<const char*>(generic_rgb_profile_data), |
| 547 arraysize(generic_rgb_profile_data)); |
| 1056 } | 548 } |
| 1057 | 549 |
| 1058 void UseSynchronousResizeMode(RenderView* render_view, bool enable) { | 550 ICCProfile ICCProfileForTestingSRGB() { |
| 1059 static_cast<RenderViewImpl*>(render_view)-> | 551 return ICCProfile::FromData(reinterpret_cast<const char*>(srgb_profile_data), |
| 1060 UseSynchronousResizeModeForTesting(enable); | 552 arraysize(srgb_profile_data)); |
| 1061 } | 553 } |
| 1062 | 554 |
| 1063 void EnableAutoResizeMode(RenderView* render_view, | 555 ICCProfile ICCProfileForTestingColorSpin() { |
| 1064 const WebSize& min_size, | 556 return ICCProfile::FromData( |
| 1065 const WebSize& max_size) { | 557 reinterpret_cast<const char*>(colorspin_profile_data), |
| 1066 static_cast<RenderViewImpl*>(render_view)-> | 558 arraysize(colorspin_profile_data)); |
| 1067 EnableAutoResizeForTesting(min_size, max_size); | |
| 1068 } | 559 } |
| 1069 | 560 |
| 1070 void DisableAutoResizeMode(RenderView* render_view, const WebSize& new_size) { | 561 } // namespace gfx |
| 1071 static_cast<RenderViewImpl*>(render_view)-> | |
| 1072 DisableAutoResizeForTesting(new_size); | |
| 1073 } | |
| 1074 | |
| 1075 // Returns True if node1 < node2. | |
| 1076 bool HistoryEntryCompareLess(HistoryEntry::HistoryNode* node1, | |
| 1077 HistoryEntry::HistoryNode* node2) { | |
| 1078 base::string16 target1 = node1->item().target(); | |
| 1079 base::string16 target2 = node2->item().target(); | |
| 1080 return base::CompareCaseInsensitiveASCII(target1, target2) < 0; | |
| 1081 } | |
| 1082 | |
| 1083 std::string DumpHistoryItem(HistoryEntry::HistoryNode* node, | |
| 1084 int indent, | |
| 1085 bool is_current_index) { | |
| 1086 std::string result; | |
| 1087 | |
| 1088 const blink::WebHistoryItem& item = node->item(); | |
| 1089 if (is_current_index) { | |
| 1090 result.append("curr->"); | |
| 1091 result.append(indent - 6, ' '); // 6 == "curr->".length() | |
| 1092 } else { | |
| 1093 result.append(indent, ' '); | |
| 1094 } | |
| 1095 | |
| 1096 std::string url = | |
| 1097 test_runner::NormalizeLayoutTestURL(item.urlString().utf8()); | |
| 1098 result.append(url); | |
| 1099 if (!item.target().isEmpty()) { | |
| 1100 result.append(" (in frame \""); | |
| 1101 result.append(item.target().utf8()); | |
| 1102 result.append("\")"); | |
| 1103 } | |
| 1104 result.append("\n"); | |
| 1105 | |
| 1106 std::vector<HistoryEntry::HistoryNode*> children = node->children(); | |
| 1107 if (!children.empty()) { | |
| 1108 std::sort(children.begin(), children.end(), HistoryEntryCompareLess); | |
| 1109 for (size_t i = 0; i < children.size(); ++i) | |
| 1110 result += DumpHistoryItem(children[i], indent + 4, false); | |
| 1111 } | |
| 1112 | |
| 1113 return result; | |
| 1114 } | |
| 1115 | |
| 1116 std::string DumpBackForwardList(std::vector<PageState>& page_state, | |
| 1117 size_t current_index) { | |
| 1118 std::string result; | |
| 1119 result.append("\n============== Back Forward List ==============\n"); | |
| 1120 for (size_t index = 0; index < page_state.size(); ++index) { | |
| 1121 std::unique_ptr<HistoryEntry> entry( | |
| 1122 PageStateToHistoryEntry(page_state[index])); | |
| 1123 result.append( | |
| 1124 DumpHistoryItem(entry->root_history_node(), | |
| 1125 8, | |
| 1126 index == current_index)); | |
| 1127 } | |
| 1128 result.append("===============================================\n"); | |
| 1129 return result; | |
| 1130 } | |
| 1131 | |
| 1132 void SchedulerRunIdleTasks(const base::Closure& callback) { | |
| 1133 blink::scheduler::RendererScheduler* scheduler = | |
| 1134 content::RenderThreadImpl::current()->GetRendererScheduler(); | |
| 1135 blink::scheduler::RunIdleTasksForTesting(scheduler, callback); | |
| 1136 } | |
| 1137 | |
| 1138 void ForceTextInputStateUpdateForRenderFrame(RenderFrame* frame) { | |
| 1139 if (auto* render_widget = | |
| 1140 static_cast<RenderFrameImpl*>(frame)->GetRenderWidget()) { | |
| 1141 render_widget->UpdateTextInputState(ShowIme::IF_NEEDED, | |
| 1142 ChangeSource::FROM_NON_IME); | |
| 1143 } | |
| 1144 } | |
| 1145 | |
| 1146 } // namespace content | |
| OLD | NEW |