Move MockScreenOrientationController to content/shell/renderer/test_runner/
Move MockScreenOrientationController to content/shell/renderer/test_runner/ and have it implement the blink::WebScreenOrientationClient API so that locking / unlocking works from layout tests. R=mlamouri@chromium.org, jochen@chromium.org Review URL: https://codereview.chromium.org/339913002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280209 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
content
content_renderer.gypicontent_shell.gypi
public
renderer
render_view_impl.ccrender_view_impl.hrenderer_webkitplatformsupport_impl.ccrenderer_webkitplatformsupport_impl.h
screen_orientation
shell
renderer
test
@ -418,8 +418,6 @@
|
||||
'renderer/sad_plugin.h',
|
||||
'renderer/savable_resources.cc',
|
||||
'renderer/savable_resources.h',
|
||||
'renderer/screen_orientation/mock_screen_orientation_controller.cc',
|
||||
'renderer/screen_orientation/mock_screen_orientation_controller.h',
|
||||
'renderer/screen_orientation/screen_orientation_dispatcher.cc',
|
||||
'renderer/screen_orientation/screen_orientation_dispatcher.h',
|
||||
'renderer/scoped_clipboard_writer_glue.cc',
|
||||
|
@ -210,6 +210,8 @@
|
||||
'shell/renderer/test_runner/mock_constraints.h',
|
||||
'shell/renderer/test_runner/mock_grammar_check.cc',
|
||||
'shell/renderer/test_runner/mock_grammar_check.h',
|
||||
'shell/renderer/test_runner/mock_screen_orientation_client.cc',
|
||||
'shell/renderer/test_runner/mock_screen_orientation_client.h',
|
||||
'shell/renderer/test_runner/mock_web_audio_device.cc',
|
||||
'shell/renderer/test_runner/mock_web_audio_device.h',
|
||||
'shell/renderer/test_runner/mock_web_push_client.cc',
|
||||
|
@ -56,14 +56,6 @@ void SetMockDeviceMotionData(const blink::WebDeviceMotionData& data);
|
||||
// a listener through WebKitPlatformSupport::setDeviceOrientationListener().
|
||||
void SetMockDeviceOrientationData(const blink::WebDeviceOrientationData& data);
|
||||
|
||||
// Sets WebScreenOrientationType that should be used as a mock orientation.
|
||||
void SetMockScreenOrientation(
|
||||
RenderView* render_view,
|
||||
const blink::WebScreenOrientationType& orientation);
|
||||
|
||||
// Resets the mock screen orientation data.
|
||||
void ResetMockScreenOrientation();
|
||||
|
||||
// Notifies blink that battery status has changed.
|
||||
void MockBatteryStatusChanged(const blink::WebBatteryStatus& status);
|
||||
|
||||
|
@ -3925,36 +3925,6 @@ void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) {
|
||||
OnResize(params);
|
||||
}
|
||||
|
||||
void RenderViewImpl::SetScreenOrientationForTesting(
|
||||
const blink::WebScreenOrientationType& orientation) {
|
||||
ViewMsg_Resize_Params params;
|
||||
params.screen_info = screen_info_;
|
||||
params.screen_info.orientationType = orientation;
|
||||
// FIXME(ostap): This relationship between orientationType and
|
||||
// orientationAngle is temporary. The test should be able to specify
|
||||
// the angle in addition to the orientation type.
|
||||
switch (orientation) {
|
||||
case blink::WebScreenOrientationLandscapePrimary:
|
||||
params.screen_info.orientationAngle = 90;
|
||||
break;
|
||||
case blink::WebScreenOrientationLandscapeSecondary:
|
||||
params.screen_info.orientationAngle = -90;
|
||||
break;
|
||||
case blink::WebScreenOrientationPortraitSecondary:
|
||||
params.screen_info.orientationAngle = 180;
|
||||
break;
|
||||
default:
|
||||
params.screen_info.orientationAngle = 0;
|
||||
}
|
||||
params.new_size = size();
|
||||
params.physical_backing_size = gfx::ToCeiledSize(
|
||||
gfx::ScaleSize(size(), params.screen_info.deviceScaleFactor));
|
||||
params.overdraw_bottom_height = 0.f;
|
||||
params.resizer_rect = WebRect();
|
||||
params.is_fullscreen = is_fullscreen();
|
||||
OnResize(params);
|
||||
}
|
||||
|
||||
void RenderViewImpl::SetDeviceColorProfileForTesting(
|
||||
const std::vector<char>& color_profile) {
|
||||
SetDeviceColorProfile(color_profile);
|
||||
|
@ -354,10 +354,6 @@ class CONTENT_EXPORT RenderViewImpl
|
||||
// Change the device scale factor and force the compositor to resize.
|
||||
void SetDeviceScaleFactorForTesting(float factor);
|
||||
|
||||
// Change screen orientation and force the compositor to resize.
|
||||
void SetScreenOrientationForTesting(
|
||||
const blink::WebScreenOrientationType& orientation);
|
||||
|
||||
// Change the device ICC color profile while running a layout test.
|
||||
void SetDeviceColorProfileForTesting(const std::vector<char>& color_profile);
|
||||
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
|
||||
#include "content/renderer/render_thread_impl.h"
|
||||
#include "content/renderer/renderer_clipboard_client.h"
|
||||
#include "content/renderer/screen_orientation/mock_screen_orientation_controller.h"
|
||||
#include "content/renderer/webclipboard_impl.h"
|
||||
#include "content/renderer/webgraphicscontext3d_provider_impl.h"
|
||||
#include "content/renderer/webpublicsuffixlist_impl.h"
|
||||
@ -145,8 +144,6 @@ base::LazyInstance<blink::WebDeviceMotionData>::Leaky
|
||||
g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
|
||||
base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
|
||||
g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
|
||||
base::LazyInstance<MockScreenOrientationController>::Leaky
|
||||
g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER;
|
||||
base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky
|
||||
g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
@ -1045,13 +1042,6 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
|
||||
g_test_device_motion_data.Get() = data;
|
||||
}
|
||||
|
||||
// static
|
||||
void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting()
|
||||
{
|
||||
if (!(g_test_screen_orientation_controller == 0))
|
||||
g_test_screen_orientation_controller.Get().ResetData();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener(
|
||||
@ -1092,16 +1082,6 @@ void RendererWebKitPlatformSupportImpl::cancelVibration() {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// static
|
||||
void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
|
||||
RenderView* render_view,
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
g_test_screen_orientation_controller.Get()
|
||||
.UpdateDeviceOrientation(render_view, orientation);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota(
|
||||
const blink::WebURL& storage_partition,
|
||||
blink::WebStorageQuotaType type,
|
||||
|
@ -169,12 +169,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
|
||||
// is invoked.
|
||||
static void SetMockDeviceOrientationDataForTesting(
|
||||
const blink::WebDeviceOrientationData& data);
|
||||
// Forces the screen orientation for testing purposes.
|
||||
static void SetMockScreenOrientationForTesting(
|
||||
RenderView* render_view,
|
||||
blink::WebScreenOrientationType);
|
||||
// Resets the mock screen orientation data used for testing.
|
||||
static void ResetMockScreenOrientationForTesting();
|
||||
|
||||
// Notifies blink::WebBatteryStatusListener that battery status has changed.
|
||||
static void MockBatteryStatusChangedForTesting(
|
||||
|
@ -1,98 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/screen_orientation/mock_screen_orientation_controller.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "content/renderer/render_view_impl.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
MockScreenOrientationController::MockScreenOrientationController()
|
||||
: RenderViewObserver(NULL),
|
||||
current_lock_(blink::WebScreenOrientationLockDefault),
|
||||
device_orientation_(blink::WebScreenOrientationPortraitPrimary),
|
||||
current_orientation_(blink::WebScreenOrientationPortraitPrimary) {
|
||||
// Since MockScreenOrientationController is held by LazyInstance reference,
|
||||
// add this ref for it.
|
||||
AddRef();
|
||||
}
|
||||
|
||||
MockScreenOrientationController::~MockScreenOrientationController() {
|
||||
}
|
||||
|
||||
void MockScreenOrientationController::ResetData() {
|
||||
if (render_view_impl())
|
||||
render_view_impl()->RemoveObserver(this);
|
||||
|
||||
current_lock_ = blink::WebScreenOrientationLockDefault;
|
||||
device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
|
||||
current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
|
||||
}
|
||||
|
||||
void MockScreenOrientationController::UpdateDeviceOrientation(
|
||||
RenderView* render_view,
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
if (this->render_view()) {
|
||||
// Make sure that render_view_ did not change during test.
|
||||
DCHECK_EQ(this->render_view(), render_view);
|
||||
} else {
|
||||
Observe(render_view);
|
||||
}
|
||||
|
||||
if (device_orientation_ == orientation)
|
||||
return;
|
||||
device_orientation_ = orientation;
|
||||
if (!IsOrientationAllowedByCurrentLock(orientation))
|
||||
return;
|
||||
UpdateScreenOrientation(orientation);
|
||||
}
|
||||
|
||||
RenderViewImpl* MockScreenOrientationController::render_view_impl() const {
|
||||
return static_cast<RenderViewImpl*>(render_view());
|
||||
}
|
||||
|
||||
void MockScreenOrientationController::UpdateScreenOrientation(
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
if (current_orientation_ == orientation)
|
||||
return;
|
||||
current_orientation_ = orientation;
|
||||
if (render_view_impl())
|
||||
render_view_impl()->SetScreenOrientationForTesting(orientation);
|
||||
}
|
||||
|
||||
bool MockScreenOrientationController::IsOrientationAllowedByCurrentLock(
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
if (current_lock_ == blink::WebScreenOrientationLockDefault ||
|
||||
current_lock_ == blink::WebScreenOrientationLockAny) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (orientation) {
|
||||
case blink::WebScreenOrientationPortraitPrimary:
|
||||
return current_lock_ == blink::WebScreenOrientationLockPortraitPrimary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockPortrait;
|
||||
case blink::WebScreenOrientationPortraitSecondary:
|
||||
return current_lock_ ==
|
||||
blink::WebScreenOrientationLockPortraitSecondary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockPortrait;
|
||||
case blink::WebScreenOrientationLandscapePrimary:
|
||||
return current_lock_ == blink::WebScreenOrientationLockLandscapePrimary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockLandscape ||
|
||||
current_lock_ == blink::WebScreenOrientationLockNatural;
|
||||
case blink::WebScreenOrientationLandscapeSecondary:
|
||||
return current_lock_ ==
|
||||
blink::WebScreenOrientationLockLandscapeSecondary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockLandscape;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MockScreenOrientationController::OnDestruct() {
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,50 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_SCREEN_ORIENTATION_MOCK_SCREEN_ORIENTATION_CONTROLLER_H_
|
||||
#define CONTENT_RENDERER_SCREEN_ORIENTATION_MOCK_SCREEN_ORIENTATION_CONTROLLER_H_
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "content/public/renderer/render_view_observer.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
|
||||
|
||||
namespace content {
|
||||
class RenderView;
|
||||
class RenderViewImpl;
|
||||
|
||||
class MockScreenOrientationController
|
||||
: public base::RefCountedThreadSafe<MockScreenOrientationController>,
|
||||
public RenderViewObserver {
|
||||
public:
|
||||
MockScreenOrientationController();
|
||||
|
||||
void ResetData();
|
||||
void UpdateDeviceOrientation(RenderView* render_view,
|
||||
blink::WebScreenOrientationType);
|
||||
|
||||
private:
|
||||
virtual ~MockScreenOrientationController();
|
||||
|
||||
void UpdateScreenOrientation(blink::WebScreenOrientationType);
|
||||
bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType);
|
||||
RenderViewImpl* render_view_impl() const;
|
||||
|
||||
// RenderViewObserver
|
||||
virtual void OnDestruct() OVERRIDE;
|
||||
|
||||
blink::WebScreenOrientationLockType current_lock_;
|
||||
blink::WebScreenOrientationType device_orientation_;
|
||||
blink::WebScreenOrientationType current_orientation_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MockScreenOrientationController);
|
||||
friend class base::LazyInstance<MockScreenOrientationController>;
|
||||
friend class base::RefCountedThreadSafe<MockScreenOrientationController>;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_RENDERER_SCREEN_ORIENTATION_MOCK_SCREEN_ORIENTATION_CONTROLLER_H_
|
@ -0,0 +1,161 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/shell/renderer/test_runner/mock_screen_orientation_client.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
MockScreenOrientationClient::MockScreenOrientationClient()
|
||||
: main_frame_(NULL),
|
||||
current_lock_(blink::WebScreenOrientationLockDefault),
|
||||
device_orientation_(blink::WebScreenOrientationPortraitPrimary),
|
||||
current_orientation_(blink::WebScreenOrientationPortraitPrimary) {
|
||||
}
|
||||
|
||||
MockScreenOrientationClient::~MockScreenOrientationClient() {
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::ResetData() {
|
||||
current_lock_ = blink::WebScreenOrientationLockDefault;
|
||||
device_orientation_ = blink::WebScreenOrientationPortraitPrimary;
|
||||
current_orientation_ = blink::WebScreenOrientationPortraitPrimary;
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::UpdateDeviceOrientation(
|
||||
blink::WebFrame* main_frame,
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
main_frame_ = main_frame;
|
||||
if (device_orientation_ == orientation)
|
||||
return;
|
||||
device_orientation_ = orientation;
|
||||
if (!IsOrientationAllowedByCurrentLock(orientation))
|
||||
return;
|
||||
UpdateScreenOrientation(orientation);
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::UpdateScreenOrientation(
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
if (current_orientation_ == orientation)
|
||||
return;
|
||||
current_orientation_ = orientation;
|
||||
if (main_frame_)
|
||||
main_frame_->sendOrientationChangeEvent();
|
||||
}
|
||||
|
||||
blink::WebScreenOrientationType
|
||||
MockScreenOrientationClient::CurrentOrientationType() const {
|
||||
return current_orientation_;
|
||||
}
|
||||
|
||||
unsigned MockScreenOrientationClient::CurrentOrientationAngle() const {
|
||||
return OrientationTypeToAngle(current_orientation_);
|
||||
}
|
||||
|
||||
unsigned MockScreenOrientationClient::OrientationTypeToAngle(
|
||||
blink::WebScreenOrientationType type) {
|
||||
unsigned angle;
|
||||
// FIXME(ostap): This relationship between orientationType and
|
||||
// orientationAngle is temporary. The test should be able to specify
|
||||
// the angle in addition to the orientation type.
|
||||
switch (type) {
|
||||
case blink::WebScreenOrientationLandscapePrimary:
|
||||
angle = 90;
|
||||
break;
|
||||
case blink::WebScreenOrientationLandscapeSecondary:
|
||||
angle = 270;
|
||||
break;
|
||||
case blink::WebScreenOrientationPortraitSecondary:
|
||||
angle = 180;
|
||||
break;
|
||||
default:
|
||||
angle = 0;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
bool MockScreenOrientationClient::IsOrientationAllowedByCurrentLock(
|
||||
blink::WebScreenOrientationType orientation) {
|
||||
if (current_lock_ == blink::WebScreenOrientationLockDefault ||
|
||||
current_lock_ == blink::WebScreenOrientationLockAny) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (orientation) {
|
||||
case blink::WebScreenOrientationPortraitPrimary:
|
||||
return current_lock_ == blink::WebScreenOrientationLockPortraitPrimary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockPortrait;
|
||||
case blink::WebScreenOrientationPortraitSecondary:
|
||||
return current_lock_ ==
|
||||
blink::WebScreenOrientationLockPortraitSecondary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockPortrait;
|
||||
case blink::WebScreenOrientationLandscapePrimary:
|
||||
return current_lock_ == blink::WebScreenOrientationLockLandscapePrimary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockLandscape;
|
||||
case blink::WebScreenOrientationLandscapeSecondary:
|
||||
return current_lock_ ==
|
||||
blink::WebScreenOrientationLockLandscapeSecondary ||
|
||||
current_lock_ == blink::WebScreenOrientationLockLandscape;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::lockOrientation(
|
||||
blink::WebScreenOrientationLockType orientation,
|
||||
blink::WebLockOrientationCallback* callback) {
|
||||
base::MessageLoop::current()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MockScreenOrientationClient::UpdateLockSync,
|
||||
base::Unretained(this),
|
||||
orientation,
|
||||
callback));
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::unlockOrientation() {
|
||||
base::MessageLoop::current()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&MockScreenOrientationClient::ResetLockSync,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::UpdateLockSync(
|
||||
blink::WebScreenOrientationLockType lock,
|
||||
blink::WebLockOrientationCallback* callback) {
|
||||
DCHECK(lock != blink::WebScreenOrientationLockDefault);
|
||||
current_lock_ = lock;
|
||||
if (!IsOrientationAllowedByCurrentLock(current_orientation_))
|
||||
UpdateScreenOrientation(SuitableOrientationForCurrentLock());
|
||||
unsigned angle = OrientationTypeToAngle(current_orientation_);
|
||||
callback->onSuccess(angle, current_orientation_);
|
||||
}
|
||||
|
||||
void MockScreenOrientationClient::ResetLockSync() {
|
||||
bool will_screen_orientation_need_updating =
|
||||
!IsOrientationAllowedByCurrentLock(device_orientation_);
|
||||
current_lock_ = blink::WebScreenOrientationLockDefault;
|
||||
if (will_screen_orientation_need_updating)
|
||||
UpdateScreenOrientation(device_orientation_);
|
||||
}
|
||||
|
||||
blink::WebScreenOrientationType
|
||||
MockScreenOrientationClient::SuitableOrientationForCurrentLock() {
|
||||
switch (current_lock_) {
|
||||
case blink::WebScreenOrientationLockPortraitSecondary:
|
||||
return blink::WebScreenOrientationPortraitSecondary;
|
||||
case blink::WebScreenOrientationLockLandscapePrimary:
|
||||
case blink::WebScreenOrientationLockLandscape:
|
||||
return blink::WebScreenOrientationLandscapePrimary;
|
||||
case blink::WebScreenOrientationLockLandscapeSecondary:
|
||||
return blink::WebScreenOrientationLandscapePrimary;
|
||||
default:
|
||||
return blink::WebScreenOrientationPortraitPrimary;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -0,0 +1,57 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_SCREEN_ORIENTATION_CLIENT_H_
|
||||
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_SCREEN_ORIENTATION_CLIENT_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "third_party/WebKit/public/platform/WebLockOrientationCallback.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenOrientationClient.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
|
||||
|
||||
namespace blink {
|
||||
class WebFrame;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
|
||||
class MockScreenOrientationClient : public blink::WebScreenOrientationClient {
|
||||
public:
|
||||
explicit MockScreenOrientationClient();
|
||||
virtual ~MockScreenOrientationClient();
|
||||
|
||||
void ResetData();
|
||||
void UpdateDeviceOrientation(blink::WebFrame*,
|
||||
blink::WebScreenOrientationType);
|
||||
|
||||
blink::WebScreenOrientationType CurrentOrientationType() const;
|
||||
unsigned CurrentOrientationAngle() const;
|
||||
|
||||
private:
|
||||
// From blink::WebScreenOrientationClient.
|
||||
virtual void lockOrientation(blink::WebScreenOrientationLockType,
|
||||
blink::WebLockOrientationCallback*);
|
||||
virtual void unlockOrientation();
|
||||
|
||||
void UpdateLockSync(blink::WebScreenOrientationLockType,
|
||||
blink::WebLockOrientationCallback*);
|
||||
void ResetLockSync();
|
||||
|
||||
void UpdateScreenOrientation(blink::WebScreenOrientationType);
|
||||
bool IsOrientationAllowedByCurrentLock(blink::WebScreenOrientationType);
|
||||
blink::WebScreenOrientationType SuitableOrientationForCurrentLock();
|
||||
static unsigned OrientationTypeToAngle(blink::WebScreenOrientationType);
|
||||
|
||||
blink::WebFrame* main_frame_;
|
||||
blink::WebScreenOrientationLockType current_lock_;
|
||||
blink::WebScreenOrientationType device_orientation_;
|
||||
blink::WebScreenOrientationType current_orientation_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MockScreenOrientationClient);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_MOCK_SCREEN_ORIENTATION_CONTROLLER_H_
|
@ -8,6 +8,7 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "content/shell/renderer/test_runner/TestInterfaces.h"
|
||||
#include "content/shell/renderer/test_runner/WebTestDelegate.h"
|
||||
#include "content/shell/renderer/test_runner/mock_screen_orientation_client.h"
|
||||
#include "content/shell/renderer/test_runner/test_runner.h"
|
||||
#include "content/shell/renderer/test_runner/web_test_proxy.h"
|
||||
#include "content/test/test_media_stream_renderer_factory.h"
|
||||
@ -34,6 +35,10 @@ class WebFrameTestProxy : public Base {
|
||||
return Base::createPlugin(frame, params);
|
||||
}
|
||||
|
||||
virtual blink::WebScreenOrientationClient* webScreenOrientationClient() {
|
||||
return base_proxy_->GetScreenOrientationClientMock();
|
||||
}
|
||||
|
||||
virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
|
||||
const blink::WebString& sourceName,
|
||||
unsigned sourceLine,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "content/shell/renderer/test_runner/WebTestInterfaces.h"
|
||||
#include "content/shell/renderer/test_runner/accessibility_controller.h"
|
||||
#include "content/shell/renderer/test_runner/event_sender.h"
|
||||
#include "content/shell/renderer/test_runner/mock_screen_orientation_client.h"
|
||||
#include "content/shell/renderer/test_runner/mock_web_push_client.h"
|
||||
#include "content/shell/renderer/test_runner/mock_web_user_media_client.h"
|
||||
#include "content/shell/renderer/test_runner/test_runner.h"
|
||||
@ -528,6 +529,25 @@ void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) {
|
||||
&WebTestProxyBase::DidDisplayAsync, base::Unretained(this), callback));
|
||||
}
|
||||
|
||||
void WebTestProxyBase::GetScreenOrientationForTesting(
|
||||
blink::WebScreenInfo& screen_info) {
|
||||
if (!screen_orientation_client_)
|
||||
return;
|
||||
// Override screen orientation information with mock data.
|
||||
screen_info.orientationType =
|
||||
screen_orientation_client_->CurrentOrientationType();
|
||||
screen_info.orientationAngle =
|
||||
screen_orientation_client_->CurrentOrientationAngle();
|
||||
}
|
||||
|
||||
MockScreenOrientationClient*
|
||||
WebTestProxyBase::GetScreenOrientationClientMock() {
|
||||
if (!screen_orientation_client_.get()) {
|
||||
screen_orientation_client_.reset(new MockScreenOrientationClient);
|
||||
}
|
||||
return screen_orientation_client_.get();
|
||||
}
|
||||
|
||||
blink::WebMIDIClientMock* WebTestProxyBase::GetMIDIClientMock() {
|
||||
if (!midi_client_.get())
|
||||
midi_client_.reset(new blink::WebMIDIClientMock);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "content/shell/renderer/test_runner/WebTask.h"
|
||||
#include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallback.h"
|
||||
#include "third_party/WebKit/public/platform/WebRect.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
|
||||
#include "third_party/WebKit/public/platform/WebURLError.h"
|
||||
#include "third_party/WebKit/public/platform/WebURLRequest.h"
|
||||
#include "third_party/WebKit/public/web/WebAXEnums.h"
|
||||
@ -75,6 +76,7 @@ typedef unsigned WebColor;
|
||||
|
||||
namespace content {
|
||||
|
||||
class MockScreenOrientationClient;
|
||||
class MockWebPushClient;
|
||||
class MockWebSpeechRecognizer;
|
||||
class MockWebUserMediaClient;
|
||||
@ -125,6 +127,8 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
|
||||
|
||||
void DisplayAsyncThen(const base::Closure& callback);
|
||||
|
||||
void GetScreenOrientationForTesting(blink::WebScreenInfo&);
|
||||
MockScreenOrientationClient* GetScreenOrientationClientMock();
|
||||
blink::WebMIDIClientMock* GetMIDIClientMock();
|
||||
MockWebSpeechRecognizer* GetSpeechRecognizerMock();
|
||||
|
||||
@ -269,6 +273,7 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
|
||||
scoped_ptr<blink::WebMIDIClientMock> midi_client_;
|
||||
scoped_ptr<MockWebSpeechRecognizer> speech_recognizer_;
|
||||
scoped_ptr<MockWebPushClient> push_client_;
|
||||
scoped_ptr<MockScreenOrientationClient> screen_orientation_client_;
|
||||
|
||||
std::string accept_languages_;
|
||||
|
||||
@ -299,6 +304,13 @@ class WebTestProxy : public Base, public WebTestProxyBase {
|
||||
|
||||
virtual ~WebTestProxy() {}
|
||||
|
||||
// WebWidgetClient implementation.
|
||||
virtual blink::WebScreenInfo screenInfo() {
|
||||
blink::WebScreenInfo info = Base::screenInfo();
|
||||
WebTestProxyBase::GetScreenOrientationForTesting(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
// WebViewClient implementation.
|
||||
virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); }
|
||||
virtual void postAccessibilityEvent(const blink::WebAXObject& object,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "content/shell/renderer/shell_render_process_observer.h"
|
||||
#include "content/shell/renderer/test_runner/WebTask.h"
|
||||
#include "content/shell/renderer/test_runner/WebTestInterfaces.h"
|
||||
#include "content/shell/renderer/test_runner/mock_screen_orientation_client.h"
|
||||
#include "content/shell/renderer/test_runner/web_test_proxy.h"
|
||||
#include "content/shell/renderer/test_runner/web_test_runner.h"
|
||||
#include "net/base/filename_util.h"
|
||||
@ -217,11 +218,16 @@ void WebKitTestRunner::setDeviceOrientationData(
|
||||
|
||||
void WebKitTestRunner::setScreenOrientation(
|
||||
const WebScreenOrientationType& orientation) {
|
||||
SetMockScreenOrientation(render_view(), orientation);
|
||||
MockScreenOrientationClient* mock_client =
|
||||
proxy()->GetScreenOrientationClientMock();
|
||||
mock_client->UpdateDeviceOrientation(render_view()->GetWebView()->mainFrame(),
|
||||
orientation);
|
||||
}
|
||||
|
||||
void WebKitTestRunner::resetScreenOrientation() {
|
||||
ResetMockScreenOrientation();
|
||||
MockScreenOrientationClient* mock_client =
|
||||
proxy()->GetScreenOrientationClientMock();
|
||||
mock_client->ResetData();
|
||||
}
|
||||
|
||||
void WebKitTestRunner::didChangeBatteryStatus(
|
||||
|
@ -95,18 +95,6 @@ void SetMockDeviceOrientationData(const WebDeviceOrientationData& data) {
|
||||
SetMockDeviceOrientationDataForTesting(data);
|
||||
}
|
||||
|
||||
void SetMockScreenOrientation(
|
||||
RenderView* render_view,
|
||||
const blink::WebScreenOrientationType& orientation) {
|
||||
RendererWebKitPlatformSupportImpl::
|
||||
SetMockScreenOrientationForTesting(render_view, orientation);
|
||||
}
|
||||
|
||||
void ResetMockScreenOrientation()
|
||||
{
|
||||
RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting();
|
||||
}
|
||||
|
||||
void MockBatteryStatusChanged(const WebBatteryStatus& status) {
|
||||
RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting(status);
|
||||
}
|
||||
|
Reference in New Issue
Block a user