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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/screen-orientation-override.html

Issue 1711083002: [DevTools] Move screen orientation override to RenderWidgetScreenMetricsEmulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 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 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script> 3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script> 4 <script>
5 5
6 if (!window.testRunner) 6 var windowOrientationChangeEvent = false;
7 debug("This test requires testRunner"); 7 var screenOrientationChangeEvent = false;
8
9 window.addEventListener("orientationchange", function() { windowOrientationChang eEvent = true; maybeLog(); });
10 screen.orientation.addEventListener("change", function() { screenOrientationChan geEvent = true; maybeLog(); });
8 11
9 function dump() 12 function dump()
10 { 13 {
11 return "angle: " + screen.orientation.angle + "; type: " + screen.orientatio n.type; 14 return "angle: " + screen.orientation.angle + "; type: " + screen.orientatio n.type;
12 } 15 }
13 16
14 if (window.testRunner) 17 function maybeLog()
15 testRunner.setMockScreenOrientation("landscape-primary"); 18 {
19 if (windowOrientationChangeEvent && screenOrientationChangeEvent) {
20 windowOrientationChangeEvent = false;
21 screenOrientationChangeEvent = false;
22 console.log(dump());
23 }
24 }
16 25
17 function test() 26 function test()
18 { 27 {
19 function addDumpResult(next) 28 function addDumpResult(next)
20 { 29 {
21 InspectorTest.evaluateInPage("dump()", dumpCallback); 30 InspectorTest.evaluateInPage("dump()", dumpCallback);
22 31
23 function dumpCallback(result) 32 function dumpCallback(result)
24 { 33 {
25 InspectorTest.addResult(result.value); 34 InspectorTest.addResult(result.value);
26 next(); 35 next();
27 } 36 }
28 } 37 }
29 38
30 function testOverride(angle, orientation, next) 39 function testOverride(angle, orientation, next)
31 { 40 {
32 var protocolCallback = addDumpResult.bind(null, next); 41 InspectorTest.addConsoleSniffer(addDumpResult.bind(null, next));
33 if (orientation) { 42 InspectorTest.EmulationAgent.invoke_setDeviceMetricsOverride({width: 0, height: 0, deviceScaleFactor: 0, mobile: true, fitWindow: false, screenOrientati on: {type: orientation, angle: angle}}, function() {});
34 InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(ang le, orientation, protocolCallback);
35 } else {
36 InspectorTest.ScreenOrientationAgent.clearScreenOrientationOverride( protocolCallback);
37 }
38 } 43 }
39 44
40 function testError(angle, orientation, next) 45 function testError(angle, orientation, next)
41 { 46 {
42 InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(angle, orientation, protocolCallback); 47 InspectorTest.EmulationAgent.invoke_setDeviceMetricsOverride({width: 0, height: 0, deviceScaleFactor: 0, mobile: true, fitWindow: false, screenOrientati on: {type: orientation, angle: angle}}, next);
48 }
43 49
44 function protocolCallback(error) 50 var original;
45 {
46 InspectorTest.addResult(error);
47 next();
48 }
49 }
50 51
51 InspectorTest.runTestSuite([ 52 InspectorTest.runTestSuite([
52 function initial(next) 53 function initial(next)
53 { 54 {
54 addDumpResult(next); 55 InspectorTest.evaluateInPage("dump()", dumpCallback);
56
57 function dumpCallback(result)
58 {
59 original = result.value;
60 next();
61 }
55 }, 62 },
56 63
57 function setWrongAngle1(next) 64 function setWrongAngle1(next)
58 { 65 {
59 testError(-1, "portraitPrimary", next); 66 testError(-1, "portraitPrimary", next);
60 }, 67 },
61 68
62 function setWrongAngle2(next) 69 function setWrongAngle2(next)
63 { 70 {
64 testError(360, "portraitPrimary", next); 71 testError(360, "portraitPrimary", next);
(...skipping 24 matching lines...) Expand all
89 InspectorTest.reloadPage(addDumpResult.bind(null, next)); 96 InspectorTest.reloadPage(addDumpResult.bind(null, next));
90 }, 97 },
91 98
92 function setLandscapeSecondary(next) 99 function setLandscapeSecondary(next)
93 { 100 {
94 testOverride(270, "landscapeSecondary", next); 101 testOverride(270, "landscapeSecondary", next);
95 }, 102 },
96 103
97 function clearOverride(next) 104 function clearOverride(next)
98 { 105 {
99 testOverride(0, "", next); 106 InspectorTest.EmulationAgent.clearDeviceMetricsOverride(checkInitial );
107
108 function checkInitial()
109 {
110 InspectorTest.evaluateInPage("dump()", dumpCallback);
111 }
112
113 function dumpCallback(result)
114 {
115 InspectorTest.addResult("Equals to initial: " + (original === re sult.value ? "true" : "false"));
116 next();
117 }
100 } 118 }
101 ]); 119 ]);
102 } 120 }
103 </script> 121 </script>
104 </head> 122 </head>
105 <body onload="runTest()"> 123 <body onload="runTest()">
106 <p> 124 <p>
107 </p> 125 </p>
108 </body> 126 </body>
109 </html> 127 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698