on xenial help sign in
Changed checks for passed action-id string. Also had to remove a waitForRendering() as it was causing a segfault... wtf
commit2559bdd43641cde17bbe1a8311e28d6018eeb7b2 authorMirco Müller <mirco.mueller@ubuntu.com> dateThu 22 Jan 2015, 14:46 (12 years ago) parenta115eaf
3 files changed+20−12
tests/mocks/Unity/Notifications/MockActionModel.cpp+5 tests/mocks/Unity/Notifications/MockActionModel.h+2 tests/qmltests/Notifications/tst_Notifications.qml+13−12
tests/mocks/Unity/Notifications/MockActionModel.cpp+5
@@ -68,3 +68,8 @@ void ActionModel::insertAction(const QString &id, const QString &label) {
6868 p->ids.push_back(id);
6969 p->labels.push_back(label);
7070}
71+
72+int ActionModel::getCount() const {
73+ return p->labels.size();
74+}
75+
tests/mocks/Unity/Notifications/MockActionModel.h+2
@@ -26,6 +26,7 @@ struct ActionModelPrivate;
2626
2727class ActionModel : public QStringListModel {
2828 Q_OBJECT
29+ Q_PROPERTY(int count READ getCount)
2930
3031public:
3132 ActionModel(QObject *parent=nullptr);
@@ -43,6 +44,7 @@ public:
4344 Q_INVOKABLE QVariant data(int row, int role) const;
4445
4546 void insertAction(const QString &id, const QString &label);
47+ int getCount() const;
4648
4749private:
4850 QScopedPointer<ActionModelPrivate> p;
tests/qmltests/Notifications/tst_Notifications.qml+13−12
@@ -546,10 +546,12 @@ Item {
546546 }
547547
548548 function test_NotificationRenderer(data) {
549− // hook up notification's completed-signal with model's onCompleted-slot, so that remove happens on close()
550− data.n.completed.connect(mockModel.onCompleted)
549+ // make sure the clicks on mocked notifications can be checked against by "actionSpy" (mimicking the NotificationServer component)
551550 data.n.actionInvoked.connect(mockModel.actionInvoked)
552551
552+ // hook up notification's completed-signal with model's onCompleted-slot, so that remove() (model) happens on close() (notification)
553+ data.n.completed.connect(mockModel.onCompleted)
554+
553555 // populate model with some mock notifications
554556 mockModel.append(data.n)
555557
@@ -591,7 +593,7 @@ Item {
591593 mouseClick(notification)
592594 if(data.n.type === Notification.Interactive) {
593595 actionSpy.wait()
594− compare(actionSpy.signalArguments[0][0], data.n.rawActions[0], "got wrong id for interactive action")
596+ compare(actionSpy.signalArguments[0][0], data.n.actions.data(0, ActionModel.RoleActionId), "got wrong id for interactive action")
595597 }
596598 compare(clickThroughSpy.count, 0, "click on notification fell through")
597599
@@ -608,9 +610,9 @@ Item {
608610 var buttonAccept = findChild(buttonRow, "notify_button0")
609611
610612 // only test the left/cancel-button if two actions have been passed in
611− if (data.n.rawActions.length === 4) {
613+ if (data.n.actions.count === 2) {
612614 tryCompareFunction(function() { mouseClick(buttonCancel); return actionSpy.signalArguments.length > 0; }, true);
613− compare(actionSpy.signalArguments[0][0], data.n.rawActions[2], "got wrong id for negative action")
615+ compare(actionSpy.signalArguments[0][0], data.n.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action")
614616 actionSpy.clear()
615617 }
616618
@@ -619,12 +621,11 @@ Item {
619621
620622 // click the positive/right button
621623 tryCompareFunction(function() { mouseClick(buttonAccept); return actionSpy.signalArguments.length > 0; }, true);
622− compare(actionSpy.signalArguments[0][0], data.n.rawActions[0], "got wrong id positive action")
624+ compare(actionSpy.signalArguments[0][0], data.n.actions.data(0, ActionModel.RoleActionId), "got wrong id positive action")
623625 actionSpy.clear()
624− waitForRendering (notification)
625626
626627 // check if there's a ComboButton created due to more actions being passed
627− if (data.n.actions.length > 2) {
628+ if (data.n.actions.count > 3) {
628629 var comboButton = findChild(notification, "notify_button2")
629630 tryCompareFunction(function() { return comboButton.expanded === false; }, true);
630631
@@ -634,19 +635,19 @@ Item {
634635 // try clicking on choices in expanded comboList
635636 var choiceButton1 = findChild(notification, "notify_button3")
636637 tryCompareFunction(function() { mouseClick(choiceButton1); return actionSpy.signalArguments.length > 0; }, true);
637− compare(actionSpy.signalArguments[0][0], data.n.rawActions[6], "got wrong id choice action 1")
638+ compare(actionSpy.signalArguments[0][0], data.n.actions.data(3, ActionModel.RoleActionId), "got wrong id choice action 1")
638639 actionSpy.clear()
639640
640641 var choiceButton2 = findChild(notification, "notify_button4")
641642 tryCompareFunction(function() { mouseClick(choiceButton2); return actionSpy.signalArguments.length > 0; }, true);
642− compare(actionSpy.signalArguments[0][0], data.n.rawActions[8], "got wrong id choice action 2")
643+ compare(actionSpy.signalArguments[0][0], data.n.actions.data(4, ActionModel.RoleActionId), "got wrong id choice action 2")
643644 actionSpy.clear()
644645
645646 // click to collapse
646− //tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
647+ tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
647648 } else {
648649 mouseClick(buttonCancel)
649− compare(actionSpy.signalArguments[0][0], data.n.rawActions[2], "got wrong id for negative action")
650+ compare(actionSpy.signalArguments[0][0], data.n.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action")
650651 }
651652 }
652653