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/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/base64.h" | 9 #include "base/base64.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation.
h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation.
h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
43 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
Task.h" | 43 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
Task.h" |
| 44 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestInterfaces.h" |
44 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestProxy.h" | 45 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestProxy.h" |
| 46 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestRunner.h" |
45 #include "webkit/base/file_path_string_conversions.h" | 47 #include "webkit/base/file_path_string_conversions.h" |
46 #include "webkit/glue/webkit_glue.h" | 48 #include "webkit/glue/webkit_glue.h" |
47 #include "webkit/glue/webpreferences.h" | 49 #include "webkit/glue/webpreferences.h" |
48 | 50 |
49 using WebKit::Platform; | 51 using WebKit::Platform; |
50 using WebKit::WebContextMenuData; | 52 using WebKit::WebContextMenuData; |
51 using WebKit::WebDevToolsAgent; | 53 using WebKit::WebDevToolsAgent; |
52 using WebKit::WebDeviceOrientation; | 54 using WebKit::WebDeviceOrientation; |
53 using WebKit::WebElement; | 55 using WebKit::WebElement; |
54 using WebKit::WebFrame; | 56 using WebKit::WebFrame; |
55 using WebKit::WebGamepads; | 57 using WebKit::WebGamepads; |
56 using WebKit::WebRect; | 58 using WebKit::WebRect; |
57 using WebKit::WebSize; | 59 using WebKit::WebSize; |
58 using WebKit::WebString; | 60 using WebKit::WebString; |
59 using WebKit::WebURL; | 61 using WebKit::WebURL; |
60 using WebKit::WebURLError; | 62 using WebKit::WebURLError; |
61 using WebKit::WebVector; | 63 using WebKit::WebVector; |
62 using WebKit::WebView; | 64 using WebKit::WebView; |
63 using WebTestRunner::WebPreferences; | 65 using WebTestRunner::WebPreferences; |
64 using WebTestRunner::WebTask; | 66 using WebTestRunner::WebTask; |
| 67 using WebTestRunner::WebTestInterfaces; |
65 | 68 |
66 namespace content { | 69 namespace content { |
67 | 70 |
68 namespace { | 71 namespace { |
69 | 72 |
70 void InvokeTaskHelper(void* context) { | 73 void InvokeTaskHelper(void* context) { |
71 WebTask* task = reinterpret_cast<WebTask*>(context); | 74 WebTask* task = reinterpret_cast<WebTask*>(context); |
72 task->run(); | 75 task->run(); |
73 delete task; | 76 delete task; |
74 } | 77 } |
75 | 78 |
76 std::string DumpDocumentText(WebFrame* frame) { | |
77 // We use the document element's text instead of the body text here because | |
78 // not all documents have a body, such as XML documents. | |
79 WebElement documentElement = frame->document().documentElement(); | |
80 if (documentElement.isNull()) | |
81 return std::string(); | |
82 return documentElement.innerText().utf8(); | |
83 } | |
84 | |
85 std::string DumpDocumentPrintedText(WebFrame* frame) { | |
86 return frame->renderTreeAsText(WebFrame::RenderAsTextPrinting).utf8(); | |
87 } | |
88 | |
89 std::string DumpFramesAsText(WebFrame* frame, bool printing, bool recursive) { | |
90 std::string result; | |
91 | |
92 // Cannot do printed format for anything other than HTML. | |
93 if (printing && !frame->document().isHTMLDocument()) | |
94 return std::string(); | |
95 | |
96 // Add header for all but the main frame. Skip emtpy frames. | |
97 if (frame->parent() && !frame->document().documentElement().isNull()) { | |
98 result.append("\n--------\nFrame: '"); | |
99 result.append(frame->uniqueName().utf8().data()); | |
100 result.append("'\n--------\n"); | |
101 } | |
102 | |
103 result.append( | |
104 printing ? DumpDocumentPrintedText(frame) : DumpDocumentText(frame)); | |
105 result.append("\n"); | |
106 | |
107 if (recursive) { | |
108 for (WebFrame* child = frame->firstChild(); child; | |
109 child = child->nextSibling()) { | |
110 result.append(DumpFramesAsText(child, printing, recursive)); | |
111 } | |
112 } | |
113 return result; | |
114 } | |
115 | |
116 std::string DumpFrameScrollPosition(WebFrame* frame, bool recursive) { | |
117 std::string result; | |
118 | |
119 WebSize offset = frame->scrollOffset(); | |
120 if (offset.width > 0 || offset.height > 0) { | |
121 if (frame->parent()) { | |
122 result.append( | |
123 base::StringPrintf("frame '%s' ", frame->uniqueName().utf8().data())); | |
124 } | |
125 result.append( | |
126 base::StringPrintf("scrolled to %d,%d\n", offset.width, offset.height)); | |
127 } | |
128 | |
129 if (recursive) { | |
130 for (WebFrame* child = frame->firstChild(); child; | |
131 child = child->nextSibling()) { | |
132 result.append(DumpFrameScrollPosition(child, recursive)); | |
133 } | |
134 } | |
135 return result; | |
136 } | |
137 | |
138 #if !defined(OS_MACOSX) | 79 #if !defined(OS_MACOSX) |
139 void MakeBitmapOpaque(SkBitmap* bitmap) { | 80 void MakeBitmapOpaque(SkBitmap* bitmap) { |
140 SkAutoLockPixels lock(*bitmap); | 81 SkAutoLockPixels lock(*bitmap); |
141 DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); | 82 DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); |
142 for (int y = 0; y < bitmap->height(); ++y) { | 83 for (int y = 0; y < bitmap->height(); ++y) { |
143 uint32_t* row = bitmap->getAddr32(0, y); | 84 uint32_t* row = bitmap->getAddr32(0, y); |
144 for (int x = 0; x < bitmap->width(); ++x) | 85 for (int x = 0; x < bitmap->width(); ++x) |
145 row[x] |= 0xFF000000; // Set alpha bits to 1. | 86 row[x] |= 0xFF000000; // Set alpha bits to 1. |
146 } | 87 } |
147 } | 88 } |
(...skipping 10 matching lines...) Expand all Loading... |
158 #endif | 99 #endif |
159 | 100 |
160 } | 101 } |
161 | 102 |
162 } // namespace | 103 } // namespace |
163 | 104 |
164 // static | 105 // static |
165 int WebKitTestRunner::window_count_ = 0; | 106 int WebKitTestRunner::window_count_ = 0; |
166 | 107 |
167 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) | 108 WebKitTestRunner::WebKitTestRunner(RenderView* render_view) |
168 : RenderViewObserver(render_view) { | 109 : RenderViewObserver(render_view), |
| 110 is_main_window_(false) { |
169 Reset(); | 111 Reset(); |
170 ++window_count_; | 112 ++window_count_; |
171 } | 113 } |
172 | 114 |
173 WebKitTestRunner::~WebKitTestRunner() { | 115 WebKitTestRunner::~WebKitTestRunner() { |
174 --window_count_; | 116 --window_count_; |
175 } | 117 } |
176 | 118 |
177 // WebTestDelegate ----------------------------------------------------------- | 119 // WebTestDelegate ----------------------------------------------------------- |
178 | 120 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 routing_id(), "WebKitTestRunner", "setMockSpeechRecognitionError")); | 401 routing_id(), "WebKitTestRunner", "setMockSpeechRecognitionError")); |
460 } | 402 } |
461 | 403 |
462 bool WebKitTestRunner::wasMockSpeechRecognitionAborted() { | 404 bool WebKitTestRunner::wasMockSpeechRecognitionAborted() { |
463 Send(new ShellViewHostMsg_NotImplemented( | 405 Send(new ShellViewHostMsg_NotImplemented( |
464 routing_id(), "WebKitTestRunner", "wasMockSpeechRecognitionAborted")); | 406 routing_id(), "WebKitTestRunner", "wasMockSpeechRecognitionAborted")); |
465 return false; | 407 return false; |
466 } | 408 } |
467 | 409 |
468 void WebKitTestRunner::testFinished() { | 410 void WebKitTestRunner::testFinished() { |
| 411 if (!is_main_window_) |
| 412 return; |
| 413 WebTestInterfaces* interfaces = |
| 414 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
| 415 interfaces->setTestIsRunning(false); |
469 CaptureDump(); | 416 CaptureDump(); |
470 } | 417 } |
471 | 418 |
472 void WebKitTestRunner::testTimedOut() { | 419 void WebKitTestRunner::testTimedOut() { |
| 420 if (!is_main_window_) |
| 421 return; |
| 422 WebTestInterfaces* interfaces = |
| 423 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
| 424 interfaces->setTestIsRunning(false); |
473 Send(new ShellViewHostMsg_TestFinished(routing_id(), true)); | 425 Send(new ShellViewHostMsg_TestFinished(routing_id(), true)); |
474 } | 426 } |
475 | 427 |
476 bool WebKitTestRunner::isBeingDebugged() { | 428 bool WebKitTestRunner::isBeingDebugged() { |
477 return base::debug::BeingDebugged(); | 429 return base::debug::BeingDebugged(); |
478 } | 430 } |
479 | 431 |
480 int WebKitTestRunner::layoutTestTimeout() { | 432 int WebKitTestRunner::layoutTestTimeout() { |
481 return layout_test_timeout_; | 433 return layout_test_timeout_; |
482 } | 434 } |
483 | 435 |
484 void WebKitTestRunner::closeRemainingWindows() { | 436 void WebKitTestRunner::closeRemainingWindows() { |
485 Send(new ShellViewHostMsg_NotImplemented( | 437 Send(new ShellViewHostMsg_NotImplemented( |
486 routing_id(), "WebKitTestRunner", "closeRemainingWindows")); | 438 routing_id(), "WebKitTestRunner", "closeRemainingWindows")); |
487 } | 439 } |
488 | 440 |
489 int WebKitTestRunner::navigationEntryCount() { | 441 int WebKitTestRunner::navigationEntryCount() { |
490 Send(new ShellViewHostMsg_NotImplemented( | |
491 routing_id(), "WebKitTestRunner", "navigationEntryCount")); | |
492 return 0; | 442 return 0; |
493 } | 443 } |
494 | 444 |
495 int WebKitTestRunner::windowCount() { | 445 int WebKitTestRunner::windowCount() { |
496 return window_count_; | 446 return window_count_; |
497 } | 447 } |
498 | 448 |
499 void WebKitTestRunner::goToOffset(int offset) { | 449 void WebKitTestRunner::goToOffset(int offset) { |
500 Send(new ShellViewHostMsg_NotImplemented( | 450 Send(new ShellViewHostMsg_NotImplemented( |
501 routing_id(), "WebKitTestRunner", "goToOffset")); | 451 routing_id(), "WebKitTestRunner", "goToOffset")); |
(...skipping 21 matching lines...) Expand all Loading... |
523 Send(new ShellViewHostMsg_NotImplemented( | 473 Send(new ShellViewHostMsg_NotImplemented( |
524 routing_id(), "WebKitTestRunner", "captureHistoryForWindow")); | 474 routing_id(), "WebKitTestRunner", "captureHistoryForWindow")); |
525 } | 475 } |
526 | 476 |
527 // RenderViewObserver -------------------------------------------------------- | 477 // RenderViewObserver -------------------------------------------------------- |
528 | 478 |
529 void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { | 479 void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) { |
530 ShellRenderProcessObserver::GetInstance()->BindTestRunnersToWindow(frame); | 480 ShellRenderProcessObserver::GetInstance()->BindTestRunnersToWindow(frame); |
531 } | 481 } |
532 | 482 |
533 void WebKitTestRunner::DidFinishLoad(WebFrame* frame) { | |
534 if (!frame->parent()) { | |
535 if (!wait_until_done_) { | |
536 test_is_running_ = false; | |
537 CaptureDump(); | |
538 } | |
539 load_finished_ = true; | |
540 } | |
541 } | |
542 | |
543 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { | 483 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { |
544 bool handled = true; | 484 bool handled = true; |
545 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) | 485 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) |
546 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, | 486 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, |
547 OnSetTestConfiguration) | 487 OnSetTestConfiguration) |
548 IPC_MESSAGE_UNHANDLED(handled = false) | 488 IPC_MESSAGE_UNHANDLED(handled = false) |
549 IPC_END_MESSAGE_MAP() | 489 IPC_END_MESSAGE_MAP() |
550 | 490 |
551 return handled; | 491 return handled; |
552 } | 492 } |
553 | 493 |
554 // Public methods - ----------------------------------------------------------- | 494 // Public methods - ----------------------------------------------------------- |
555 | 495 |
556 void WebKitTestRunner::NotifyDone() { | |
557 if (load_finished_) { | |
558 test_is_running_ = false; | |
559 CaptureDump(); | |
560 } else { | |
561 wait_until_done_ = false; | |
562 } | |
563 } | |
564 | |
565 void WebKitTestRunner::DumpAsText() { | |
566 dump_as_text_ = true; | |
567 } | |
568 | |
569 void WebKitTestRunner::DumpChildFramesAsText() { | |
570 dump_child_frames_as_text_ = true; | |
571 } | |
572 | |
573 void WebKitTestRunner::WaitUntilDone() { | |
574 wait_until_done_ = true; | |
575 } | |
576 | |
577 void WebKitTestRunner::OverridePreference(const std::string& key, | |
578 v8::Local<v8::Value> value) { | |
579 if (key == "WebKitDefaultFontSize") { | |
580 prefs_.defaultFontSize = value->Int32Value(); | |
581 } else if (key == "WebKitMinimumFontSize") { | |
582 prefs_.minimumFontSize = value->Int32Value(); | |
583 } else if (key == "WebKitDefaultTextEncodingName") { | |
584 prefs_.defaultTextEncodingName = | |
585 WebString::fromUTF8(std::string(*v8::String::AsciiValue(value))); | |
586 } else if (key == "WebKitJavaScriptEnabled") { | |
587 prefs_.javaScriptEnabled = value->BooleanValue(); | |
588 } else if (key == "WebKitSupportsMultipleWindows") { | |
589 prefs_.supportsMultipleWindows = value->BooleanValue(); | |
590 } else if (key == "WebKitDisplayImagesKey") { | |
591 prefs_.loadsImagesAutomatically = value->BooleanValue(); | |
592 } else if (key == "WebKitPluginsEnabled") { | |
593 prefs_.pluginsEnabled = value->BooleanValue(); | |
594 } else if (key == "WebKitJavaEnabled") { | |
595 prefs_.javaEnabled = value->BooleanValue(); | |
596 } else if (key == "WebKitUsesPageCachePreferenceKey") { | |
597 prefs_.usesPageCache = value->BooleanValue(); | |
598 } else if (key == "WebKitPageCacheSupportsPluginsPreferenceKey") { | |
599 prefs_.pageCacheSupportsPlugins = value->BooleanValue(); | |
600 } else if (key == "WebKitOfflineWebApplicationCacheEnabled") { | |
601 prefs_.offlineWebApplicationCacheEnabled = value->BooleanValue(); | |
602 } else if (key == "WebKitTabToLinksPreferenceKey") { | |
603 prefs_.tabsToLinks = value->BooleanValue(); | |
604 } else if (key == "WebKitWebGLEnabled") { | |
605 prefs_.experimentalWebGLEnabled = value->BooleanValue(); | |
606 } else if (key == "WebKitCSSRegionsEnabled") { | |
607 prefs_.experimentalCSSRegionsEnabled = value->BooleanValue(); | |
608 } else if (key == "WebKitCSSGridLayoutEnabled") { | |
609 prefs_.experimentalCSSGridLayoutEnabled = value->BooleanValue(); | |
610 } else if (key == "WebKitHyperlinkAuditingEnabled") { | |
611 prefs_.hyperlinkAuditingEnabled = value->BooleanValue(); | |
612 } else if (key == "WebKitEnableCaretBrowsing") { | |
613 prefs_.caretBrowsingEnabled = value->BooleanValue(); | |
614 } else if (key == "WebKitAllowDisplayingInsecureContent") { | |
615 prefs_.allowDisplayOfInsecureContent = value->BooleanValue(); | |
616 } else if (key == "WebKitAllowRunningInsecureContent") { | |
617 prefs_.allowRunningOfInsecureContent = value->BooleanValue(); | |
618 } else if (key == "WebKitCSSCustomFilterEnabled") { | |
619 prefs_.cssCustomFilterEnabled = value->BooleanValue(); | |
620 } else if (key == "WebKitShouldRespectImageOrientation") { | |
621 prefs_.shouldRespectImageOrientation = value->BooleanValue(); | |
622 } else if (key == "WebKitWebAudioEnabled") { | |
623 DCHECK(value->BooleanValue()); | |
624 } else { | |
625 std::string message("CONSOLE MESSAGE: Invalid name for preference: "); | |
626 printMessage(message + key + "\n"); | |
627 } | |
628 applyPreferences(); | |
629 } | |
630 | |
631 void WebKitTestRunner::NotImplemented(const std::string& object, | |
632 const std::string& method) { | |
633 Send(new ShellViewHostMsg_NotImplemented(routing_id(), object, method)); | |
634 } | |
635 | |
636 void WebKitTestRunner::Reset() { | 496 void WebKitTestRunner::Reset() { |
637 prefs_.reset(); | 497 prefs_.reset(); |
638 webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); | 498 webkit_glue::WebPreferences prefs = render_view()->GetWebkitPreferences(); |
639 ExportLayoutTestSpecificPreferences(prefs_, &prefs); | 499 ExportLayoutTestSpecificPreferences(prefs_, &prefs); |
640 render_view()->SetWebkitPreferences(prefs); | 500 render_view()->SetWebkitPreferences(prefs); |
641 test_is_running_ = true; | |
642 load_finished_ = false; | |
643 wait_until_done_ = false; | |
644 dump_as_text_ = false; | |
645 dump_child_frames_as_text_ = false; | |
646 printing_ = false; | |
647 enable_pixel_dumping_ = true; | 501 enable_pixel_dumping_ = true; |
648 layout_test_timeout_ = 30 * 1000; | 502 layout_test_timeout_ = 30 * 1000; |
649 allow_external_pages_ = false; | 503 allow_external_pages_ = false; |
650 expected_pixel_hash_ = std::string(); | 504 expected_pixel_hash_ = std::string(); |
651 } | 505 } |
652 | 506 |
653 // Private methods ----------------------------------------------------------- | 507 // Private methods ----------------------------------------------------------- |
654 | 508 |
655 void WebKitTestRunner::CaptureDump() { | 509 void WebKitTestRunner::CaptureDump() { |
656 std::string mime_type = render_view()->GetWebView()->mainFrame()->dataSource() | 510 WebTestInterfaces* interfaces = |
657 ->response().mimeType().utf8(); | 511 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
658 if (mime_type == "text/plain") { | 512 |
659 dump_as_text_ = true; | 513 Send( |
660 enable_pixel_dumping_ = false; | 514 new ShellViewHostMsg_TextDump(routing_id(), proxy()->captureTree(false))); |
| 515 |
| 516 if (interfaces->testRunner()->shouldGeneratePixelResults()) { |
| 517 SkBitmap snapshot; |
| 518 CopyCanvasToBitmap(proxy()->capturePixels(), &snapshot); |
| 519 |
| 520 SkAutoLockPixels snapshot_lock(snapshot); |
| 521 base::MD5Digest digest; |
| 522 #if defined(OS_ANDROID) |
| 523 // On Android, pixel layout is RGBA, however, other Chrome platforms use |
| 524 // BGRA. |
| 525 const uint8_t* raw_pixels = |
| 526 reinterpret_cast<const uint8_t*>(snapshot.getPixels()); |
| 527 size_t snapshot_size = snapshot.getSize(); |
| 528 scoped_array<uint8_t> reordered_pixels(new uint8_t[snapshot_size]); |
| 529 for (size_t i = 0; i < snapshot_size; i += 4) { |
| 530 reordered_pixels[i] = raw_pixels[i + 2]; |
| 531 reordered_pixels[i + 1] = raw_pixels[i + 1]; |
| 532 reordered_pixels[i + 2] = raw_pixels[i]; |
| 533 reordered_pixels[i + 3] = raw_pixels[i + 3]; |
| 534 } |
| 535 base::MD5Sum(reordered_pixels.get(), snapshot_size, &digest); |
| 536 #else |
| 537 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); |
| 538 #endif |
| 539 std::string actual_pixel_hash = base::MD5DigestToBase16(digest); |
| 540 |
| 541 if (actual_pixel_hash == expected_pixel_hash_) { |
| 542 SkBitmap empty_image; |
| 543 Send(new ShellViewHostMsg_ImageDump( |
| 544 routing_id(), actual_pixel_hash, empty_image)); |
| 545 } else { |
| 546 Send(new ShellViewHostMsg_ImageDump( |
| 547 routing_id(), actual_pixel_hash, snapshot)); |
| 548 } |
661 } | 549 } |
662 CaptureTextDump(); | 550 |
663 if (enable_pixel_dumping_) | |
664 CaptureImageDump(); | |
665 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); | 551 Send(new ShellViewHostMsg_TestFinished(routing_id(), false)); |
666 } | 552 } |
667 | 553 |
668 void WebKitTestRunner::CaptureTextDump() { | |
669 WebFrame* frame = render_view()->GetWebView()->mainFrame(); | |
670 std::string dump; | |
671 if (dump_as_text_) { | |
672 dump = DumpFramesAsText(frame, printing_, dump_child_frames_as_text_); | |
673 } else { | |
674 WebFrame::RenderAsTextControls render_text_behavior = | |
675 WebFrame::RenderAsTextNormal; | |
676 if (printing_) | |
677 render_text_behavior |= WebFrame::RenderAsTextPrinting; | |
678 dump = frame->renderTreeAsText(render_text_behavior).utf8(); | |
679 dump.append(DumpFrameScrollPosition(frame, dump_child_frames_as_text_)); | |
680 } | |
681 Send(new ShellViewHostMsg_TextDump(routing_id(), dump)); | |
682 } | |
683 | |
684 void WebKitTestRunner::CaptureImageDump() { | |
685 SkBitmap empty_image; | |
686 Send(new ShellViewHostMsg_ImageDump( | |
687 routing_id(), expected_pixel_hash_, empty_image)); | |
688 } | |
689 | |
690 void WebKitTestRunner::OnSetTestConfiguration( | 554 void WebKitTestRunner::OnSetTestConfiguration( |
691 const base::FilePath& current_working_directory, | 555 const base::FilePath& current_working_directory, |
692 bool enable_pixel_dumping, | 556 bool enable_pixel_dumping, |
693 int layout_test_timeout, | 557 int layout_test_timeout, |
694 bool allow_external_pages, | 558 bool allow_external_pages, |
695 const std::string& expected_pixel_hash) { | 559 const std::string& expected_pixel_hash) { |
696 current_working_directory_ = current_working_directory; | 560 current_working_directory_ = current_working_directory; |
697 enable_pixel_dumping_ = enable_pixel_dumping; | 561 enable_pixel_dumping_ = enable_pixel_dumping; |
698 layout_test_timeout_ = layout_test_timeout; | 562 layout_test_timeout_ = layout_test_timeout; |
699 allow_external_pages_ = allow_external_pages; | 563 allow_external_pages_ = allow_external_pages; |
700 expected_pixel_hash_ = expected_pixel_hash; | 564 expected_pixel_hash_ = expected_pixel_hash; |
| 565 is_main_window_ = true; |
| 566 |
| 567 WebTestInterfaces* interfaces = |
| 568 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
| 569 interfaces->setTestIsRunning(true); |
| 570 interfaces->configureForTestWithURL( |
| 571 net::FilePathToFileURL(current_working_directory), enable_pixel_dumping); |
701 } | 572 } |
702 | 573 |
703 } // namespace content | 574 } // namespace content |
OLD | NEW |