~paulliu/unity8/zoomImage

« back to all changes in this revision

Viewing changes to tests/qmltests/Components/tst_Stage.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:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
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
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 */
16
 
 
17
 
import QtQuick 2.0
18
 
import QtTest 1.0
19
 
import ".."
20
 
import "../../../qml/Components"
21
 
import Unity.Application 0.1
22
 
import Ubuntu.Components 0.1
23
 
import Unity.Test 0.1 as UT
24
 
import "tst_Stage"
25
 
 
26
 
Rectangle {
27
 
    width: units.gu(70)
28
 
    height: stageRect.height
29
 
 
30
 
    // Even though we replace the ApplicationScreenshot instances in Stage
31
 
    // with our own fake ones, ApplicationScreenshot.qml still gives out a warning
32
 
    // if shell.importUbuntuApplicationAvailable is missing.
33
 
    // For we have this here for the sake of keeping a clean log output.
34
 
    Item {
35
 
        id: shell
36
 
        property bool importUbuntuApplicationAvailable: false
37
 
    }
38
 
 
39
 
    // A fake ApplicationManager implementation to be passed to Stage
40
 
    QtObject {
41
 
        id: fakeAppManager
42
 
        property ListModel mainStageApplications: ListModel {}
43
 
        property ListModel sideStageApplications: ListModel {}
44
 
        property var mainStageFocusedApplication
45
 
 
46
 
        property Component fakeAppWindowComponent: Component {
47
 
            Rectangle {
48
 
                width: stage.width
49
 
                height: stage.height
50
 
                property alias text : txt.text
51
 
                Text {id:txt}
52
 
            }
53
 
        }
54
 
 
55
 
        function activateApplication(desktopFile, argument) {
56
 
            var appWindow = fakeAppWindowComponent.createObject(fakeWindowContainer)
57
 
            var application = {
58
 
                'icon': "foo",
59
 
                'handle': desktopFile,
60
 
                'name': "Foo",
61
 
                'fullscreen': false,
62
 
                'desktopFile': desktopFile,
63
 
                'stage': ApplicationInfo.MainStage,
64
 
                'argument': 0,
65
 
                'color': desktopFile,
66
 
                'window': appWindow
67
 
            };
68
 
            appWindow.color = application.color
69
 
            appWindow.text = desktopFile + " actual";
70
 
 
71
 
            mainStageApplications.append(application)
72
 
            updateZOrderOfWindows(mainStageApplications)
73
 
 
74
 
            return application
75
 
        }
76
 
 
77
 
        function focusApplication(application) {
78
 
            mainStageFocusedApplication = application
79
 
        }
80
 
 
81
 
        function getApplicationFromDesktopFile(desktopFile, stageType) {
82
 
            var sideStage = (stage == ApplicationInfo.SideStage);
83
 
            var applications = sideStage ? sideStageApplications
84
 
                                         : mainStageApplications;
85
 
 
86
 
            for (var i = 0; i < applications.count; i++ ) {
87
 
                var application = applications.get(i);
88
 
                if (application.desktopFile === desktopFile) {
89
 
                    return application;
90
 
                }
91
 
            }
92
 
            return null;
93
 
        }
94
 
 
95
 
        function moveRunningApplicationStackPosition(from, to, stage) {
96
 
            var sideStage = (stage == ApplicationInfo.SideStage);
97
 
            var applications = sideStage ? sideStageApplications
98
 
                                         : mainStageApplications;
99
 
 
100
 
            if (from !== to && applications.count > 0 && from >= 0 && to >= 0) {
101
 
                applications.move(from, to, 1);
102
 
            }
103
 
 
104
 
            updateZOrderOfWindows(applications)
105
 
        }
106
 
 
107
 
        function updateZOrderOfWindows(applications) {
108
 
            var nextZ = 100
109
 
            for (var i = 0; i < applications.count; i++ ) {
110
 
                var application = applications.get(i);
111
 
                application.window.z = nextZ--;
112
 
            }
113
 
        }
114
 
 
115
 
        function deacticateApplication(desktopFile) {
116
 
            for (var i = 0; i < mainStageApplications.count; i++ ) {
117
 
                var application = mainStageApplications.get(i)
118
 
                if (application.desktopFile === desktopFile) {
119
 
                    focusApplication(null)
120
 
                    application.window.destroy();
121
 
                    mainStageApplications.remove(i)
122
 
                    updateZOrderOfWindows(mainStageApplications)
123
 
                    return;
124
 
                }
125
 
            }
126
 
        }
127
 
    }
128
 
 
129
 
    Rectangle {
130
 
        id: stageRect
131
 
        x:0
132
 
        y:0
133
 
        width: childrenRect.width
134
 
        height: childrenRect.height
135
 
 
136
 
        color: "grey"
137
 
 
138
 
        // This is where the fake windows are held.
139
 
        // They stay behind the stage, so that the stage's screenshots are shown
140
 
        // on top of them
141
 
        // On a real usage scenario, the current application's surface is composited behind
142
 
        // the shell's surface (where Stage lives). fakeWindowContainer simulates this stacking
143
 
        Item {
144
 
            id: fakeWindowContainer
145
 
            anchors.fill: parent
146
 
        }
147
 
 
148
 
 
149
 
        // A black rectangle behind the stage so that the window switch animations
150
 
        // look good, just like in Stage's real usage.
151
 
        Rectangle {
152
 
            anchors.fill: parent
153
 
            color: "black"
154
 
            visible: stage.usingScreenshots
155
 
        }
156
 
 
157
 
        Stage {
158
 
            id: stage
159
 
            y: 0
160
 
            shouldUseScreenshots: false
161
 
            applicationManager: fakeAppManager
162
 
            rightEdgeDraggingAreaWidth: units.gu(2)
163
 
            fullyShown: true
164
 
            fullyHidden: false
165
 
            newApplicationScreenshot: FakeApplicationScreenshot {
166
 
                    id: newAppScreenshot
167
 
                    parent: stage
168
 
                    width: stage.width
169
 
                    height: stage.height - stage.y}
170
 
            oldApplicationScreenshot: FakeApplicationScreenshot {
171
 
                    id: oldAppScreenshot
172
 
                    parent: stage
173
 
                    width: stage.width
174
 
                    height: stage.height - stage.y}
175
 
        }
176
 
    }
177
 
 
178
 
    Rectangle {
179
 
        id: controlsRect
180
 
        anchors.top: parent.top
181
 
        anchors.bottom: parent.bottom
182
 
        anchors.left: stageRect.right
183
 
        anchors.right: parent.right
184
 
        color: "lightgrey"
185
 
 
186
 
        Column {
187
 
            id: controls
188
 
            spacing: units.gu(1)
189
 
            AppControl {id: redControl; desktopFile:"red"}
190
 
            AppControl {id: greenControl; desktopFile:"green"}
191
 
            AppControl {id: blueControl; desktopFile:"blue"}
192
 
        }
193
 
    }
194
 
 
195
 
    UT.UnityTestCase {
196
 
        name: "Stage"
197
 
        when: windowShown
198
 
 
199
 
        function isCurrentAppFadingOut() {
200
 
            // it should get a bit translucent and smaller
201
 
            return oldAppScreenshot.opacity < 0.99
202
 
                && oldAppScreenshot.opacity >= 0.1
203
 
                && oldAppScreenshot.scale < 0.99
204
 
                && oldAppScreenshot.scale >= 0.1
205
 
                && oldAppScreenshot.visible
206
 
        }
207
 
 
208
 
        function init() {
209
 
            redControl.checked = false;
210
 
            greenControl.checked = false;
211
 
            blueControl.checked = false;
212
 
            // give some room for animations to start
213
 
            wait(50)
214
 
            // wait until animations end, if any
215
 
            tryCompare(stage, "usingScreenshots", false)
216
 
        }
217
 
 
218
 
        /* If you flick from the right edge of the stage leftwards it should cause an
219
 
           application switch.  */
220
 
        function test_dragFromRightEdgeToSwitchApplication() {
221
 
            redControl.checked = true
222
 
 
223
 
            tryCompare(stage, "usingScreenshots", true) // wait for the animation to start
224
 
            tryCompare(stage, "usingScreenshots", false) // and then for it to end
225
 
            compare(fakeAppManager.mainStageFocusedApplication.desktopFile, "red")
226
 
            compare(fakeAppManager.mainStageApplications.get(0).desktopFile, "red")
227
 
 
228
 
            greenControl.checked = true
229
 
 
230
 
            tryCompare(stage, "usingScreenshots", true) // wait for the animation to start
231
 
            tryCompare(stage, "usingScreenshots", false) // and then for it to end
232
 
            compare(fakeAppManager.mainStageFocusedApplication.desktopFile, "green")
233
 
            compare(fakeAppManager.mainStageApplications.get(0).desktopFile, "green")
234
 
 
235
 
            var touchX = stage.width - (stage.rightEdgeDraggingAreaWidth / 2)
236
 
            var touchY = stage.height / 2
237
 
            touchFlick(stage, touchX, touchY, stage.width * 0.25, touchY)
238
 
 
239
 
            // wait until animations end, if any
240
 
            tryCompare(stage, "usingScreenshots", false)
241
 
 
242
 
            // "red" should be the new topmost, focused, application
243
 
            compare(fakeAppManager.mainStageFocusedApplication.desktopFile, "red")
244
 
            compare(fakeAppManager.mainStageApplications.get(0).desktopFile, "red")
245
 
        }
246
 
 
247
 
        /* When an application is launched, it needs a background before it's drawn on screen
248
 
           so that the user does not see the previous running app while the new one is launching.
249
 
           When switching between applications, backgrounds are unnecessary, 'cause the
250
 
           applications are in front of them. */
251
 
        function test_background() {
252
 
            redControl.checked = true
253
 
            tryCompare(stage, "usingScreenshots", true) // wait for the animation to start
254
 
 
255
 
            compare(newAppScreenshot.withBackground, true, "starting app screenshot does not have background enabled")
256
 
 
257
 
            tryCompare(stage, "usingScreenshots", false) // wait for the animation to finish
258
 
 
259
 
            greenControl.checked = true
260
 
            tryCompare(stage, "usingScreenshots", true) // wait for the animation to start
261
 
            tryCompare(stage, "usingScreenshots", false) // and finish
262
 
 
263
 
            var draggingAreaCenterX = stage.width - (stage.rightEdgeDraggingAreaWidth / 2)
264
 
            var draggingAreaCenterY = stage.height / 2
265
 
            var finalTouchX = draggingAreaCenterX - units.gu(5)
266
 
            touchFlick(stage, draggingAreaCenterX, draggingAreaCenterY,
267
 
                       finalTouchX, draggingAreaCenterY,
268
 
                       true /* beginTouch */, false /* endTouch */)
269
 
 
270
 
            // wait for the animation to start
271
 
            tryCompare(stage, "usingScreenshots", true)
272
 
 
273
 
            compare(newAppScreenshot.withBackground, false, "switched app does have background enabled")
274
 
 
275
 
            touchRelease(stage, finalTouchX, draggingAreaCenterY)
276
 
        }
277
 
    }
278
 
}