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

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: 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
Index: content/renderer/renderer_webkitplatformsupport_impl.cc
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 388fb92322c0d01c10430136f3e48622bc51b9aa..3d2562fa9580f48c19fc90b53d357c91354b0dc3 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -48,6 +48,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;
//------------------------------------------------------------------------------
@@ -1059,11 +1062,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

Powered by Google App Engine
This is Rietveld 408576698