OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body> | |
4 <script src="../resources/js-test.js"></script> | |
5 <script> | |
6 description("Validates that lockOrientation() can take an array in argument."); | |
kenneth.r.christiansen
2014/02/12 13:42:37
nit: as argument
Inactive
2014/02/12 16:03:11
Done.
| |
7 window.jsTestIsAsync = true; | |
8 | |
9 var orientationChangeCount = 0; | |
10 var currentTestOrientation = 0; | |
11 var testOrientations = [ | |
12 "portrait-secondary", | |
13 "landscape-primary", | |
14 "landscape-secondary", | |
15 "portrait-primary" | |
16 ]; | |
17 | |
18 function testComplete() { | |
19 screen.unlockOrientation(); | |
20 finishJSTest(); | |
21 } | |
22 | |
23 var testEvent; | |
24 function onOrientationChangeEvent(ev) { | |
25 ++orientationChangeCount; | |
26 testEvent = ev; | |
27 if (screen.orientation != "portrait-primary" && screen.orientation != "lands cape-primary") { | |
28 ++orientationChangeCount; | |
29 testFailed("Unexpected 'orientationchange' event for " + screen.orientat ion); | |
30 testComplete(); | |
31 } | |
32 testPassed("Received an 'orientationchange' event."); | |
33 shouldBeEqualToString("testEvent.type", "orientationchange"); | |
34 if (orientationChangeCount == 1) { | |
35 shouldBeEqualToString("screen.orientation", "landscape-primary"); | |
36 } else { | |
37 shouldBe("orientationChangeCount", "2"); | |
38 shouldBeEqualToString("screen.orientation", "portrait-primary"); | |
39 testComplete(); | |
40 } | |
41 } | |
42 | |
43 function changeOrientation() { | |
44 internals.setScreenOrientation(document, testOrientations[currentTestOrienta tion++]); | |
45 if (currentTestOrientation < testOrientations.length) | |
46 setTimeout(changeOrientation, 100); | |
kenneth.r.christiansen
2014/02/12 13:42:37
no way to avoid the time out? isnt your mock objec
Inactive
2014/02/12 16:03:11
We need to give the events a chance to fire. Event
| |
47 } | |
48 | |
49 internals.setScreenOrientationClientMock(document); | |
50 screen.addEventListener("orientationchange", onOrientationChangeEvent); | |
51 | |
52 shouldBeEqualToString("screen.orientation", "portrait-primary"); | |
53 | |
54 debug("locking orientation to ['portrait-primary', 'landscape-primary']."); | |
55 shouldBeTrue("screen.lockOrientation(['portrait-primary', 'landscape-primary'])" ); | |
56 setTimeout(changeOrientation, 100); | |
57 </script> | |
58 </body> | |
59 </html> | |
OLD | NEW |