on xenial help sign in
Added qmltests for value-label and value-tint of synchronous notifications.
ec13d0eMirco Müller
qml/Notifications/Notification.qml+3
@@ -298,6 +298,8 @@ Item {
298 }
298 }
299
299
300 Label {
300 Label {
301+ id: valueLabel
302+ objectName: "valueLabel"
301 text: body
303 text: body
302 anchors.horizontalCenter: parent.horizontalCenter
304 anchors.horizontalCenter: parent.horizontalCenter
303 visible: type === Notification.Confirmation && body !== ""
305 visible: type === Notification.Confirmation && body !== ""
@@ -328,6 +330,7 @@ Item {
328
330
329 UbuntuShape {
331 UbuntuShape {
330 id: innerBar
332 id: innerBar
333+ objectName: "innerBar"
331 width: valueIndicator.width * valueIndicator.value / 100
334 width: valueIndicator.width * valueIndicator.value / 100
332 height: units.gu(1)
335 height: units.gu(1)
333 color: notification.hints["x-canonical-value-bar-tint"] === "true" ? UbuntuColors.orange : darkOnBright ? UbuntuColors.lightGrey : "white"
336 color: notification.hints["x-canonical-value-bar-tint"] === "true" ? UbuntuColors.orange : darkOnBright ? UbuntuColors.lightGrey : "white"
tests/qmltests/Notifications/tst_Notifications.qml+81−11
@@ -165,6 +165,22 @@ Row {
165 mockModel.append(n)
165 mockModel.append(n)
166 }
166 }
167
167
168+ function add2ndConfirmationNotification() {
169+ var n = {
170+ type: Notification.Confirmation,
171+ hints: {"x-canonical-non-shaped-icon": "true",
172+ "x-canonical-value-bar-tint": "true"},
173+ summary: "Confirmation notification",
174+ body: "High Volume",
175+ icon: "image://theme/audio-volume-high",
176+ secondaryIcon: "",
177+ value: 85,
178+ actions: [],
179+ }
180+
181+ mockModel.append(n)
182+ }
183+
168 function clearNotifications() {
184 function clearNotifications() {
169 while(mockModel.count > 1) {
185 while(mockModel.count > 1) {
170 remove1stNotification()
186 remove1stNotification()
@@ -180,7 +196,7 @@ Row {
180 id: notificationsRect
196 id: notificationsRect
181
197
182 width: units.gu(40)
198 width: units.gu(40)
183− height: units.gu(90)
199+ height: units.gu(115)
184
200
185 MouseArea{
201 MouseArea{
186 id: clickThroughCatcher
202 id: clickThroughCatcher
@@ -202,7 +218,7 @@ Row {
202 id: interactiveControls
218 id: interactiveControls
203
219
204 width: units.gu(30)
220 width: units.gu(30)
205− height: units.gu(90)
221+ height: units.gu(115)
206 color: "grey"
222 color: "grey"
207
223
208 Column {
224 Column {
@@ -252,6 +268,12 @@ Row {
252 onClicked: addConfirmationNotification()
268 onClicked: addConfirmationNotification()
253 }
269 }
254
270
271+ Button {
272+ width: parent.width
273+ text: "add a 2nd confirmation"
274+ onClicked: add2ndConfirmationNotification()
275+ }
276+
255 Button {
277 Button {
256 width: parent.width
278 width: parent.width
257 text: "remove 1st notification"
279 text: "remove 1st notification"
@@ -296,7 +318,9 @@ Row {
296 buttonRowVisible: true,
318 buttonRowVisible: true,
297 buttonTinted: true,
319 buttonTinted: true,
298 hasSound: false,
320 hasSound: false,
299− valueVisible: false
321+ valueVisible: false,
322+ valueLabelVisible: false,
323+ valueTinted: false
300 },
324 },
301 {
325 {
302 tag: "2-over-1 Snap Decision with button-tint",
326 tag: "2-over-1 Snap Decision with button-tint",
@@ -318,7 +342,9 @@ Row {
318 buttonRowVisible: false,
342 buttonRowVisible: false,
319 buttonTinted: true,
343 buttonTinted: true,
320 hasSound: false,
344 hasSound: false,
321− valueVisible: false
345+ valueVisible: false,
346+ valueLabelVisible: false,
347+ valueTinted: false
322 },
348 },
323 {
349 {
324 tag: "Ephemeral notification - icon-summary layout",
350 tag: "Ephemeral notification - icon-summary layout",
@@ -338,7 +364,9 @@ Row {
338 buttonRowVisible: false,
364 buttonRowVisible: false,
339 buttonTinted: false,
365 buttonTinted: false,
340 hasSound: false,
366 hasSound: false,
341− valueVisible: false
367+ valueVisible: false,
368+ valueLabelVisible: false,
369+ valueTinted: false
342 },
370 },
343 {
371 {
344 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
372 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
@@ -361,7 +389,9 @@ Row {
361 buttonRowVisible: false,
389 buttonRowVisible: false,
362 buttonTinted: false,
390 buttonTinted: false,
363 hasSound: false,
391 hasSound: false,
364− valueVisible: false
392+ valueVisible: false,
393+ valueLabelVisible: false,
394+ valueTinted: false
365 },
395 },
366 {
396 {
367 tag: "Interactive notification",
397 tag: "Interactive notification",
@@ -382,7 +412,9 @@ Row {
382 buttonRowVisible: false,
412 buttonRowVisible: false,
383 buttonTinted: false,
413 buttonTinted: false,
384 hasSound: true,
414 hasSound: true,
385− valueVisible: false
415+ valueVisible: false,
416+ valueLabelVisible: false,
417+ valueTinted: false
386 },
418 },
387 {
419 {
388 tag: "Snap Decision without secondary icon and no button-tint",
420 tag: "Snap Decision without secondary icon and no button-tint",
@@ -404,7 +436,9 @@ Row {
404 buttonRowVisible: true,
436 buttonRowVisible: true,
405 buttonTinted: false,
437 buttonTinted: false,
406 hasSound: true,
438 hasSound: true,
407− valueVisible: false
439+ valueVisible: false,
440+ valueLabelVisible: false,
441+ valueTinted: false
408 },
442 },
409 {
443 {
410 tag: "Ephemeral notification",
444 tag: "Ephemeral notification",
@@ -425,7 +459,9 @@ Row {
425 buttonRowVisible: false,
459 buttonRowVisible: false,
426 buttonTinted: false,
460 buttonTinted: false,
427 hasSound: true,
461 hasSound: true,
428− valueVisible: false
462+ valueVisible: false,
463+ valueLabelVisible: false,
464+ valueTinted: false
429 },
465 },
430 {
466 {
431 tag: "Ephemeral notification with non-shaped icon",
467 tag: "Ephemeral notification with non-shaped icon",
@@ -446,7 +482,9 @@ Row {
446 buttonRowVisible: false,
482 buttonRowVisible: false,
447 buttonTinted: false,
483 buttonTinted: false,
448 hasSound: false,
484 hasSound: false,
449− valueVisible: false
485+ valueVisible: false,
486+ valueLabelVisible: false,
487+ valueTinted: false
450 },
488 },
451 {
489 {
452 tag: "Confirmation notification with value",
490 tag: "Confirmation notification with value",
@@ -467,7 +505,33 @@ Row {
467 buttonRowVisible: false,
505 buttonRowVisible: false,
468 buttonTinted: false,
506 buttonTinted: false,
469 hasSound: false,
507 hasSound: false,
470− valueVisible: true
508+ valueVisible: true,
509+ valueLabelVisible: false,
510+ valueTinted: false
511+ },
512+ {
513+ tag: "Confirmation notification with value, label and tint",
514+ type: Notification.Confirmation,
515+ hints: {"x-canonical-non-shaped-icon": "true",
516+ "x-canonical-value-bar-tint" : "true"},
517+ summary: "",
518+ body: "High Volume",
519+ icon: "image://theme/audio-volume-high",
520+ secondaryIcon: "",
521+ value: 85,
522+ actions: [],
523+ summaryVisible: false,
524+ bodyVisible: false,
525+ iconVisible: false,
526+ centeredIconVisible: true,
527+ shaped: false,
528+ secondaryIconVisible: false,
529+ buttonRowVisible: false,
530+ buttonTinted: false,
531+ hasSound: false,
532+ valueVisible: true,
533+ valueLabelVisible: true,
534+ valueTinted: true
471 }
535 }
472 ]
536 ]
473 }
537 }
@@ -512,6 +576,8 @@ Row {
512 var bodyLabel = findChild(notification, "bodyLabel")
576 var bodyLabel = findChild(notification, "bodyLabel")
513 var buttonRow = findChild(notification, "buttonRow")
577 var buttonRow = findChild(notification, "buttonRow")
514 var valueIndicator = findChild(notification, "valueIndicator")
578 var valueIndicator = findChild(notification, "valueIndicator")
579+ var valueLabel = findChild(notification, "valueLabel")
580+ var innerBar = findChild(notification, "innerBar")
515
581
516 compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
582 compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
517 if (icon.visible) {
583 if (icon.visible) {
@@ -522,6 +588,10 @@ Row {
522 compare(centeredIcon.shaped, data.shaped, "shaped-status is incorrect")
588 compare(centeredIcon.shaped, data.shaped, "shaped-status is incorrect")
523 }
589 }
524 compare(valueIndicator.visible, data.valueVisible, "value-indicator visibility is incorrect")
590 compare(valueIndicator.visible, data.valueVisible, "value-indicator visibility is incorrect")
591+ if (valueIndicator.visible) {
592+ verify(innerBar.color === data.valueTinted ? UbuntuColors.orange : "white", "value-bar has the wrong color-tint")
593+ }
594+ compare(valueLabel.visible, data.valueLabelVisible, "value-label visibility is incorrect")
525
595
526 // test input does not fall through
596 // test input does not fall through
527 mouseClick(notification, notification.width / 2, notification.height / 2)
597 mouseClick(notification, notification.width / 2, notification.height / 2)