OLD | NEW |
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 "content/shell/renderer/test_runner/test_interfaces.h" | 5 #include "content/shell/renderer/test_runner/test_interfaces.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.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/test_runner.h" | 16 #include "content/shell/renderer/test_runner/test_runner.h" |
17 #include "content/shell/renderer/test_runner/text_input_controller.h" | 17 #include "content/shell/renderer/test_runner/text_input_controller.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/WebURL.h" | 19 #include "third_party/WebKit/public/platform/WebURL.h" |
20 #include "third_party/WebKit/public/web/WebCache.h" | 20 #include "third_party/WebKit/public/web/WebCache.h" |
21 #include "third_party/WebKit/public/web/WebKit.h" | 21 #include "third_party/WebKit/public/web/WebKit.h" |
22 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 TestInterfaces::TestInterfaces() | 26 TestInterfaces::TestInterfaces() |
27 : accessibility_controller_(new AccessibilityController()), | 27 : accessibility_controller_(new AccessibilityController()), |
28 event_sender_(new EventSender(this)), | 28 event_sender_(new EventSender(this)), |
29 gamepad_controller_(new GamepadController()), | |
30 text_input_controller_(new TextInputController()), | 29 text_input_controller_(new TextInputController()), |
31 test_runner_(new TestRunner(this)), | 30 test_runner_(new TestRunner(this)), |
32 delegate_(0) { | 31 delegate_(0) { |
33 blink::setLayoutTestMode(true); | 32 blink::setLayoutTestMode(true); |
34 if (CommandLine::ForCurrentProcess()->HasSwitch( | 33 if (CommandLine::ForCurrentProcess()->HasSwitch( |
35 switches::kEnableFontAntialiasing)) | 34 switches::kEnableFontAntialiasing)) |
36 blink::setFontAntialiasingEnabledForTest(true); | 35 blink::setFontAntialiasingEnabledForTest(true); |
37 | 36 |
38 // NOTE: please don't put feature specific enable flags here, | 37 // NOTE: please don't put feature specific enable flags here, |
39 // instead add them to RuntimeEnabledFeatures.in | 38 // instead add them to RuntimeEnabledFeatures.in |
40 | 39 |
41 ResetAll(); | 40 ResetAll(); |
42 } | 41 } |
43 | 42 |
44 TestInterfaces::~TestInterfaces() { | 43 TestInterfaces::~TestInterfaces() { |
45 accessibility_controller_->SetWebView(0); | 44 accessibility_controller_->SetWebView(0); |
46 event_sender_->SetWebView(0); | 45 event_sender_->SetWebView(0); |
47 // gamepad_controller_ doesn't depend on WebView. | 46 // gamepad_controller_ doesn't depend on WebView. |
48 text_input_controller_->SetWebView(NULL); | 47 text_input_controller_->SetWebView(NULL); |
49 test_runner_->SetWebView(0, 0); | 48 test_runner_->SetWebView(0, 0); |
50 | 49 |
51 accessibility_controller_->SetDelegate(0); | 50 accessibility_controller_->SetDelegate(0); |
52 event_sender_->SetDelegate(0); | 51 event_sender_->SetDelegate(0); |
53 gamepad_controller_->SetDelegate(0); | 52 // gamepad_controller_ ignores SetDelegate(0) |
54 // text_input_controller_ doesn't depend on WebTestDelegate. | 53 // text_input_controller_ doesn't depend on WebTestDelegate. |
55 test_runner_->SetDelegate(0); | 54 test_runner_->SetDelegate(0); |
56 } | 55 } |
57 | 56 |
58 void TestInterfaces::SetWebView(blink::WebView* web_view, | 57 void TestInterfaces::SetWebView(blink::WebView* web_view, |
59 WebTestProxyBase* proxy) { | 58 WebTestProxyBase* proxy) { |
60 proxy_ = proxy; | 59 proxy_ = proxy; |
61 accessibility_controller_->SetWebView(web_view); | 60 accessibility_controller_->SetWebView(web_view); |
62 event_sender_->SetWebView(web_view); | 61 event_sender_->SetWebView(web_view); |
63 // gamepad_controller_ doesn't depend on WebView. | 62 // gamepad_controller_ doesn't depend on WebView. |
64 text_input_controller_->SetWebView(web_view); | 63 text_input_controller_->SetWebView(web_view); |
65 test_runner_->SetWebView(web_view, proxy); | 64 test_runner_->SetWebView(web_view, proxy); |
66 } | 65 } |
67 | 66 |
68 void TestInterfaces::SetDelegate(WebTestDelegate* delegate) { | 67 void TestInterfaces::SetDelegate(WebTestDelegate* delegate) { |
69 accessibility_controller_->SetDelegate(delegate); | 68 accessibility_controller_->SetDelegate(delegate); |
70 event_sender_->SetDelegate(delegate); | 69 event_sender_->SetDelegate(delegate); |
71 gamepad_controller_->SetDelegate(delegate); | 70 gamepad_controller_ = GamepadController::Create(delegate); |
72 // text_input_controller_ doesn't depend on WebTestDelegate. | 71 // text_input_controller_ doesn't depend on WebTestDelegate. |
73 test_runner_->SetDelegate(delegate); | 72 test_runner_->SetDelegate(delegate); |
74 delegate_ = delegate; | 73 delegate_ = delegate; |
75 } | 74 } |
76 | 75 |
77 void TestInterfaces::BindTo(blink::WebFrame* frame) { | 76 void TestInterfaces::BindTo(blink::WebFrame* frame) { |
78 accessibility_controller_->Install(frame); | 77 accessibility_controller_->Install(frame); |
79 event_sender_->Install(frame); | 78 event_sender_->Install(frame); |
80 gamepad_controller_->Install(frame); | 79 if (gamepad_controller_) |
| 80 gamepad_controller_->Install(frame); |
81 text_input_controller_->Install(frame); | 81 text_input_controller_->Install(frame); |
82 test_runner_->Install(frame); | 82 test_runner_->Install(frame); |
83 } | 83 } |
84 | 84 |
85 void TestInterfaces::ResetTestHelperControllers() { | 85 void TestInterfaces::ResetTestHelperControllers() { |
86 accessibility_controller_->Reset(); | 86 accessibility_controller_->Reset(); |
87 event_sender_->Reset(); | 87 event_sender_->Reset(); |
88 gamepad_controller_->Reset(); | 88 if (gamepad_controller_) |
| 89 gamepad_controller_->Reset(); |
89 // text_input_controller_ doesn't have any state to reset. | 90 // text_input_controller_ doesn't have any state to reset. |
90 blink::WebCache::clear(); | 91 blink::WebCache::clear(); |
91 } | 92 } |
92 | 93 |
93 void TestInterfaces::ResetAll() { | 94 void TestInterfaces::ResetAll() { |
94 ResetTestHelperControllers(); | 95 ResetTestHelperControllers(); |
95 test_runner_->Reset(); | 96 test_runner_->Reset(); |
96 } | 97 } |
97 | 98 |
98 void TestInterfaces::SetTestIsRunning(bool running) { | 99 void TestInterfaces::SetTestIsRunning(bool running) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (!theme_engine_.get()) | 176 if (!theme_engine_.get()) |
176 theme_engine_.reset(new MockWebThemeEngineMac()); | 177 theme_engine_.reset(new MockWebThemeEngineMac()); |
177 #else | 178 #else |
178 if (!theme_engine_.get()) | 179 if (!theme_engine_.get()) |
179 theme_engine_.reset(new MockWebThemeEngine()); | 180 theme_engine_.reset(new MockWebThemeEngine()); |
180 #endif | 181 #endif |
181 return theme_engine_.get(); | 182 return theme_engine_.get(); |
182 } | 183 } |
183 | 184 |
184 } // namespace content | 185 } // namespace content |
OLD | NEW |