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)
37
52
NotificationModel {
40
// add the default/PlaceHolder notification to the model
41
Component.onCompleted: {
42
var component = Qt.createComponent("Notification.qml")
43
var n = component.createObject("notification", {"nid": index++,
44
"type": Notification.PlaceHolder,
51
n.completed.connect(mockModel.onCompleted)
56
56
function add2over1SnapDecisionNotification() {
582
581
waitForRendering(notifications);
584
583
var notification = findChild(notifications, "notification" + (mockModel.count - 1))
585
verify(notification !== undefined, "notification wasn't found");
587
584
waitForRendering(notification);
588
tryCompare(notification, "height", notification.state === "contracted" ? units.gu(10) : notification.implicitHeight);
585
verify(notification, "notification wasn't found");
586
tryCompare(notification, "height", notification.implicitHeight);
590
588
var icon = findChild(notification, "icon")
591
589
var centeredIcon = findChild(notification, "centeredIcon")
596
594
var buttonRow = findChild(notification, "buttonRow")
597
595
var valueIndicator = findChild(notification, "valueIndicator")
598
596
var valueLabel = findChild(notification, "valueLabel")
599
var innerBar = findChild(notification, "innerBar")
601
598
compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
602
599
if (icon.visible) {
607
604
compare(centeredIcon.shaped, data.shaped, "shaped-status is incorrect")
609
606
compare(valueIndicator.visible, data.valueVisible, "value-indicator visibility is incorrect")
610
if (valueIndicator.visible) {
611
verify(innerBar.color === data.valueTinted ? UbuntuColors.orange : "white", "value-bar has the wrong color-tint")
613
607
compare(valueLabel.visible, data.valueLabelVisible, "value-label visibility is incorrect")
615
609
// test input does not fall through
629
623
// for their height animations to finish before continuing
630
624
for (var i = 0; i < mockModel.count; ++i) {
631
625
var n = findChild(notifications, "notification" + i)
632
tryCompare(n, "height", n.state === "contracted" ? units.gu(10) : n.implicitHeight);
626
if (n.type === Notification.PlaceHolder)
629
var outterColumn = findChild(n, "outterColumn");
630
var shapedBack = findChild(n, "shapedBack");
631
tryCompare(n, "height", outterColumn.height + n.margins * 2 + shapedBack.anchors.topMargin);
635
634
if (data.hasSound) {
662
661
tryCompareFunction(function() { return comboButton.expanded === false; }, true);
664
663
// click to expand
665
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded === true; }, true);
664
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded; }, true);
667
666
// try clicking on choices in expanded comboList
668
667
var choiceButton1 = findChild(notification, "notify_button3")
676
675
actionSpy.clear()
678
677
// click to collapse
679
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
678
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return !comboButton.expanded; }, true);
681
680
mouseClick(buttonCancel)
682
681
compare(actionSpy.signalArguments[0][0], data.n.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action")
691
690
var dragY = notification.height / 2;
692
691
touchFlick(notification, dragStart, dragY, dragEnd, dragY)
693
692
waitForRendering(notification)
694
if ((data.n.type === Notification.SnapDecision && notification.state === "expanded") || data.n.type === Notification.Confirmation) {
695
tryCompare(mockModel, "count", before)
697
tryCompare(mockModel, "count", before - 1)
693
tryCompare(mockModel, "count", before - 1)
701
function test_clickToClose_data() { // reuse the data
696
function test_closeButton_data() { // reuse the data
702
697
notifications.hasMouse = true;
703
698
return test_NotificationRenderer_data();
706
function test_clickToClose(data) {
701
function test_closeButton(data) {
702
// hook up notification's completed-signal with model's onCompleted-slot, so that remove() (model) happens on close() (notification)
703
data.n.completed.connect(mockModel.onCompleted)
707
705
// populate model with some mock notifications
708
706
mockModel.append(data.n)
712
710
waitForRendering(notifications);
714
712
var notification = findChild(notifications, "notification" + (mockModel.count - 1))
713
waitForRendering(notification);
715
714
verify(!!notification, "notification wasn't found");
717
// click-to-dismiss check
718
waitForRendering(notification);
716
// close button check
717
mouseMove(notification, notification.width/2, notification.height/2);
718
var closeButton = findChild(notification, "closeButton");
719
tryCompare(closeButton, "visible", true);
719
720
var before = mockModel.count;
720
var canBeClosed = notification.canBeClosed;
721
mouseClick(notification);
721
mouseClick(closeButton);
722
waitForRendering(notification);
724
// closing the notification, the model count should be one less
725
tryCompare(mockModel, "count", before - 1)
727
// not closing, model stays the same
728
tryCompare(mockModel, "count", before)
724
// closing the notification, the model count should be one less
725
tryCompare(mockModel, "count", before - 1)
732
728
function cleanupTestCase() {