@@ -15,18 +15,62 @@
17import QtQuick 2.4
17import QtQuick 2.4
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19import Unity.Test 0.1
20import Unity.Test 0.1
21+import Ubuntu.Components 1.3
22+import Ubuntu.Components.ListItems 1.3
20import "../../qml"
23import "../../qml"
24− width: units.gu(40)
27+ width: units.gu(80)
25 height: units.gu(70)
28 height: units.gu(70)
27 DisabledScreenNotice {
30 DisabledScreenNotice {
28 id: touchScreenPad
31 id: touchScreenPad
29 anchors.fill: parent
32 anchors.fill: parent
33+ anchors.rightMargin: units.gu(40)
36+ property int orientation: {
37+ switch (orientationSelector.selectedIndex) {
39+ return Qt.PortraitOrientation;
41+ return Qt.LandscapeOrientation;
43+ return Qt.InvertedPortraitOrientation;
45+ return Qt.InvertedLandscapeOrientation;
49+ orientationLock: QtObject {
50+ property bool enabled: orientationLockCheckBox.checked
56+ anchors.leftMargin: units.gu(40)
59+ id: orientationSelector
60+ model: ["Portrait", "Landscape", "InvertedPortrait", "InvertedLandscape"]
66+ id: orientationLockCheckBox
70+ text: "Rotation lock"
71+ Layout.fillWidth: true
32 UnityTestCase {
76 UnityTestCase {
@@ -36,10 +80,40 @@ Item {
37 function test_mouseAreaHidesOnFirstTap() {
81 function test_mouseAreaHidesOnFirstTap() {
38 var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
82 var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
39− print("noticeArea", noticeArea.visible)
40 compare(noticeArea.visible, true)
83 compare(noticeArea.visible, true)
42 tryCompare(noticeArea, "visible", false)
85 tryCompare(noticeArea, "visible", false)
88+ function test_rotation_data() {
90+ {tag: "portrait", selectedOrientation: 0, expectedAngle: 0},
91+ {tag: "landscape", selectedOrientation: 1, expectedAngle: 270},
92+ {tag: "invertedportrait", selectedOrientation: 2, expectedAngle: 180},
93+ {tag: "invertetlandscape", selectedOrientation: 3, expectedAngle: 90}
97+ function test_rotation(data) {
98+ var content = findChild(touchScreenPad, "contentContainer");
100+ var oldRotation = content.rotation;
102+ // Turn on orientation lock
103+ orientationLockCheckBox.checked = true;
105+ // simulate the rotation
106+ orientationSelector.selectedIndex = data.selectedOrientation;
108+ // Make sure it is still in the old rotation (as we have the lock turned on)
109+ expectFail("", "Rotation lock set. Expecting automatic rotation to fail.");
110+ tryCompareFunction(function() { return content.rotation != oldRotation; }, true, 300);
112+ // Now uncheck the rotation lock
113+ orientationLockCheckBox.checked = false;
115+ // And make sure it catches up to the expected angle
116+ tryCompare(content, "rotation", data.expectedAngle);