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

Side by Side Diff: content/shell/renderer/test_runner/TestInterfaces.cpp

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/shell/renderer/test_runner/TestInterfaces.h"
6
7 #include <string>
8
9 #include "content/shell/renderer/test_runner/AccessibilityController.h"
10 #include "content/shell/renderer/test_runner/EventSender.h"
11 #include "content/shell/renderer/test_runner/GamepadController.h"
12 #include "content/shell/renderer/test_runner/TestRunner.h"
13 #include "content/shell/renderer/test_runner/TextInputController.h"
14 #include "content/shell/renderer/test_runner/WebTestProxy.h"
15 #include "third_party/WebKit/public/platform/WebString.h"
16 #include "third_party/WebKit/public/platform/WebURL.h"
17 #include "third_party/WebKit/public/web/WebCache.h"
18 #include "third_party/WebKit/public/web/WebKit.h"
19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
20 #include "third_party/WebKit/public/web/WebView.h"
21
22 using namespace blink;
23 using namespace std;
24
25 namespace WebTestRunner {
26
27 TestInterfaces::TestInterfaces()
28 : m_accessibilityController(new AccessibilityController())
29 , m_eventSender(new EventSender(this))
30 , m_gamepadController(new GamepadController())
31 , m_textInputController(new TextInputController())
32 , m_testRunner(new TestRunner(this))
33 , m_delegate(0)
34 {
35 blink::setLayoutTestMode(true);
36
37 // NOTE: please don't put feature specific enable flags here,
38 // instead add them to RuntimeEnabledFeatures.in
39
40 resetAll();
41 }
42
43 TestInterfaces::~TestInterfaces()
44 {
45 m_accessibilityController->setWebView(0);
46 m_eventSender->setWebView(0);
47 // m_gamepadController doesn't depend on WebView.
48 m_textInputController->setWebView(0);
49 m_testRunner->setWebView(0, 0);
50
51 m_accessibilityController->setDelegate(0);
52 m_eventSender->setDelegate(0);
53 m_gamepadController->setDelegate(0);
54 // m_textInputController doesn't depend on WebTestDelegate.
55 m_testRunner->setDelegate(0);
56 }
57
58 void TestInterfaces::setWebView(WebView* webView, WebTestProxyBase* proxy)
59 {
60 m_proxy = proxy;
61 m_accessibilityController->setWebView(webView);
62 m_eventSender->setWebView(webView);
63 // m_gamepadController doesn't depend on WebView.
64 m_textInputController->setWebView(webView);
65 m_testRunner->setWebView(webView, proxy);
66 }
67
68 void TestInterfaces::setDelegate(WebTestDelegate* delegate)
69 {
70 m_accessibilityController->setDelegate(delegate);
71 m_eventSender->setDelegate(delegate);
72 m_gamepadController->setDelegate(delegate);
73 // m_textInputController doesn't depend on WebTestDelegate.
74 m_testRunner->setDelegate(delegate);
75 m_delegate = delegate;
76 }
77
78 void TestInterfaces::bindTo(WebFrame* frame)
79 {
80 m_accessibilityController->bindToJavascript(frame, WebString::fromUTF8("acce ssibilityController"));
81 m_eventSender->bindToJavascript(frame, WebString::fromUTF8("eventSender"));
82 m_gamepadController->bindToJavascript(frame, WebString::fromUTF8("gamepadCon troller"));
83 m_textInputController->bindToJavascript(frame, WebString::fromUTF8("textInpu tController"));
84 m_testRunner->bindToJavascript(frame, WebString::fromUTF8("testRunner"));
85 m_testRunner->bindToJavascript(frame, WebString::fromUTF8("layoutTestControl ler"));
86 }
87
88 void TestInterfaces::resetTestHelperControllers()
89 {
90 m_accessibilityController->reset();
91 m_eventSender->reset();
92 m_gamepadController->reset();
93 // m_textInputController doesn't have any state to reset.
94 WebCache::clear();
95 }
96
97 void TestInterfaces::resetAll()
98 {
99 resetTestHelperControllers();
100 m_testRunner->reset();
101 }
102
103 void TestInterfaces::setTestIsRunning(bool running)
104 {
105 m_testRunner->setTestIsRunning(running);
106 }
107
108 void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat ePixels)
109 {
110 string spec = GURL(testURL).spec();
111 m_testRunner->setShouldGeneratePixelResults(generatePixels);
112 if (spec.find("loading/") != string::npos)
113 m_testRunner->setShouldDumpFrameLoadCallbacks(true);
114 if (spec.find("/dumpAsText/") != string::npos) {
115 m_testRunner->setShouldDumpAsText(true);
116 m_testRunner->setShouldGeneratePixelResults(false);
117 }
118 if (spec.find("/inspector/") != string::npos)
119 m_testRunner->showDevTools();
120 if (spec.find("/viewsource/") != string::npos) {
121 m_testRunner->setShouldEnableViewSource(true);
122 m_testRunner->setShouldGeneratePixelResults(false);
123 m_testRunner->setShouldDumpAsMarkup(true);
124 }
125 }
126
127 void TestInterfaces::windowOpened(WebTestProxyBase* proxy)
128 {
129 m_windowList.push_back(proxy);
130 }
131
132 void TestInterfaces::windowClosed(WebTestProxyBase* proxy)
133 {
134 vector<WebTestProxyBase*>::iterator pos = find(m_windowList.begin(), m_windo wList.end(), proxy);
135 if (pos == m_windowList.end()) {
136 BLINK_ASSERT_NOT_REACHED();
137 return;
138 }
139 m_windowList.erase(pos);
140 }
141
142 AccessibilityController* TestInterfaces::accessibilityController()
143 {
144 return m_accessibilityController.get();
145 }
146
147 EventSender* TestInterfaces::eventSender()
148 {
149 return m_eventSender.get();
150 }
151
152 TestRunner* TestInterfaces::testRunner()
153 {
154 return m_testRunner.get();
155 }
156
157 WebTestDelegate* TestInterfaces::delegate()
158 {
159 return m_delegate;
160 }
161
162 WebTestProxyBase* TestInterfaces::proxy()
163 {
164 return m_proxy;
165 }
166
167 const vector<WebTestProxyBase*>& TestInterfaces::windowList()
168 {
169 return m_windowList;
170 }
171
172 WebThemeEngine* TestInterfaces::themeEngine()
173 {
174 #if defined(USE_DEFAULT_RENDER_THEME) || !(defined(WIN32) || defined(__APPLE__) || defined(ANDROID))
175 if (!m_themeEngine.get())
176 m_themeEngine.reset(new WebTestThemeEngineMock());
177 return m_themeEngine.get();
178 #elif defined(WIN32)
179 if (!m_themeEngine.get())
180 m_themeEngine.reset(new WebTestThemeEngineWin());
181 return m_themeEngine.get();
182 #elif defined(__APPLE__)
183 if (!m_themeEngine.get())
184 m_themeEngine.reset(new WebTestThemeEngineMac());
185 return m_themeEngine.get();
186 #else
187 return 0;
188 #endif
189 }
190
191 }
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/TestInterfaces.h ('k') | content/shell/renderer/test_runner/TestPlugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698