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

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

Issue 2648123003: MockColorChooser
Patch Set: Created 3 years, 11 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') | no next file » | 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/nullable_string16.h" 14 #include "base/strings/nullable_string16.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "components/test_runner/layout_and_paint_async_then.h" 19 #include "components/test_runner/layout_and_paint_async_then.h"
20 #include "components/test_runner/layout_dump.h" 20 #include "components/test_runner/layout_dump.h"
21 #include "components/test_runner/mock_color_chooser.h"
21 #include "components/test_runner/mock_content_settings_client.h" 22 #include "components/test_runner/mock_content_settings_client.h"
22 #include "components/test_runner/mock_credential_manager_client.h" 23 #include "components/test_runner/mock_credential_manager_client.h"
23 #include "components/test_runner/mock_screen_orientation_client.h" 24 #include "components/test_runner/mock_screen_orientation_client.h"
24 #include "components/test_runner/mock_web_document_subresource_filter.h" 25 #include "components/test_runner/mock_web_document_subresource_filter.h"
25 #include "components/test_runner/mock_web_speech_recognizer.h" 26 #include "components/test_runner/mock_web_speech_recognizer.h"
26 #include "components/test_runner/mock_web_user_media_client.h" 27 #include "components/test_runner/mock_web_user_media_client.h"
27 #include "components/test_runner/pixel_dump.h" 28 #include "components/test_runner/pixel_dump.h"
28 #include "components/test_runner/spell_check_client.h" 29 #include "components/test_runner/spell_check_client.h"
29 #include "components/test_runner/test_common.h" 30 #include "components/test_runner/test_common.h"
30 #include "components/test_runner/test_interfaces.h" 31 #include "components/test_runner/test_interfaces.h"
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 web_history_item_count_(0), 1611 web_history_item_count_(0),
1611 test_interfaces_(interfaces), 1612 test_interfaces_(interfaces),
1612 delegate_(nullptr), 1613 delegate_(nullptr),
1613 main_view_(nullptr), 1614 main_view_(nullptr),
1614 mock_content_settings_client_( 1615 mock_content_settings_client_(
1615 new MockContentSettingsClient(&layout_test_runtime_flags_)), 1616 new MockContentSettingsClient(&layout_test_runtime_flags_)),
1616 will_navigate_(false), 1617 will_navigate_(false),
1617 credential_manager_client_(new MockCredentialManagerClient), 1618 credential_manager_client_(new MockCredentialManagerClient),
1618 mock_screen_orientation_client_(new MockScreenOrientationClient), 1619 mock_screen_orientation_client_(new MockScreenOrientationClient),
1619 spellcheck_(new SpellCheckClient(this)), 1620 spellcheck_(new SpellCheckClient(this)),
1620 chooser_count_(0),
1621 previously_focused_view_(nullptr), 1621 previously_focused_view_(nullptr),
1622 is_web_platform_tests_mode_(false), 1622 is_web_platform_tests_mode_(false),
1623 effective_connection_type_( 1623 effective_connection_type_(
1624 blink::WebEffectiveConnectionType::TypeUnknown), 1624 blink::WebEffectiveConnectionType::TypeUnknown),
1625 weak_factory_(this) {} 1625 weak_factory_(this) {}
1626 1626
1627 TestRunner::~TestRunner() {} 1627 TestRunner::~TestRunner() {}
1628 1628
1629 void TestRunner::Install( 1629 void TestRunner::Install(
1630 WebLocalFrame* frame, 1630 WebLocalFrame* frame,
1631 base::WeakPtr<TestRunnerForSpecificView> view_test_runner) { 1631 base::WeakPtr<TestRunnerForSpecificView> view_test_runner) {
1632 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), view_test_runner, 1632 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), view_test_runner,
1633 frame); 1633 frame);
1634 } 1634 }
1635 1635
1636 void TestRunner::SetDelegate(WebTestDelegate* delegate) { 1636 void TestRunner::SetDelegate(WebTestDelegate* delegate) {
1637 delegate_ = delegate; 1637 delegate_ = delegate;
1638 mock_content_settings_client_->SetDelegate(delegate); 1638 mock_content_settings_client_->SetDelegate(delegate);
1639 spellcheck_->SetDelegate(delegate); 1639 spellcheck_->SetDelegate(delegate);
1640 if (speech_recognizer_) 1640 if (speech_recognizer_)
1641 speech_recognizer_->SetDelegate(delegate); 1641 speech_recognizer_->SetDelegate(delegate);
1642 for (auto& chooser : active_color_choosers_) {
1643 chooser->SetDelegate(delegate);
1644 }
1642 } 1645 }
1643 1646
1644 void TestRunner::SetMainView(WebView* web_view) { 1647 void TestRunner::SetMainView(WebView* web_view) {
1645 main_view_ = web_view; 1648 main_view_ = web_view;
1646 if (disable_v8_cache_) 1649 if (disable_v8_cache_)
1647 SetV8CacheDisabled(true); 1650 SetV8CacheDisabled(true);
1648 } 1651 }
1649 1652
1650 void TestRunner::Reset() { 1653 void TestRunner::Reset() {
1651 is_web_platform_tests_mode_ = false; 1654 is_web_platform_tests_mode_ = false;
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 mock_screen_orientation_client_->UpdateDeviceOrientation( 2320 mock_screen_orientation_client_->UpdateDeviceOrientation(
2318 main_frame->toWebLocalFrame(), orientation); 2321 main_frame->toWebLocalFrame(), orientation);
2319 } 2322 }
2320 } 2323 }
2321 } 2324 }
2322 2325
2323 void TestRunner::DisableMockScreenOrientation() { 2326 void TestRunner::DisableMockScreenOrientation() {
2324 mock_screen_orientation_client_->SetDisabled(true); 2327 mock_screen_orientation_client_->SetDisabled(true);
2325 } 2328 }
2326 2329
2327 void TestRunner::DidOpenChooser() { 2330 void TestRunner::DidOpenChooser(MockColorChooser* color_chooser) {
2328 chooser_count_++; 2331 DCHECK(active_color_choosers_.count(color_chooser) == 0);
2332 active_color_choosers_.insert(color_chooser);
2329 } 2333 }
2330 2334
2331 void TestRunner::DidCloseChooser() { 2335 void TestRunner::DidCloseChooser(MockColorChooser* color_chooser) {
2332 chooser_count_--; 2336 active_color_choosers_.erase(color_chooser);
2333 DCHECK_LE(0, chooser_count_); 2337 DCHECK_LE(0U, active_color_choosers_.size());
2334 } 2338 }
2335 2339
2336 void TestRunner::SetPopupBlockingEnabled(bool block_popups) { 2340 void TestRunner::SetPopupBlockingEnabled(bool block_popups) {
2337 delegate_->Preferences()->java_script_can_open_windows_automatically = 2341 delegate_->Preferences()->java_script_can_open_windows_automatically =
2338 !block_popups; 2342 !block_popups;
2339 delegate_->ApplyPreferences(); 2343 delegate_->ApplyPreferences();
2340 } 2344 }
2341 2345
2342 void TestRunner::SetJavaScriptCanAccessClipboard(bool can_access) { 2346 void TestRunner::SetJavaScriptCanAccessClipboard(bool can_access) {
2343 delegate_->Preferences()->java_script_can_access_clipboard = can_access; 2347 delegate_->Preferences()->java_script_can_access_clipboard = can_access;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 2659
2656 bool TestRunner::ShouldDumpJavaScriptDialogs() const { 2660 bool TestRunner::ShouldDumpJavaScriptDialogs() const {
2657 return layout_test_runtime_flags_.dump_javascript_dialogs(); 2661 return layout_test_runtime_flags_.dump_javascript_dialogs();
2658 } 2662 }
2659 2663
2660 void TestRunner::CloseWebInspector() { 2664 void TestRunner::CloseWebInspector() {
2661 delegate_->CloseDevTools(); 2665 delegate_->CloseDevTools();
2662 } 2666 }
2663 2667
2664 bool TestRunner::IsChooserShown() { 2668 bool TestRunner::IsChooserShown() {
2665 return 0 < chooser_count_; 2669 return 0 < active_color_choosers_.size();
2666 } 2670 }
2667 2671
2668 void TestRunner::EvaluateInWebInspector(int call_id, 2672 void TestRunner::EvaluateInWebInspector(int call_id,
2669 const std::string& script) { 2673 const std::string& script) {
2670 delegate_->EvaluateInWebInspector(call_id, script); 2674 delegate_->EvaluateInWebInspector(call_id, script);
2671 } 2675 }
2672 2676
2673 std::string TestRunner::EvaluateInWebInspectorOverlay( 2677 std::string TestRunner::EvaluateInWebInspectorOverlay(
2674 const std::string& script) { 2678 const std::string& script) {
2675 return delegate_->EvaluateInWebInspectorOverlay(script); 2679 return delegate_->EvaluateInWebInspectorOverlay(script);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 2817
2814 void TestRunner::NotifyDone() { 2818 void TestRunner::NotifyDone() {
2815 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && 2819 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
2816 !will_navigate_ && work_queue_.is_empty()) 2820 !will_navigate_ && work_queue_.is_empty())
2817 delegate_->TestFinished(); 2821 delegate_->TestFinished();
2818 layout_test_runtime_flags_.set_wait_until_done(false); 2822 layout_test_runtime_flags_.set_wait_until_done(false);
2819 OnLayoutTestRuntimeFlagsChanged(); 2823 OnLayoutTestRuntimeFlagsChanged();
2820 } 2824 }
2821 2825
2822 } // namespace test_runner 2826 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/test_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698