@@ -1,5 +1,5 @@
2− * Copyright 2014-2015 Canonical Ltd.
2+ * Copyright 2014-2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -132,10 +132,12 @@ Rectangle {
132 property int value: selectedIndex * 90
132 property int value: selectedIndex * 90
135+ id: matchShellButton
135 text: "matchShellOrientation()"
136 text: "matchShellOrientation()"
136 onClicked: { spreadDelegateLoader.item.matchShellOrientation(); }
137 onClicked: { spreadDelegateLoader.item.matchShellOrientation(); }
140+ id: animateToShellButton
139 text: "animateToShellOrientation()"
141 text: "animateToShellOrientation()"
140 onClicked: { spreadDelegateLoader.item.animateToShellOrientation(); }
142 onClicked: { spreadDelegateLoader.item.animateToShellOrientation(); }
@@ -197,6 +199,77 @@ Rectangle {
202+ function waitUntilAppWindowIsFullyLoaded() {
203+ var appWindowStateGroup = findInvisibleChild(spreadDelegate, "applicationWindowStateGroup");
204+ tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
205+ waitUntilTransitionsEnd(appWindowStateGroup);
207+ var priv = findInvisibleChild(spreadDelegate, "spreadDelegatePriv");
209+ tryCompare(priv, "startingUp", false);
212+ function rotateShellTo(angle) {
213+ shellOrientationAngleSelector.selectedIndex = angle / 90;
216+ function waitUntilRotationAnimationStops() {
217+ var orientationChangeAnimation = findInvisibleChild(spreadDelegate, "orientationChangeAnimation");
218+ verify(orientationChangeAnimation);
219+ tryCompare(orientationChangeAnimation, "running", false);
222+ function checkAppWindowTransformationMatchesRotation(appWindow, angle) {
226+ var bottomRightX = 0;
227+ var bottomRightY = 0;
233+ bottomRightX = fakeShell.shortestDimension;
234+ bottomRightY = fakeShell.longestDimension;
237+ topLeftX = fakeShell.shortestDimension;
240+ bottomRightY = fakeShell.longestDimension;
243+ // TODO implement 180 and 270 once we need them
247+ var appWindowTopLeftInRootCoords = appWindow.mapToItem(root, 0, 0);
249+ if (appWindowTopLeftInRootCoords.x !== topLeftX) {
250+ qtest_fail("appWindow topLeft.x ("+appWindowTopLeftInRootCoords.x+")"
251+ +" doesn't match expectations ("+topLeftX+").", 1);
253+ if (appWindowTopLeftInRootCoords.y !== topLeftY) {
254+ qtest_fail("appWindow topLeft.y ("+appWindowTopLeftInRootCoords.y+")"
255+ +" doesn't match expectations ("+topLeftY+").", 1);
258+ var appWindowBottomRightInRootCoords = appWindow.mapToItem(root, appWindow.width,
260+ compare(appWindowBottomRightInRootCoords.x, bottomRightX);
261+ compare(appWindowBottomRightInRootCoords.y, bottomRightY);
263+ if (appWindowBottomRightInRootCoords.x !== bottomRightX) {
264+ qtest_fail("appWindow bottomRight.x ("+appWindowBottomRightInRootCoords.x+")"
265+ +" doesn't match expectations ("+bottomRightX+").", 1);
267+ if (appWindowBottomRightInRootCoords.y !== bottomRightY) {
268+ qtest_fail("appWindow bottomRight.y ("+appWindowBottomRightInRootCoords.y+")"
269+ +" doesn't match expectations ("+bottomRightY+").", 1);
200 function test_swipeToClose_data() {
273 function test_swipeToClose_data() {
202 {tag: "swipeToClose=true closeable=true -> appWindow moves away",
275 {tag: "swipeToClose=true closeable=true -> appWindow moves away",
@@ -278,11 +351,7 @@ Rectangle {
278 function test_keepsSceneTransformationWhenShellRotates(data) {
351 function test_keepsSceneTransformationWhenShellRotates(data) {
279 loadWithGalleryApp.clicked();
352 loadWithGalleryApp.clicked();
281− {
354+ waitUntilAppWindowIsFullyLoaded();
282− var priv = findInvisibleChild(spreadDelegate, "spreadDelegatePriv");
284− tryCompare(priv, "startingUp", false);
287 var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
356 var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
288 verify(appWindowWithShadow);
357 verify(appWindowWithShadow);
@@ -297,14 +366,7 @@ Rectangle {
299 // and scene transformation must be the identity (ie, no rotation or translation)
368 // and scene transformation must be the identity (ie, no rotation or translation)
300− var pointInDelegateCoords = appWindowWithShadow.mapToItem(root, 0, 0);
369+ checkAppWindowTransformationMatchesRotation(appWindowWithShadow, 0);
301− compare(pointInDelegateCoords.x, 0);
302− compare(pointInDelegateCoords.y, 0);
304− pointInDelegateCoords = appWindowWithShadow.mapToItem(root,
305− fakeShell.shortestDimension, fakeShell.longestDimension);
306− compare(pointInDelegateCoords.x, fakeShell.shortestDimension);
307− compare(pointInDelegateCoords.y, fakeShell.longestDimension);
310 function waitForCloseAnimationToFinish() {
372 function waitForCloseAnimationToFinish() {
@@ -320,5 +382,42 @@ Rectangle {
320 spreadDelegateLoader.item.highlightShown = true;
382 spreadDelegateLoader.item.highlightShown = true;
321 tryCompare(highlightRect, "visible", true)
383 tryCompare(highlightRect, "visible", true)
387+ Checks that the ApplicationWindow position, size and rotation is correct after
388+ a sequence of shell rotations folowed by rotations (immediate or not) to match them
390+ function test_animateToShellThenMatchShell() {
391+ loadWithGalleryApp.clicked();
392+ waitUntilAppWindowIsFullyLoaded();
394+ var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
395+ verify(appWindowWithShadow);
397+ // appWindow transformation is 0 relative to display
398+ checkAppWindowTransformationMatchesRotation(appWindowWithShadow, 0);
402+ // appWindow transformation remains 0 relative to display
403+ checkAppWindowTransformationMatchesRotation(appWindowWithShadow, 0);
405+ animateToShellButton.clicked();
406+ waitUntilRotationAnimationStops();
408+ // appWindow transformation is now 90 relative to display, just like shell
409+ checkAppWindowTransformationMatchesRotation(appWindowWithShadow, 90);
413+ // appWindow transformation is remains 90 relative to display.
414+ checkAppWindowTransformationMatchesRotation(appWindowWithShadow, 90);
416+ matchShellButton.clicked();
418+ // appWindow transformation is back to 0 relative to display, just like shell
419+ checkAppWindowTransformationMatchesRotation(appWindowWithShadow, 0);