on xenial help sign in
add tests for maximize and minimize an app
commitf99bdcffd8b32af014aeaf6ba93122f8efb45cfd authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 21 Oct 2015, 00:14 (11 years ago) parentf7d3606
3 files changed+29−13
qml/Stages/DesktopSpreadDelegate.qml+2−2 qml/Stages/DesktopStage.qml+1 tests/qmltests/Stages/tst_DesktopStage.qml+26−11
qml/Stages/DesktopSpreadDelegate.qml+2−2
@@ -29,8 +29,8 @@ Item {
2929 property bool highlightShown: false
3030 property real shadowOpacity: 1
3131
32− property int windowWidth: 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
32+ property int windowWidth: application && application.session && application.session.surface ? application.session.surface.size.width : 0
33+ property int windowHeight: application && application.session && application.session.surface ? application.session.surface.size.height : 0
3434
3535 state: "normal"
3636 states: [
qml/Stages/DesktopStage.qml+1
@@ -237,6 +237,7 @@ Rectangle {
237237
238238 delegate: FocusScope {
239239 id: appDelegate
240+ objectName: "appDelegate_" + appId
240241 z: ApplicationManager.count - index
241242 y: units.gu(3)
242243 width: units.gu(60)
tests/qmltests/Stages/tst_DesktopStage.qml+26−11
@@ -53,14 +53,10 @@ Item {
5353
5454 focus: true
5555
56− property bool itemDestroyed: false
5756 sourceComponent: Component {
5857 DesktopStage {
5958 color: "darkblue"
6059 anchors.fill: parent
61− Component.onDestruction: {
62− desktopStageLoader.itemDestroyed = true;
63− }
6460 }
6561 }
6662 }
@@ -95,16 +91,10 @@ Item {
9591 property Item desktopStage: desktopStageLoader.status === Loader.Ready ? desktopStageLoader.item : null
9692
9793 function cleanup() {
98− desktopStageLoader.itemDestroyed = false;
9994 desktopStageLoader.active = false;
10095
10196 tryCompare(desktopStageLoader, "status", Loader.Null);
10297 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);
10898
10999 killAllRunningApps();
110100
@@ -117,7 +107,7 @@ Item {
117107 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
118108 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
119109 }
120− compare(ApplicationManager.count, 1)
110+ compare(ApplicationManager.count, 1);
121111 }
122112
123113 function waitUntilAppSurfaceShowsUp(appId) {
@@ -241,5 +231,30 @@ Item {
241231 mouseClick(toAppDecoration);
242232 tryCompare(ApplicationManager.findApplication(data.apps[data.focusTo]).session.surface, "activeFocus", true);
243233 }
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+ }
244259 }
245260}