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

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: fixed add-listener-from-callback-expected.txt 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 1d3587c26e154427906eed330dc7056227ef1c92..6b760084aba7ac58b19a3522dc397e5be562ec61 100644
--- a/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
+++ b/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
@@ -61,7 +61,9 @@
#include "v8/include/v8.h"
#include <limits>
#include <memory>
+#include <modules/device_orientation/DeviceMotionDispatcher.h>
abarth-chromium 2013/05/13 18:39:56 This is a bad dependency. TestRunner cannot reach
timvolodine 2013/05/14 18:07:46 Done.
#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("enableMockDeviceMotion", &TestRunner::enableMockDeviceMotion);
bindMethod("didAcquirePointerLock", &TestRunner::didAcquirePointerLock);
bindMethod("didLosePointerLock", &TestRunner::didLosePointerLock);
bindMethod("didNotAcquirePointerLock", &TestRunner::didNotAcquirePointerLock);
@@ -1502,6 +1506,59 @@ void TestRunner::setMockDeviceOrientation(const CppArgumentList& arguments, CppV
m_proxy->deviceOrientationClientMock()->setOrientation(orientation);
}
+void TestRunner::enableMockDeviceMotion(const CppArgumentList& arguments, CppVariant* result)
+{
+ WebCore::DeviceMotionDispatcher::shared().setEnableTesting(true);
+}
+
+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());
+
+ WebCore::DeviceMotionDispatcher::shared().didChangeDeviceMotion(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