diff options
-rw-r--r-- | content/public/test/layouttest_support.h | 5 | ||||
-rw-r--r-- | content/renderer/renderer_webkitplatformsupport_impl.cc | 25 | ||||
-rw-r--r-- | content/renderer/renderer_webkitplatformsupport_impl.h | 4 | ||||
-rw-r--r-- | content/shell/renderer/webkit_test_runner.cc | 5 | ||||
-rw-r--r-- | content/shell/renderer/webkit_test_runner.h | 2 | ||||
-rw-r--r-- | content/test/layouttest_support.cc | 6 |
6 files changed, 43 insertions, 4 deletions
diff --git a/content/public/test/layouttest_support.h b/content/public/test/layouttest_support.h index 5ae7396..01577bd 100644 --- a/content/public/test/layouttest_support.h +++ b/content/public/test/layouttest_support.h @@ -8,6 +8,7 @@ #include "base/callback_forward.h" namespace WebKit { +class WebDeviceMotionData; class WebGamepads; struct WebSize; } @@ -39,6 +40,10 @@ void EnableWebTestProxyCreation(const base::Callback< // WebKitPlatformSupport::sampleGamepads(). void SetMockGamepads(const WebKit::WebGamepads& pads); +// Sets WebDeviceMotionData that should be used when registering +// a listener through WebKitPlatformSupport::setDeviceMotionListener(). +void SetMockDeviceMotionData(const WebKit::WebDeviceMotionData& data); + // Returns the length of the local session history of a render view. int GetLocalSessionHistoryLength(RenderView* render_view); diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index c5db186..47a24c4 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 diff --git a/content/renderer/renderer_webkitplatformsupport_impl.h b/content/renderer/renderer_webkitplatformsupport_impl.h index 7f096e5..12b3ba9 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.h +++ b/content/renderer/renderer_webkitplatformsupport_impl.h @@ -28,6 +28,7 @@ class SyncMessageFilter; } namespace WebKit { +class WebDeviceMotionData; class WebGraphicsContext3DProvider; } @@ -150,6 +151,9 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl // Set WebGamepads to return when sampleGamepads() is invoked. static void SetMockGamepadsForTesting(const WebKit::WebGamepads& pads); + // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked. + static void SetMockDeviceMotionDataForTesting( + const WebKit::WebDeviceMotionData& data); private: bool CheckPreparsedJsCachingEnabled() const; diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc index d3d77eb..99ffb61 100644 --- a/content/shell/renderer/webkit_test_runner.cc +++ b/content/shell/renderer/webkit_test_runner.cc @@ -64,6 +64,7 @@ using WebKit::Platform; using WebKit::WebArrayBufferView; using WebKit::WebContextMenuData; using WebKit::WebDevToolsAgent; +using WebKit::WebDeviceMotionData; using WebKit::WebDeviceOrientation; using WebKit::WebElement; using WebKit::WebFrame; @@ -211,6 +212,10 @@ void WebKitTestRunner::setGamepadData(const WebGamepads& gamepads) { SetMockGamepads(gamepads); } +void WebKitTestRunner::setDeviceMotionData(const WebDeviceMotionData& data) { + SetMockDeviceMotionData(data); +} + void WebKitTestRunner::printMessage(const std::string& message) { Send(new ShellViewHostMsg_PrintMessage(routing_id(), message)); } diff --git a/content/shell/renderer/webkit_test_runner.h b/content/shell/renderer/webkit_test_runner.h index f5f40d3..0d63e76 100644 --- a/content/shell/renderer/webkit_test_runner.h +++ b/content/shell/renderer/webkit_test_runner.h @@ -20,6 +20,7 @@ class SkCanvas; namespace WebKit { +class WebDeviceMotionData; struct WebRect; } @@ -51,6 +52,7 @@ class WebKitTestRunner : public RenderViewObserver, virtual void setEditCommand(const std::string& name, const std::string& value); virtual void setGamepadData(const WebKit::WebGamepads& gamepads); + virtual void setDeviceMotionData(const WebKit::WebDeviceMotionData& data); virtual void printMessage(const std::string& message); virtual void postTask(::WebTestRunner::WebTask* task); virtual void postDelayedTask(::WebTestRunner::WebTask* task, diff --git a/content/test/layouttest_support.cc b/content/test/layouttest_support.cc index 1993917..2698330 100644 --- a/content/test/layouttest_support.cc +++ b/content/test/layouttest_support.cc @@ -12,6 +12,7 @@ #include "content/renderer/render_view_impl.h" #include "content/renderer/renderer_webkitplatformsupport_impl.h" #include "content/test/test_media_stream_client.h" +#include "third_party/WebKit/public/platform/WebDeviceMotionData.h" #include "third_party/WebKit/public/platform/WebGamepads.h" #include "third_party/WebKit/public/testing/WebFrameTestProxy.h" #include "third_party/WebKit/public/testing/WebTestProxy.h" @@ -24,6 +25,7 @@ #include "content/browser/renderer_host/popup_menu_helper_mac.h" #endif +using WebKit::WebDeviceMotionData; using WebKit::WebGamepads; using WebKit::WebRect; using WebKit::WebSize; @@ -77,6 +79,10 @@ void SetMockGamepads(const WebGamepads& pads) { RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(pads); } +void SetMockDeviceMotionData(const WebDeviceMotionData& data) { + RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(data); +} + void EnableRendererLayoutTestMode() { RenderThreadImpl::current()->set_layout_test_mode(true); } |