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 <algorithm> | 7 #include <algorithm> |
8 #include <clocale> | 8 #include <clocale> |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBufferView.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebArrayBufferView.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation. h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation. h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | |
50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h" |
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
52 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web Task.h" | 53 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web Task.h" |
53 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h" | 54 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestInterfaces.h" |
54 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h" | 55 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h" |
55 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestRunner.h" | 56 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestRunner.h" |
56 #include "ui/gfx/rect.h" | 57 #include "ui/gfx/rect.h" |
57 #include "webkit/base/file_path_string_conversions.h" | 58 #include "webkit/base/file_path_string_conversions.h" |
58 #include "webkit/glue/glue_serialize.h" | 59 #include "webkit/glue/glue_serialize.h" |
59 #include "webkit/glue/webkit_glue.h" | 60 #include "webkit/glue/webkit_glue.h" |
60 #include "webkit/glue/webpreferences.h" | 61 #include "webkit/glue/webpreferences.h" |
61 #include "webkit/mocks/test_media_stream_client.h" | 62 #include "webkit/mocks/test_media_stream_client.h" |
62 | 63 |
63 using WebKit::Platform; | 64 using WebKit::Platform; |
64 using WebKit::WebArrayBufferView; | 65 using WebKit::WebArrayBufferView; |
65 using WebKit::WebContextMenuData; | 66 using WebKit::WebContextMenuData; |
66 using WebKit::WebDevToolsAgent; | 67 using WebKit::WebDevToolsAgent; |
67 using WebKit::WebDeviceOrientation; | 68 using WebKit::WebDeviceOrientation; |
68 using WebKit::WebElement; | 69 using WebKit::WebElement; |
69 using WebKit::WebFrame; | 70 using WebKit::WebFrame; |
70 using WebKit::WebGamepads; | 71 using WebKit::WebGamepads; |
71 using WebKit::WebHistoryItem; | 72 using WebKit::WebHistoryItem; |
72 using WebKit::WebMediaPlayer; | 73 using WebKit::WebMediaPlayer; |
73 using WebKit::WebMediaPlayerClient; | 74 using WebKit::WebMediaPlayerClient; |
74 using WebKit::WebPoint; | 75 using WebKit::WebPoint; |
75 using WebKit::WebRect; | 76 using WebKit::WebRect; |
77 using WebKit::WebScriptSource; | |
76 using WebKit::WebSize; | 78 using WebKit::WebSize; |
77 using WebKit::WebString; | 79 using WebKit::WebString; |
78 using WebKit::WebURL; | 80 using WebKit::WebURL; |
79 using WebKit::WebURLError; | 81 using WebKit::WebURLError; |
80 using WebKit::WebURLRequest; | 82 using WebKit::WebURLRequest; |
81 using WebKit::WebTestingSupport; | 83 using WebKit::WebTestingSupport; |
82 using WebKit::WebVector; | 84 using WebKit::WebVector; |
83 using WebKit::WebView; | 85 using WebKit::WebView; |
84 using WebTestRunner::WebPreferences; | 86 using WebTestRunner::WebPreferences; |
85 using WebTestRunner::WebTask; | 87 using WebTestRunner::WebTask; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 result.substr(strlen("file:////")); | 400 result.substr(strlen("file:////")); |
399 } | 401 } |
400 return rewriteLayoutTestsURL(result).spec(); | 402 return rewriteLayoutTestsURL(result).spec(); |
401 } | 403 } |
402 | 404 |
403 void WebKitTestRunner::setLocale(const std::string& locale) { | 405 void WebKitTestRunner::setLocale(const std::string& locale) { |
404 setlocale(LC_ALL, locale.c_str()); | 406 setlocale(LC_ALL, locale.c_str()); |
405 } | 407 } |
406 | 408 |
407 void WebKitTestRunner::testFinished() { | 409 void WebKitTestRunner::testFinished() { |
408 if (!is_main_window_) | 410 if (!is_main_window_) { |
411 Send(new ShellViewHostMsg_TestFinishedInSecondaryWindow(routing_id())); | |
409 return; | 412 return; |
413 } | |
410 WebTestInterfaces* interfaces = | 414 WebTestInterfaces* interfaces = |
411 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 415 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
412 interfaces->setTestIsRunning(false); | 416 interfaces->setTestIsRunning(false); |
413 if (interfaces->testRunner()->shouldDumpBackForwardList()) { | 417 if (interfaces->testRunner()->shouldDumpBackForwardList()) { |
414 SyncNavigationStateVisitor visitor; | 418 SyncNavigationStateVisitor visitor; |
415 RenderView::ForEach(&visitor); | 419 RenderView::ForEach(&visitor); |
416 Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id())); | 420 Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id())); |
417 } else { | 421 } else { |
418 CaptureDump(); | 422 CaptureDump(); |
419 } | 423 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); | 514 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); |
511 } | 515 } |
512 | 516 |
513 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { | 517 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { |
514 bool handled = true; | 518 bool handled = true; |
515 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) | 519 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) |
516 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, | 520 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, |
517 OnSetTestConfiguration) | 521 OnSetTestConfiguration) |
518 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) | 522 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) |
519 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) | 523 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) |
524 IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone) | |
520 IPC_MESSAGE_UNHANDLED(handled = false) | 525 IPC_MESSAGE_UNHANDLED(handled = false) |
521 IPC_END_MESSAGE_MAP() | 526 IPC_END_MESSAGE_MAP() |
522 | 527 |
523 return handled; | 528 return handled; |
524 } | 529 } |
525 | 530 |
526 void WebKitTestRunner::Navigate(const GURL& url) { | 531 void WebKitTestRunner::Navigate(const GURL& url) { |
532 | |
Mike West
2013/04/08 13:50:50
Nit: Extra newline.
| |
527 focus_on_next_commit_ = true; | 533 focus_on_next_commit_ = true; |
534 if (!is_main_window_ && | |
535 ShellRenderProcessObserver::GetInstance()->main_test_runner() == this) { | |
536 WebTestInterfaces* interfaces = | |
537 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | |
538 interfaces->setTestIsRunning(true); | |
539 interfaces->configureForTestWithURL(GURL(), false); | |
Mike West
2013/04/08 13:50:50
When does this kick in? I don't understand when th
jochen (gone - plz use gerrit)
2013/04/08 13:53:40
The main test runner is per process, while the mai
| |
540 } | |
528 } | 541 } |
529 | 542 |
530 void WebKitTestRunner::DidCommitProvisionalLoad(WebFrame* frame, | 543 void WebKitTestRunner::DidCommitProvisionalLoad(WebFrame* frame, |
531 bool is_new_navigation) { | 544 bool is_new_navigation) { |
532 if (!focus_on_next_commit_) | 545 if (!focus_on_next_commit_) |
533 return; | 546 return; |
534 focus_on_next_commit_ = false; | 547 focus_on_next_commit_ = false; |
535 render_view()->GetWebView()->setFocusedFrame(frame); | 548 render_view()->GetWebView()->setFocusedFrame(frame); |
536 } | 549 } |
537 | 550 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 void WebKitTestRunner::OnReset() { | 667 void WebKitTestRunner::OnReset() { |
655 ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll(); | 668 ShellRenderProcessObserver::GetInstance()->test_interfaces()->resetAll(); |
656 Reset(); | 669 Reset(); |
657 // Navigating to about:blank will make sure that no new loads are initiated | 670 // Navigating to about:blank will make sure that no new loads are initiated |
658 // by the renderer. | 671 // by the renderer. |
659 render_view()->GetWebView()->mainFrame() | 672 render_view()->GetWebView()->mainFrame() |
660 ->loadRequest(WebURLRequest(GURL("about:blank"))); | 673 ->loadRequest(WebURLRequest(GURL("about:blank"))); |
661 Send(new ShellViewHostMsg_ResetDone(routing_id())); | 674 Send(new ShellViewHostMsg_ResetDone(routing_id())); |
662 } | 675 } |
663 | 676 |
677 void WebKitTestRunner::OnNotifyDone() { | |
678 render_view()->GetWebView()->mainFrame()->executeScript( | |
679 WebScriptSource(WebString::fromUTF8("testRunner.notifyDone();"))); | |
680 } | |
681 | |
664 } // namespace content | 682 } // namespace content |
OLD | NEW |