on xenial help sign in
add tests for maximize and minimize an app
f99bdcfLukáš Tinkl
qml/Stages/DesktopSpreadDelegate.qml+2−2
@@ -29,8 +29,8 @@ Item {
29 property bool highlightShown: false
29 property bool highlightShown: false
30 property real shadowOpacity: 1
30 property real shadowOpacity: 1
31
31
32− property int windowWidth: application.session && application.session.surface ? application.session.surface.size.width : 0
32+ property int windowWidth: application && application.session && application.session.surface ? application.session.surface.size.width : 0
33− property int windowHeight: application.session && application.session.surface ? application.session.surface.size.height : 0
33+ property int windowHeight: application && application.session && application.session.surface ? application.session.surface.size.height : 0
34
34
35 state: "normal"
35 state: "normal"
36 states: [
36 states: [
qml/Stages/DesktopStage.qml+1
@@ -237,6 +237,7 @@ Rectangle {
237
237
238 delegate: FocusScope {
238 delegate: FocusScope {
239 id: appDelegate
239 id: appDelegate
240+ objectName: "appDelegate_" + appId
240 z: ApplicationManager.count - index
241 z: ApplicationManager.count - index
241 y: units.gu(3)
242 y: units.gu(3)
242 width: units.gu(60)
243 width: units.gu(60)
tests/qmltests/Stages/tst_DesktopStage.qml+26−11
@@ -53,14 +53,10 @@ Item {
53
53
54 focus: true
54 focus: true
55
55
56− property bool itemDestroyed: false
57 sourceComponent: Component {
56 sourceComponent: Component {
58 DesktopStage {
57 DesktopStage {
59 color: "darkblue"
58 color: "darkblue"
60 anchors.fill: parent
59 anchors.fill: parent
61− Component.onDestruction: {
62− desktopStageLoader.itemDestroyed = true;
63− }
64 }
60 }
65 }
61 }
66 }
62 }
@@ -95,16 +91,10 @@ Item {
95 property Item desktopStage: desktopStageLoader.status === Loader.Ready ? desktopStageLoader.item : null
91 property Item desktopStage: desktopStageLoader.status === Loader.Ready ? desktopStageLoader.item : null
96
92
97 function cleanup() {
93 function cleanup() {
98− desktopStageLoader.itemDestroyed = false;
99 desktopStageLoader.active = false;
94 desktopStageLoader.active = false;
100
95
101 tryCompare(desktopStageLoader, "status", Loader.Null);
96 tryCompare(desktopStageLoader, "status", Loader.Null);
102 tryCompare(desktopStageLoader, "item", null);
97 tryCompare(desktopStageLoader, "item", null);
103− // Loader.status might be Loader.Null and Loader.item might be null but the Loader
104− // actually took place. Likely because Loader waits until the next event loop
105− // iteration to do its work. So to ensure the reload, we will wait until the
106− // Shell instance gets destroyed.
107− tryCompare(desktopStageLoader, "itemDestroyed", true);
108
98
109 killAllRunningApps();
99 killAllRunningApps();
110
100
@@ -117,7 +107,7 @@ Item {
117 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
107 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
118 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
108 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
119 }
109 }
120− compare(ApplicationManager.count, 1)
110+ compare(ApplicationManager.count, 1);
121 }
111 }
122
112
123 function waitUntilAppSurfaceShowsUp(appId) {
113 function waitUntilAppSurfaceShowsUp(appId) {
@@ -241,5 +231,30 @@ Item {
241 mouseClick(toAppDecoration);
231 mouseClick(toAppDecoration);
242 tryCompare(ApplicationManager.findApplication(data.apps[data.focusTo]).session.surface, "activeFocus", true);
232 tryCompare(ApplicationManager.findApplication(data.apps[data.focusTo]).session.surface, "activeFocus", true);
243 }
233 }
234+
235+ function test_maximizeApp() {
236+ var apps = ["unity8-dash", "dialer-app", "camera-app"];
237+ apps.forEach(startApplication);
238+ var appName = "dialer-app";
239+ var appDelegate = findChild(desktopStage, "appDelegate_" + appName);
240+ verify(appDelegate);
241+ ApplicationManager.focusApplication(appName);
242+ keyClick(Qt.Key_Up, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Up shortcut to maximize
243+ tryCompare(appDelegate, "maximized", true);
244+ tryCompare(appDelegate, "minimized", false);
245+ }
246+
247+ function test_minimizeApp() {
248+ var apps = ["unity8-dash", "dialer-app", "camera-app"];
249+ apps.forEach(startApplication);
250+ var appName = "dialer-app";
251+ var appDelegate = findChild(desktopStage, "appDelegate_" + appName);
252+ verify(appDelegate);
253+ ApplicationManager.focusApplication(appName);
254+ keyClick(Qt.Key_Down, Qt.MetaModifier|Qt.ControlModifier); // Ctrl+Super+Down shortcut to minimize
255+ tryCompare(appDelegate, "maximized", false);
256+ tryCompare(appDelegate, "minimized", true);
257+ verify(ApplicationManager.focusedApplicationId != ""); // verify we don't lose focus when minimizing an app
258+ }
244 }
259 }
245}
260}