~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/tst_DashContent.qml

  • Committer: Nick Dedekind
  • Date: 2014-03-26 16:07:33 UTC
  • mfrom: (638.1.146 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140326160733-kw8xa3sj8ut2ykqv
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import "../../../qml/Dash"
20
20
import "../../../qml/Components"
21
21
import Ubuntu.Components 0.1
22
 
import Unity 0.1
 
22
import Unity 0.2
23
23
import Unity.Test 0.1 as UT
24
24
import Utils 0.1
25
25
 
28
28
    width: units.gu(40)
29
29
    height: units.gu(80)
30
30
 
31
 
    Item {
32
 
        // Fake. Make a few components less noisy
33
 
        id: greeter
34
 
        signal shownChanged
35
 
    }
36
 
 
37
 
    Item {
38
 
        // Fake. Make a few components less noisy
39
 
        id: panel
40
 
        signal searchClicked
41
 
    }
 
31
    // BEGIN To reduce warnings
 
32
    // TODO I think it we should pass down these variables
 
33
    // as needed instead of hoping they will be globally around
 
34
    property var greeter: null
 
35
    property var panel: null
 
36
    // BEGIN To reduce warnings
42
37
 
43
38
    property var scopeStatus: {
44
39
        'MockScope1': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
45
40
        'MockScope2': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
46
 
        'home.scope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
47
 
        'applications.scope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
 
41
        'clickscope': { 'movementStarted': 0, 'positionedAtBeginning': 0 },
48
42
        'MockScope5': { 'movementStarted': 0, 'positionedAtBeginning': 0 }
49
43
    }
50
44
 
70
64
        scopeDelegateMapping: {
71
65
            "MockScope1": Qt.resolvedUrl("qml/fake_scopeView1.qml"),
72
66
            "MockScope2": Qt.resolvedUrl("qml/fake_scopeView2.qml"),
73
 
            "home.scope": Qt.resolvedUrl("qml/fake_scopeView3.qml"),
74
 
            "applications.scope": Qt.resolvedUrl("qml/fake_scopeView4.qml")
 
67
            "clickscope": Qt.resolvedUrl("qml/fake_scopeView3.qml"),
75
68
        }
76
69
        genericScope: Qt.resolvedUrl("qml/fake_generic_scopeView.qml")
77
70
    }
83
76
        scopeStatus["MockScope2"].movementStarted = 0;
84
77
        scopeStatus["MockScope2"].positionedAtBeginning = 0;
85
78
 
86
 
        scopeStatus["home.scope"].movementStarted = 0;
87
 
        scopeStatus["home.scope"].positionedAtBeginning = 0;
88
 
 
89
 
        scopeStatus["applications.scope"].movementStarted = 0;
90
 
        scopeStatus["applications.scope"].positionedAtBeginning = 0;
 
79
        scopeStatus["clickscope"].movementStarted = 0;
 
80
        scopeStatus["clickscope"].positionedAtBeginning = 0;
91
81
 
92
82
        scopeStatus["MockScope5"].movementStarted = 0;
93
83
        scopeStatus["MockScope5"].positionedAtBeginning = 0;
113
103
            scopesModel.clear();
114
104
            scopeLoadedSpy.clear();
115
105
            scopesModel.load();
116
 
            tryCompare(scopeLoadedSpy, "count", 5);
 
106
            tryCompare(scopeLoadedSpy, "count", 4);
117
107
        }
118
108
 
119
109
        function cleanup() {
138
128
 
139
129
            scopeLoadedSpy.clear();
140
130
            scopesModel.load();
141
 
            tryCompare(scopeLoadedSpy, "count", 5);
 
131
            tryCompare(scopeLoadedSpy, "count", 4);
142
132
 
143
133
            verify(dashContentList.currentIndex >= 0);
144
134
        }
154
144
 
155
145
            scopeLoadedSpy.clear();
156
146
            scopesModel.load();
157
 
            tryCompare(scopeLoadedSpy, "count", 5);
 
147
            tryCompare(scopeLoadedSpy, "count", 4);
158
148
 
159
149
            verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
160
150
        }
170
160
            compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
171
161
            compare(scopeStatus["MockScope1"].movementStarted, 1, "MockScope1 should have emitted movementStarted signal when content list did.");
172
162
            compare(scopeStatus["MockScope2"].movementStarted, 1, "MockScope2 should have emitted movementStarted signal when content list did.");
173
 
            compare(scopeStatus["home.scope"].movementStarted, 1, "home.scope should have emitted movementStarted signal when content list did.");
174
 
            compare(scopeStatus["applications.scope"].movementStarted, 1, "applications.scope should have emitted movementStarted signal when content list did.");
 
163
            compare(scopeStatus["clickscope"].movementStarted, 1, "clickscope should have emitted movementStarted signal when content list did.");
175
164
            compare(scopeStatus["MockScope5"].movementStarted, 1, "MockScope5 should have emitted movementStarted signal when content list did.");
176
165
        }
177
166
 
181
170
            dashContent.positionedAtBeginning();
182
171
            compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
183
172
            compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
184
 
            compare(scopeStatus["home.scope"].positionedAtBeginning, 1, "home.scope should have emitted positionedAtBeginning signal when DashContent did.");
185
 
            compare(scopeStatus["applications.scope"].positionedAtBeginning, 1, "applications.scope should have emitted positionedAtBeginning signal when DashContent did.");
 
173
            compare(scopeStatus["clickscope"].positionedAtBeginning, 1, "clickscope should have emitted positionedAtBeginning signal when DashContent did.");
186
174
            compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
187
175
        }
188
176
 
220
208
 
221
209
        function test_scope_mapping_data() {
222
210
            return [
223
 
                {tag: "index0", index: 0, objectName: "fake_scopeView1"},
224
 
                {tag: "index1", index: 1, objectName: "fake_scopeView2"},
225
 
                {tag: "index2", index: 2, objectName: "fake_scopeView3"},
226
 
                {tag: "index3", index: 3, objectName: "fake_scopeView4"},
227
 
                {tag: "index4", index: 4, objectName: "fake_generic_scopeView"}
 
211
                {tag: "index0", index: 0, objectName: "MockScope1"},
 
212
                {tag: "index1", index: 1, objectName: "MockScope2"},
 
213
                {tag: "index2", index: 2, objectName: "clickscope"},
 
214
                {tag: "index3", index: 3, objectName: "MockScope5"}
228
215
            ]
229
216
        }
230
217
 
298
285
            tryCompareFunction(function() { button = findMusicButton(); return button != undefined; }, true);
299
286
            waitForRendering(button);
300
287
 
 
288
            tryCompareFunction(function() { return button.opacity > 0; }, true);
301
289
            mouseClick(button, button.width / 2, button.height / 2)
302
290
 
303
291
            tryCompare(tabbar, "selectionMode", false);
309
297
            var tabbar = findChild(dashContent, "tabbar");
310
298
            tryCompare(dashContent, "currentIndex", 0);
311
299
            compare(tabbar.selectedIndex, 0);
312
 
            dashContent.currentIndex = 1;
 
300
            var dashContentList = findChild(dashContent, "dashContentList");
 
301
            dashContentList.currentIndex = 1;
313
302
            compare(tabbar.selectedIndex, 1);
314
303
        }
315
304
 
334
323
 
335
324
            tryCompareFunction(checkFlickMovingAndNotInteractive, true);
336
325
        }
 
326
 
 
327
        function openPreview() {
 
328
            tryCompareFunction(function() {
 
329
                                    var filterGrid = findChild(dashContent, "0");
 
330
                                    if (filterGrid != null) {
 
331
                                        var tile = findChild(filterGrid, "delegate0");
 
332
                                        return tile != null;
 
333
                                    }
 
334
                                    return false;
 
335
                                },
 
336
                                true);
 
337
            var tile = findChild(findChild(dashContent, "0"), "delegate0");
 
338
            mouseClick(tile, tile.width / 2, tile.height / 2);
 
339
            var previewListView = findChild(dashContent, "dashContentPreviewList");
 
340
            tryCompare(previewListView, "open", true);
 
341
            tryCompare(previewListView, "x", 0);
 
342
        }
 
343
 
 
344
        function closePreview() {
 
345
            var closePreviewMouseArea = findChild(dashContent, "dashContentPreviewList_pageHeader_backButton");
 
346
            mouseClick(closePreviewMouseArea, closePreviewMouseArea.width / 2, closePreviewMouseArea.height / 2);
 
347
 
 
348
            var previewListView = findChild(dashContent, "dashContentPreviewList");
 
349
            tryCompare(previewListView, "open", false);
 
350
        }
 
351
 
 
352
        function test_previewOpenClose() {
 
353
            tryCompare(scopeLoadedSpy, "count", 4);
 
354
 
 
355
            var previewListView = findChild(dashContent, "dashContentPreviewList");
 
356
            tryCompare(previewListView, "open", false);
 
357
 
 
358
            var categoryListView = findChild(dashContent, "categoryListView");
 
359
            categoryListView.positionAtBeginning();
 
360
 
 
361
            openPreview();
 
362
            closePreview();
 
363
        }
 
364
 
 
365
        function test_showPreviewCarousel() {
 
366
            tryCompareFunction(function() {
 
367
                                    var scope = findChild(dashContent, "MockScope1 loader");
 
368
                                    if (scope != null) {
 
369
                                        var dashCategory1 = findChild(scope, "dashCategory1");
 
370
                                        if (dashCategory1 != null) {
 
371
                                            var tile = findChild(dashCategory1, "carouselDelegate1");
 
372
                                            return tile != null;
 
373
                                        }
 
374
                                    }
 
375
                                    return false;
 
376
                                },
 
377
                                true);
 
378
 
 
379
            tryCompare(scopeLoadedSpy, "count", 4);
 
380
 
 
381
            var previewListView = findChild(dashContent, "dashContentPreviewList");
 
382
            tryCompare(previewListView, "open", false);
 
383
 
 
384
            var scope = findChild(dashContent, "MockScope1 loader");
 
385
            var dashCategory1 = findChild(scope, "dashCategory1");
 
386
            var tile = findChild(dashCategory1, "carouselDelegate1");
 
387
            mouseClick(tile, tile.width / 2, tile.height / 2);
 
388
            tryCompare(previewListView, "open", true);
 
389
            tryCompare(previewListView, "x", 0);
 
390
 
 
391
            closePreview();
 
392
        }
 
393
 
 
394
        function test_previewCycle() {
 
395
            tryCompare(scopeLoadedSpy, "count", 4);
 
396
 
 
397
            var categoryListView = findChild(dashContent, "categoryListView");
 
398
            categoryListView.positionAtBeginning();
 
399
 
 
400
            var previewListView = findChild(dashContent, "dashContentPreviewList");
 
401
            tryCompare(previewListView, "open", false);
 
402
            var previewListViewList = findChild(dashContent, "dashContentPreviewList_listView");
 
403
 
 
404
            openPreview();
 
405
 
 
406
            // flick to the next previews
 
407
            tryCompare(previewListView, "count", 15);
 
408
            for (var i = 1; i < previewListView.count; ++i) {
 
409
                mouseFlick(previewListView, previewListView.width - units.gu(1),
 
410
                                            previewListView.height / 2,
 
411
                                            units.gu(2),
 
412
                                            previewListView.height / 2);
 
413
                tryCompare(previewListViewList, "moving", false);
 
414
                tryCompare(previewListView.currentItem, "objectName", "previewItem" + i);
 
415
 
 
416
            }
 
417
            closePreview();
 
418
        }
337
419
    }
338
420
}