Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: content/shell/webkit_test_runner.cc

Issue 11416177: [content shell] change how the main render view is picked for layout tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/webkit_test_runner.h ('k') | content/shell/webkit_test_runner_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/shell/webkit_test_runner.h" 5 #include "content/shell/webkit_test_runner.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Only the expected PNGs for Mac have a valid alpha channel. 137 // Only the expected PNGs for Mac have a valid alpha channel.
138 MakeBitmapOpaque(snapshot); 138 MakeBitmapOpaque(snapshot);
139 #endif 139 #endif
140 140
141 } 141 }
142 142
143 } // namespace 143 } // namespace
144 144
145 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) 145 WebKitTestRunner::WebKitTestRunner(RenderView* render_view)
146 : RenderViewObserver(render_view), 146 : RenderViewObserver(render_view),
147 RenderViewObserverTracker<WebKitTestRunner>(render_view), 147 RenderViewObserverTracker<WebKitTestRunner>(render_view) {
148 is_main_window_(false) {
149 } 148 }
150 149
151 WebKitTestRunner::~WebKitTestRunner() { 150 WebKitTestRunner::~WebKitTestRunner() {
152 if (is_main_window_)
153 ShellRenderProcessObserver::GetInstance()->SetMainWindow(NULL, this);
154 } 151 }
155 152
156 // WebTestDelegate ----------------------------------------------------------- 153 // WebTestDelegate -----------------------------------------------------------
157 154
158 void WebKitTestRunner::clearContextMenuData() { 155 void WebKitTestRunner::clearContextMenuData() {
159 last_context_menu_data_.reset(); 156 last_context_menu_data_.reset();
160 } 157 }
161 158
162 WebContextMenuData* WebKitTestRunner::lastContextMenuData() const { 159 WebContextMenuData* WebKitTestRunner::lastContextMenuData() const {
163 return last_context_menu_data_.get(); 160 return last_context_menu_data_.get();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 last_context_menu_data_.reset(new WebContextMenuData(data)); 249 last_context_menu_data_.reset(new WebContextMenuData(data));
253 } 250 }
254 251
255 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { 252 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) {
256 bool handled = true; 253 bool handled = true;
257 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) 254 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message)
258 IPC_MESSAGE_HANDLER(ShellViewMsg_CaptureTextDump, OnCaptureTextDump) 255 IPC_MESSAGE_HANDLER(ShellViewMsg_CaptureTextDump, OnCaptureTextDump)
259 IPC_MESSAGE_HANDLER(ShellViewMsg_CaptureImageDump, OnCaptureImageDump) 256 IPC_MESSAGE_HANDLER(ShellViewMsg_CaptureImageDump, OnCaptureImageDump)
260 IPC_MESSAGE_HANDLER(ShellViewMsg_SetCurrentWorkingDirectory, 257 IPC_MESSAGE_HANDLER(ShellViewMsg_SetCurrentWorkingDirectory,
261 OnSetCurrentWorkingDirectory) 258 OnSetCurrentWorkingDirectory)
262 IPC_MESSAGE_HANDLER(ShellViewMsg_SetIsMainWindow, OnSetIsMainWindow)
263 IPC_MESSAGE_UNHANDLED(handled = false) 259 IPC_MESSAGE_UNHANDLED(handled = false)
264 IPC_END_MESSAGE_MAP() 260 IPC_END_MESSAGE_MAP()
265 261
266 return handled; 262 return handled;
267 } 263 }
268 264
269 // Public methods - ----------------------------------------------------------- 265 // Public methods - -----------------------------------------------------------
270 266
271 void WebKitTestRunner::Display() { 267 void WebKitTestRunner::Display() {
272 const WebSize& size = render_view()->GetWebView()->size(); 268 const WebSize& size = render_view()->GetWebView()->size();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 326 }
331 Send(new ShellViewHostMsg_ImageDump( 327 Send(new ShellViewHostMsg_ImageDump(
332 routing_id(), actual_pixel_hash, snapshot)); 328 routing_id(), actual_pixel_hash, snapshot));
333 } 329 }
334 330
335 void WebKitTestRunner::OnSetCurrentWorkingDirectory( 331 void WebKitTestRunner::OnSetCurrentWorkingDirectory(
336 const FilePath& current_working_directory) { 332 const FilePath& current_working_directory) {
337 current_working_directory_ = current_working_directory; 333 current_working_directory_ = current_working_directory;
338 } 334 }
339 335
340 void WebKitTestRunner::OnSetIsMainWindow() {
341 is_main_window_ = true;
342 ShellRenderProcessObserver::GetInstance()->SetMainWindow(render_view(), this);
343 }
344
345 SkCanvas* WebKitTestRunner::GetCanvas() { 336 SkCanvas* WebKitTestRunner::GetCanvas() {
346 WebView* view = render_view()->GetWebView(); 337 WebView* view = render_view()->GetWebView();
347 const WebSize& size = view->size(); 338 const WebSize& size = view->size();
348 float device_scale_factor = view->deviceScaleFactor(); 339 float device_scale_factor = view->deviceScaleFactor();
349 int width = std::ceil(device_scale_factor * size.width); 340 int width = std::ceil(device_scale_factor * size.width);
350 int height = std::ceil(device_scale_factor * size.height); 341 int height = std::ceil(device_scale_factor * size.height);
351 342
352 if (canvas_ && 343 if (canvas_ &&
353 canvas_->getDeviceSize().width() == width && 344 canvas_->getDeviceSize().width() == width &&
354 canvas_->getDeviceSize().height() == height) { 345 canvas_->getDeviceSize().height() == height) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 PaintRect(rect); 392 PaintRect(rect);
402 } 393 }
403 CHECK(proxy_->paintRect().isEmpty()); 394 CHECK(proxy_->paintRect().isEmpty());
404 } 395 }
405 396
406 void WebKitTestRunner::DisplayRepaintMask() { 397 void WebKitTestRunner::DisplayRepaintMask() {
407 GetCanvas()->drawARGB(167, 0, 0, 0); 398 GetCanvas()->drawARGB(167, 0, 0, 0);
408 } 399 }
409 400
410 } // namespace content 401 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/webkit_test_runner.h ('k') | content/shell/webkit_test_runner_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698