OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> |
| 5 |
| 6 if (!window.testRunner) |
| 7 debug("This test requires testRunner"); |
| 8 |
| 9 function dump() |
| 10 { |
| 11 return "angle: " + screen.orientation.angle + "; type: " + screen.orientatio
n.type; |
| 12 } |
| 13 |
| 14 function setup() |
| 15 { |
| 16 if (window.testRunner) |
| 17 testRunner.setMockScreenOrientation("landscape-primary"); |
| 18 return dump(); |
| 19 } |
| 20 |
| 21 function test() |
| 22 { |
| 23 function testOverride(angle, orientation, next) |
| 24 { |
| 25 if (orientation) { |
| 26 InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(ang
le, orientation, protocolCallback); |
| 27 } else { |
| 28 InspectorTest.ScreenOrientationAgent.clearScreenOrientationOverride(
protocolCallback); |
| 29 } |
| 30 |
| 31 function protocolCallback() |
| 32 { |
| 33 InspectorTest.evaluateInPage("dump()", dumpCallback); |
| 34 } |
| 35 |
| 36 function dumpCallback(result) |
| 37 { |
| 38 InspectorTest.addResult(result.value); |
| 39 next(); |
| 40 } |
| 41 } |
| 42 |
| 43 function testError(angle, orientation, next) |
| 44 { |
| 45 InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(angle,
orientation, protocolCallback); |
| 46 |
| 47 function protocolCallback(error) |
| 48 { |
| 49 InspectorTest.addResult(error); |
| 50 next(); |
| 51 } |
| 52 } |
| 53 |
| 54 InspectorTest.runTestSuite([ |
| 55 function setUp(next) |
| 56 { |
| 57 InspectorTest.evaluateInPage("setup()", callback); |
| 58 |
| 59 function callback(result) |
| 60 { |
| 61 InspectorTest.addResult(result.value); |
| 62 next(); |
| 63 } |
| 64 }, |
| 65 |
| 66 function setWrongAngle1(next) |
| 67 { |
| 68 testError(-1, "portraitPrimary", next); |
| 69 }, |
| 70 |
| 71 function setWrongAngle2(next) |
| 72 { |
| 73 testError(360, "portraitPrimary", next); |
| 74 }, |
| 75 |
| 76 function setWrongType(next) |
| 77 { |
| 78 testError(120, "wrongType", next); |
| 79 }, |
| 80 |
| 81 function setPortraitPrimary(next) |
| 82 { |
| 83 testOverride(0, "portraitPrimary", next); |
| 84 }, |
| 85 |
| 86 function setPortraitSecondary(next) |
| 87 { |
| 88 testOverride(180, "portraitSecondary", next); |
| 89 }, |
| 90 |
| 91 function setLandscapePrimary(next) |
| 92 { |
| 93 testOverride(90, "landscapePrimary", next); |
| 94 }, |
| 95 |
| 96 function setLandscapeSecondary(next) |
| 97 { |
| 98 testOverride(270, "landscapeSecondary", next); |
| 99 }, |
| 100 |
| 101 function clearOverride(next) |
| 102 { |
| 103 testOverride(0, "", next); |
| 104 } |
| 105 ]); |
| 106 } |
| 107 </script> |
| 108 </head> |
| 109 <body onload="runTest()"> |
| 110 <p> |
| 111 </p> |
| 112 </body> |
| 113 </html> |
OLD | NEW |