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

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

Issue 16020003: Blink-side Device Motion API testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed window-property layout test 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 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(true, mockAccelerationX, true, mockAccelerati onY, true, mockAccelerationZ,
19 true, mockAccelerationIncludingGravityX, true , mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ,
20 true, mockRotationRateAlpha, true, mockRotati onRateBeta, true, mockRotationRateGamma,
21 mockInterval);
22 debug('TEST MODE enabled');
23 } else
24 debug('This test can not be run without the TestRunner');
25
26 var deviceMotionEvent;
27 function checkMotion(event) {
28 deviceMotionEvent = event;
29 shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX');
30 shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY');
31 shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ');
32
33 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerati onIncludingGravityX');
34 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerati onIncludingGravityY');
35 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerati onIncludingGravityZ');
36
37 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha');
38 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta');
39 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma');
40
41 shouldBe('deviceMotionEvent.interval', 'mockInterval');
42 }
43
44 function listener(event) {
45 checkMotion(event);
46 finishJSTest();
47 }
48
49 window.addEventListener('devicemotion', listener);
50 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698