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

Side by Side Diff: LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js

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 Darin's comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 description('Tests that adding a new devicemotion event listener from a callback works as expected.');
2
3 var mockAccelerationX = 1.1;
4 var mockAccelerationY = 2.1;
5 var mockAccelerationZ = 3.1;
6
7 var mockAccelerationIncludingGravityX = 1.2;
8 var mockAccelerationIncludingGravityY = 2.2;
9 var mockAccelerationIncludingGravityZ = 3.2;
10
11 var mockRotationRateAlpha = 1.3;
12 var mockRotationRateBeta = 2.3;
13 var mockRotationRateGamma = 3.3;
14
15 var mockInterval = 100;
16
17 if (window.testRunner) {
18 testRunner.setMockDeviceMotion();
19 debug('TEST MODE enabled');
20 } else
21 debug('This test can not be run without the TestRunner');
22
23 var deviceOrientationEvent;
24 function checkOrientation(event) {
25 deviceOrientationEvent = event;
26 shouldBe('deviceOrientationEvent.acceleration.x', 'mockAccelerationX');
27 shouldBe('deviceOrientationEvent.acceleration.y', 'mockAccelerationY');
28 shouldBe('deviceOrientationEvent.acceleration.z', 'mockAccelerationZ');
29
30 shouldBe('deviceOrientationEvent.accelerationIncludingGravity.x', 'mockAccel erationIncludingGravityX');
31 shouldBe('deviceOrientationEvent.accelerationIncludingGravity.y', 'mockAccel erationIncludingGravityY');
32 shouldBe('deviceOrientationEvent.accelerationIncludingGravity.z', 'mockAccel erationIncludingGravityZ');
33
34 shouldBe('deviceOrientationEvent.rotationRate.alpha', 'mockRotationRateAlpha ');
35 shouldBe('deviceOrientationEvent.rotationRate.beta', 'mockRotationRateBeta') ;
36 shouldBe('deviceOrientationEvent.rotationRate.gamma', 'mockRotationRateGamma ');
37
38 shouldBe('deviceOrientationEvent.interval', 'mockInterval');
39 }
40
41 function listener(event) {
42 checkOrientation(event);
43 finishJSTest();
44 }
45
46 window.addEventListener('devicemotion', listener);
47 window.jsTestIsAsync = true;
48
49 if (window.testRunner)
50 testRunner.fireMockDeviceMotion(true, mockAccelerationX, true, mockAccelerat ionY, true, mockAccelerationZ,
51 true, mockAccelerationIncludingGravityX, tru e, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ,
52 true, mockRotationRateAlpha, true, mockRotat ionRateBeta, true, mockRotationRateGamma,
53 mockInterval);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698