~aacid/unity8/moreAsyncAudioCard

« back to all changes in this revision

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

  • Committer: Albert Astals Cid
  • Date: 2016-03-10 08:32:16 UTC
  • mfrom: (2136.2.83 unity8)
  • Revision ID: albert.astals@canonical.com-20160310083216-8nnplxl85qx13xd0
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        id: mockResultsModel
37
37
    }
38
38
 
39
 
    PreviewListView {
40
 
        id: listView
 
39
    PreviewView {
 
40
        id: view
41
41
        anchors.fill: parent
42
42
        scope: mockScope
43
43
        scopeStyle: ScopeStyle {
45
45
        }
46
46
    }
47
47
 
 
48
    Item {
 
49
        Repeater {
 
50
            id: repeater
 
51
            model: mockResultsModel
 
52
            Item {
 
53
                property var previewModel: mockScope.preview(model.result, model.categoryId);
 
54
            }
 
55
        }
 
56
    }
 
57
 
48
58
    UT.UnityTestCase {
49
59
        id: testCase
50
 
        name: "PreviewListView"
 
60
        name: "PreviewView"
51
61
        when: windowShown
52
62
 
53
 
        property MouseArea mouseArea: findChild(listView, "processingMouseArea")
 
63
        property MouseArea mouseArea: findChild(view, "processingMouseArea")
54
64
 
55
65
        SignalSpy {
56
66
            id: clickedSpy
59
69
        }
60
70
 
61
71
        function init() {
62
 
            listView.model = mockResultsModel;
63
 
            listView.currentIndex = 1;
64
 
            listView.open = true;
 
72
            view.open = true;
 
73
            view.previewModel = repeater.itemAt(0).previewModel
65
74
            verify(testCase.mouseArea, "Can't find the processingMouseArea object.");
66
75
        }
67
76
 
68
77
        function cleanup() {
69
 
            listView.open = false;
70
 
            listView.model = null;
 
78
            view.open = false;
71
79
            clickedSpy.clear();
72
80
        }
73
81
 
74
82
        function test_notProcessing() {
75
83
            expectFail("", "processingMouseArea should not receive the click.");
76
 
            mouseClick(listView);
 
84
            mouseClick(view);
77
85
            clickedSpy.wait();
78
86
        }
79
87
 
80
88
        function test_processing() {
81
 
            verify(listView.currentItem, "currentItem is not ready yet");
82
 
            listView.currentItem.previewModel.setLoaded(false);
83
 
 
84
 
            tryCompare(listView, "processing", true);
85
 
 
86
 
            mouseClick(listView);
 
89
            view.previewModel.setLoaded(false);
 
90
 
 
91
            tryCompare(view, "processing", true);
 
92
 
 
93
            mouseClick(view);
87
94
            clickedSpy.wait();
88
95
        }
89
96
 
90
97
        function test_title() {
91
 
            var header = findChild(listView, "innerPageHeader");
 
98
            var header = findChild(view, "innerPageHeader");
92
99
            verify(header, "Could not find the preview header");
93
100
 
94
101
            compare(header.config.title, "Mock Scope");
95
102
        }
96
103
 
97
104
        function test_header_style() {
98
 
            var header = findChild(listView, "pageHeader");
 
105
            var header = findChild(view, "pageHeader");
99
106
            verify(header, "Could not find the header");
100
107
 
101
108
            var innerHeader = findChild(header, "innerPageHeader");