| Index: content/renderer/renderer_webkitplatformsupport_impl.cc
|
| diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
|
| index c5db18644d6a3fbdff104428201b001a4c6014c6..47a24c46a4dc4dc39d9be2562a2da32309686c8d 100644
|
| --- a/content/renderer/renderer_webkitplatformsupport_impl.cc
|
| +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
|
| @@ -49,6 +49,7 @@
|
| #include "net/base/mime_util.h"
|
| #include "net/base/net_util.h"
|
| #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
|
| +#include "third_party/WebKit/public/platform/WebDeviceMotionListener.h"
|
| #include "third_party/WebKit/public/platform/WebFileInfo.h"
|
| #include "third_party/WebKit/public/platform/WebGamepads.h"
|
| #include "third_party/WebKit/public/platform/WebHyphenator.h"
|
| @@ -117,6 +118,8 @@ namespace content {
|
| static bool g_sandbox_enabled = true;
|
| base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
|
| LAZY_INSTANCE_INITIALIZER;
|
| +base::LazyInstance<WebKit::WebDeviceMotionData>::Leaky
|
| + g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
|
|
|
| //------------------------------------------------------------------------------
|
|
|
| @@ -1065,11 +1068,25 @@ WebKit::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
|
|
|
| void RendererWebKitPlatformSupportImpl::setDeviceMotionListener(
|
| WebKit::WebDeviceMotionListener* listener) {
|
| - if (!device_motion_event_pump_) {
|
| - device_motion_event_pump_.reset(new DeviceMotionEventPump);
|
| - device_motion_event_pump_->Attach(RenderThreadImpl::current());
|
| + if (g_test_device_motion_data == 0) {
|
| + if (!device_motion_event_pump_) {
|
| + device_motion_event_pump_.reset(new DeviceMotionEventPump);
|
| + device_motion_event_pump_->Attach(RenderThreadImpl::current());
|
| + }
|
| + device_motion_event_pump_->SetListener(listener);
|
| + } else {
|
| + base::MessageLoopProxy::current()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&WebKit::WebDeviceMotionListener::didChangeDeviceMotion,
|
| + base::Unretained(listener),
|
| + g_test_device_motion_data.Get()));
|
| }
|
| - device_motion_event_pump_->SetListener(listener);
|
| +}
|
| +
|
| +// static
|
| +void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
|
| + const WebKit::WebDeviceMotionData& data) {
|
| + g_test_device_motion_data.Get() = data;
|
| }
|
|
|
| } // namespace content
|
|
|