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

Side by Side Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 916893003: Add test_runner hook to dump drag image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check flag instead of drag_image_. Handle isNull case. Created 5 years, 10 months 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
« no previous file with comments | « content/shell/renderer/test_runner/web_test_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/test_runner/web_test_proxy.h" 5 #include "content/shell/renderer/test_runner/web_test_proxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 } 368 }
369 369
370 blink::WebView* WebTestProxyBase::GetWebView() const { 370 blink::WebView* WebTestProxyBase::GetWebView() const {
371 DCHECK(web_widget_); 371 DCHECK(web_widget_);
372 // TestRunner does not support popup widgets. So |web_widget|_ is always a 372 // TestRunner does not support popup widgets. So |web_widget|_ is always a
373 // WebView. 373 // WebView.
374 return static_cast<blink::WebView*>(web_widget_); 374 return static_cast<blink::WebView*>(web_widget_);
375 } 375 }
376 376
377 void WebTestProxyBase::Reset() { 377 void WebTestProxyBase::Reset() {
378 drag_image_.reset();
378 animate_scheduled_ = false; 379 animate_scheduled_ = false;
379 resource_identifier_map_.clear(); 380 resource_identifier_map_.clear();
380 log_console_output_ = true; 381 log_console_output_ = true;
381 if (midi_client_.get()) 382 if (midi_client_.get())
382 midi_client_->resetMock(); 383 midi_client_->resetMock();
383 accept_languages_ = ""; 384 accept_languages_ = "";
384 } 385 }
385 386
386 blink::WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const { 387 blink::WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const {
387 return spellcheck_.get(); 388 return spellcheck_.get();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 canvas.drawBitmap(bitmap, popup_position_.x(), popup_position_.y()); 559 canvas.drawBitmap(bitmap, popup_position_.x(), popup_position_.y());
559 callback_.Run(main_bitmap_); 560 callback_.Run(main_bitmap_);
560 delete this; 561 delete this;
561 } 562 }
562 563
563 void WebTestProxyBase::CapturePixelsAsync( 564 void WebTestProxyBase::CapturePixelsAsync(
564 const base::Callback<void(const SkBitmap&)>& callback) { 565 const base::Callback<void(const SkBitmap&)>& callback) {
565 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync"); 566 TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync");
566 DCHECK(!callback.is_null()); 567 DCHECK(!callback.is_null());
567 568
569 if (test_interfaces_->GetTestRunner()->shouldDumpDragImage()) {
570 if (drag_image_.isNull()) {
571 // This means the test called dumpDragImage but did not initiate a drag.
572 // Return a blank image so that the test fails.
573 SkBitmap bitmap;
574 bitmap.allocN32Pixels(1, 1);
575 {
576 SkAutoLockPixels lock(bitmap);
577 bitmap.eraseColor(0);
578 }
579 callback.Run(bitmap);
580 return;
581 }
582
583 callback.Run(drag_image_.getSkBitmap());
584 return;
585 }
586
568 if (test_interfaces_->GetTestRunner()->isPrinting()) { 587 if (test_interfaces_->GetTestRunner()->isPrinting()) {
569 base::MessageLoopProxy::current()->PostTask( 588 base::MessageLoopProxy::current()->PostTask(
570 FROM_HERE, 589 FROM_HERE,
571 base::Bind(&WebTestProxyBase::CapturePixelsForPrinting, 590 base::Bind(&WebTestProxyBase::CapturePixelsForPrinting,
572 base::Unretained(this), 591 base::Unretained(this),
573 callback)); 592 callback));
574 return; 593 return;
575 } 594 }
576 595
577 CaptureCallback* capture_callback = new CaptureCallback(base::Bind( 596 CaptureCallback* capture_callback = new CaptureCallback(base::Bind(
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 818
800 delegate_->PrintMessage(message + "\n"); 819 delegate_->PrintMessage(message + "\n");
801 } 820 }
802 } 821 }
803 822
804 void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame, 823 void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame,
805 const blink::WebDragData& data, 824 const blink::WebDragData& data,
806 blink::WebDragOperationsMask mask, 825 blink::WebDragOperationsMask mask,
807 const blink::WebImage& image, 826 const blink::WebImage& image,
808 const blink::WebPoint& point) { 827 const blink::WebPoint& point) {
828 if (test_interfaces_->GetTestRunner()->shouldDumpDragImage()) {
829 if (drag_image_.isNull())
830 drag_image_ = image;
831 }
809 // When running a test, we need to fake a drag drop operation otherwise 832 // When running a test, we need to fake a drag drop operation otherwise
810 // Windows waits for real mouse events to know when the drag is over. 833 // Windows waits for real mouse events to know when the drag is over.
811 test_interfaces_->GetEventSender()->DoDragDrop(data, mask); 834 test_interfaces_->GetEventSender()->DoDragDrop(data, mask);
812 } 835 }
813 836
814 // The output from these methods in layout test mode should match that 837 // The output from these methods in layout test mode should match that
815 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree. 838 // expected by the layout tests. See EditingDelegate.m in DumpRenderTree.
816 839
817 void WebTestProxyBase::DidChangeSelection(bool is_empty_callback) { 840 void WebTestProxyBase::DidChangeSelection(bool is_empty_callback) {
818 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks()) 841 if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks())
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 // to cancel the input method's ongoing composition session. 1336 // to cancel the input method's ongoing composition session.
1314 if (web_widget_) 1337 if (web_widget_)
1315 web_widget_->confirmComposition(); 1338 web_widget_->confirmComposition();
1316 } 1339 }
1317 1340
1318 blink::WebString WebTestProxyBase::acceptLanguages() { 1341 blink::WebString WebTestProxyBase::acceptLanguages() {
1319 return blink::WebString::fromUTF8(accept_languages_); 1342 return blink::WebString::fromUTF8(accept_languages_);
1320 } 1343 }
1321 1344
1322 } // namespace content 1345 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/web_test_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698