| 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 "components/test_runner/test_interfaces.h" | 5 #include "components/test_runner/test_interfaces.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/json/string_escape.h" | 12 #include "base/json/string_escape.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "components/test_runner/accessibility_controller.h" | 16 #include "components/test_runner/accessibility_controller.h" |
| 17 #include "components/test_runner/app_banner_client.h" | 17 #include "components/test_runner/app_banner_client.h" |
| 18 #include "components/test_runner/event_sender.h" | |
| 19 #include "components/test_runner/gamepad_controller.h" | 18 #include "components/test_runner/gamepad_controller.h" |
| 20 #include "components/test_runner/gc_controller.h" | 19 #include "components/test_runner/gc_controller.h" |
| 21 #include "components/test_runner/test_runner.h" | 20 #include "components/test_runner/test_runner.h" |
| 22 #include "components/test_runner/text_input_controller.h" | 21 #include "components/test_runner/text_input_controller.h" |
| 23 #include "components/test_runner/web_test_proxy.h" | 22 #include "components/test_runner/web_test_proxy.h" |
| 24 #include "third_party/WebKit/public/platform/WebURL.h" | 23 #include "third_party/WebKit/public/platform/WebURL.h" |
| 25 #include "third_party/WebKit/public/web/WebCache.h" | 24 #include "third_party/WebKit/public/web/WebCache.h" |
| 26 #include "third_party/WebKit/public/web/WebKit.h" | 25 #include "third_party/WebKit/public/web/WebKit.h" |
| 27 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 28 | 27 |
| 29 namespace test_runner { | 28 namespace test_runner { |
| 30 | 29 |
| 31 TestInterfaces::TestInterfaces() | 30 TestInterfaces::TestInterfaces() |
| 32 : accessibility_controller_(new AccessibilityController()), | 31 : accessibility_controller_(new AccessibilityController()), |
| 33 event_sender_(new EventSender(this)), | |
| 34 text_input_controller_(new TextInputController()), | 32 text_input_controller_(new TextInputController()), |
| 35 test_runner_(new TestRunner(this)), | 33 test_runner_(new TestRunner(this)), |
| 36 delegate_(nullptr), | 34 delegate_(nullptr), |
| 37 app_banner_client_(nullptr) { | 35 app_banner_client_(nullptr) { |
| 38 blink::setLayoutTestMode(true); | 36 blink::setLayoutTestMode(true); |
| 39 // NOTE: please don't put feature specific enable flags here, | 37 // NOTE: please don't put feature specific enable flags here, |
| 40 // instead add them to RuntimeEnabledFeatures.in | 38 // instead add them to RuntimeEnabledFeatures.in |
| 41 | 39 |
| 42 ResetAll(); | 40 ResetAll(); |
| 43 } | 41 } |
| 44 | 42 |
| 45 TestInterfaces::~TestInterfaces() { | 43 TestInterfaces::~TestInterfaces() { |
| 46 accessibility_controller_->SetWebView(nullptr); | 44 accessibility_controller_->SetWebView(nullptr); |
| 47 event_sender_->SetWebView(nullptr); | |
| 48 // gamepad_controller_ doesn't depend on WebView. | 45 // gamepad_controller_ doesn't depend on WebView. |
| 49 text_input_controller_->SetWebView(nullptr); | 46 text_input_controller_->SetWebView(nullptr); |
| 50 test_runner_->SetWebView(nullptr); | 47 test_runner_->SetWebView(nullptr); |
| 51 | 48 |
| 52 accessibility_controller_->SetDelegate(nullptr); | 49 accessibility_controller_->SetDelegate(nullptr); |
| 53 event_sender_->SetDelegate(nullptr); | |
| 54 // gamepad_controller_ ignores SetDelegate(nullptr) | 50 // gamepad_controller_ ignores SetDelegate(nullptr) |
| 55 // text_input_controller_ doesn't depend on WebTestDelegate. | 51 // text_input_controller_ doesn't depend on WebTestDelegate. |
| 56 test_runner_->SetDelegate(nullptr); | 52 test_runner_->SetDelegate(nullptr); |
| 57 } | 53 } |
| 58 | 54 |
| 59 void TestInterfaces::SetWebView(blink::WebView* web_view, | 55 void TestInterfaces::SetWebView(blink::WebView* web_view, |
| 60 WebTestProxyBase* proxy) { | 56 WebTestProxyBase* proxy) { |
| 61 accessibility_controller_->SetWebView(web_view); | 57 accessibility_controller_->SetWebView(web_view); |
| 62 event_sender_->SetWebView(web_view); | |
| 63 // gamepad_controller_ doesn't depend on WebView. | 58 // gamepad_controller_ doesn't depend on WebView. |
| 64 text_input_controller_->SetWebView(web_view); | 59 text_input_controller_->SetWebView(web_view); |
| 65 test_runner_->SetWebView(web_view); | 60 test_runner_->SetWebView(web_view); |
| 66 } | 61 } |
| 67 | 62 |
| 68 void TestInterfaces::SetDelegate(WebTestDelegate* delegate) { | 63 void TestInterfaces::SetDelegate(WebTestDelegate* delegate) { |
| 69 accessibility_controller_->SetDelegate(delegate); | 64 accessibility_controller_->SetDelegate(delegate); |
| 70 event_sender_->SetDelegate(delegate); | |
| 71 gamepad_controller_ = GamepadController::Create(delegate); | 65 gamepad_controller_ = GamepadController::Create(delegate); |
| 72 // text_input_controller_ doesn't depend on WebTestDelegate. | 66 // text_input_controller_ doesn't depend on WebTestDelegate. |
| 73 test_runner_->SetDelegate(delegate); | 67 test_runner_->SetDelegate(delegate); |
| 74 delegate_ = delegate; | 68 delegate_ = delegate; |
| 75 } | 69 } |
| 76 | 70 |
| 77 void TestInterfaces::BindTo(blink::WebFrame* frame) { | 71 void TestInterfaces::BindTo(blink::WebFrame* frame) { |
| 78 accessibility_controller_->Install(frame); | 72 accessibility_controller_->Install(frame); |
| 79 event_sender_->Install(frame); | |
| 80 if (gamepad_controller_) | 73 if (gamepad_controller_) |
| 81 gamepad_controller_->Install(frame); | 74 gamepad_controller_->Install(frame); |
| 82 text_input_controller_->Install(frame); | 75 text_input_controller_->Install(frame); |
| 83 test_runner_->Install(frame); | 76 test_runner_->Install(frame); |
| 84 GCController::Install(frame); | 77 GCController::Install(frame); |
| 85 } | 78 } |
| 86 | 79 |
| 87 void TestInterfaces::ResetTestHelperControllers() { | 80 void TestInterfaces::ResetTestHelperControllers() { |
| 88 accessibility_controller_->Reset(); | 81 accessibility_controller_->Reset(); |
| 89 event_sender_->Reset(); | |
| 90 if (gamepad_controller_) | 82 if (gamepad_controller_) |
| 91 gamepad_controller_->Reset(); | 83 gamepad_controller_->Reset(); |
| 92 // text_input_controller_ doesn't have any state to reset. | 84 // text_input_controller_ doesn't have any state to reset. |
| 93 blink::WebCache::clear(); | 85 blink::WebCache::clear(); |
| 86 |
| 87 for (WebTestProxyBase* web_test_proxy_base : window_list_) |
| 88 web_test_proxy_base->Reset(); |
| 94 } | 89 } |
| 95 | 90 |
| 96 void TestInterfaces::ResetAll() { | 91 void TestInterfaces::ResetAll() { |
| 97 ResetTestHelperControllers(); | 92 ResetTestHelperControllers(); |
| 98 test_runner_->Reset(); | 93 test_runner_->Reset(); |
| 99 } | 94 } |
| 100 | 95 |
| 101 void TestInterfaces::SetTestIsRunning(bool running) { | 96 void TestInterfaces::SetTestIsRunning(bool running) { |
| 102 test_runner_->SetTestIsRunning(running); | 97 test_runner_->SetTestIsRunning(running); |
| 103 } | 98 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 NOTREACHED(); | 144 NOTREACHED(); |
| 150 return; | 145 return; |
| 151 } | 146 } |
| 152 window_list_.erase(pos); | 147 window_list_.erase(pos); |
| 153 } | 148 } |
| 154 | 149 |
| 155 AccessibilityController* TestInterfaces::GetAccessibilityController() { | 150 AccessibilityController* TestInterfaces::GetAccessibilityController() { |
| 156 return accessibility_controller_.get(); | 151 return accessibility_controller_.get(); |
| 157 } | 152 } |
| 158 | 153 |
| 159 EventSender* TestInterfaces::GetEventSender() { | |
| 160 return event_sender_.get(); | |
| 161 } | |
| 162 | |
| 163 TestRunner* TestInterfaces::GetTestRunner() { | 154 TestRunner* TestInterfaces::GetTestRunner() { |
| 164 return test_runner_.get(); | 155 return test_runner_.get(); |
| 165 } | 156 } |
| 166 | 157 |
| 167 WebTestDelegate* TestInterfaces::GetDelegate() { | 158 WebTestDelegate* TestInterfaces::GetDelegate() { |
| 168 return delegate_; | 159 return delegate_; |
| 169 } | 160 } |
| 170 | 161 |
| 171 const std::vector<WebTestProxyBase*>& TestInterfaces::GetWindowList() { | 162 const std::vector<WebTestProxyBase*>& TestInterfaces::GetWindowList() { |
| 172 return window_list_; | 163 return window_list_; |
| 173 } | 164 } |
| 174 | 165 |
| 175 blink::WebThemeEngine* TestInterfaces::GetThemeEngine() { | 166 blink::WebThemeEngine* TestInterfaces::GetThemeEngine() { |
| 176 if (!test_runner_->UseMockTheme()) | 167 if (!test_runner_->UseMockTheme()) |
| 177 return 0; | 168 return 0; |
| 178 if (!theme_engine_.get()) | 169 if (!theme_engine_.get()) |
| 179 theme_engine_.reset(new MockWebThemeEngine()); | 170 theme_engine_.reset(new MockWebThemeEngine()); |
| 180 return theme_engine_.get(); | 171 return theme_engine_.get(); |
| 181 } | 172 } |
| 182 | 173 |
| 183 AppBannerClient* TestInterfaces::GetAppBannerClient() { | 174 AppBannerClient* TestInterfaces::GetAppBannerClient() { |
| 184 return app_banner_client_; | 175 return app_banner_client_; |
| 185 } | 176 } |
| 186 | 177 |
| 187 } // namespace test_runner | 178 } // namespace test_runner |
| OLD | NEW |