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