2
* This file is part of system-settings
4
* Copyright (C) 2016 Canonical Ltd.
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.
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.
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/>.
21
import Ubuntu.Components 1.3
22
import Ubuntu.SystemSettings.Notifications 1.0
24
import NotificationsSource 1.0
33
name: "NotificationsPageComponent"
37
ClickApplicationsModel.cleanup()
40
function test_start_empty() {
41
var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
42
compare(soundsModel.count, 0)
44
var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
45
compare(vibrationsModel.count, 0)
47
var appsList = findChild(root, "notificationsList")
48
compare(appsList.count, 0)
51
function test_updated_when_added() {
52
var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
53
compare(soundsModel.count, 0)
55
var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
56
compare(vibrationsModel.count, 0)
58
var appsList = findChild(root, "notificationsList")
59
compare(appsList.count, 0)
61
ClickApplicationsModel.addApplication("Pkg01", "App01")
62
ClickApplicationsModel.addApplication("Pkg02", "App02")
64
compare(soundsModel.count, 2)
65
compare(vibrationsModel.count, 2)
66
compare(appsList.count, 2)
68
var soundsLabel = findChild(root, "clickAppsSoundsNotifyLabel")
69
tryCompare(soundsLabel, "text", "2")
71
var vibrationsLabel = findChild(root, "clickAppsVibrationsNotifyLabel")
72
tryCompare(vibrationsLabel, "text", "2")
75
function test_updated_when_removed() {
76
ClickApplicationsModel.addApplication("Pkg01", "App01")
77
ClickApplicationsModel.addApplication("Pkg02", "App02")
79
var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
80
compare(soundsModel.count, 2)
82
var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
83
compare(vibrationsModel.count, 2)
85
var appsList = findChild(root, "notificationsList")
86
compare(appsList.count, 2)
88
ClickApplicationsModel.removeApplicationByIndex(0)
90
compare(soundsModel.count, 1)
91
compare(vibrationsModel.count, 1)
92
compare(appsList.count, 1)
94
var soundsLabel = findChild(root, "clickAppsSoundsNotifyLabel")
95
tryCompare(soundsLabel, "text", "1")
97
var vibrationsLabel = findChild(root, "clickAppsVibrationsNotifyLabel")
98
tryCompare(vibrationsLabel, "text", "1")
101
function test_sounds_filter_is_updated() {
102
var soundsModel = findChild(root, "clickAppsSoundsNotifyModel")
103
compare(soundsModel.count, 0)
105
var soundsLabel = findChild(root, "clickAppsSoundsNotifyLabel")
107
ClickApplicationsModel.addApplication("Pkg01", "App01")
108
ClickApplicationsModel.addApplication("Pkg02", "App02")
109
ClickApplicationsModel.addApplication("Pkg03", "App03")
111
soundsModel.updateEnabledEntries()
112
compare(soundsModel.count, 3)
113
tryCompare(soundsLabel, "text", "3")
115
ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.EnableNotifications, 0, false)
117
soundsModel.updateEnabledEntries()
118
compare(soundsModel.count, 2)
119
tryCompare(soundsLabel, "text", "2")
121
ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.SoundsNotify, 1, false)
123
soundsModel.updateEnabledEntries()
124
compare(soundsModel.count, 1)
125
tryCompare(soundsLabel, "text", "1")
127
ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.VibrationsNotify, 2, false)
129
soundsModel.updateEnabledEntries()
130
compare(soundsModel.count, 1)
131
tryCompare(soundsLabel, "text", "1")
134
function test_vibrations_filter_is_updated() {
135
var vibrationsModel = findChild(root, "clickAppsVibrationsNotifyModel")
136
compare(vibrationsModel.count, 0)
138
var vibrationsLabel = findChild(root, "clickAppsVibrationsNotifyLabel")
140
ClickApplicationsModel.addApplication("Pkg01", "App01")
141
ClickApplicationsModel.addApplication("Pkg02", "App02")
142
ClickApplicationsModel.addApplication("Pkg03", "App03")
144
vibrationsModel.updateEnabledEntries()
145
compare(vibrationsModel.count, 3)
146
tryCompare(vibrationsLabel, "text", "3")
148
ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.EnableNotifications, 0, false)
150
vibrationsModel.updateEnabledEntries()
151
compare(vibrationsModel.count, 2)
152
tryCompare(vibrationsLabel, "text", "2")
154
ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.VibrationsNotify, 1, false)
156
vibrationsModel.updateEnabledEntries()
157
compare(vibrationsModel.count, 1)
158
tryCompare(vibrationsLabel, "text", "1")
160
ClickApplicationsModel.setNotificationByIndex(ClickApplicationsModel.SoundsNotify, 2, false)
162
vibrationsModel.updateEnabledEntries()
163
compare(vibrationsModel.count, 1)
164
tryCompare(vibrationsLabel, "text", "1")