diff options
author | lukasza <lukasza@chromium.org> | 2016-03-17 15:41:20 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-17 22:43:40 +0000 |
commit | 6a113ae1eed99940208bef750221d2f9ff058c9b (patch) | |
tree | 4aaf8490adbdf493eb85cd900f9008a6f2179d50 | |
parent | c70a5078f6305cc29ab8f5f8023979cdb8b42236 (diff) | |
download | chromium_src-6a113ae1eed99940208bef750221d2f9ff058c9b.zip chromium_src-6a113ae1eed99940208bef750221d2f9ff058c9b.tar.gz chromium_src-6a113ae1eed99940208bef750221d2f9ff058c9b.tar.bz2 |
Make MockScreenOrientationClient an internal detail of components/test_runner.
Ownership of MockScreenOrientationClient can be moved to TestRunner
(which holds ownership of other things that can be influenced by
javascript bindings).
Furthermore, TestRunner doesn't need to take a detour via
WebTestDelegate (aka BlinkTestRunner) to interact with
MockScreenOrientationClient. This means that we can remove three
screen-orientation-related methods from WebTestDelegate. This in turn
means that components/test_runner/mock_screen_orientation_client.h
header no longer needs to be included outside of components/test_runner.
BUG=595089
Review URL: https://codereview.chromium.org/1807733002
Cr-Commit-Position: refs/heads/master@{#381814}
-rw-r--r-- | components/test_runner/test_runner.cc | 18 | ||||
-rw-r--r-- | components/test_runner/test_runner.h | 4 | ||||
-rw-r--r-- | components/test_runner/web_test_delegate.h | 11 | ||||
-rw-r--r-- | components/test_runner/web_test_proxy.cc | 14 | ||||
-rw-r--r-- | components/test_runner/web_test_proxy.h | 1 | ||||
-rw-r--r-- | content/shell/renderer/layout_test/blink_test_runner.cc | 22 | ||||
-rw-r--r-- | content/shell/renderer/layout_test/blink_test_runner.h | 5 |
7 files changed, 23 insertions, 52 deletions
diff --git a/components/test_runner/test_runner.cc b/components/test_runner/test_runner.cc index acc03f7..571ffb0 100644 --- a/components/test_runner/test_runner.cc +++ b/components/test_runner/test_runner.cc @@ -16,6 +16,7 @@ #include "build/build_config.h" #include "components/test_runner/app_banner_client.h" #include "components/test_runner/mock_credential_manager_client.h" +#include "components/test_runner/mock_screen_orientation_client.h" #include "components/test_runner/mock_web_speech_recognizer.h" #include "components/test_runner/test_interfaces.h" #include "components/test_runner/test_preferences.h" @@ -1663,6 +1664,7 @@ TestRunner::TestRunner(TestInterfaces* interfaces) delegate_(nullptr), web_view_(nullptr), web_content_settings_(new WebContentSettings()), + mock_screen_orientation_client_(new MockScreenOrientationClient), weak_factory_(this) {} TestRunner::~TestRunner() {} @@ -1700,6 +1702,7 @@ void TestRunner::Reset() { top_loading_frame_ = nullptr; layout_dump_flags_.Reset(); + mock_screen_orientation_client_->ResetData(); wait_until_external_url_load_ = false; policy_delegate_enabled_ = false; policy_delegate_is_permissive_ = false; @@ -1720,7 +1723,6 @@ void TestRunner::Reset() { delegate_->UseUnfortunateSynchronousResizeMode(false); delegate_->DisableAutoResizeMode(WebSize()); delegate_->DeleteAllCookies(); - delegate_->ResetScreenOrientation(); delegate_->SetBluetoothMockDataSet(""); delegate_->ClearGeofencingMockProvider(); delegate_->ResetPermissions(); @@ -2500,6 +2502,10 @@ void TestRunner::SetMockDeviceOrientation(bool has_alpha, double alpha, delegate_->SetDeviceOrientationData(orientation); } +MockScreenOrientationClient* TestRunner::getMockScreenOrientationClient() { + return mock_screen_orientation_client_.get(); +} + void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { blink::WebScreenOrientationType orientation; @@ -2509,15 +2515,19 @@ void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { orientation = WebScreenOrientationPortraitSecondary; } else if (orientation_str == "landscape-primary") { orientation = WebScreenOrientationLandscapePrimary; - } else if (orientation_str == "landscape-secondary") { + } else { + DCHECK_EQ("landscape-secondary", orientation_str); orientation = WebScreenOrientationLandscapeSecondary; } - delegate_->SetScreenOrientation(orientation); + // TODO(lukasza): This is broken for OOPIFs. + WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame(); + mock_screen_orientation_client_->UpdateDeviceOrientation( + main_frame, orientation); } void TestRunner::DisableMockScreenOrientation() { - delegate_->DisableMockScreenOrientation(); + mock_screen_orientation_client_->SetDisabled(true); } void TestRunner::DidAcquirePointerLock() { diff --git a/components/test_runner/test_runner.h b/components/test_runner/test_runner.h index b671cee..8abc27b 100644 --- a/components/test_runner/test_runner.h +++ b/components/test_runner/test_runner.h @@ -41,6 +41,7 @@ class Arguments; namespace test_runner { class InvokeCallbackTask; +class MockScreenOrientationClient; class TestInterfaces; class WebContentSettings; class WebTestDelegate; @@ -81,6 +82,7 @@ class TestRunner : public WebTestRunner, // Methods used by WebTestProxyBase. bool shouldStayOnPageAfterHandlingBeforeUnload() const; + MockScreenOrientationClient* getMockScreenOrientationClient(); bool shouldDumpSelectionRect() const; bool isPrinting() const; bool shouldDumpAsTextWithPixelResults(); @@ -812,6 +814,8 @@ class TestRunner : public WebTestRunner, } pointer_lock_planned_result_; bool use_mock_theme_; + scoped_ptr<MockScreenOrientationClient> mock_screen_orientation_client_; + base::WeakPtrFactory<TestRunner> weak_factory_; DISALLOW_COPY_AND_ASSIGN(TestRunner); diff --git a/components/test_runner/web_test_delegate.h b/components/test_runner/web_test_delegate.h index 32a3457..8a0edea 100644 --- a/components/test_runner/web_test_delegate.h +++ b/components/test_runner/web_test_delegate.h @@ -77,17 +77,6 @@ class WebTestDelegate { virtual void SetDeviceOrientationData( const blink::WebDeviceOrientationData& data) = 0; - // Set orientation to set when registering via - // Platform::setScreenOrientationListener(). - virtual void SetScreenOrientation( - const blink::WebScreenOrientationType& orientation) = 0; - - // Reset the screen orientation data used for testing. - virtual void ResetScreenOrientation() = 0; - - // Disables screen orientation test-specific mock. - virtual void DisableMockScreenOrientation() = 0; - // Add a message to the text dump for the layout test. virtual void PrintMessage(const std::string& message) = 0; diff --git a/components/test_runner/web_test_proxy.cc b/components/test_runner/web_test_proxy.cc index 2db9db4..0f181e5 100644 --- a/components/test_runner/web_test_proxy.cc +++ b/components/test_runner/web_test_proxy.cc @@ -608,21 +608,17 @@ void WebTestProxyBase::LayoutAndPaintAsyncThen(const base::Closure& callback) { void WebTestProxyBase::GetScreenOrientationForTesting( blink::WebScreenInfo& screen_info) { - if (!screen_orientation_client_ || screen_orientation_client_->IsDisabled()) + MockScreenOrientationClient* mock_client = GetScreenOrientationClientMock(); + if (mock_client->IsDisabled()) return; // Override screen orientation information with mock data. - screen_info.orientationType = - screen_orientation_client_->CurrentOrientationType(); - screen_info.orientationAngle = - screen_orientation_client_->CurrentOrientationAngle(); + screen_info.orientationType = mock_client->CurrentOrientationType(); + screen_info.orientationAngle = mock_client->CurrentOrientationAngle(); } MockScreenOrientationClient* WebTestProxyBase::GetScreenOrientationClientMock() { - if (!screen_orientation_client_.get()) { - screen_orientation_client_.reset(new MockScreenOrientationClient); - } - return screen_orientation_client_.get(); + return test_interfaces_->GetTestRunner()->getMockScreenOrientationClient(); } MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() { diff --git a/components/test_runner/web_test_proxy.h b/components/test_runner/web_test_proxy.h index de8c181..f9e9ef8 100644 --- a/components/test_runner/web_test_proxy.h +++ b/components/test_runner/web_test_proxy.h @@ -270,7 +270,6 @@ class TEST_RUNNER_EXPORT WebTestProxyBase { scoped_ptr<MockCredentialManagerClient> credential_manager_client_; scoped_ptr<MockWebSpeechRecognizer> speech_recognizer_; - scoped_ptr<MockScreenOrientationClient> screen_orientation_client_; std::string accept_languages_; diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc index 93d19f58..758d945 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.cc +++ b/content/shell/renderer/layout_test/blink_test_runner.cc @@ -32,7 +32,6 @@ #include "components/test_runner/gamepad_controller.h" #include "components/test_runner/layout_dump.h" #include "components/test_runner/layout_dump_flags.h" -#include "components/test_runner/mock_screen_orientation_client.h" #include "components/test_runner/test_interfaces.h" #include "components/test_runner/web_task.h" #include "components/test_runner/web_test_interfaces.h" @@ -107,7 +106,6 @@ using blink::WebString; using blink::WebURL; using blink::WebURLError; using blink::WebURLRequest; -using blink::WebScreenOrientationType; using blink::WebTestingSupport; using blink::WebTraceLocation; using blink::WebThread; @@ -290,26 +288,6 @@ void BlinkTestRunner::SetDeviceOrientationData( SetMockDeviceOrientationData(data); } -void BlinkTestRunner::SetScreenOrientation( - const WebScreenOrientationType& orientation) { - test_runner::MockScreenOrientationClient* mock_client = - proxy()->GetScreenOrientationClientMock(); - mock_client->UpdateDeviceOrientation( - render_view()->GetWebView()->mainFrame()->toWebLocalFrame(), orientation); -} - -void BlinkTestRunner::DisableMockScreenOrientation() { - test_runner::MockScreenOrientationClient* mock_client = - proxy()->GetScreenOrientationClientMock(); - mock_client->SetDisabled(true); -} - -void BlinkTestRunner::ResetScreenOrientation() { - test_runner::MockScreenOrientationClient* mock_client = - proxy()->GetScreenOrientationClientMock(); - mock_client->ResetData(); -} - void BlinkTestRunner::PrintMessage(const std::string& message) { Send(new ShellViewHostMsg_PrintMessage(routing_id(), message)); } diff --git a/content/shell/renderer/layout_test/blink_test_runner.h b/content/shell/renderer/layout_test/blink_test_runner.h index 3827920..902badc 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.h +++ b/content/shell/renderer/layout_test/blink_test_runner.h @@ -18,7 +18,6 @@ #include "content/public/renderer/render_view_observer.h" #include "content/public/renderer/render_view_observer_tracker.h" #include "content/shell/common/shell_test_configuration.h" -#include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationType.h" #include "v8/include/v8.h" class SkBitmap; @@ -71,10 +70,6 @@ class BlinkTestRunner : public RenderViewObserver, void SetDeviceMotionData(const blink::WebDeviceMotionData& data) override; void SetDeviceOrientationData( const blink::WebDeviceOrientationData& data) override; - void SetScreenOrientation( - const blink::WebScreenOrientationType& orientation) override; - void DisableMockScreenOrientation() override; - void ResetScreenOrientation() override; void PrintMessage(const std::string& message) override; void PostTask(test_runner::WebTask* task) override; void PostDelayedTask(test_runner::WebTask* task, long long ms) override; |