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

Side by Side Diff: components/test_runner/web_test_proxy.cc

Issue 1889673002: Move LayoutAndPaintAsyncThen to a separate compilation unit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 8 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
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 "components/test_runner/web_test_proxy.h" 5 #include "components/test_runner/web_test_proxy.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cctype>
11
12 #include "base/callback_helpers.h"
13 #include "base/command_line.h"
14 #include "base/logging.h"
15 #include "base/strings/string_util.h"
16 #include "base/thread_task_runner_handle.h"
17 #include "base/trace_event/trace_event.h"
18 #include "components/test_runner/mock_credential_manager_client.h"
19 #include "components/test_runner/mock_screen_orientation_client.h" 10 #include "components/test_runner/mock_screen_orientation_client.h"
20 #include "components/test_runner/spell_check_client.h"
21 #include "components/test_runner/test_common.h"
22 #include "components/test_runner/test_interfaces.h" 11 #include "components/test_runner/test_interfaces.h"
23 #include "components/test_runner/test_plugin.h"
24 #include "components/test_runner/test_runner.h" 12 #include "components/test_runner/test_runner.h"
25 #include "components/test_runner/web_test_delegate.h" 13 #include "components/test_runner/web_test_delegate.h"
26 #include "components/test_runner/web_test_interfaces.h" 14 #include "components/test_runner/web_test_interfaces.h"
27 #include "components/test_runner/web_test_runner.h"
28 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h"
29 #include "third_party/WebKit/public/platform/WebURLError.h"
30 #include "third_party/WebKit/public/platform/WebURLRequest.h"
31 #include "third_party/WebKit/public/platform/WebURLResponse.h"
32 #include "third_party/WebKit/public/web/WebAXEnums.h"
33 #include "third_party/WebKit/public/web/WebAXObject.h"
34 #include "third_party/WebKit/public/web/WebDocument.h"
35 #include "third_party/WebKit/public/web/WebElement.h"
36 #include "third_party/WebKit/public/web/WebHistoryItem.h"
37 #include "third_party/WebKit/public/web/WebLocalFrame.h"
38 #include "third_party/WebKit/public/web/WebNode.h"
39 #include "third_party/WebKit/public/web/WebPagePopup.h"
40 #include "third_party/WebKit/public/web/WebPluginParams.h"
41 #include "third_party/WebKit/public/web/WebPrintParams.h"
42 #include "third_party/WebKit/public/web/WebRange.h"
43 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
44 #include "third_party/WebKit/public/web/WebView.h"
45 15
46 namespace test_runner { 16 namespace test_runner {
47 17
48 namespace { 18 namespace {
49 19
50 class LayoutAndPaintCallback : public blink::WebLayoutAndPaintAsyncCallback {
51 public:
52 LayoutAndPaintCallback(const base::Closure& callback)
53 : callback_(callback), wait_for_popup_(false) {
54 }
55 virtual ~LayoutAndPaintCallback() {
56 }
57
58 void set_wait_for_popup(bool wait) { wait_for_popup_ = wait; }
59
60 // WebLayoutAndPaintAsyncCallback implementation.
61 void didLayoutAndPaint() override;
62
63 private:
64 base::Closure callback_;
65 bool wait_for_popup_;
66 };
67
68 std::string DumpAllBackForwardLists(TestInterfaces* interfaces, 20 std::string DumpAllBackForwardLists(TestInterfaces* interfaces,
69 WebTestDelegate* delegate) { 21 WebTestDelegate* delegate) {
70 std::string result; 22 std::string result;
71 const std::vector<WebTestProxyBase*>& window_list = 23 const std::vector<WebTestProxyBase*>& window_list =
72 interfaces->GetWindowList(); 24 interfaces->GetWindowList();
73 for (size_t i = 0; i < window_list.size(); ++i) 25 for (size_t i = 0; i < window_list.size(); ++i)
74 result.append(delegate->DumpHistoryForWindow(window_list.at(i))); 26 result.append(delegate->DumpHistoryForWindow(window_list.at(i)));
75 return result; 27 return result;
76 } 28 }
77 29
(...skipping 11 matching lines...) Expand all
89 41
90 void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) { 42 void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) {
91 test_interfaces_ = interfaces->GetTestInterfaces(); 43 test_interfaces_ = interfaces->GetTestInterfaces();
92 test_interfaces_->WindowOpened(this); 44 test_interfaces_->WindowOpened(this);
93 } 45 }
94 46
95 std::string WebTestProxyBase::DumpBackForwardLists() { 47 std::string WebTestProxyBase::DumpBackForwardLists() {
96 return DumpAllBackForwardLists(test_interfaces_, delegate_); 48 return DumpAllBackForwardLists(test_interfaces_, delegate_);
97 } 49 }
98 50
99 void LayoutAndPaintCallback::didLayoutAndPaint() {
100 TRACE_EVENT0("shell", "LayoutAndPaintCallback::didLayoutAndPaint");
101 if (wait_for_popup_) {
102 wait_for_popup_ = false;
103 return;
104 }
105
106 if (!callback_.is_null())
107 callback_.Run();
108 delete this;
109 }
110
111 void WebTestProxyBase::LayoutAndPaintAsyncThen(const base::Closure& callback) {
112 TRACE_EVENT0("shell", "WebTestProxyBase::LayoutAndPaintAsyncThen");
113
114 LayoutAndPaintCallback* layout_and_paint_callback =
115 new LayoutAndPaintCallback(callback);
116 web_widget_->layoutAndPaintAsync(layout_and_paint_callback);
117 if (blink::WebPagePopup* popup = web_widget_->pagePopup()) {
118 layout_and_paint_callback->set_wait_for_popup(true);
119 popup->layoutAndPaintAsync(layout_and_paint_callback);
120 }
121 }
122
123 void WebTestProxyBase::GetScreenOrientationForTesting( 51 void WebTestProxyBase::GetScreenOrientationForTesting(
124 blink::WebScreenInfo& screen_info) { 52 blink::WebScreenInfo& screen_info) {
125 MockScreenOrientationClient* mock_client = 53 MockScreenOrientationClient* mock_client =
126 test_interfaces_->GetTestRunner()->getMockScreenOrientationClient(); 54 test_interfaces_->GetTestRunner()->getMockScreenOrientationClient();
127 if (mock_client->IsDisabled()) 55 if (mock_client->IsDisabled())
128 return; 56 return;
129 // Override screen orientation information with mock data. 57 // Override screen orientation information with mock data.
130 screen_info.orientationType = mock_client->CurrentOrientationType(); 58 screen_info.orientationType = mock_client->CurrentOrientationType();
131 screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); 59 screen_info.orientationAngle = mock_client->CurrentOrientationAngle();
132 } 60 }
133 61
134 } // namespace test_runner 62 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/web_test_proxy.h ('k') | content/shell/renderer/layout_test/blink_test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698