OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test_runner/TestInterfaces.h" | 5 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "content/shell/renderer/test_runner/EventSender.h" | 10 #include "content/shell/renderer/test_runner/EventSender.h" |
11 #include "content/shell/renderer/test_runner/TestRunner.h" | |
12 #include "content/shell/renderer/test_runner/WebTestProxy.h" | 11 #include "content/shell/renderer/test_runner/WebTestProxy.h" |
13 #include "content/shell/renderer/test_runner/accessibility_controller.h" | 12 #include "content/shell/renderer/test_runner/accessibility_controller.h" |
14 #include "content/shell/renderer/test_runner/gamepad_controller.h" | 13 #include "content/shell/renderer/test_runner/gamepad_controller.h" |
15 #include "content/shell/renderer/test_runner/text_input_controller.h" | 14 #include "content/shell/renderer/test_runner/text_input_controller.h" |
| 15 #include "content/shell/renderer/test_runner/test_runner.h" |
16 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
17 #include "third_party/WebKit/public/platform/WebURL.h" | 17 #include "third_party/WebKit/public/platform/WebURL.h" |
18 #include "third_party/WebKit/public/web/WebCache.h" | 18 #include "third_party/WebKit/public/web/WebCache.h" |
19 #include "third_party/WebKit/public/web/WebKit.h" | 19 #include "third_party/WebKit/public/web/WebKit.h" |
20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
21 #include "third_party/WebKit/public/web/WebView.h" | 21 #include "third_party/WebKit/public/web/WebView.h" |
22 | 22 |
23 using namespace blink; | 23 using namespace blink; |
24 using namespace std; | 24 using namespace std; |
25 | 25 |
26 namespace WebTestRunner { | 26 namespace WebTestRunner { |
27 | 27 |
28 TestInterfaces::TestInterfaces() | 28 TestInterfaces::TestInterfaces() |
29 : m_accessibilityController(new content::AccessibilityController()) | 29 : m_accessibilityController(new content::AccessibilityController()) |
30 , m_eventSender(new EventSender(this)) | 30 , m_eventSender(new EventSender(this)) |
31 , m_gamepadController(new content::GamepadController()) | 31 , m_gamepadController(new content::GamepadController()) |
32 , m_textInputController(new content::TextInputController()) | 32 , m_textInputController(new content::TextInputController()) |
33 , m_testRunner(new TestRunner(this)) | 33 , m_testRunner(new content::TestRunner(this)) |
34 , m_delegate(0) | 34 , m_delegate(0) |
35 { | 35 { |
36 blink::setLayoutTestMode(true); | 36 blink::setLayoutTestMode(true); |
37 | 37 |
38 // NOTE: please don't put feature specific enable flags here, | 38 // NOTE: please don't put feature specific enable flags here, |
39 // instead add them to RuntimeEnabledFeatures.in | 39 // instead add them to RuntimeEnabledFeatures.in |
40 | 40 |
41 resetAll(); | 41 resetAll(); |
42 } | 42 } |
43 | 43 |
44 TestInterfaces::~TestInterfaces() | 44 TestInterfaces::~TestInterfaces() |
45 { | 45 { |
46 m_accessibilityController->SetWebView(0); | 46 m_accessibilityController->SetWebView(0); |
47 m_eventSender->setWebView(0); | 47 m_eventSender->setWebView(0); |
48 // m_gamepadController doesn't depend on WebView. | 48 // m_gamepadController doesn't depend on WebView. |
49 m_textInputController->SetWebView(NULL); | 49 m_textInputController->SetWebView(NULL); |
50 m_testRunner->setWebView(0, 0); | 50 m_testRunner->SetWebView(0, 0); |
51 | 51 |
52 m_accessibilityController->SetDelegate(0); | 52 m_accessibilityController->SetDelegate(0); |
53 m_eventSender->setDelegate(0); | 53 m_eventSender->setDelegate(0); |
54 m_gamepadController->SetDelegate(0); | 54 m_gamepadController->SetDelegate(0); |
55 // m_textInputController doesn't depend on WebTestDelegate. | 55 // m_textInputController doesn't depend on WebTestDelegate. |
56 m_testRunner->setDelegate(0); | 56 m_testRunner->SetDelegate(0); |
57 } | 57 } |
58 | 58 |
59 void TestInterfaces::setWebView(WebView* webView, WebTestProxyBase* proxy) | 59 void TestInterfaces::setWebView(WebView* webView, WebTestProxyBase* proxy) |
60 { | 60 { |
61 m_proxy = proxy; | 61 m_proxy = proxy; |
62 m_accessibilityController->SetWebView(webView); | 62 m_accessibilityController->SetWebView(webView); |
63 m_eventSender->setWebView(webView); | 63 m_eventSender->setWebView(webView); |
64 // m_gamepadController doesn't depend on WebView. | 64 // m_gamepadController doesn't depend on WebView. |
65 m_textInputController->SetWebView(webView); | 65 m_textInputController->SetWebView(webView); |
66 m_testRunner->setWebView(webView, proxy); | 66 m_testRunner->SetWebView(webView, proxy); |
67 } | 67 } |
68 | 68 |
69 void TestInterfaces::setDelegate(WebTestDelegate* delegate) | 69 void TestInterfaces::setDelegate(WebTestDelegate* delegate) |
70 { | 70 { |
71 m_accessibilityController->SetDelegate(delegate); | 71 m_accessibilityController->SetDelegate(delegate); |
72 m_eventSender->setDelegate(delegate); | 72 m_eventSender->setDelegate(delegate); |
73 m_gamepadController->SetDelegate(delegate); | 73 m_gamepadController->SetDelegate(delegate); |
74 // m_textInputController doesn't depend on WebTestDelegate. | 74 // m_textInputController doesn't depend on WebTestDelegate. |
75 m_testRunner->setDelegate(delegate); | 75 m_testRunner->SetDelegate(delegate); |
76 m_delegate = delegate; | 76 m_delegate = delegate; |
77 } | 77 } |
78 | 78 |
79 void TestInterfaces::bindTo(WebFrame* frame) | 79 void TestInterfaces::bindTo(WebFrame* frame) |
80 { | 80 { |
81 m_accessibilityController->Install(frame); | 81 m_accessibilityController->Install(frame); |
82 m_eventSender->bindToJavascript(frame, WebString::fromUTF8("eventSender")); | 82 m_eventSender->bindToJavascript(frame, WebString::fromUTF8("eventSender")); |
83 m_gamepadController->Install(frame); | 83 m_gamepadController->Install(frame); |
84 m_textInputController->Install(frame); | 84 m_textInputController->Install(frame); |
85 m_testRunner->bindToJavascript(frame, WebString::fromUTF8("testRunner")); | 85 m_testRunner->Install(frame); |
86 m_testRunner->bindToJavascript(frame, WebString::fromUTF8("layoutTestControl
ler")); | |
87 } | 86 } |
88 | 87 |
89 void TestInterfaces::resetTestHelperControllers() | 88 void TestInterfaces::resetTestHelperControllers() |
90 { | 89 { |
91 m_accessibilityController->Reset(); | 90 m_accessibilityController->Reset(); |
92 m_eventSender->reset(); | 91 m_eventSender->reset(); |
93 m_gamepadController->Reset(); | 92 m_gamepadController->Reset(); |
94 // m_textInputController doesn't have any state to reset. | 93 // m_textInputController doesn't have any state to reset. |
95 WebCache::clear(); | 94 WebCache::clear(); |
96 } | 95 } |
97 | 96 |
98 void TestInterfaces::resetAll() | 97 void TestInterfaces::resetAll() |
99 { | 98 { |
100 resetTestHelperControllers(); | 99 resetTestHelperControllers(); |
101 m_testRunner->reset(); | 100 m_testRunner->Reset(); |
102 } | 101 } |
103 | 102 |
104 void TestInterfaces::setTestIsRunning(bool running) | 103 void TestInterfaces::setTestIsRunning(bool running) |
105 { | 104 { |
106 m_testRunner->setTestIsRunning(running); | 105 m_testRunner->SetTestIsRunning(running); |
107 } | 106 } |
108 | 107 |
109 void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat
ePixels) | 108 void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat
ePixels) |
110 { | 109 { |
111 string spec = GURL(testURL).spec(); | 110 string spec = GURL(testURL).spec(); |
112 m_testRunner->setShouldGeneratePixelResults(generatePixels); | 111 m_testRunner->setShouldGeneratePixelResults(generatePixels); |
113 if (spec.find("loading/") != string::npos) | 112 if (spec.find("loading/") != string::npos) |
114 m_testRunner->setShouldDumpFrameLoadCallbacks(true); | 113 m_testRunner->setShouldDumpFrameLoadCallbacks(true); |
115 if (spec.find("/dumpAsText/") != string::npos) { | 114 if (spec.find("/dumpAsText/") != string::npos) { |
116 m_testRunner->setShouldDumpAsText(true); | 115 m_testRunner->setShouldDumpAsText(true); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 content::AccessibilityController* TestInterfaces::accessibilityController() | 155 content::AccessibilityController* TestInterfaces::accessibilityController() |
157 { | 156 { |
158 return m_accessibilityController.get(); | 157 return m_accessibilityController.get(); |
159 } | 158 } |
160 | 159 |
161 EventSender* TestInterfaces::eventSender() | 160 EventSender* TestInterfaces::eventSender() |
162 { | 161 { |
163 return m_eventSender.get(); | 162 return m_eventSender.get(); |
164 } | 163 } |
165 | 164 |
166 TestRunner* TestInterfaces::testRunner() | 165 content::TestRunner* TestInterfaces::testRunner() |
167 { | 166 { |
168 return m_testRunner.get(); | 167 return m_testRunner.get(); |
169 } | 168 } |
170 | 169 |
171 WebTestDelegate* TestInterfaces::delegate() | 170 WebTestDelegate* TestInterfaces::delegate() |
172 { | 171 { |
173 return m_delegate; | 172 return m_delegate; |
174 } | 173 } |
175 | 174 |
176 WebTestProxyBase* TestInterfaces::proxy() | 175 WebTestProxyBase* TestInterfaces::proxy() |
177 { | 176 { |
178 return m_proxy; | 177 return m_proxy; |
179 } | 178 } |
180 | 179 |
181 const vector<WebTestProxyBase*>& TestInterfaces::windowList() | 180 const vector<WebTestProxyBase*>& TestInterfaces::windowList() |
182 { | 181 { |
183 return m_windowList; | 182 return m_windowList; |
184 } | 183 } |
185 | 184 |
186 WebThemeEngine* TestInterfaces::themeEngine() | 185 WebThemeEngine* TestInterfaces::themeEngine() |
187 { | 186 { |
188 if (!m_testRunner->useMockTheme()) | 187 if (!m_testRunner->UseMockTheme()) |
189 return 0; | 188 return 0; |
190 #if defined(__APPLE__) | 189 #if defined(__APPLE__) |
191 if (!m_themeEngine.get()) | 190 if (!m_themeEngine.get()) |
192 m_themeEngine.reset(new WebTestThemeEngineMac()); | 191 m_themeEngine.reset(new WebTestThemeEngineMac()); |
193 #else | 192 #else |
194 if (!m_themeEngine.get()) | 193 if (!m_themeEngine.get()) |
195 m_themeEngine.reset(new WebTestThemeEngineMock()); | 194 m_themeEngine.reset(new WebTestThemeEngineMock()); |
196 #endif | 195 #endif |
197 return m_themeEngine.get(); | 196 return m_themeEngine.get(); |
198 } | 197 } |
199 | 198 |
200 } | 199 } |
OLD | NEW |