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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "content/shell/common/shell_switches.h" | 12 #include "content/shell/common/shell_switches.h" |
13 #include "content/shell/renderer/test_runner/accessibility_controller.h" | 13 #include "content/shell/renderer/test_runner/accessibility_controller.h" |
14 #include "content/shell/renderer/test_runner/event_sender.h" | 14 #include "content/shell/renderer/test_runner/event_sender.h" |
15 #include "content/shell/renderer/test_runner/gamepad_controller.h" | 15 #include "content/shell/renderer/test_runner/gamepad_controller.h" |
16 #include "content/shell/renderer/test_runner/text_input_controller.h" | 16 #include "content/shell/renderer/test_runner/text_input_controller.h" |
17 #include "content/shell/renderer/test_runner/test_runner.h" | 17 #include "content/shell/renderer/test_runner/test_runner.h" |
18 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 18 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
20 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
21 #include "third_party/WebKit/public/web/WebCache.h" | 21 #include "third_party/WebKit/public/web/WebCache.h" |
22 #include "third_party/WebKit/public/web/WebKit.h" | 22 #include "third_party/WebKit/public/web/WebKit.h" |
23 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 23 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
24 #include "third_party/WebKit/public/web/WebView.h" | 24 #include "third_party/WebKit/public/web/WebView.h" |
25 | 25 |
26 using namespace blink; | 26 using namespace blink; |
27 using namespace std; | |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 | 29 |
31 TestInterfaces::TestInterfaces() | 30 TestInterfaces::TestInterfaces() |
32 : m_accessibilityController(new AccessibilityController()) | 31 : m_accessibilityController(new AccessibilityController()) |
33 , m_eventSender(new EventSender(this)) | 32 , m_eventSender(new EventSender(this)) |
34 , m_gamepadController(new GamepadController()) | 33 , m_gamepadController(new GamepadController()) |
35 , m_textInputController(new TextInputController()) | 34 , m_textInputController(new TextInputController()) |
36 , m_testRunner(new TestRunner(this)) | 35 , m_testRunner(new TestRunner(this)) |
37 , m_delegate(0) | 36 , m_delegate(0) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 m_testRunner->Reset(); | 104 m_testRunner->Reset(); |
106 } | 105 } |
107 | 106 |
108 void TestInterfaces::setTestIsRunning(bool running) | 107 void TestInterfaces::setTestIsRunning(bool running) |
109 { | 108 { |
110 m_testRunner->SetTestIsRunning(running); | 109 m_testRunner->SetTestIsRunning(running); |
111 } | 110 } |
112 | 111 |
113 void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat
ePixels) | 112 void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat
ePixels) |
114 { | 113 { |
115 string spec = GURL(testURL).spec(); | 114 std::string spec = GURL(testURL).spec(); |
116 m_testRunner->setShouldGeneratePixelResults(generatePixels); | 115 m_testRunner->setShouldGeneratePixelResults(generatePixels); |
117 if (spec.find("loading/") != string::npos) | 116 if (spec.find("loading/") != std::string::npos) |
118 m_testRunner->setShouldDumpFrameLoadCallbacks(true); | 117 m_testRunner->setShouldDumpFrameLoadCallbacks(true); |
119 if (spec.find("/dumpAsText/") != string::npos) { | 118 if (spec.find("/dumpAsText/") != std::string::npos) { |
120 m_testRunner->setShouldDumpAsText(true); | 119 m_testRunner->setShouldDumpAsText(true); |
121 m_testRunner->setShouldGeneratePixelResults(false); | 120 m_testRunner->setShouldGeneratePixelResults(false); |
122 } | 121 } |
123 if (spec.find("/inspector/") != string::npos | 122 if (spec.find("/inspector/") != std::string::npos |
124 || spec.find("/inspector-enabled/") != string::npos) | 123 || spec.find("/inspector-enabled/") != std::string::npos) |
125 m_testRunner->clearDevToolsLocalStorage(); | 124 m_testRunner->clearDevToolsLocalStorage(); |
126 if (spec.find("/inspector/") != string::npos) { | 125 if (spec.find("/inspector/") != std::string::npos) { |
127 // Subfolder name determines default panel to open. | 126 // Subfolder name determines default panel to open. |
128 string settings = ""; | 127 std::string settings = ""; |
129 string test_path = spec.substr(spec.find("/inspector/") + 11); | 128 std::string test_path = spec.substr(spec.find("/inspector/") + 11); |
130 size_t slash_index = test_path.find("/"); | 129 size_t slash_index = test_path.find("/"); |
131 if (slash_index != string::npos) { | 130 if (slash_index != std::string::npos) { |
132 settings = base::StringPrintf( | 131 settings = base::StringPrintf( |
133 "{\"lastActivePanel\":\"\\\"%s\\\"\"}", | 132 "{\"lastActivePanel\":\"\\\"%s\\\"\"}", |
134 test_path.substr(0, slash_index).c_str()); | 133 test_path.substr(0, slash_index).c_str()); |
135 } | 134 } |
136 m_testRunner->showDevTools(settings, string()); | 135 m_testRunner->showDevTools(settings, std::string()); |
137 } | 136 } |
138 if (spec.find("/viewsource/") != string::npos) { | 137 if (spec.find("/viewsource/") != std::string::npos) { |
139 m_testRunner->setShouldEnableViewSource(true); | 138 m_testRunner->setShouldEnableViewSource(true); |
140 m_testRunner->setShouldGeneratePixelResults(false); | 139 m_testRunner->setShouldGeneratePixelResults(false); |
141 m_testRunner->setShouldDumpAsMarkup(true); | 140 m_testRunner->setShouldDumpAsMarkup(true); |
142 } | 141 } |
143 } | 142 } |
144 | 143 |
145 void TestInterfaces::windowOpened(WebTestProxyBase* proxy) | 144 void TestInterfaces::windowOpened(WebTestProxyBase* proxy) |
146 { | 145 { |
147 m_windowList.push_back(proxy); | 146 m_windowList.push_back(proxy); |
148 } | 147 } |
149 | 148 |
150 void TestInterfaces::windowClosed(WebTestProxyBase* proxy) | 149 void TestInterfaces::windowClosed(WebTestProxyBase* proxy) |
151 { | 150 { |
152 vector<WebTestProxyBase*>::iterator pos = find(m_windowList.begin(), m_windo
wList.end(), proxy); | 151 std::vector<WebTestProxyBase*>::iterator pos = std::find(m_windowList.begin(
), m_windowList.end(), proxy); |
153 if (pos == m_windowList.end()) { | 152 if (pos == m_windowList.end()) { |
154 NOTREACHED(); | 153 NOTREACHED(); |
155 return; | 154 return; |
156 } | 155 } |
157 m_windowList.erase(pos); | 156 m_windowList.erase(pos); |
158 } | 157 } |
159 | 158 |
160 AccessibilityController* TestInterfaces::accessibilityController() | 159 AccessibilityController* TestInterfaces::accessibilityController() |
161 { | 160 { |
162 return m_accessibilityController.get(); | 161 return m_accessibilityController.get(); |
(...skipping 12 matching lines...) Expand all Loading... |
175 WebTestDelegate* TestInterfaces::delegate() | 174 WebTestDelegate* TestInterfaces::delegate() |
176 { | 175 { |
177 return m_delegate; | 176 return m_delegate; |
178 } | 177 } |
179 | 178 |
180 WebTestProxyBase* TestInterfaces::proxy() | 179 WebTestProxyBase* TestInterfaces::proxy() |
181 { | 180 { |
182 return m_proxy; | 181 return m_proxy; |
183 } | 182 } |
184 | 183 |
185 const vector<WebTestProxyBase*>& TestInterfaces::windowList() | 184 const std::vector<WebTestProxyBase*>& TestInterfaces::windowList() |
186 { | 185 { |
187 return m_windowList; | 186 return m_windowList; |
188 } | 187 } |
189 | 188 |
190 WebThemeEngine* TestInterfaces::themeEngine() | 189 WebThemeEngine* TestInterfaces::themeEngine() |
191 { | 190 { |
192 if (!m_testRunner->UseMockTheme()) | 191 if (!m_testRunner->UseMockTheme()) |
193 return 0; | 192 return 0; |
194 #if defined(__APPLE__) | 193 #if defined(__APPLE__) |
195 if (!m_themeEngine.get()) | 194 if (!m_themeEngine.get()) |
196 m_themeEngine.reset(new WebTestThemeEngineMac()); | 195 m_themeEngine.reset(new WebTestThemeEngineMac()); |
197 #else | 196 #else |
198 if (!m_themeEngine.get()) | 197 if (!m_themeEngine.get()) |
199 m_themeEngine.reset(new WebTestThemeEngineMock()); | 198 m_themeEngine.reset(new WebTestThemeEngineMock()); |
200 #endif | 199 #endif |
201 return m_themeEngine.get(); | 200 return m_themeEngine.get(); |
202 } | 201 } |
203 | 202 |
204 } // namespace content | 203 } // namespace content |
OLD | NEW |