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

Side by Side Diff: components/test_runner/test_runner.cc

Issue 1847893002: Extract WebFrameClient implementation out of WebTestProxyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert some changes to mock_color_chooser.cc + fix counting of TestRunner::chooser_count_. Created 4 years, 8 months 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
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/test_runner.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_runner.h" 5 #include "components/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "components/test_runner/app_banner_client.h" 17 #include "components/test_runner/app_banner_client.h"
18 #include "components/test_runner/layout_dump.h" 18 #include "components/test_runner/layout_dump.h"
19 #include "components/test_runner/mock_credential_manager_client.h" 19 #include "components/test_runner/mock_credential_manager_client.h"
20 #include "components/test_runner/mock_screen_orientation_client.h" 20 #include "components/test_runner/mock_screen_orientation_client.h"
21 #include "components/test_runner/mock_web_speech_recognizer.h" 21 #include "components/test_runner/mock_web_speech_recognizer.h"
22 #include "components/test_runner/mock_web_user_media_client.h"
22 #include "components/test_runner/test_interfaces.h" 23 #include "components/test_runner/test_interfaces.h"
23 #include "components/test_runner/test_preferences.h" 24 #include "components/test_runner/test_preferences.h"
24 #include "components/test_runner/web_content_settings.h" 25 #include "components/test_runner/web_content_settings.h"
25 #include "components/test_runner/web_test_delegate.h" 26 #include "components/test_runner/web_test_delegate.h"
26 #include "components/test_runner/web_test_proxy.h" 27 #include "components/test_runner/web_test_proxy.h"
27 #include "gin/arguments.h" 28 #include "gin/arguments.h"
28 #include "gin/array_buffer.h" 29 #include "gin/array_buffer.h"
29 #include "gin/handle.h" 30 #include "gin/handle.h"
30 #include "gin/object_template_builder.h" 31 #include "gin/object_template_builder.h"
31 #include "gin/wrappable.h" 32 #include "gin/wrappable.h"
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 : test_is_running_(false), 1661 : test_is_running_(false),
1661 close_remaining_windows_(false), 1662 close_remaining_windows_(false),
1662 work_queue_(this), 1663 work_queue_(this),
1663 web_history_item_count_(0), 1664 web_history_item_count_(0),
1664 intercept_post_message_(false), 1665 intercept_post_message_(false),
1665 test_interfaces_(interfaces), 1666 test_interfaces_(interfaces),
1666 delegate_(nullptr), 1667 delegate_(nullptr),
1667 web_view_(nullptr), 1668 web_view_(nullptr),
1668 web_content_settings_(new WebContentSettings()), 1669 web_content_settings_(new WebContentSettings()),
1669 mock_screen_orientation_client_(new MockScreenOrientationClient), 1670 mock_screen_orientation_client_(new MockScreenOrientationClient),
1671 chooser_count_(0),
1670 weak_factory_(this) {} 1672 weak_factory_(this) {}
1671 1673
1672 TestRunner::~TestRunner() {} 1674 TestRunner::~TestRunner() {}
1673 1675
1674 void TestRunner::Install(WebFrame* frame) { 1676 void TestRunner::Install(WebFrame* frame) {
1675 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); 1677 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame);
1676 } 1678 }
1677 1679
1678 void TestRunner::SetDelegate(WebTestDelegate* delegate) { 1680 void TestRunner::SetDelegate(WebTestDelegate* delegate) {
1679 delegate_ = delegate; 1681 delegate_ = delegate;
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 // absolute 2513 // absolute
2512 orientation.absolute = absolute; 2514 orientation.absolute = absolute;
2513 2515
2514 delegate_->SetDeviceOrientationData(orientation); 2516 delegate_->SetDeviceOrientationData(orientation);
2515 } 2517 }
2516 2518
2517 MockScreenOrientationClient* TestRunner::getMockScreenOrientationClient() { 2519 MockScreenOrientationClient* TestRunner::getMockScreenOrientationClient() {
2518 return mock_screen_orientation_client_.get(); 2520 return mock_screen_orientation_client_.get();
2519 } 2521 }
2520 2522
2523 MockWebUserMediaClient* TestRunner::getMockWebUserMediaClient() {
2524 if (!user_media_client_.get())
2525 user_media_client_.reset(new MockWebUserMediaClient(delegate_));
2526 return user_media_client_.get();
2527 }
2528
2521 void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { 2529 void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) {
2522 blink::WebScreenOrientationType orientation; 2530 blink::WebScreenOrientationType orientation;
2523 2531
2524 if (orientation_str == "portrait-primary") { 2532 if (orientation_str == "portrait-primary") {
2525 orientation = WebScreenOrientationPortraitPrimary; 2533 orientation = WebScreenOrientationPortraitPrimary;
2526 } else if (orientation_str == "portrait-secondary") { 2534 } else if (orientation_str == "portrait-secondary") {
2527 orientation = WebScreenOrientationPortraitSecondary; 2535 orientation = WebScreenOrientationPortraitSecondary;
2528 } else if (orientation_str == "landscape-primary") { 2536 } else if (orientation_str == "landscape-primary") {
2529 orientation = WebScreenOrientationLandscapePrimary; 2537 orientation = WebScreenOrientationLandscapePrimary;
2530 } else { 2538 } else {
2531 DCHECK_EQ("landscape-secondary", orientation_str); 2539 DCHECK_EQ("landscape-secondary", orientation_str);
2532 orientation = WebScreenOrientationLandscapeSecondary; 2540 orientation = WebScreenOrientationLandscapeSecondary;
2533 } 2541 }
2534 2542
2535 // TODO(lukasza): This is broken for OOPIFs. 2543 // TODO(lukasza): This is broken for OOPIFs.
2536 WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame(); 2544 WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame();
2537 mock_screen_orientation_client_->UpdateDeviceOrientation( 2545 mock_screen_orientation_client_->UpdateDeviceOrientation(
2538 main_frame, orientation); 2546 main_frame, orientation);
2539 } 2547 }
2540 2548
2541 void TestRunner::DisableMockScreenOrientation() { 2549 void TestRunner::DisableMockScreenOrientation() {
2542 mock_screen_orientation_client_->SetDisabled(true); 2550 mock_screen_orientation_client_->SetDisabled(true);
2543 } 2551 }
2544 2552
2553 void TestRunner::DidOpenChooser() {
2554 chooser_count_++;
2555 }
2556
2557 void TestRunner::DidCloseChooser() {
2558 chooser_count_--;
2559 DCHECK_LE(0, chooser_count_);
2560 }
2561
2545 void TestRunner::DidAcquirePointerLock() { 2562 void TestRunner::DidAcquirePointerLock() {
2546 DidAcquirePointerLockInternal(); 2563 DidAcquirePointerLockInternal();
2547 } 2564 }
2548 2565
2549 void TestRunner::DidNotAcquirePointerLock() { 2566 void TestRunner::DidNotAcquirePointerLock() {
2550 DidNotAcquirePointerLockInternal(); 2567 DidNotAcquirePointerLockInternal();
2551 } 2568 }
2552 2569
2553 void TestRunner::DidLosePointerLock() { 2570 void TestRunner::DidLosePointerLock() {
2554 DidLosePointerLockInternal(); 2571 DidLosePointerLockInternal();
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 signals->issuedNonGetFetchFromScript() ? "true" : "false"); 2861 signals->issuedNonGetFetchFromScript() ? "true" : "false");
2845 if (delegate_) 2862 if (delegate_)
2846 delegate_->PrintMessage(message); 2863 delegate_->PrintMessage(message);
2847 } 2864 }
2848 2865
2849 void TestRunner::CloseWebInspector() { 2866 void TestRunner::CloseWebInspector() {
2850 delegate_->CloseDevTools(); 2867 delegate_->CloseDevTools();
2851 } 2868 }
2852 2869
2853 bool TestRunner::IsChooserShown() { 2870 bool TestRunner::IsChooserShown() {
2854 return proxy_->IsChooserShown(); 2871 return 0 < chooser_count_;
2855 } 2872 }
2856 2873
2857 void TestRunner::EvaluateInWebInspector(int call_id, 2874 void TestRunner::EvaluateInWebInspector(int call_id,
2858 const std::string& script) { 2875 const std::string& script) {
2859 delegate_->EvaluateInWebInspector(call_id, script); 2876 delegate_->EvaluateInWebInspector(call_id, script);
2860 } 2877 }
2861 2878
2862 std::string TestRunner::EvaluateInWebInspectorOverlay( 2879 std::string TestRunner::EvaluateInWebInspectorOverlay(
2863 const std::string& script) { 2880 const std::string& script) {
2864 return delegate_->EvaluateInWebInspectorOverlay(script); 2881 return delegate_->EvaluateInWebInspectorOverlay(script);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3225 } 3242 }
3226 3243
3227 void TestRunner::DidLosePointerLockInternal() { 3244 void TestRunner::DidLosePointerLockInternal() {
3228 bool was_locked = pointer_locked_; 3245 bool was_locked = pointer_locked_;
3229 pointer_locked_ = false; 3246 pointer_locked_ = false;
3230 if (was_locked) 3247 if (was_locked)
3231 web_view_->didLosePointerLock(); 3248 web_view_->didLosePointerLock();
3232 } 3249 }
3233 3250
3234 } // namespace test_runner 3251 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/test_runner.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698