~aacid/unity8/dash_overview

« back to all changes in this revision

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

  • Committer: Albert Astals
  • Date: 2014-08-07 15:27:32 UTC
  • mfrom: (1155.1.29 do_merged)
  • Revision ID: albert.astals@canonical.com-20140807152732-0zf22298f1lsxrz8
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        name: "Dash"
44
44
        when: windowShown
45
45
 
46
 
        property var scopes
47
 
 
48
 
        Component.onCompleted: {
49
 
            var dashContent = findChild(dash, "dashContent");
50
 
            scopes = dashContent.scopes;
51
 
        }
 
46
        readonly property Item dashContent: findChild(dash, "dashContent");
 
47
        readonly property var scopes: dashContent.scopes
52
48
 
53
49
        function init() {
54
50
            // clear and reload the scopes.
62
58
 
63
59
        function get_scope_data() {
64
60
            return [
65
 
                        { tag: "MockScope1", visualIndex: 0, shouldBeVisible: true },
66
 
                        { tag: "MockScope2", visualIndex: -1, shouldBeVisible: false },
67
 
                        { tag: "clickscope", visualIndex: 1, shouldBeVisible: true },
68
 
                        { tag: "MockScope5", visualIndex: 2, shouldBeVisible: true },
 
61
                        { tag: "MockScope1", visualIndex: 0 },
 
62
                        { tag: "MockScope2", visualIndex: -1 },
 
63
                        { tag: "clickscope", visualIndex: 1 },
 
64
                        { tag: "MockScope5", visualIndex: 2 },
69
65
            ]
70
66
        }
71
67
 
74
70
        }
75
71
 
76
72
        function test_show_scope_on_load(data) {
77
 
            if (data.shouldBeVisible == false) {
78
 
                console.log("Not testing " + data.tag + ": not visible");
79
 
                return;
80
 
            }
81
73
            var dashContentList = findChild(dash, "dashContentList");
82
74
 
83
75
            dash.showScopeOnLoaded = data.tag
88
80
            tryCompare(dashContentList, "count", 6);
89
81
 
90
82
            verify(dashContentList != undefined);
91
 
            tryCompare(dashContentList, "currentIndex", data.visualIndex);
 
83
            if (data.visualIndex == -1) {
 
84
                tryCompare(dashContentList, "currentIndex", 0);
 
85
                expectFail(data.tag, "non favorite scopes should not be visble in the scopes model");
 
86
                compare(dashContentList.currentItem.scopeId, data.tag); // this should fail
 
87
            } else {
 
88
                tryCompare(dashContentList, "currentIndex", data.visualIndex);
 
89
                compare(dashContentList.currentItem.scopeId, data.tag);
 
90
            }
92
91
        }
93
92
 
94
93
        function test_dash_overview_show_select_same_favorite() {
325
324
            dashCommunicatorService.mockSetCurrentScope("clickscope", true, true);
326
325
            tryCompare(dashContentList, "currentIndex", 1)
327
326
        }
 
327
 
 
328
        function test_processing_indicator() {
 
329
            tryCompare(scopes, "loaded", true);
 
330
 
 
331
            var processingIndicator = findChild(dash, "processingIndicator");
 
332
            verify(processingIndicator, "Can't find the processing indicator.");
 
333
 
 
334
            verify(!processingIndicator.visible, "Processing indicator should be visible.");
 
335
 
 
336
            tryCompareFunction(function() {
 
337
                return scopes.getScope(dashContent.currentIndex) != null;
 
338
            }, true);
 
339
            var currentScope = scopes.getScope(dashContent.currentIndex);
 
340
            verify(currentScope, "Can't find the current scope.");
 
341
 
 
342
            currentScope.setSearchInProgress(true);
 
343
            tryCompare(processingIndicator, "visible", true);
 
344
 
 
345
            currentScope.setSearchInProgress(false);
 
346
            tryCompare(processingIndicator, "visible", false);
 
347
        }
328
348
    }
329
349
}