~aacid/unity8/add_override_warning

« back to all changes in this revision

Viewing changes to tests/qmltests/Notifications/tst_Notifications.qml

  • Committer: Albert Astals Cid
  • Date: 2016-05-05 07:30:08 UTC
  • mfrom: (2341.1.42 unity8)
  • Revision ID: albert.astals@canonical.com-20160505073008-d8u2rkkh0sg1te0l
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    height: notificationsRect.height
32
32
    property int index: 0
33
33
 
 
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,
 
39
                                                        "hints": {},
 
40
                                                        "summary": "",
 
41
                                                        "body": "",
 
42
                                                        "icon": "",
 
43
                                                        "secondaryIcon": "",
 
44
                                                        "rawActions": []})
 
45
        n.completed.connect(mockModel.onCompleted)
 
46
        mockModel.append(n)
 
47
    }
 
48
 
34
49
    Row {
35
50
        id: rootRow
36
51
 
37
52
        NotificationModel {
38
53
            id: mockModel
39
 
 
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,
45
 
                                                                "hints": {},
46
 
                                                                "summary": "",
47
 
                                                                "body": "",
48
 
                                                                "icon": "",
49
 
                                                                "secondaryIcon": "",
50
 
                                                                "rawActions": []})
51
 
                n.completed.connect(mockModel.onCompleted)
52
 
                append(n)
53
 
            }
54
54
        }
55
55
 
56
56
        function add2over1SnapDecisionNotification() {
188
188
                anchors.fill: parent
189
189
                model: mockModel
190
190
                hasMouse: fakeMouseCB.checked
191
 
                inverseMode: inverseModeCB.checked
192
191
            }
193
192
        }
194
193
 
269
268
                    }
270
269
                }
271
270
 
272
 
                RowLayout {
273
 
                    Layout.fillWidth: true
274
 
                    CheckBox {
275
 
                        id: inverseModeCB
276
 
                    }
277
 
                    Label {
278
 
                        text: "Inverse mode"
279
 
                        anchors.verticalCenter: parent.verticalCenter
280
 
                    }
 
271
                MouseTouchEmulationCheckbox {
 
272
                    id: mouseEmulation
 
273
                    checked: false
281
274
                }
282
275
            }
283
276
        }
562
555
                signalName: "actionInvoked"
563
556
            }
564
557
 
 
558
            function init() {
 
559
                while (mockModel.count > 0) {
 
560
                    mockModel.remove(0);
 
561
                }
 
562
            }
 
563
 
565
564
            function cleanup() {
566
565
                clickThroughSpy.clear()
567
566
                actionSpy.clear()
582
581
                waitForRendering(notifications);
583
582
 
584
583
                var notification = findChild(notifications, "notification" + (mockModel.count - 1))
585
 
                verify(notification !== undefined, "notification wasn't found");
586
 
 
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);
589
587
 
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")
600
597
 
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")
608
605
                }
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")
612
 
                }
613
607
                compare(valueLabel.visible, data.valueLabelVisible, "value-label visibility is incorrect")
614
608
 
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)
 
627
                        continue;
 
628
                    waitForRendering(n);
 
629
                    var outterColumn = findChild(n, "outterColumn");
 
630
                    var shapedBack = findChild(n, "shapedBack");
 
631
                    tryCompare(n, "height", outterColumn.height + n.margins * 2 + shapedBack.anchors.topMargin);
633
632
                }
634
633
 
635
634
                if (data.hasSound) {
662
661
                        tryCompareFunction(function() { return comboButton.expanded === false; }, true);
663
662
 
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);
666
665
 
667
666
                        // try clicking on choices in expanded comboList
668
667
                        var choiceButton1 = findChild(notification, "notify_button3")
676
675
                        actionSpy.clear()
677
676
 
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);
680
679
                    } else {
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)
696
 
                } else {
697
 
                    tryCompare(mockModel, "count", before - 1)
698
 
                }
 
693
                tryCompare(mockModel, "count", before - 1)
699
694
            }
700
695
 
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();
704
699
            }
705
700
 
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)
 
704
 
707
705
                // populate model with some mock notifications
708
706
                mockModel.append(data.n)
709
707
 
712
710
                waitForRendering(notifications);
713
711
 
714
712
                var notification = findChild(notifications, "notification" + (mockModel.count - 1))
 
713
                waitForRendering(notification);
715
714
                verify(!!notification, "notification wasn't found");
716
715
 
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);
722
723
 
723
 
                if (canBeClosed) {
724
 
                    // closing the notification, the model count should be one less
725
 
                    tryCompare(mockModel, "count", before - 1)
726
 
                } else {
727
 
                    // not closing, model stays the same
728
 
                    tryCompare(mockModel, "count", before)
729
 
                }
 
724
                // closing the notification, the model count should be one less
 
725
                tryCompare(mockModel, "count", before - 1)
730
726
            }
731
727
 
732
728
            function cleanupTestCase() {