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

Side by Side Diff: LayoutTests/screen_orientation/orientationchange-event.html

Issue 364253007: Revert of [screen-orientation] Expose orientation info in OrientationInformation interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../resources/testharness.js"></script> 4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script> 5 <script src="../resources/testharnessreport.js"></script>
6 <script> 6 <script>
7 7
8 var orientations = [ 8 var orientations = [
9 'portrait-primary', 9 'portrait-primary',
10 'portrait-secondary', 10 'portrait-secondary',
11 'landscape-primary', 11 'landscape-primary',
12 'landscape-secondary' 12 'landscape-secondary'
13 ]; 13 ];
14 14
15 var currentIndex = orientations.indexOf(window.screen.orientation.type); 15 var currentIndex = orientations.indexOf(window.screen.orientation);
16 // Count the number of calls received from the EventHandler set on window.onorie ntationchange. 16 // Count the number of calls received from the EventHandler set on window.onorie ntationchange.
17 var orientationChangeEventHandlerCalls = 0; 17 var orientationChangeEventHandlerCalls = 0;
18 // Count the number of calls received from the listener set with window.addEvent Listene(). 18 // Count the number of calls received from the listener set with window.addEvent Listene().
19 var orientationChangeEventListenerCalls = 0; 19 var orientationChangeEventListenerCalls = 0;
20 20
21 // TODO: window.onorientationchange is enabled on Android only. We will enable 21 // TODO: window.onorientationchange is enabled on Android only. We will enable
22 // it with ScreenOrientation later, at which point this test will fail. We will 22 // it with ScreenOrientation later, at which point this test will fail. We will
23 // then have to fix it. 23 // then have to fix it.
24 function todo_equals(actual, expected) { 24 function todo_equals(actual, expected) {
25 assert_not_equals(actual, expected, "TODO: if this fails, it means that someth ing got fixed."); 25 assert_not_equals(actual, expected, "TODO: if this fails, it means that someth ing got fixed.");
26 } 26 }
27 27
28 function getNextIndex() { 28 function getNextIndex() {
29 return (currentIndex + 1) % orientations.length; 29 return (currentIndex + 1) % orientations.length;
30 } 30 }
31 31
32 window.onorientationchange = function() { 32 window.onorientationchange = function() {
33 orientationChangeEventHandlerCalls++; 33 orientationChangeEventHandlerCalls++;
34 }; 34 };
35 35
36 window.addEventListener('orientationchange', function() { 36 window.addEventListener('orientationchange', function() {
37 orientationChangeEventListenerCalls++; 37 orientationChangeEventListenerCalls++;
38 }); 38 });
39 39
40 for (var i = 0; i < 4; ++i) { 40 for (var i = 0; i < 4; ++i) {
41 test(function() { 41 test(function() {
42 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]); 42 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]);
43 43
44 currentIndex = getNextIndex(); 44 currentIndex = getNextIndex();
45 assert_equals(screen.orientation.type, orientations[currentIndex]); 45 assert_equals(screen.orientation, orientations[currentIndex]);
46 46
47 todo_equals(orientationChangeEventHandlerCalls, i + 1); 47 todo_equals(orientationChangeEventHandlerCalls, i + 1);
48 assert_equals(orientationChangeEventListenerCalls, i + 1); 48 assert_equals(orientationChangeEventListenerCalls, i + 1);
49 }, "Test that orientationchange event is fired when the orientation changes"); 49 }, "Test that orientationchange event is fired when the orientation changes");
50 } 50 }
51 51
52 test(function() { 52 test(function() {
53 window.testRunner.setMockScreenOrientation(orientations[currentIndex]); 53 window.testRunner.setMockScreenOrientation(orientations[currentIndex]);
54 assert_equals(screen.orientation.type, orientations[currentIndex]); 54 assert_equals(screen.orientation, orientations[currentIndex]);
55 55
56 todo_equals(orientationChangeEventHandlerCalls, 4); 56 todo_equals(orientationChangeEventHandlerCalls, 4);
57 assert_equals(orientationChangeEventListenerCalls, 4); 57 assert_equals(orientationChangeEventListenerCalls, 4);
58 }, "Test that orientationchange event is not fired when the orientation does not change"); 58 }, "Test that orientationchange event is not fired when the orientation does not change");
59 59
60 </script> 60 </script>
61 </body> 61 </body>
62 </html> 62 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698