@@ -15,18 +15,62 @@
1515 */
1616
1717import QtQuick 2.4
18+import QtQuick.Layouts 1.1
1819import QtTest 1.0
1920import Unity.Test 0.1
21+import Ubuntu.Components 1.3
22+import Ubuntu.Components.ListItems 1.3
2023import "../../qml"
2124
2225Item {
2326 id: root
24− width: units.gu(40)
27+ width: units.gu(80)
2528 height: units.gu(70)
2629
2730 DisabledScreenNotice {
2831 id: touchScreenPad
2932 anchors.fill: parent
33+ anchors.rightMargin: units.gu(40)
34+
35+ screen: QtObject {
36+ property int orientation: {
37+ switch (orientationSelector.selectedIndex) {
38+ case 0:
39+ return Qt.PortraitOrientation;
40+ case 1:
41+ return Qt.LandscapeOrientation;
42+ case 2:
43+ return Qt.InvertedPortraitOrientation;
44+ case 3:
45+ return Qt.InvertedLandscapeOrientation;
46+ }
47+ }
48+ }
49+ orientationLock: QtObject {
50+ property bool enabled: orientationLockCheckBox.checked
51+ }
52+ }
53+
54+ Column {
55+ anchors.fill: parent
56+ anchors.leftMargin: units.gu(40)
57+
58+ ItemSelector {
59+ id: orientationSelector
60+ model: ["Portrait", "Landscape", "InvertedPortrait", "InvertedLandscape"]
61+ selectedIndex: 0
62+ }
63+
64+ RowLayout {
65+ CheckBox {
66+ id: orientationLockCheckBox
67+ checked: false
68+ }
69+ Label {
70+ text: "Rotation lock"
71+ Layout.fillWidth: true
72+ }
73+ }
3074 }
3175
3276 UnityTestCase {
@@ -36,10 +80,40 @@ Item {
3680
3781 function test_mouseAreaHidesOnFirstTap() {
3882 var noticeArea = findChild(touchScreenPad, "infoNoticeArea")
39− print("noticeArea", noticeArea.visible)
4083 compare(noticeArea.visible, true)
4184 tap(root)
4285 tryCompare(noticeArea, "visible", false)
4386 }
87+
88+ function test_rotation_data() {
89+ return [
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}
94+ ];
95+ }
96+
97+ function test_rotation(data) {
98+ var content = findChild(touchScreenPad, "contentContainer");
99+
100+ var oldRotation = content.rotation;
101+
102+ // Turn on orientation lock
103+ orientationLockCheckBox.checked = true;
104+
105+ // simulate the rotation
106+ orientationSelector.selectedIndex = data.selectedOrientation;
107+
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);
111+
112+ // Now uncheck the rotation lock
113+ orientationLockCheckBox.checked = false;
114+
115+ // And make sure it catches up to the expected angle
116+ tryCompare(content, "rotation", data.expectedAngle);
117+ }
44118 }
45119}