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

Unified Diff: Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp

Issue 14460010: Implement the Blink part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: made WebDeviceMotionData more "POD-ish" Created 7 years, 7 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: Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
index 9d38dd97c34aee109d39364179ac275f622011ab..4aa5900ff4fef6f073050e01e8d546b8f82a980a 100644
--- a/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
+++ b/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
@@ -33,6 +33,7 @@
#include "config.h"
#include "TestRunner.h"
+#include "MockWebDeviceMotionHandler.h"
#include "MockWebSpeechInputController.h"
#include "MockWebSpeechRecognizer.h"
#include "NotificationPresenter.h"
@@ -62,6 +63,7 @@
#include <limits>
#include <memory>
#include <public/WebData.h>
+#include <public/WebDeviceMotionData.h>
#include <public/WebPoint.h>
#include <public/WebURLResponse.h>
@@ -207,6 +209,8 @@ TestRunner::TestRunner(TestInterfaces* interfaces)
bindMethod("disableAutoResizeMode", &TestRunner::disableAutoResizeMode);
bindMethod("enableAutoResizeMode", &TestRunner::enableAutoResizeMode);
bindMethod("setMockDeviceOrientation", &TestRunner::setMockDeviceOrientation);
+ bindMethod("fireMockDeviceMotion", &TestRunner::fireMockDeviceMotion);
+ bindMethod("setMockDeviceMotion", &TestRunner::setMockDeviceMotion);
bindMethod("didAcquirePointerLock", &TestRunner::didAcquirePointerLock);
bindMethod("didLosePointerLock", &TestRunner::didLosePointerLock);
bindMethod("didNotAcquirePointerLock", &TestRunner::didNotAcquirePointerLock);
@@ -1510,6 +1514,59 @@ void TestRunner::setMockDeviceOrientation(const CppArgumentList& arguments, CppV
m_proxy->deviceOrientationClientMock()->setOrientation(orientation);
}
+void TestRunner::setMockDeviceMotion(const CppArgumentList& arguments, CppVariant* result)
+{
+ m_delegate->setDeviceMotionHandler(m_proxy->deviceMotionHandlerMock());
+}
+
+void TestRunner::fireMockDeviceMotion(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+ if (arguments.size() < 19
+ || !arguments[0].isBool() || !arguments[1].isNumber() // acceleration.x
+ || !arguments[2].isBool() || !arguments[3].isNumber() // acceleration.y
+ || !arguments[4].isBool() || !arguments[5].isNumber() // acceleration.z
+ || !arguments[6].isBool() || !arguments[7].isNumber() // accelerationIncludingGravity.x
+ || !arguments[8].isBool() || !arguments[9].isNumber() // accelerationIncludingGravity.y
+ || !arguments[10].isBool() || !arguments[11].isNumber() // accelerationIncludingGravity.z
+ || !arguments[12].isBool() || !arguments[13].isNumber() // rotationRate.alpha
+ || !arguments[14].isBool() || !arguments[15].isNumber() // rotationRate.beta
+ || !arguments[16].isBool() || !arguments[17].isNumber() // rotationRate.gamma
+ || !arguments[18].isNumber()) // interval
+ return;
+
+ WebDeviceMotionData motion;
+
+ // acceleration
+ if (arguments[0].toBoolean())
+ motion.setAccelerationX(arguments[1].toDouble());
+ if (arguments[2].toBoolean())
+ motion.setAccelerationY(arguments[3].toDouble());
+ if (arguments[4].toBoolean())
+ motion.setAccelerationZ(arguments[5].toDouble());
+
+ // accelerationIncludingGravity
+ if (arguments[6].toBoolean())
+ motion.setAccelerationIncludingGravityX(arguments[7].toDouble());
+ if (arguments[8].toBoolean())
+ motion.setAccelerationIncludingGravityY(arguments[9].toDouble());
+ if (arguments[10].toBoolean())
+ motion.setAccelerationIncludingGravityZ(arguments[11].toDouble());
+
+ // rotationRate
+ if (arguments[12].toBoolean())
+ motion.setRotationRateAlpha(arguments[13].toDouble());
+ if (arguments[14].toBoolean())
+ motion.setRotationRateBeta(arguments[15].toDouble());
+ if (arguments[16].toBoolean())
+ motion.setRotationRateGamma(arguments[17].toDouble());
+
+ // interval
+ motion.setInterval(arguments[18].toDouble());
+
+ m_proxy->deviceMotionHandlerMock()->fireEvent(motion);
+}
+
void TestRunner::setUserStyleSheetEnabled(const CppArgumentList& arguments, CppVariant* result)
{
if (arguments.size() > 0 && arguments[0].isBool()) {

Powered by Google App Engine
This is Rietveld 408576698