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

Side by Side Diff: LayoutTests/fast/dom/DeviceOrientation/script-tests/null-values.js

Issue 22599005: Blink-side layout tests for the new Device Orientation API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased once more Created 7 years, 2 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
1 description('Tests using null values for some of the event properties.'); 1 description('Tests using null values for some of the event properties.');
2 2
3 var mockEvent; 3 var mockEvent;
4 function setMockOrientation(alpha, beta, gamma) { 4 function setMockOrientation(alpha, beta, gamma, absolute) {
5 mockEvent = {alpha: alpha, beta: beta, gamma: gamma}; 5 mockEvent = {alpha: alpha, beta: beta, gamma: gamma, absolute: absolute};
6 if (window.testRunner) 6 if (window.testRunner)
7 testRunner.setMockDeviceOrientation( 7 testRunner.setMockDeviceOrientation(
8 null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alp ha, 8 null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alp ha,
9 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta, 9 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta,
10 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gam ma); 10 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gam ma,
11 null != mockEvent.absolute, null == mockEvent.absolute ? false : moc kEvent.absolute);
11 else 12 else
12 debug('This test can not be run without the TestRunner'); 13 debug('This test can not be run without the TestRunner');
13 } 14 }
14 15
15 var deviceOrientationEvent; 16 var deviceOrientationEvent;
16 function checkOrientation(event) { 17 function checkOrientation(event) {
17 deviceOrientationEvent = event; 18 deviceOrientationEvent = event;
18 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); 19 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha');
19 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); 20 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta');
20 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); 21 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma');
22 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute');
21 } 23 }
22 24
23 function firstListener(event) { 25 function firstListener(event) {
24 checkOrientation(event); 26 checkOrientation(event);
25 window.removeEventListener('deviceorientation', firstListener); 27 window.removeEventListener('deviceorientation', firstListener);
28 setTimeout(function(){initSecondListener();}, 0);
29 }
26 30
27 setMockOrientation(1.1, null, null); 31 function initSecondListener() {
32 setMockOrientation(1.1, null, null, true);
28 window.addEventListener('deviceorientation', secondListener); 33 window.addEventListener('deviceorientation', secondListener);
29 } 34 }
30 35
31 function secondListener(event) { 36 function secondListener(event) {
32 checkOrientation(event); 37 checkOrientation(event);
33 window.removeEventListener('deviceorientation', secondListener); 38 window.removeEventListener('deviceorientation', secondListener);
39 setTimeout(function(){initThirdListener();}, 0);
40 }
34 41
35 setMockOrientation(null, 2.2, null); 42 function initThirdListener() {
43 setMockOrientation(null, 2.2, null, true);
36 window.addEventListener('deviceorientation', thirdListener); 44 window.addEventListener('deviceorientation', thirdListener);
37 } 45 }
38 46
39 function thirdListener(event) { 47 function thirdListener(event) {
40 checkOrientation(event); 48 checkOrientation(event);
41 window.removeEventListener('deviceorientation', thirdListener); 49 window.removeEventListener('deviceorientation', thirdListener);
50 setTimeout(function(){initFourthListener();}, 0);
51 }
42 52
43 setMockOrientation(null, null, 3.3); 53 function initFourthListener() {
54 setMockOrientation(null, null, 3.3, true);
44 window.addEventListener('deviceorientation', fourthListener); 55 window.addEventListener('deviceorientation', fourthListener);
45 } 56 }
46 57
47 function fourthListener(event) { 58 function fourthListener(event) {
48 checkOrientation(event); 59 checkOrientation(event);
49 finishJSTest(); 60 finishJSTest();
50 } 61 }
51 62
52 setMockOrientation(null, null, null); 63 setMockOrientation(null, null, null, false);
53 window.addEventListener('deviceorientation', firstListener); 64 window.addEventListener('deviceorientation', firstListener);
54 65
55 window.jsTestIsAsync = true; 66 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698