on xenial help sign in
fix the notification focus test
commitec888f3051fb50afbc9070f5283713ba7b2cddf0 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 10 Oct 2014, 19:31 (12 years ago) parente9d1240
2 files changed+19−21
qml/Notifications/Notifications.qml+1 tests/qmltests/tst_Shell.qml+18−21
qml/Notifications/Notifications.qml+1
@@ -31,6 +31,7 @@ ListView {
3131
3232 SortFilterProxyModel {
3333 id: snapDecisionProxyModel
34+ objectName: "snapDecisionProxyModel"
3435
3536 model: notificationList.model
3637 filterRole: UnityNotifications.ModelInterface != undefined ? UnityNotifications.ModelInterface.RoleType : 0
tests/qmltests/tst_Shell.qml+18−21
@@ -210,37 +210,34 @@ Row {
210210 ApplicationManager.focusApplication(app);
211211 compare(app.session.surface.activeFocus, true, "Focused application didn't have activeFocus");
212212
213− // Pop-up a notification
214− addSnapDecisionNotification();
215213 notifications.model = mockNotificationsModel;
216214
217− var notification = findChild(notifications, "notification" + (mockNotificationsModel.count - 1));
218− verify(notification !== undefined, "notification wasn't found");
219−
220− var buttonRow = findChild(notification, "buttonRow");
221− verify(buttonRow !== undefined, "notification buttonRow wasn't found");
222−
223− var buttonAccept = findChild(buttonRow, "notify_button0");
224− verify(buttonAccept !== undefined, "notification accept button wasn't found");
215+ // FIXME: Hack: SortFilterProxyModelQML doesn't work with QML ListModels which we use
216+ // for mocking here (RoleType can't be found in the QML model). As we only need to show
217+ // one SnapDecision lets just disable the filtering and make appear any notification as a
218+ // SnapDecision.
219+ var snapDecisionProxyModel = findInvisibleChild(shell, "snapDecisionProxyModel");
220+ snapDecisionProxyModel.filterRegExp = RegExp("");
225221
226− var buttonCancel = findChild(buttonRow, "notify_button1");
227− verify(buttonCancel !== undefined, "notification cancel button wasn't found");
222+ // Pop-up a notification
223+ addSnapDecisionNotification();
224+ waitForRendering(shell);
228225
226+ // Make sure the notification really opened
227+ var notification = findChild(notifications, "notification" + (mockNotificationsModel.count - 1));
228+ verify(notification !== undefined && notification != null, "notification wasn't found");
229229
230− // Pressing the button should give focus to the notification
231− // The cancel button is pressed, as pressing Ok would cause
232− // the notification to close. This is only due to the mock object
233− mousePress(buttonCancel, 0, 0);
234− stage.interactive = false;
230+ // Make sure activeFocus went away from the app window
235231 compare(app.session.surface.activeFocus, false, "Notification didn't take active focus");
236− mouseRelease(buttonCancel);
237232 compare(stage.interactive, false, "the stage is interactive with a notification showing")
238233
239234 // Clicking the button should dismiss the notification and return focus
240− mouseClick(buttonAccept, 0, 0);
241− ApplicationManager.focusApplication(app);
242− stage.interactive = true;
235+ var buttonAccept = findChild(notification, "notify_button0");
236+ mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
237+
238+ // Make sure we're back to normal
243239 compare(app.session.surface.activeFocus, true, "App didn't take active focus after snap notification was dismissed");
240+ compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
244241 }
245242
246243 function addSnapDecisionNotification() {