on xenial help sign in
Fixed transfer item test. Added button-section test
7c6a174Nick Dedekind
qml/Panel/Indicators/MenuItemFactory.qml+5−5
@@ -517,11 +517,11 @@ Item {
517 busName: rootModel.busName
517 busName: rootModel.busName
518 objectPath: rootModel.actions["indicator"]
518 objectPath: rootModel.actions["indicator"]
519
519
520− property QtObject activateAction: action("activate-transfer")
520+ property var activateAction: action("activate-transfer")
521− property QtObject cancelAction: action("cancel-transfer")
521+ property var cancelAction: action("cancel-transfer")
522− property QtObject pauseAction: action("pause-transfer")
522+ property var pauseAction: action("pause-transfer")
523− property QtObject resumeAction: action("resume-transfer")
523+ property var resumeAction: action("resume-transfer")
524− property QtObject transferStateAction: uid !== undefined ? action("transfer-state."+uid) : null
524+ property var transferStateAction: uid !== undefined ? action("transfer-state."+uid) : null
525
525
526 Component.onCompleted: actionGroup.start()
526 Component.onCompleted: actionGroup.start()
527 }
527 }
tests/mocks/QMenuModel/QDBusActionGroup.qml+60
@@ -18,10 +18,70 @@
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
21+import Ubuntu.Settings.Menus 0.1 as Menus
21
22
22QtObject {
23QtObject {
23 property int busType
24 property int busType
24 property string busName
25 property string busName
25 property string objectPath
26 property string objectPath
26 function start() {}
27 function start() {}
28+ function action(actionName) {
29+ switch (actionName) {
30+ case "transfer-state.queued":
31+ return {
32+ 'valid': true,
33+ 'state': {
34+ 'state': Menus.TransferState.QUEUED,
35+ 'percent': 0.0
36+ }
37+ }
38+ case "transfer-state.running":
39+ return {
40+ 'valid': true,
41+ 'state': {
42+ 'state': Menus.TransferState.RUNNING,
43+ 'seconds-left': 100,
44+ 'percent': 0.1
45+ }
46+ }
47+ case "transfer-state.paused":
48+ return {
49+ 'valid': true,
50+ 'state': {
51+ 'state': Menus.TransferState.PAUSED,
52+ 'seconds-left': 100,
53+ 'percent': 0.5
54+ }
55+ }
56+ case "transfer-state.cancelled":
57+ return {
58+ 'valid': true,
59+ 'state': {
60+ 'state': Menus.TransferState.CANCELED,
61+ 'percent': 0.4
62+ }
63+ }
64+ case "transfer-state.finished": return {
65+ 'valid': true,
66+ 'state': {
67+ 'state': Menus.TransferState.FINISHED,
68+ 'seconds-left': 0,
69+ 'percent': 1.0
70+ }
71+ }
72+ case "transfer-state.error":
73+ return {
74+ 'valid': true,
75+ 'state': {
76+ 'state': Menus.TransferState.ERROR,
77+ 'seconds-left': 100,
78+ 'percent': 0.0
79+ }
80+ }
81+ default:
82+ break;
83+ }
84+
85+ return null;
86+ }
27}
87}
tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+36−5
@@ -99,6 +99,7 @@ Item {
99 { tag: 'alarm', type: "com.canonical.indicator.alarm", objectName: "alarmMenu" },
99 { tag: 'alarm', type: "com.canonical.indicator.alarm", objectName: "alarmMenu" },
100 { tag: 'appointment', type: "com.canonical.indicator.appointment", objectName: "appointmentMenu" },
100 { tag: 'appointment', type: "com.canonical.indicator.appointment", objectName: "appointmentMenu" },
101 { tag: 'transfer', type: "com.canonical.indicator.transfer", objectName: "transferMenu" },
101 { tag: 'transfer', type: "com.canonical.indicator.transfer", objectName: "transferMenu" },
102+ { tag: 'buttonSection', type: "com.canonical.indicator.button-section", objectName: "buttonSectionMenu" },
102
103
103 { tag: 'messageItem', type: "com.canonical.indicator.messages.messageitem", objectName: "messageItem" },
104 { tag: 'messageItem', type: "com.canonical.indicator.messages.messageitem", objectName: "messageItem" },
104 { tag: 'sourceItem', type: "com.canonical.indicator.messages.sourceitem", objectName: "groupedMessage" },
105 { tag: 'sourceItem', type: "com.canonical.indicator.messages.sourceitem", objectName: "groupedMessage" },
@@ -431,8 +432,12 @@ Item {
431
432
432 function test_create_transferMenu_data() {
433 function test_create_transferMenu_data() {
433 return [
434 return [
434− {label: "testLabel1", enabled: true, active: true, icon: "file:///testIcon1", progress: 0.1 },
435+ {tag: "queued", label: "testLabel1", enabled: true, active: true, icon: "file:///testIcon1", progress: 0, stateText: i18n.tr("In queue...") },
435− {label: "testLabel2", enabled: false, active: false, icon: "file:///testIcon2", progress: 0.5 },
436+ {tag: "running", label: "testLabel2", enabled: true, active: true, icon: "file:///testIcon2", progress: 0.1, stateText: "1 minute, 40 seconds remaining" },
437+ {tag: "paused", label: "testLabel3", enabled: true, active: true, icon: "file:///testIcon3", progress: 0.5, stateText: i18n.tr("Paused, tap to resume") },
438+ {tag: "cancelled", label: "testLabel4", enabled: true, active: true, icon: "file:///testIcon4", progress: 0.4, stateText: i18n.tr("Canceled") },
439+ {tag: "finished", label: "testLabel5", enabled: false, active: false, icon: "file:///testIcon5", progress: 1.0, stateText: i18n.tr("Finished") },
440+ {tag: "error", label: "testLabel6", enabled: false, active: true, icon: "file:///testIcon6", progress: 0, stateText: i18n.tr("Failed, tap to retry") },
436 ];
441 ];
437 }
442 }
438
443
@@ -442,10 +447,8 @@ Item {
442 menuData.sensitive = data.enabled;
447 menuData.sensitive = data.enabled;
443 menuData.icon = data.icon;
448 menuData.icon = data.icon;
444 menuData.ext = {
449 menuData.ext = {
445− 'xCanonicalActive': data.active,
450+ 'xCanonicalUid': data.tag
446− 'maxValue': 1.0
447 };
451 };
448− menuData.actionState = data.progress;
449
452
450 loader.data = menuData;
453 loader.data = menuData;
451 loader.sourceComponent = factory.load(menuData);
454 loader.sourceComponent = factory.load(menuData);
@@ -454,9 +457,37 @@ Item {
454
457
455 compare(loader.item.text, data.label, "Label does not match data");
458 compare(loader.item.text, data.label, "Label does not match data");
456 compare(loader.item.iconSource, data.icon, "Icon does not match data");
459 compare(loader.item.iconSource, data.icon, "Icon does not match data");
460+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
457 compare(loader.item.progress, data.progress, "Icon does not match data");
461 compare(loader.item.progress, data.progress, "Icon does not match data");
458 compare(loader.item.active, data.active, "Active does not match data");
462 compare(loader.item.active, data.active, "Active does not match data");
463+ compare(loader.item.stateText, data.stateText, "State text does not match data");
464+ }
465+
466+ function test_create_buttonSectionMenu_data() {
467+ return [
468+ {label: "testLabel1", enabled: true, buttonText: "buttonLabel1", icon: "file:///testIcon1" },
469+ {label: "testLabel2", enabled: false, buttonText: "buttonLabel1", icon: "file:///testIcon2" },
470+ ];
471+ }
472+
473+ function test_create_buttonSectionMenu(data) {
474+ menuData.type = "com.canonical.indicator.button-section";
475+ menuData.label = data.label;
476+ menuData.sensitive = data.enabled;
477+ menuData.icon = data.icon;
478+ menuData.ext = {
479+ 'xCanonicalExtraLabel': data.buttonText
480+ };
481+
482+ loader.data = menuData;
483+ loader.sourceComponent = factory.load(menuData);
484+ tryCompareFunction(function() { return loader.item != undefined; }, true);
485+ compare(loader.item.objectName, "buttonSectionMenu", "Should have created a transfer menu");
486+
487+ compare(loader.item.text, data.label, "Label does not match data");
488+ compare(loader.item.iconSource, data.icon, "Icon does not match data");
459 compare(loader.item.enabled, data.enabled, "Enabled does not match data");
489 compare(loader.item.enabled, data.enabled, "Enabled does not match data");
490+ compare(loader.item.control.text, data.buttonText, "Button text does not match data");
460 }
491 }
461
492
462 function test_create_wifiSection_data() {
493 function test_create_wifiSection_data() {