~mterry/+junk/u8.2

« back to all changes in this revision

Viewing changes to tests/qmltests/tst_Shell.qml

  • Committer: Michael Terry
  • Date: 2014-11-17 14:56:04 UTC
  • mfrom: (1317.1.118 unity8)
  • Revision ID: michael.terry@canonical.com-20141117145604-96dn9p5nwkifq2f4
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import Ubuntu.Telephony 0.1 as Telephony
26
26
import Unity.Application 0.1
27
27
import Unity.Connectivity 0.1
 
28
import Unity.Notifications 1.0
28
29
import Unity.Test 0.1 as UT
29
30
import Powerd 0.1
30
31
 
31
32
import "../../qml"
32
33
 
33
 
Row {
 
34
Item {
34
35
    id: root
35
 
    spacing: 0
 
36
    width: units.gu(60)
 
37
    height: units.gu(71)
36
38
 
37
39
    QtObject {
38
40
        id: applicationArguments
50
52
        }
51
53
    }
52
54
 
53
 
    Loader {
54
 
        id: shellLoader
55
 
 
56
 
        // Copied from Shell.qml
57
 
        property bool tablet: false
58
 
        width: tablet ? units.gu(160)
59
 
                      : applicationArguments.hasGeometry() ? applicationArguments.width()
60
 
                                                           : units.gu(40)
61
 
        height: tablet ? units.gu(100)
62
 
                       : applicationArguments.hasGeometry() ? applicationArguments.height()
63
 
                                                            : units.gu(71)
64
 
 
65
 
        property bool itemDestroyed: false
66
 
        sourceComponent: Component {
67
 
            Shell {
68
 
                property string indicatorProfile: "phone"
69
 
                Component.onDestruction: {
70
 
                    shellLoader.itemDestroyed = true;
 
55
    Row {
 
56
        anchors.fill: parent
 
57
        Loader {
 
58
            id: shellLoader
 
59
 
 
60
            property bool itemDestroyed: false
 
61
            sourceComponent: Component {
 
62
                Shell {
 
63
                    property string indicatorProfile: "phone"
 
64
 
 
65
                    Component.onDestruction: {
 
66
                        shellLoader.itemDestroyed = true;
 
67
                    }
71
68
                }
72
69
            }
73
70
        }
74
 
    }
75
 
 
76
 
    Rectangle {
77
 
        color: "white"
78
 
        width: units.gu(30)
79
 
        height: shellLoader.height
80
 
 
81
 
        Column {
82
 
            anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
83
 
            spacing: units.gu(1)
84
 
            Row {
85
 
                anchors { left: parent.left; right: parent.right }
86
 
                Button {
87
 
                    text: "Show Greeter"
88
 
                    onClicked: {
89
 
                        if (shellLoader.status !== Loader.Ready)
90
 
                            return;
91
 
 
92
 
                        var greeter = testCase.findChild(shellLoader.item, "greeter");
93
 
                        if (!greeter.shown) {
94
 
                            greeter.show();
 
71
 
 
72
        Rectangle {
 
73
            color: "white"
 
74
            width: units.gu(30)
 
75
            height: shellLoader.height
 
76
 
 
77
            Column {
 
78
                anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
 
79
                spacing: units.gu(1)
 
80
                Row {
 
81
                    anchors { left: parent.left; right: parent.right }
 
82
                    Button {
 
83
                        text: "Show Greeter"
 
84
                        onClicked: {
 
85
                            if (shellLoader.status !== Loader.Ready)
 
86
                                return;
 
87
 
 
88
                            var greeter = testCase.findChild(shellLoader.item, "greeter");
 
89
                            if (!greeter.shown) {
 
90
                                greeter.show();
 
91
                            }
95
92
                        }
96
93
                    }
97
94
                }
99
96
        }
100
97
    }
101
98
 
 
99
    Component {
 
100
        id: mockNotification
 
101
 
 
102
        QtObject {
 
103
            function invokeAction(actionId) {
 
104
                mockNotificationsModel.actionInvoked(actionId)
 
105
            }
 
106
        }
 
107
    }
 
108
    ListModel {
 
109
        id: mockNotificationsModel
 
110
 
 
111
        signal actionInvoked(string actionId)
 
112
 
 
113
        function getRaw(id) {
 
114
            return mockNotification.createObject(mockNotificationsModel)
 
115
        }
 
116
 
 
117
        onActionInvoked: {
 
118
            if(actionId == "ok_id") {
 
119
                mockNotificationsModel.clear()
 
120
            }
 
121
        }
 
122
    }
 
123
 
102
124
    SignalSpy {
103
125
        id: launcherShowDashHomeSpy
104
126
        signalName: "showDashHome"
120
142
        signalName: "unlockingAllModems"
121
143
    }
122
144
 
 
145
    SignalSpy {
 
146
        id: notificationActionSpy
 
147
        target: mockNotificationsModel
 
148
        signalName: "actionInvoked"
 
149
    }
 
150
 
123
151
    Telephony.CallEntry {
124
152
        id: phoneCall
125
153
        phoneNumber: "+447812221111"
133
161
        property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
134
162
 
135
163
        function init() {
 
164
            tryCompare(shell, "enabled", true); // enabled by greeter when ready
 
165
 
136
166
            swipeAwayGreeter();
137
167
 
138
168
            sessionSpy.target = findChild(shell, "greeter")
143
173
        }
144
174
 
145
175
        function cleanup() {
 
176
            tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
146
177
            launcherShowDashHomeSpy.target = null;
147
178
 
148
179
            shellLoader.itemDestroyed = false;
179
210
            compare(ApplicationManager.count, 1)
180
211
        }
181
212
 
 
213
        function test_snapDecisionDismissalReturnsFocus() {
 
214
            var notifications = findChild(shell, "notificationList");
 
215
            var app = ApplicationManager.startApplication("camera-app");
 
216
            var stage = findChild(shell, "stage")
 
217
            // Open an application and focus
 
218
            waitUntilApplicationWindowIsFullyVisible(app);
 
219
            ApplicationManager.focusApplication(app);
 
220
            tryCompare(app.session.surface, "activeFocus", true);
 
221
 
 
222
            notifications.model = mockNotificationsModel;
 
223
 
 
224
            // FIXME: Hack: SortFilterProxyModelQML doesn't work with QML ListModels which we use
 
225
            // for mocking here (RoleType can't be found in the QML model). As we only need to show
 
226
            // one SnapDecision lets just disable the filtering and make appear any notification as a
 
227
            // SnapDecision.
 
228
            var snapDecisionProxyModel = findInvisibleChild(shell, "snapDecisionProxyModel");
 
229
            snapDecisionProxyModel.filterRegExp = RegExp("");
 
230
 
 
231
            // Pop-up a notification
 
232
            addSnapDecisionNotification();
 
233
            waitForRendering(shell);
 
234
 
 
235
            // Make sure the notification really opened
 
236
            var notification = findChild(notifications, "notification" + (mockNotificationsModel.count - 1));
 
237
            verify(notification !== undefined && notification != null, "notification wasn't found");
 
238
            tryCompare(notification, "height", notification.implicitHeight)
 
239
            waitForRendering(notification);
 
240
 
 
241
            // Make sure activeFocus went away from the app window
 
242
            tryCompare(app.session.surface, "activeFocus", false);
 
243
            tryCompare(stage, "interactive", false);
 
244
 
 
245
            // Clicking the button should dismiss the notification and return focus
 
246
            var buttonAccept = findChild(notification, "notify_button0");
 
247
            mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
 
248
 
 
249
            // Make sure we're back to normal
 
250
            tryCompare(app.session.surface, "activeFocus", true);
 
251
            compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
 
252
        }
 
253
 
 
254
        function addSnapDecisionNotification() {
 
255
            var n = {
 
256
                type: Notification.SnapDecision,
 
257
                hints: {"x-canonical-private-affirmative-tint": "true"},
 
258
                summary: "Tom Ato",
 
259
                body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
 
260
                icon: "../graphics/avatars/funky.png",
 
261
                secondaryIcon: "../graphics/applicationIcons/facebook.png",
 
262
                actions: [{ id: "ok_id", label: "Ok"},
 
263
                    { id: "cancel_id", label: "Cancel"},
 
264
                    { id: "notreally_id", label: "Not really"},
 
265
                    { id: "noway_id", label: "messages:No way"},
 
266
                    { id: "nada_id", label: "messages:Nada"}]
 
267
            }
 
268
 
 
269
            mockNotificationsModel.append(n)
 
270
        }
 
271
 
182
272
        function test_leftEdgeDrag_data() {
183
273
            return [
184
274
                {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true},
295
385
            tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
296
386
 
297
387
            compare(dashCommunicatorSpy.count, 1);
298
 
            compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
 
388
            compare(dashCommunicatorSpy.signalArguments[0][0], 0);
299
389
        }
300
390
 
301
391
        function test_showInputMethod() {
346
436
            var touchX = shell.width / 2;
347
437
            var indicators = findChild(shell, "indicators");
348
438
            touchFlick(indicators,
349
 
                    touchX /* fromX */, indicators.panelHeight * 0.5 /* fromY */,
 
439
                    touchX /* fromX */, indicators.minimizedPanelHeight * 0.5 /* fromY */,
350
440
                    touchX /* toX */, shell.height * 0.5 /* toY */,
351
441
                    true /* beginTouch */, false /* endTouch */);
352
442
            verify(indicators.partiallyOpened);
383
473
            var indicators = findChild(shell, "indicators");
384
474
 
385
475
            var touchStartX = shell.width / 2;
386
 
            var touchStartY = shell.height - (indicators.panelHeight * 0.5);
 
476
            var touchStartY = shell.height - (indicators.minimizedPanelHeight * 0.5);
387
477
            touchFlick(shell,
388
478
                    touchStartX, touchStartY,
389
479
                    touchStartX, shell.height * 0.1);
571
661
        }
572
662
 
573
663
        function test_unlockAllModemsOnBoot() {
574
 
            // TODO reenable when service ready (LP: #1361074)
575
 
            expectFail("", "Unlock on boot temporarily disabled");
576
664
            tryCompare(unlockAllModemsSpy, "count", 1)
577
665
        }
578
666