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/renderer/webkit_test_runner.h" | 5 #include "content/shell/renderer/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 12 matching lines...) Expand all Loading... | |
23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
25 #include "content/public/common/web_preferences.h" | 25 #include "content/public/common/web_preferences.h" |
26 #include "content/public/renderer/render_view.h" | 26 #include "content/public/renderer/render_view.h" |
27 #include "content/public/renderer/render_view_visitor.h" | 27 #include "content/public/renderer/render_view_visitor.h" |
28 #include "content/public/test/layouttest_support.h" | 28 #include "content/public/test/layouttest_support.h" |
29 #include "content/shell/common/shell_messages.h" | 29 #include "content/shell/common/shell_messages.h" |
30 #include "content/shell/common/shell_switches.h" | 30 #include "content/shell/common/shell_switches.h" |
31 #include "content/shell/common/webkit_test_helpers.h" | 31 #include "content/shell/common/webkit_test_helpers.h" |
32 #include "content/shell/renderer/gc_controller.h" | 32 #include "content/shell/renderer/gc_controller.h" |
33 #include "content/shell/renderer/ipc_echo.h" | |
33 #include "content/shell/renderer/leak_detector.h" | 34 #include "content/shell/renderer/leak_detector.h" |
34 #include "content/shell/renderer/shell_render_process_observer.h" | 35 #include "content/shell/renderer/shell_render_process_observer.h" |
35 #include "content/shell/renderer/test_runner/WebTask.h" | 36 #include "content/shell/renderer/test_runner/WebTask.h" |
36 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" | 37 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" |
37 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" | 38 #include "content/shell/renderer/test_runner/mock_screen_orientation_client.h" |
38 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 39 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
39 #include "content/shell/renderer/test_runner/web_test_runner.h" | 40 #include "content/shell/renderer/test_runner/web_test_runner.h" |
40 #include "net/base/filename_util.h" | 41 #include "net/base/filename_util.h" |
41 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
42 #include "skia/ext/platform_canvas.h" | 43 #include "skia/ext/platform_canvas.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 } | 556 } |
556 | 557 |
557 if (id == routing_ids_.end()) { | 558 if (id == routing_ids_.end()) { |
558 NOTREACHED(); | 559 NOTREACHED(); |
559 return std::string(); | 560 return std::string(); |
560 } | 561 } |
561 return DumpBackForwardList(session_histories_[pos], | 562 return DumpBackForwardList(session_histories_[pos], |
562 current_entry_indexes_[pos]); | 563 current_entry_indexes_[pos]); |
563 } | 564 } |
564 | 565 |
566 void WebKitTestRunner::requestEcho(int id, int size) { | |
567 if (!ipc_echo_) { | |
568 RenderView* view = render_view(); | |
569 ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(), | |
570 view, view->GetRoutingID())); | |
571 } | |
572 | |
573 ipc_echo_->RequestEcho(id, size); | |
574 } | |
575 | |
576 int WebKitTestRunner::lastEchoId() { | |
577 DCHECK(ipc_echo_); | |
sof
2014/08/16 15:45:52
This is an unsound assumption. For code that trave
| |
578 return ipc_echo_->last_echo_id(); | |
579 } | |
580 | |
581 int WebKitTestRunner::lastEchoSize() { | |
582 DCHECK(ipc_echo_); | |
583 return ipc_echo_->last_echo_size(); | |
584 } | |
585 | |
565 // RenderViewObserver -------------------------------------------------------- | 586 // RenderViewObserver -------------------------------------------------------- |
566 | 587 |
567 void WebKitTestRunner::DidClearWindowObject(WebLocalFrame* frame) { | 588 void WebKitTestRunner::DidClearWindowObject(WebLocalFrame* frame) { |
568 WebTestingSupport::injectInternalsObject(frame); | 589 WebTestingSupport::injectInternalsObject(frame); |
569 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); | 590 ShellRenderProcessObserver::GetInstance()->test_interfaces()->bindTo(frame); |
570 GCController::Install(frame); | 591 GCController::Install(frame); |
571 } | 592 } |
572 | 593 |
573 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { | 594 bool WebKitTestRunner::OnMessageReceived(const IPC::Message& message) { |
574 bool handled = true; | 595 bool handled = true; |
575 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) | 596 IPC_BEGIN_MESSAGE_MAP(WebKitTestRunner, message) |
597 IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong) | |
576 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, | 598 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, |
577 OnSetTestConfiguration) | 599 OnSetTestConfiguration) |
578 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) | 600 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) |
579 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) | 601 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) |
580 IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone) | 602 IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone) |
581 IPC_MESSAGE_HANDLER(ShellViewMsg_TryLeakDetection, OnTryLeakDetection) | 603 IPC_MESSAGE_HANDLER(ShellViewMsg_TryLeakDetection, OnTryLeakDetection) |
582 IPC_MESSAGE_UNHANDLED(handled = false) | 604 IPC_MESSAGE_UNHANDLED(handled = false) |
583 IPC_END_MESSAGE_MAP() | 605 IPC_END_MESSAGE_MAP() |
584 | 606 |
585 return handled; | 607 return handled; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 void WebKitTestRunner::CaptureDumpComplete() { | 707 void WebKitTestRunner::CaptureDumpComplete() { |
686 render_view()->GetWebView()->mainFrame()->stopLoading(); | 708 render_view()->GetWebView()->mainFrame()->stopLoading(); |
687 | 709 |
688 base::MessageLoop::current()->PostTask( | 710 base::MessageLoop::current()->PostTask( |
689 FROM_HERE, | 711 FROM_HERE, |
690 base::Bind(base::IgnoreResult(&WebKitTestRunner::Send), | 712 base::Bind(base::IgnoreResult(&WebKitTestRunner::Send), |
691 base::Unretained(this), | 713 base::Unretained(this), |
692 new ShellViewHostMsg_TestFinished(routing_id()))); | 714 new ShellViewHostMsg_TestFinished(routing_id()))); |
693 } | 715 } |
694 | 716 |
717 void WebKitTestRunner::OnEchoPong(int id, const std::string& body) { | |
718 ipc_echo_->DidRespondEcho(id, body.size()); | |
719 } | |
720 | |
695 void WebKitTestRunner::OnSetTestConfiguration( | 721 void WebKitTestRunner::OnSetTestConfiguration( |
696 const ShellTestConfiguration& params) { | 722 const ShellTestConfiguration& params) { |
697 test_config_ = params; | 723 test_config_ = params; |
698 is_main_window_ = true; | 724 is_main_window_ = true; |
699 | 725 |
700 ForceResizeRenderView( | 726 ForceResizeRenderView( |
701 render_view(), | 727 render_view(), |
702 WebSize(params.initial_size.width(), params.initial_size.height())); | 728 WebSize(params.initial_size.width(), params.initial_size.height())); |
703 setFocus(proxy_, true); | 729 setFocus(proxy_, true); |
704 | 730 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 | 768 |
743 leak_detector_->TryLeakDetection(main_frame); | 769 leak_detector_->TryLeakDetection(main_frame); |
744 } | 770 } |
745 | 771 |
746 void WebKitTestRunner::ReportLeakDetectionResult( | 772 void WebKitTestRunner::ReportLeakDetectionResult( |
747 const LeakDetectionResult& report) { | 773 const LeakDetectionResult& report) { |
748 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 774 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
749 } | 775 } |
750 | 776 |
751 } // namespace content | 777 } // namespace content |
OLD | NEW |