@@ -18,87 +18,20 @@ import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import "../../../../qml/Dash/Apps"
19import "../../../../qml/Dash/Apps"
20import Unity.Test 0.1 as UT
20import Unity.Test 0.1 as UT
21+import Unity.Application 0.1
22−Item {
23+// Using Rectangle to have an opaque surface because AppManager paints app surfaces behind it.
23 width: units.gu(50)
25 width: units.gu(50)
24 height: units.gu(40)
26 height: units.gu(40)
26− QtObject {
28+ function resetRunningApplications() {
27− id: fakeApplicationManager
29+ while (ApplicationManager.count > 0) {
28−
30+ ApplicationManager.stopApplication(ApplicationManager.get(0).appId)
29− property bool sideStageEnabled: false
31− function stopApplication(appId) {
32− for (var i=0, len=fakeRunningAppsModel.count; i<len; i++) {
33− if (appId == fakeRunningAppsModel.get(i).appId) {
34− fakeRunningAppsModel.remove(i)
42− property bool dashShown: true
43− property bool stageScreenshotsReady: false
44− property var applicationManager: fakeApplicationManager
46− function activateApplication(appId) {
51− id: fakeRunningAppsModel
53− function contains(appId) {
54− for (var i=0, len=fakeRunningAppsModel.count; i<len; i++) {
55− if (appId == fakeRunningAppsModel.get(i).appId) {
62− function rePopulate() {
63− for (var i=0, len=availableAppsModel.count; i<len; i++) {
64− fakeRunningAppsModel.append(availableAppsModel.get(i));
70− id: availableAppsModel
74− exec: "/usr/bin/phone-app"
76− imageQml: "import QtQuick 2.0\n \
78− anchors.fill:parent \n \
79− color:'darkgreen' \n \
80− Text { anchors.centerIn: parent; text: 'PHONE' } \n \
84− ListElement {
33+ ApplicationManager.startApplication("phone-app");
85− name: "Calendar"
34+ ApplicationManager.startApplication("webbrowser-app");
87− exec: "/usr/bin/calendar-app"
89− imageQml: "import QtQuick 2.0\n \
91− anchors.fill:parent \n \
92− color:'darkblue' \n \
93− Text { anchors.centerIn: parent; text: 'CALENDAR'\n \
99− function resetRunningApplications() {
100− fakeRunningAppsModel.clear()
101− fakeRunningAppsModel.rePopulate()
104 Component.onCompleted: {
37 Component.onCompleted: {
@@ -109,7 +42,7 @@ Item {
109 RunningApplicationsGrid {
42 RunningApplicationsGrid {
110 id: runningApplicationsGrid
43 id: runningApplicationsGrid
111 anchors.fill: parent
44 anchors.fill: parent
112− firstModel: fakeRunningAppsModel
45+ model: ApplicationManager
115 UT.UnityTestCase {
48 UT.UnityTestCase {
@@ -121,11 +54,11 @@ Item {
121 resetRunningApplications()
54 resetRunningApplications()
124− property var calendarTile
57+ property var browserTile
125 property var phoneTile
58 property var phoneTile
127− property var isCalendarLongPressed: false
60+ property var isBrowserLongPressed: false
128− function onCalendarLongPressed() {isCalendarLongPressed = true}
61+ function onBrowserLongPressed() {isBrowserLongPressed = true}
130 property var isPhoneLongPressed: false
63 property var isPhoneLongPressed: false
131 function onPhoneLongPressed() {isPhoneLongPressed = true}
64 function onPhoneLongPressed() {isPhoneLongPressed = true}
@@ -133,25 +66,25 @@ Item {
133 // Tiles should go to termination mode when any one of them is long-pressed.
66 // Tiles should go to termination mode when any one of them is long-pressed.
134 // Long-pressing when they're in termination mode brings them back to activation mode
67 // Long-pressing when they're in termination mode brings them back to activation mode
135 function test_enterTerminationMode() {
68 function test_enterTerminationMode() {
136− calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
69+ browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
137− verify(calendarTile != undefined)
70+ verify(browserTile != undefined)
138− calendarTile.onPressAndHold.connect(onCalendarLongPressed)
71+ browserTile.onPressAndHold.connect(onBrowserLongPressed)
140 phoneTile = findChild(runningApplicationsGrid, "runningAppTile Phone")
73 phoneTile = findChild(runningApplicationsGrid, "runningAppTile Phone")
141 verify(phoneTile != undefined)
74 verify(phoneTile != undefined)
142 phoneTile.onPressAndHold.connect(onPhoneLongPressed)
75 phoneTile.onPressAndHold.connect(onPhoneLongPressed)
144− compare(calendarTile.terminationModeEnabled, false)
77+ compare(browserTile.terminationModeEnabled, false)
145 compare(phoneTile.terminationModeEnabled, false)
78 compare(phoneTile.terminationModeEnabled, false)
146 compare(runningApplicationsGrid.terminationModeEnabled, false)
79 compare(runningApplicationsGrid.terminationModeEnabled, false)
148− isCalendarLongPressed = false
81+ isBrowserLongPressed = false
149− mousePress(calendarTile, calendarTile.width/2, calendarTile.height/2)
82+ mousePress(browserTile, browserTile.width/2, browserTile.height/2)
150 tryCompareFunction(checkSwitchToTerminationModeAfterLongPress, true)
83 tryCompareFunction(checkSwitchToTerminationModeAfterLongPress, true)
152− mouseRelease(calendarTile, calendarTile.width/2, calendarTile.height/2)
85+ mouseRelease(browserTile, browserTile.width/2, browserTile.height/2)
154− compare(calendarTile.terminationModeEnabled, true)
87+ compare(browserTile.terminationModeEnabled, true)
155 compare(phoneTile.terminationModeEnabled, true)
88 compare(phoneTile.terminationModeEnabled, true)
156 compare(runningApplicationsGrid.terminationModeEnabled, true)
89 compare(runningApplicationsGrid.terminationModeEnabled, true)
@@ -161,23 +94,23 @@ Item {
162 mouseRelease(phoneTile, phoneTile.width/2, phoneTile.height/2)
95 mouseRelease(phoneTile, phoneTile.width/2, phoneTile.height/2)
164− compare(calendarTile.terminationModeEnabled, false)
97+ compare(browserTile.terminationModeEnabled, false)
165 compare(phoneTile.terminationModeEnabled, false)
98 compare(phoneTile.terminationModeEnabled, false)
166 compare(runningApplicationsGrid.terminationModeEnabled, false)
99 compare(runningApplicationsGrid.terminationModeEnabled, false)
168− calendarTile.onPressAndHold.disconnect(onCalendarLongPressed)
101+ browserTile.onPressAndHold.disconnect(onBrowserLongPressed)
169 phoneTile.onPressAndHold.disconnect(onPhoneLongPressed)
102 phoneTile.onPressAndHold.disconnect(onPhoneLongPressed)
172 // Checks that components swicth to termination mode after (and only after) a long
105 // Checks that components swicth to termination mode after (and only after) a long
173− // press happens on Calendar tile.
106+ // press happens on Browser tile.
174 function checkSwitchToTerminationModeAfterLongPress() {
107 function checkSwitchToTerminationModeAfterLongPress() {
175− compare(calendarTile.terminationModeEnabled, isCalendarLongPressed)
108+ compare(browserTile.terminationModeEnabled, isBrowserLongPressed)
176− compare(phoneTile.terminationModeEnabled, isCalendarLongPressed)
109+ compare(phoneTile.terminationModeEnabled, isBrowserLongPressed)
177− compare(runningApplicationsGrid.terminationModeEnabled, isCalendarLongPressed)
110+ compare(runningApplicationsGrid.terminationModeEnabled, isBrowserLongPressed)
179− return isCalendarLongPressed &&
112+ return isBrowserLongPressed &&
180− calendarTile.terminationModeEnabled &&
113+ browserTile.terminationModeEnabled &&
181 phoneTile.terminationModeEnabled &&
114 phoneTile.terminationModeEnabled &&
182 runningApplicationsGrid.terminationModeEnabled
115 runningApplicationsGrid.terminationModeEnabled
@@ -185,12 +118,12 @@ Item {
185 // Checks that components swicth to activation mode after (and only after) a long
118 // Checks that components swicth to activation mode after (and only after) a long
186 // press happens on Phone tile.
119 // press happens on Phone tile.
187 function checkSwitchToActivationModeAfterLongPress() {
120 function checkSwitchToActivationModeAfterLongPress() {
188− compare(calendarTile.terminationModeEnabled, !isPhoneLongPressed)
121+ compare(browserTile.terminationModeEnabled, !isPhoneLongPressed)
189 compare(phoneTile.terminationModeEnabled, !isPhoneLongPressed)
122 compare(phoneTile.terminationModeEnabled, !isPhoneLongPressed)
190 compare(runningApplicationsGrid.terminationModeEnabled, !isPhoneLongPressed)
123 compare(runningApplicationsGrid.terminationModeEnabled, !isPhoneLongPressed)
192 return isPhoneLongPressed &&
125 return isPhoneLongPressed &&
193− !calendarTile.terminationModeEnabled &&
126+ !browserTile.terminationModeEnabled &&
194 !phoneTile.terminationModeEnabled &&
127 !phoneTile.terminationModeEnabled &&
195 !runningApplicationsGrid.terminationModeEnabled
128 !runningApplicationsGrid.terminationModeEnabled
@@ -200,17 +133,17 @@ Item {
200 function test_clickTileNotClose() {
133 function test_clickTileNotClose() {
201 runningApplicationsGrid.terminationModeEnabled = true
134 runningApplicationsGrid.terminationModeEnabled = true
203− var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
136+ var browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
204− verify(calendarTile != undefined)
137+ verify(browserTile != undefined)
206− verify(fakeRunningAppsModel.contains("calendar"))
139+ verify(ApplicationManager.findApplication("webbrowser-app") !== null)
208− mouseClick(calendarTile, calendarTile.width/2, calendarTile.height/2)
141+ mouseClick(browserTile, browserTile.width/2, browserTile.height/2)
210− verify(fakeRunningAppsModel.contains("calendar"))
143+ verify(ApplicationManager.findApplication("webbrowser-app") !== null)
212− // The tile for the Calendar app should stay there
145+ // The tile for the Browser app should stay there
213− tryCompareFunction(checkCalendarTileExists, true)
146+ tryCompareFunction(checkBrowserTileExists, true)
216 // While in termination mode, clicking on a running application tile's close icon
149 // While in termination mode, clicking on a running application tile's close icon
@@ -218,25 +151,25 @@ Item {
218 function test_clickCloseIconToTerminateApp() {
151 function test_clickCloseIconToTerminateApp() {
219 runningApplicationsGrid.terminationModeEnabled = true
152 runningApplicationsGrid.terminationModeEnabled = true
221− var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
154+ var browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
222− var calendarTileCloseButton = findChild(runningApplicationsGrid, "closeIcon Calendar")
155+ var browserTileCloseButton = findChild(runningApplicationsGrid, "closeIcon Browser")
224− verify(calendarTile != undefined)
157+ verify(browserTile != undefined)
225− verify(calendarTileCloseButton != undefined)
158+ verify(browserTileCloseButton != undefined)
226− verify(fakeRunningAppsModel.contains("calendar"))
159+ verify(ApplicationManager.findApplication("webbrowser-app") !== 0)
228− mouseClick(calendarTileCloseButton, calendarTileCloseButton.width/2, calendarTileCloseButton.height/2)
161+ mouseClick(browserTileCloseButton, browserTileCloseButton.width/2, browserTileCloseButton.height/2)
229 wait(0) // spin event loop to start any pending animation
162 wait(0) // spin event loop to start any pending animation
231− verify(!fakeRunningAppsModel.contains("calendar"))
164+ verify(ApplicationManager.findApplication("webbrowser-app") === null)
233− // The tile for the Calendar app should eventually vanish since the
166+ // The tile for the Browser app should eventually vanish since the
234 // application has been terminated.
167 // application has been terminated.
235− tryCompareFunction(checkCalendarTileExists, false)
168+ tryCompareFunction(checkBrowserTileExists, false)
238− function checkCalendarTileExists() {
171+ function checkBrowserTileExists() {
239− return findChild(runningApplicationsGrid, "runningAppTile Calendar")
172+ return findChild(runningApplicationsGrid, "runningAppTile Browser")
240 != undefined
173 != undefined
@@ -245,8 +178,8 @@ Item {
245 function test_clickOutsideTilesDisablesTerminationMode() {
178 function test_clickOutsideTilesDisablesTerminationMode() {
246 runningApplicationsGrid.terminationModeEnabled = true
179 runningApplicationsGrid.terminationModeEnabled = true
248− var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
181+ var browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
249− verify(calendarTile != undefined)
182+ verify(browserTile != undefined)
251 verify(runningApplicationsGrid.terminationModeEnabled);
184 verify(runningApplicationsGrid.terminationModeEnabled);