| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "third_party/WebKit/public/platform/WebURL.h" | 22 #include "third_party/WebKit/public/platform/WebURL.h" |
| 23 #include "third_party/WebKit/public/web/WebCache.h" | 23 #include "third_party/WebKit/public/web/WebCache.h" |
| 24 #include "third_party/WebKit/public/web/WebKit.h" | 24 #include "third_party/WebKit/public/web/WebKit.h" |
| 25 #include "third_party/WebKit/public/web/WebView.h" | 25 #include "third_party/WebKit/public/web/WebView.h" |
| 26 | 26 |
| 27 namespace test_runner { | 27 namespace test_runner { |
| 28 | 28 |
| 29 TestInterfaces::TestInterfaces() | 29 TestInterfaces::TestInterfaces() |
| 30 : test_runner_(new TestRunner(this)), | 30 : test_runner_(new TestRunner(this)), |
| 31 delegate_(nullptr), | 31 delegate_(nullptr), |
| 32 app_banner_client_(nullptr) { | 32 app_banner_client_(nullptr), |
| 33 main_view_(nullptr) { |
| 33 blink::setLayoutTestMode(true); | 34 blink::setLayoutTestMode(true); |
| 34 // NOTE: please don't put feature specific enable flags here, | 35 // NOTE: please don't put feature specific enable flags here, |
| 35 // instead add them to RuntimeEnabledFeatures.in | 36 // instead add them to RuntimeEnabledFeatures.in |
| 36 | 37 |
| 37 ResetAll(); | 38 ResetAll(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 TestInterfaces::~TestInterfaces() { | 41 TestInterfaces::~TestInterfaces() { |
| 41 // gamepad_controller_ doesn't depend on WebView. | 42 // gamepad_controller_ doesn't depend on WebView. |
| 42 test_runner_->SetWebView(nullptr); | 43 test_runner_->SetMainView(nullptr); |
| 43 | 44 |
| 44 // gamepad_controller_ ignores SetDelegate(nullptr) | 45 // gamepad_controller_ ignores SetDelegate(nullptr) |
| 45 test_runner_->SetDelegate(nullptr); | 46 test_runner_->SetDelegate(nullptr); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void TestInterfaces::SetWebView(blink::WebView* web_view, | 49 void TestInterfaces::SetMainView(blink::WebView* web_view) { |
| 49 WebTestProxyBase* proxy) { | |
| 50 // gamepad_controller_ doesn't depend on WebView. | 50 // gamepad_controller_ doesn't depend on WebView. |
| 51 test_runner_->SetWebView(web_view); | 51 main_view_ = web_view; |
| 52 test_runner_->SetMainView(web_view); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void TestInterfaces::SetDelegate(WebTestDelegate* delegate) { | 55 void TestInterfaces::SetDelegate(WebTestDelegate* delegate) { |
| 55 gamepad_controller_ = GamepadController::Create(delegate); | 56 gamepad_controller_ = GamepadController::Create(delegate); |
| 56 test_runner_->SetDelegate(delegate); | 57 test_runner_->SetDelegate(delegate); |
| 57 delegate_ = delegate; | 58 delegate_ = delegate; |
| 58 } | 59 } |
| 59 | 60 |
| 60 void TestInterfaces::BindTo(blink::WebFrame* frame) { | 61 void TestInterfaces::BindTo(blink::WebFrame* frame) { |
| 61 if (gamepad_controller_) | 62 if (gamepad_controller_) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 123 } |
| 123 | 124 |
| 124 void TestInterfaces::WindowClosed(WebTestProxyBase* proxy) { | 125 void TestInterfaces::WindowClosed(WebTestProxyBase* proxy) { |
| 125 std::vector<WebTestProxyBase*>::iterator pos = | 126 std::vector<WebTestProxyBase*>::iterator pos = |
| 126 std::find(window_list_.begin(), window_list_.end(), proxy); | 127 std::find(window_list_.begin(), window_list_.end(), proxy); |
| 127 if (pos == window_list_.end()) { | 128 if (pos == window_list_.end()) { |
| 128 NOTREACHED(); | 129 NOTREACHED(); |
| 129 return; | 130 return; |
| 130 } | 131 } |
| 131 window_list_.erase(pos); | 132 window_list_.erase(pos); |
| 133 |
| 134 if (proxy->web_view() == main_view_) |
| 135 SetMainView(nullptr); |
| 132 } | 136 } |
| 133 | 137 |
| 134 TestRunner* TestInterfaces::GetTestRunner() { | 138 TestRunner* TestInterfaces::GetTestRunner() { |
| 135 return test_runner_.get(); | 139 return test_runner_.get(); |
| 136 } | 140 } |
| 137 | 141 |
| 138 WebTestDelegate* TestInterfaces::GetDelegate() { | 142 WebTestDelegate* TestInterfaces::GetDelegate() { |
| 139 return delegate_; | 143 return delegate_; |
| 140 } | 144 } |
| 141 | 145 |
| 142 const std::vector<WebTestProxyBase*>& TestInterfaces::GetWindowList() { | 146 const std::vector<WebTestProxyBase*>& TestInterfaces::GetWindowList() { |
| 143 return window_list_; | 147 return window_list_; |
| 144 } | 148 } |
| 145 | 149 |
| 146 blink::WebThemeEngine* TestInterfaces::GetThemeEngine() { | 150 blink::WebThemeEngine* TestInterfaces::GetThemeEngine() { |
| 147 if (!test_runner_->UseMockTheme()) | 151 if (!test_runner_->UseMockTheme()) |
| 148 return 0; | 152 return 0; |
| 149 if (!theme_engine_.get()) | 153 if (!theme_engine_.get()) |
| 150 theme_engine_.reset(new MockWebThemeEngine()); | 154 theme_engine_.reset(new MockWebThemeEngine()); |
| 151 return theme_engine_.get(); | 155 return theme_engine_.get(); |
| 152 } | 156 } |
| 153 | 157 |
| 154 AppBannerClient* TestInterfaces::GetAppBannerClient() { | 158 AppBannerClient* TestInterfaces::GetAppBannerClient() { |
| 155 return app_banner_client_; | 159 return app_banner_client_; |
| 156 } | 160 } |
| 157 | 161 |
| 158 } // namespace test_runner | 162 } // namespace test_runner |
| OLD | NEW |