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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 242703002: Improve the handling of mock screen orientation for layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_webkitplatformsupport_impl.cc
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 5f9d1761715de67710378faec4ca89b1844749ad..519b71a595d0e7be70958260fe895a85a8799508 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -145,8 +145,8 @@ 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<blink::WebScreenOrientationType>::Leaky
- g_test_screen_orientation_value = LAZY_INSTANCE_INITIALIZER;
+static blink::WebScreenOrientationListener*
+ g_test_screen_orientation_listener = NULL;
//------------------------------------------------------------------------------
@@ -1119,18 +1119,13 @@ void RendererWebKitPlatformSupportImpl::cancelVibration() {
void RendererWebKitPlatformSupportImpl::setScreenOrientationListener(
blink::WebScreenOrientationListener* listener) {
- if (!(g_test_screen_orientation_value == 0)) {
- if (!listener)
- return;
-
- // When testing, we only pretend that the screen orientation is now set to
- // g_test_screen_orientation_value.
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(
- &blink::WebScreenOrientationListener::didChangeScreenOrientation,
- base::Unretained(listener),
- g_test_screen_orientation_value.Get()));
+ if (RenderThreadImpl::current() &&
+ RenderThreadImpl::current()->layout_test_mode()) {
+ // If we are in test mode, we want to fully disable the screen orientation
+ // backend in order to let Blink get tested properly, That means that screen
+ // orientation updates have to be done manually instead of from signals sent
+ // by the browser process.
+ g_test_screen_orientation_listener = listener;
return;
}
@@ -1144,23 +1139,27 @@ void RendererWebKitPlatformSupportImpl::setScreenOrientationListener(
void RendererWebKitPlatformSupportImpl::lockOrientation(
blink::WebScreenOrientationLockType orientation) {
- // No-op if we are currently using mock values.
- if (!(g_test_screen_orientation_value == 0))
+ if (RenderThreadImpl::current() &&
+ RenderThreadImpl::current()->layout_test_mode()) {
return;
+ }
RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation));
}
void RendererWebKitPlatformSupportImpl::unlockOrientation() {
- // No-op if we are currently using mock values.
- if (!(g_test_screen_orientation_value == 0))
+ if (RenderThreadImpl::current() &&
+ RenderThreadImpl::current()->layout_test_mode()) {
return;
+ }
RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock);
}
// static
void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
blink::WebScreenOrientationType orientation) {
- g_test_screen_orientation_value.Get() = orientation;
+ if (!g_test_screen_orientation_listener)
+ return;
+ g_test_screen_orientation_listener->didChangeScreenOrientation(orientation);
}
//------------------------------------------------------------------------------
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698