on xenial help sign in
Add test for SurfaceContainer
c9bd434Gerry Boland
tests/qmltests/Stages/tst_SessionContainer.qml+63
@@ -41,6 +41,7 @@ Rectangle {
41 SessionContainer {
41 SessionContainer {
42 id: sessionContainer
42 id: sessionContainer
43 anchors.fill: parent
43 anchors.fill: parent
44+ orientation: Qt.PortraitOrientation
44 }
45 }
45 }
46 }
46
47
@@ -112,6 +113,24 @@ Rectangle {
112 session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null
113 session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null
113 }
114 }
114 }
115 }
116+
117+ Button {
118+ anchors { left: parent.left; right: parent.right }
119+ text: "Rotate device \u27F3"
120+ onClicked: {
121+ var orientation = sessionContainerLoader.item.orientation
122+ if (orientation == Qt.PortraitOrientation) {
123+ orientation = Qt.LandscapeOrientation;
124+ } else if (orientation == Qt.LandscapeOrientation) {
125+ orientation = Qt.InvertedPortraitOrientation;
126+ } else if (orientation == Qt.InvertedPortraitOrientation) {
127+ orientation = Qt.InvertedLandscapeOrientation;
128+ } else {
129+ orientation = Qt.PortraitOrientation;
130+ }
131+ sessionContainerLoader.item.orientation = orientation;
132+ }
133+ }
115 }
134 }
116 }
135 }
117
136
@@ -263,5 +282,49 @@ Rectangle {
263 // wait for animation to end
282 // wait for animation to end
264 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
283 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
265 }
284 }
285+
286+ function test_orientationPropagatedToChildren_data() {
287+ return [ { tag: "count=1", count: 1 },
288+ { tag: "count=4", count: 4 } ];
289+ }
290+
291+ /* Text orientation changes are propagated to all children immediately */
292+ function test_orientationPropagatedToChildren(data) {
293+ sessionCheckbox.checked = true;
294+ var sessionContainer = sessionContainerLoader.item;
295+ compare(sessionContainer.childSessions.count(), 0);
296+
297+ var i;
298+ var sessions = [];
299+ for (i = 0; i < data.count; i++) {
300+ var session = ApplicationTest.addChildSession(sessionContainer.session,
301+ "gallery");
302+ session.createSurface();
303+ sessionContainer.session.addChildSession(session);
304+
305+ // Check child SessionContainer has orientation matching the parent
306+ var delegate = findChild(sessionContainer, "childDelegate" + i);
307+ var childContainer = findChild(delegate, "sessionContainer");
308+
309+ tryCompare(sessionContainer, "orientation", sessionContainer.orientation);
310+
311+ sessions.push(session);
312+ }
313+
314+ // Change orientation and verify all children updated
315+ sessionContainer.orientation = Qt.LandscapeOrientation;
316+
317+ for (i = 0; i < data.count; i++) {
318+ var delegate = findChild(sessionContainer, "childDelegate" + i);
319+ var childContainer = findChild(delegate, "sessionContainer");
320+
321+ tryCompare(sessionContainer, "orientation", sessionContainer.orientation);
322+ }
323+
324+ // Clean up
325+ for (i = data.count-1; i >= 0; i--) {
326+ ApplicationTest.removeSession(sessions[i]);
327+ }
328+ }
266 }
329 }
267}
330}