~paulliu/unity8/zoomImage

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/Apps/tst_RunningApplicationsGrid.qml

  • Committer: Ying-Chun Liu
  • Date: 2014-04-22 15:33:24 UTC
  • mfrom: (734.1.119 unity8)
  • Revision ID: paul.liu@canonical.com-20140422153324-9o7r3gh3dzczx4sr
Merge upstream
[ Albert Astals ]
* Fix last item X position Fixes clicking on the last item sometimes
  not working (LP: #1301871)
* Use upstart in ./run Makes it so that you can use the lock button on
  the device without getting that nasty hwc crash
* Remove AnimationControllerWithSignals.
* Use the correct delegate base item for the Carousel test
* Some simplification in DashContent Kill the ScopeDelegateMapper in
  favour of a simple if (that will eventually go away). Removal of all
  the fake scopes in the tests that added nothing of value to the
  tests. Removal of movementEnded signal that was unused. Removal of
  movementStarted and positionedAtBeginning signals that were being
  used as function calls. Rework DashContent tests so they what the
  function does what it is supposed to do instead of just making sure
  QML signals work .
* Improve Card creation time by adding loaders that make sure only
  what's needed is loaded In my computer it goes from RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotSummaryMode
  l": 3.217 msecs per iteration (total: 3,218, iterations: 1000)
  RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotModel":
  1.647 msecs per iteration (total: 1,648, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleModel": 1.514
  msecs per iteration (total: 1,515, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtModel": 1.471 msecs per
  iteration (total: 1,471, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardArtModel": 1.447 msecs per
  iteration (total: 1,448, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleModel": 1.276 msecs per
  iteration (total: 1,276, iterations: 1000) to RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotSummaryMode
  l": 2.916 msecs per iteration (total: 2,917, iterations: 1000)
  RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleMascotModel":
  1.504 msecs per iteration (total: 1,504, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtSubtitleModel": 1.060
  msecs per iteration (total: 1,061, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleArtModel": 1.052 msecs per
  iteration (total: 1,053, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardArtModel": 0.727 msecs per
  iteration (total: 728, iterations: 1000) RESULT :
  qmltestrunner::benchmark_time:"cardTitleModel": 0.817 msecs per
  iteration (total: 818, iterations: 1000) (LP: #1297197)
[ Allan LeSage ]
* DashApps emulator get_applications should return a list ordered by
  visible y, x.
[ Andrea Cimitan ]
* Workaround for lp1301309 until fixes for palette in ui toolkit (LP:
  #1301309)
[ Leo Arias ]
* Reverted the change that returns application cards instead of
  titles.
[ Nick Dedekind ]
* Indicator services started by unity8 upstart configuration rather
  than manual emmision from indicator manager.
[ Mirco Müller ]
* Fix notification ap-test assertions.
[ Michael Terry ]
* Use new tablet and phone backgrounds from Design.
[ Michael Zanetti ]
* workaround the QTestLogger assertion issue with make tryXyz and our
  custom uqmlscene
[ Michael Terry ]
* When an application requests focus, handle it in Shell.qml by hiding
  the greeter and stopping any edge demo. (LP: #1227753)
[ Leo Arias ]
* Use subprocess.check_call when caling url-dispatcher, so an error
  will be raised if it fails.
* Test application life cycle with fake apps, instead of messaging and
  address book.
[ Didier Roche ]
* Resync trunk with previous revert upload
[ Michał Sawicz ]
* Set the Qt.ImhNoPredictiveText flag on wifi password field, fixes
  lp:1291575 (LP: #1291575)
[ Albert Astals ]
* Take into account the originY when specifying the delegate ranges
  Fixes bug #1300302 (LP: #1300302)
[ CI bot ]
* Resync trunk
[ Allan LeSage ]
* Swiping open an indicator must show its correct title--protect
  against lp:1253804 . (LP: #1253804)
[ Alexander Sack ]
* Fix TypeError: issue seen in system_integration autopilot test on
  image 279. (LP: #1303685)
[ Bill Filler ]
* Set the Qt.ImhNoPredictiveText flag on wifi password field, fixes
  lp:1291575 (LP: #1291575)
[ Leo Arias ]
* Added a search autopilot helper.
[ Michael Terry ]
* Provide a all-in-one script for getting a device to an unlocked
  state.
* Revert to previous version as it's linked to latest sdk change which
  is making gallery-app AP tests failing on the CI dashboard
[ Albert Astals ]
* Adapt to new TabBar
[ Michael Terry ]
* Re-enable test_networkmanager_integration autopilot test on phone
  platforms
[ CI bot ]
* Resync trunk
[ Leo Arias ]
* Reverted the open_preview autopilot helper to return a Preview
  object.
[ Albert Astals ]
* If not running in Mir load the "fake" application manager (LP:
  #1301547)
* Remove unused properties from DashRenderer
[ Michael Zanetti ]
* Fix tests after right edge merge. Drop old stages tests. Fix right
  edge tests if someone doesn't have the GRID_UNIT_PX exported. make
  GenericScopeView test more robust that broke because the ordering
  changed
* add "make xvfbtestSomething" target to run qml tests in xvfb
* make the "make test" commit hook work again
[ Michał Sawicz ]
* Bump version to ensure incompatibility with previous Unity.Application
  implementations.
* We'll only have the unity-mir and mock Ubuntu.Application plugins
  now, no need for mangling the import paths.
[ Michal Hruby ]
* Remove the albumart image provider. (LP: #1262711)
* Don't reset search string after 2 seconds. (LP: #1297246)
[ James Henstridge ]
* Remove the albumart image provider. (LP: #1262711)
[ Albert Astals ]
* Carousel: Add test to make sure we only create the needed delegates
  and not more
* LVWPH: Remove processEvents() call from updatePolish() It causes
  some reentrancy issues and in some times you end up in polishItems()
  with items that have been deleted because you called processEvents()
  This means i need a small tweak in itemGeometryChanged to not
  reposition items if we are inside a setContentHeight call and two
  small tweaks to tests since now things happen in a different order
  and numbers are different (though equivalent) (LP: #1297240)
* Card.qml binding loops are gone. hooray \o/ Also made the aspect
  properties readonly
[ Mirco Müller ]
* A potential fix for "Cannot read property 'state' of null"-failure
  on Jenkins with the VisualSnapDecisionsQueue QML-test of
  notifications.
[ Michael Terry ]
* Pass user's preference for auto-brightness on to powerd. (LP:
  #1273174)
[ Michael Zanetti ]
* Registers a dummy QObject as QTestRootObject in uqmlscene in order
  to fix make trySomething with Qt 5.2.
* For now, have libunity-private depending on libunity-core-6.0-9 as the
  gsettings schema is here. The dependency wasn't direct and dropped from
  Touch image #271. Consequently, unity8 didn't start (gsettings
  segfaulting).
  Proper strategy will be to include the schema in another package to only
  pull it.

Show diffs side-by-side

added added

removed removed

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