on xenial help sign in
Adapt notification qmltest to reflect the new layout of snap-decisions with the ComboButton.
commitc1725b9773829de9099f331133770b3cbae48042 authorMirco Müller <mirco.mueller@canonical.com> dateThu 29 May 2014, 15:15 (12 years ago) parent3d5c63f
2 files changed+20−23
qml/Notifications/Notification.qml+2 tests/qmltests/Notifications/tst_Notifications.qml+18−23
qml/Notifications/Notification.qml+2
@@ -329,6 +329,7 @@ Item {
329329 ComboButton {
330330 id: comboButton
331331
332+ objectName: "button2"
332333 width: parent.width
333334 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3
334335 gradient: darkgreyGradient
@@ -365,6 +366,7 @@ Item {
365366 MouseArea {
366367 id: comboInputArea
367368
369+ objectName: "button" + index
368370 width: comboButton.width
369371 height: comboIcon.height + units.gu(2)
370372
tests/qmltests/Notifications/tst_Notifications.qml+18−23
@@ -71,8 +71,8 @@ Row {
7171 actions: [{ id: "ok_id", label: "Ok"},
7272 { id: "cancel_id", label: "Cancel"},
7373 { id: "notreally_id", label: "Not really"},
74− { id: "noway_id", label: "No way"},
75− { id: "nada_id", label: "Nada"}]
74+ { id: "noway_id", label: "messages:No way"},
75+ { id: "nada_id", label: "messages:Nada"}]
7676 }
7777
7878 mockModel.append(n)
@@ -236,8 +236,8 @@ Row {
236236 actions: [{ id: "ok_id", label: "Ok"},
237237 { id: "cancel_id", label: "Cancel"},
238238 { id: "notreally_id", label: "Not really"},
239− { id: "noway_id", label: "No way"},
240− { id: "nada_id", label: "Nada"}],
239+ { id: "noway_id", label: "messages:No way"},
240+ { id: "nada_id", label: "messages:Nada"}],
241241 summaryVisible: true,
242242 bodyVisible: true,
243243 iconVisible: true,
@@ -439,32 +439,27 @@ Row {
439439 actionSpy.clear()
440440 waitForRendering(notification)
441441
442− // check if there's more than one negative choice
442+ // check if there's a ComboButton created due to more actions being passed
443443 if (data.actions.length > 2) {
444− var initialHeight = notification.implicitHeight
444+ var comboButton = findChild(notification, "button2")
445+ tryCompareFunction(function() { return comboButton.expanded == false; }, true);
445446
446447 // click to expand
447− mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
448− var contentColumn = findChild(notification, "contentColumn")
449− var collapsedContentColumnHeight = contentColumn.height;
450− // Waiting for the inner column to change height because buttons appear
451− tryCompareFunction(function() { return collapsedContentColumnHeight != contentColumn.height; }, true);
452− // Waiting for notification to reach its target size
453− tryCompare(notification, "height", contentColumn.height + contentColumn.spacing * 2)
448+ tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == true; }, true);
449+
450+ // try clicking on choices in expanded comboList
451+ var choiceButton1 = findChild(notification, "button3")
452+ tryCompareFunction(function() { mouseClick(choiceButton1, choiceButton1.width / 2, choiceButton1.height / 2); return actionSpy.signalArguments.length > 0; }, true);
453+ compare(actionSpy.signalArguments[0][0], data.actions[3]["id"], "got wrong id choice action 1")
454454 actionSpy.clear()
455455
456− // test the additional buttons
457− for (var i = 2; i < data.actions.length; i++) {
458− var buttonColumn = findChild(notification, "buttonColumn")
459− var button = findChild(buttonColumn, "button" + i)
460− mouseClick(button, button.width / 2, button.height / 2)
461− compare(actionSpy.signalArguments[0][0], data.actions[i]["id"], "got wrong id for additional negative action")
462− actionSpy.clear()
463− }
456+ var choiceButton2 = findChild(notification, "button4")
457+ tryCompareFunction(function() { mouseClick(choiceButton2, choiceButton2.width / 2, choiceButton2.height / 2); return actionSpy.signalArguments.length > 0; }, true);
458+ compare(actionSpy.signalArguments[0][0], data.actions[4]["id"], "got wrong id choice action 2")
459+ actionSpy.clear()
464460
465461 // click to collapse
466− mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
467− tryCompare(notification, "height", initialHeight)
462+ //tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
468463 } else {
469464 mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
470465 compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")