~unity-team/unity8/ota9.5

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/People/tst_PeopleFilterGrid.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

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 "../.."
 
21
import "../../../../Dash/People"
 
22
import Ubuntu.Components 0.1
 
23
import Unity.Test 0.1 as UT
 
24
 
 
25
Item {
 
26
    id: root
 
27
    width: units.gu(120)
 
28
    height: units.gu(40)
 
29
 
 
30
    PeopleFilterGrid {
 
31
        id: peopleFilterGrid
 
32
        anchors.fill: parent
 
33
        model: mockModel
 
34
    }
 
35
 
 
36
    SignalSpy {
 
37
        id: signalSpy
 
38
        target: peopleFilterGrid
 
39
        signalName: "clicked"
 
40
    }
 
41
 
 
42
    ListModel {
 
43
        id: mockModel
 
44
 
 
45
        ListElement {
 
46
            column_0: 'user://001'
 
47
            column_1: "gtk-apply"
 
48
            column_2: ""
 
49
            column_3: ""
 
50
            column_4: "User 1"
 
51
            column_5: "Text 1"
 
52
        }
 
53
 
 
54
        ListElement {
 
55
            column_0: 'user://002'
 
56
            column_1: "gtk-apply"
 
57
            column_2: ""
 
58
            column_3: ""
 
59
            column_4: "User 2"
 
60
            column_5: "Text 2"
 
61
        }
 
62
 
 
63
        ListElement {
 
64
            column_0: 'user://003'
 
65
            column_1: "gtk-apply"
 
66
            column_2: ""
 
67
            column_3: ""
 
68
            column_4: "User 3"
 
69
            column_5: "Text 3"
 
70
        }
 
71
 
 
72
        ListElement {
 
73
            column_0: 'user://004'
 
74
            column_1: "gtk-apply"
 
75
            column_2: ""
 
76
            column_3: ""
 
77
            column_4: "User 4"
 
78
            column_5: "Text 4"
 
79
        }
 
80
 
 
81
        ListElement {
 
82
            column_0: 'user://005'
 
83
            column_1: "gtk-apply"
 
84
            column_2: ""
 
85
            column_3: ""
 
86
            column_4: "User 5"
 
87
            column_5: "Text 5"
 
88
        }
 
89
 
 
90
    }
 
91
 
 
92
    UT.UnityTestCase {
 
93
        id: testCase
 
94
        name: "DashPeopleFilterGrid"
 
95
        when: windowShown
 
96
 
 
97
        function init() {
 
98
        }
 
99
 
 
100
        function test_clickCell_data() {
 
101
            return [
 
102
                {
 
103
                    x: peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth/2,
 
104
                    y: peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight/2,
 
105
                    index: 0,
 
106
                    uri: "user://001"
 
107
                },
 
108
                {
 
109
                    x: 2*peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth+peopleFilterGrid.cellWidth/2,
 
110
                    y: peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight/2,
 
111
                    index: 1,
 
112
                    uri: "user://002"
 
113
                },
 
114
                {
 
115
                    x: 3*peopleFilterGrid.minimumHorizontalSpacing+2*peopleFilterGrid.cellWidth+peopleFilterGrid.cellWidth/2,
 
116
                    y: peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight/2,
 
117
                    index: 2,
 
118
                    uri: "user://003"
 
119
                },
 
120
                {
 
121
                    x: peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth/2,
 
122
                    y: 2*peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight+peopleFilterGrid.cellHeight/2,
 
123
                    index: 3,
 
124
                    uri: "user://004"
 
125
                },
 
126
                {
 
127
                    x: 2*peopleFilterGrid.minimumHorizontalSpacing+peopleFilterGrid.cellWidth+peopleFilterGrid.cellWidth/2,
 
128
                    y: 2*peopleFilterGrid.verticalSpacing+peopleFilterGrid.cellHeight+peopleFilterGrid.cellHeight/2,
 
129
                    index: 4,
 
130
                    uri: "user://005"
 
131
                },
 
132
            ]
 
133
        }
 
134
 
 
135
        function test_columns() {
 
136
            compare(peopleFilterGrid.columns,3)
 
137
        }
 
138
 
 
139
        function test_clickCell(data) {
 
140
            tryCompare(peopleFilterGrid, "flicking", false)
 
141
            tryCompare(peopleFilterGrid, "moving", false)
 
142
            signalSpy.clear()
 
143
            wait(peopleFilterGrid.pressDelay > 0 ? peopleFilterGrid.pressDelay : 5)
 
144
            mouseClick(peopleFilterGrid, data.x, data.y)
 
145
            tryCompare(peopleFilterGrid, "flicking", false)
 
146
            tryCompare(peopleFilterGrid, "moving", false)
 
147
            compare(signalSpy.count, 1)
 
148
            compare(signalSpy.signalArguments.length, 1, "signalArguments.length != 1")
 
149
            compare(signalSpy.signalArguments[0][0], data.index)
 
150
            compare(signalSpy.signalArguments[0][1]["uri"], data.uri)
 
151
        }
 
152
 
 
153
    }
 
154
}