2
* Copyright 2015 Canonical Ltd.
2
* Copyright 2015-2016 Canonical Ltd.
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU Lesser General Public License as published by
31
31
height: notificationsRect.height
32
32
property int index: 0
34
// add the default/PlaceHolder notification to the model
35
Component.onCompleted: {
36
var component = Qt.createComponent("Notification.qml")
37
var n = component.createObject("notification", {"nid": index++,
38
"type": Notification.PlaceHolder,
45
n.completed.connect(mockModel.onCompleted)
156
141
mockModel.append(n)
144
function addFullscreenNotification() {
145
var component = Qt.createComponent("Notification.qml")
146
var n = component.createObject("notification", {"nid": index++,
147
"type": Notification.SnapDecision,
148
"hints": {"x-canonical-private-affirmative-tint": "true"},
149
"summary": "SIM PIN screen",
150
"body": "Enter your PIN to unlock the SIM",
152
n.completed.connect(mockModel.onCompleted)
159
156
function clearNotifications() {
160
while(mockModel.count > 1) {
161
remove1stNotification()
157
while(mockModel.count > 0) {
158
remove1stNotification();
165
162
function remove1stNotification() {
166
if (mockModel.count > 1) {
167
mockModel.removeSecond()
163
mockModel.removeFirst();
388
389
rawActions: ["ok_id", "Ok",
389
390
"snooze_id", "Snooze",
390
391
"view_id", "View"]
395
type: Notification.SnapDecision
396
hints: {"x-canonical-private-affirmative-tint": "true"}
397
summary: "SIM PIN screen"
398
body: "Enter your PIN to unlock the SIM"
791
797
waitForRendering(notifications);
793
799
// first one should be expanded by default
794
var notification1 = findChild(notifications, "notification1") // 0 is placeholder...
800
var notification1 = findChild(notifications, "notification0")
795
801
verify(!!notification1, "notification wasn't found");
796
802
waitForRendering(notification1);
797
803
verify(notification1.expanded);
799
805
// click the 2nd one, verify it's now expanded
800
var notification2 = findChild(notifications, "notification2") // 0 is placeholder...
806
var notification2 = findChild(notifications, "notification1")
801
807
verify(!!notification2, "notification wasn't found");
802
808
waitForRendering(notification2);
803
809
mouseClick(notification2);
814
820
tryCompareFunction(function() { return notification2.expanded; }, undefined);
823
function topmostIsFullscreen_data() {
825
tag: "Confirmation notification with value",
829
tag: "SIM PIN fullscreen notification",
833
tag: "Snap Decision without secondary icon and no button-tint",
838
function test_topmostIsFullscreen() {
839
var data = topmostIsFullscreen_data();
842
data.forEach(function(notification) {
843
mockModel.append(notification.n);
844
notification.n.completed.connect(mockModel.onCompleted);
847
// make sure the view is properly updated before going on
848
notifications.forceLayout();
849
waitForRendering(notifications);
851
// initially, topmost is not fullscreen
852
verify(!notifications.topmostIsFullscreen)
854
// close the 1st one, 2nd one should be fullscreen
855
var notification0 = findChild(notifications, "notification0")
856
notification0.closeNotification();
857
waitForRendering(notifications);
858
verify(notifications.topmostIsFullscreen)
860
// close the 1st one (SIM PIN) again, topmost should no longer be fullscreen
861
notification0 = findChild(notifications, "notification0")
862
notification0.closeNotification();
863
waitForRendering(notifications);
864
verify(!notifications.topmostIsFullscreen)
817
867
function cleanupTestCase() {
818
868
notifications.hasMouse = false;