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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector/screen-orientation-override.html
diff --git a/third_party/WebKit/LayoutTests/inspector/screen-orientation-override.html b/third_party/WebKit/LayoutTests/inspector/screen-orientation-override.html
index 11bf460764e2d1a18ac3e1cf144028d06accf05f..b65b21dbb2306a3d65820307ecfa22614eac8010 100644
--- a/third_party/WebKit/LayoutTests/inspector/screen-orientation-override.html
+++ b/third_party/WebKit/LayoutTests/inspector/screen-orientation-override.html
@@ -3,16 +3,25 @@
<script src="../http/tests/inspector/inspector-test.js"></script>
<script>
-if (!window.testRunner)
- debug("This test requires testRunner");
+var windowOrientationChangeEvent = false;
+var screenOrientationChangeEvent = false;
+
+window.addEventListener("orientationchange", function() { windowOrientationChangeEvent = true; maybeLog(); });
+screen.orientation.addEventListener("change", function() { screenOrientationChangeEvent = true; maybeLog(); });
function dump()
{
return "angle: " + screen.orientation.angle + "; type: " + screen.orientation.type;
}
-if (window.testRunner)
- testRunner.setMockScreenOrientation("landscape-primary");
+function maybeLog()
+{
+ if (windowOrientationChangeEvent && screenOrientationChangeEvent) {
+ windowOrientationChangeEvent = false;
+ screenOrientationChangeEvent = false;
+ console.log(dump());
+ }
+}
function test()
{
@@ -29,29 +38,27 @@ function test()
function testOverride(angle, orientation, next)
{
- var protocolCallback = addDumpResult.bind(null, next);
- if (orientation) {
- InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(angle, orientation, protocolCallback);
- } else {
- InspectorTest.ScreenOrientationAgent.clearScreenOrientationOverride(protocolCallback);
- }
+ InspectorTest.addConsoleSniffer(addDumpResult.bind(null, next));
+ InspectorTest.EmulationAgent.invoke_setDeviceMetricsOverride({width: 0, height: 0, deviceScaleFactor: 0, mobile: true, fitWindow: false, screenOrientation: {type: orientation, angle: angle}}, function() {});
}
function testError(angle, orientation, next)
{
- InspectorTest.ScreenOrientationAgent.setScreenOrientationOverride(angle, orientation, protocolCallback);
-
- function protocolCallback(error)
- {
- InspectorTest.addResult(error);
- next();
- }
+ InspectorTest.EmulationAgent.invoke_setDeviceMetricsOverride({width: 0, height: 0, deviceScaleFactor: 0, mobile: true, fitWindow: false, screenOrientation: {type: orientation, angle: angle}}, next);
}
+ var original;
+
InspectorTest.runTestSuite([
function initial(next)
{
- addDumpResult(next);
+ InspectorTest.evaluateInPage("dump()", dumpCallback);
+
+ function dumpCallback(result)
+ {
+ original = result.value;
+ next();
+ }
},
function setWrongAngle1(next)
@@ -96,7 +103,18 @@ function test()
function clearOverride(next)
{
- testOverride(0, "", next);
+ InspectorTest.EmulationAgent.clearDeviceMetricsOverride(checkInitial);
+
+ function checkInitial()
+ {
+ InspectorTest.evaluateInPage("dump()", dumpCallback);
+ }
+
+ function dumpCallback(result)
+ {
+ InspectorTest.addResult("Equals to initial: " + (original === result.value ? "true" : "false"));
+ next();
+ }
}
]);
}

Powered by Google App Engine
This is Rietveld 408576698