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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 5222955109842944: Add plumbing for platform based Device Motion testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forward declare of WebDeviceMotionData Created 7 years, 5 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') | content/shell/renderer/webkit_test_runner.h » ('j') | 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 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
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | content/shell/renderer/webkit_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698