~untrusted-ci-dev-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-yakkety-landing-004

« back to all changes in this revision

Viewing changes to tests/plugins/notifications/tst_PageComponent.qml

  • Committer: Ken VanDine
  • Date: 2016-07-22 14:36:16 UTC
  • mfrom: (1673 ubuntu-system-settings)
  • mto: This revision was merged to the branch mainline in revision 1678.
  • Revision ID: ken.vandine@canonical.com-20160722143616-xdhvfbvp1g8dku77
merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2016 Canonical Ltd.
 
5
 *
 
6
 * This program is free software: you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License version 3, as published
 
8
 * by the Free Software Foundation.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
12
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
13
 * PURPOSE.  See the GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import QtTest 1.0
 
21
import Ubuntu.Components 1.3
 
22
import Ubuntu.SystemSettings.Notifications 1.0 
 
23
 
 
24
import NotificationsSource 1.0
 
25
 
 
26
PageComponent {
 
27
    id: root
 
28
 
 
29
    width: 300
 
30
    height: 500
 
31
 
 
32
    TestCase {
 
33
        name: "NotificationsPageComponent"
 
34
        when: windowShown
 
35
 
 
36
        function cleanup() {
 
37
            ClickApplicationsModel.cleanup()
 
38
        }
 
39
 
 
40
        function test_start_empty() {
 
41
            var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
 
42
            compare(soundsModel.count, 0)
 
43
 
 
44
            var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
 
45
            compare(vibrationsModel.count, 0)
 
46
 
 
47
            var appsList = findChild(root, "notificationsList")
 
48
            compare(appsList.count, 0)
 
49
        }
 
50
 
 
51
        function test_updated_when_added() {
 
52
            var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
 
53
            compare(soundsModel.count, 0)
 
54
 
 
55
            var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
 
56
            compare(vibrationsModel.count, 0)
 
57
 
 
58
            var appsList = findChild(root, "notificationsList")
 
59
            compare(appsList.count, 0)
 
60
 
 
61
            ClickApplicationsModel.addApplication("Pkg01", "App01")
 
62
            ClickApplicationsModel.addApplication("Pkg02", "App02")
 
63
 
 
64
            compare(soundsModel.count, 2)
 
65
            compare(vibrationsModel.count, 2)
 
66
            compare(appsList.count, 2)
 
67
 
 
68
            var soundsLabel = findChild(root, "clickAppsSoundsNotifyLabel")
 
69
            tryCompare(soundsLabel, "text", "2")
 
70
 
 
71
            var vibrationsLabel = findChild(root, "clickAppsVibrationsNotifyLabel")
 
72
            tryCompare(vibrationsLabel, "text", "2")
 
73
        }
 
74
 
 
75
        function test_updated_when_removed() {
 
76
            ClickApplicationsModel.addApplication("Pkg01", "App01")
 
77
            ClickApplicationsModel.addApplication("Pkg02", "App02")
 
78
 
 
79
            var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
 
80
            compare(soundsModel.count, 2)
 
81
 
 
82
            var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
 
83
            compare(vibrationsModel.count, 2)
 
84
 
 
85
            var appsList = findChild(root, "notificationsList")
 
86
            compare(appsList.count, 2)
 
87
 
 
88
            ClickApplicationsModel.removeApplicationByIndex(0)
 
89
 
 
90
            compare(soundsModel.count, 1)
 
91
            compare(vibrationsModel.count, 1)
 
92
            compare(appsList.count, 1)
 
93
 
 
94
            var soundsLabel = findChild(root, "clickAppsSoundsNotifyLabel")
 
95
            tryCompare(soundsLabel, "text", "1")
 
96
 
 
97
            var vibrationsLabel = findChild(root, "clickAppsVibrationsNotifyLabel")
 
98
            tryCompare(vibrationsLabel, "text", "1")
 
99
        }
 
100
 
 
101
        function test_sounds_filter_is_updated() {
 
102
            var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
 
103
            compare(soundsModel.count, 0)
 
104
 
 
105
            var soundsLabel = findChild(root, "clickAppsSoundsNotifyLabel")
 
106
 
 
107
            ClickApplicationsModel.addApplication("Pkg01", "App01")
 
108
            ClickApplicationsModel.addApplication("Pkg02", "App02")
 
109
            ClickApplicationsModel.addApplication("Pkg03", "App03")
 
110
 
 
111
            soundsModel.updateEnabledEntries()
 
112
            compare(soundsModel.count, 3)
 
113
            tryCompare(soundsLabel, "text", "3")
 
114
 
 
115
            ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.EnableNotifications, 0, false)
 
116
 
 
117
            soundsModel.updateEnabledEntries()
 
118
            compare(soundsModel.count, 2)
 
119
            tryCompare(soundsLabel, "text", "2")
 
120
 
 
121
            ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.SoundsNotify, 1, false)
 
122
 
 
123
            soundsModel.updateEnabledEntries()
 
124
            compare(soundsModel.count, 1)
 
125
            tryCompare(soundsLabel, "text", "1")
 
126
 
 
127
            ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.VibrationsNotify, 2, false)
 
128
 
 
129
            soundsModel.updateEnabledEntries()
 
130
            compare(soundsModel.count, 1)
 
131
            tryCompare(soundsLabel, "text", "1")
 
132
        }
 
133
 
 
134
        function test_vibrations_filter_is_updated() {
 
135
            var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
 
136
            compare(vibrationsModel.count, 0)
 
137
 
 
138
            var vibrationsLabel = findChild(root, "clickAppsVibrationsNotifyLabel")
 
139
 
 
140
            ClickApplicationsModel.addApplication("Pkg01", "App01")
 
141
            ClickApplicationsModel.addApplication("Pkg02", "App02")
 
142
            ClickApplicationsModel.addApplication("Pkg03", "App03")
 
143
 
 
144
            vibrationsModel.updateEnabledEntries()
 
145
            compare(vibrationsModel.count, 3)
 
146
            tryCompare(vibrationsLabel, "text", "3")
 
147
 
 
148
            ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.EnableNotifications, 0, false)
 
149
 
 
150
            vibrationsModel.updateEnabledEntries()
 
151
            compare(vibrationsModel.count, 2)
 
152
            tryCompare(vibrationsLabel, "text", "2")
 
153
 
 
154
            ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.VibrationsNotify, 1, false)
 
155
 
 
156
            vibrationsModel.updateEnabledEntries()
 
157
            compare(vibrationsModel.count, 1)
 
158
            tryCompare(vibrationsLabel, "text", "1")
 
159
 
 
160
            ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.SoundsNotify, 2, false)
 
161
 
 
162
            vibrationsModel.updateEnabledEntries()
 
163
            compare(vibrationsModel.count, 1)
 
164
            tryCompare(vibrationsLabel, "text", "1")
 
165
        }
 
166
    }
 
167
}