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

Unified Diff: LayoutTests/screen_orientation/locking-then-unlocking.html

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update compile-time assertion for matching enum Created 6 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: LayoutTests/screen_orientation/locking-then-unlocking.html
diff --git a/LayoutTests/screen_orientation/locking-then-unlocking.html b/LayoutTests/screen_orientation/locking-then-unlocking.html
new file mode 100644
index 0000000000000000000000000000000000000000..c7c4261279654edfef4229de6c1c5ccf86dc2c0f
--- /dev/null
+++ b/LayoutTests/screen_orientation/locking-then-unlocking.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/js-test.js"></script>
+<script>
+description("Validates that screen orientation can be unlocked");
+window.jsTestIsAsync = true;
+
+var orientationChangeEventCount = 0;
+var locked = false;
+
+function checkNoOrientationChangeThenContinue() {
+ shouldBeEqualToString("screen.orientation", "portrait-primary");
+ shouldBe("orientationChangeEventCount", "0");
+ debug("Unlocking orientation...");
+ locked = false;
+ screen.unlockOrientation();
+}
+
+function completeTest() {
+ screen.removeEventListener("orientationchange", onOrientationChangeEvent);
+ internals.setScreenOrientation(document, "portrait-primary");
+ finishJSTest();
+}
+
+var testEvent;
+function onOrientationChangeEvent(ev) {
+ ++orientationChangeEventCount;
+ testEvent = ev;
+ debug("Received an 'orientationchange' event.");
+ shouldBeFalse('locked');
+ shouldBe("orientationChangeEventCount", "1");
+ shouldBeEqualToString("testEvent.type", "orientationchange");
+ shouldBeEqualToString("screen.orientation", "landscape-primary");
+ completeTest();
+}
+
+function setScreenOrientationtoLandscapePrimary() {
+ debug("Faking device screen orientation change to 'landscape-primary'...");
+ internals.setScreenOrientation(document, "landscape-primary");
+ setTimeout(checkNoOrientationChangeThenContinue, 0);
+}
+
+internals.setScreenOrientationClientMock(document);
+screen.addEventListener("orientationchange", onOrientationChangeEvent);
+
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+debug("locking orientation to 'portrait-primary'.");
+locked = true;
+shouldBeTrue("screen.lockOrientation('portrait-primary')");
+// Doing this asynchronously as lockOrientation() is asynchronous.
+setTimeout(setScreenOrientationtoLandscapePrimary, 0);
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698