on xenial help sign in
Fixed transfer item test. Added button-section test
commit7c6a174671adb35c3e7016fe73c8213f79102136 authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 4 Jul 2014, 17:55 (12 years ago) parent9f97ae7
3 files changed+101−10
qml/Panel/Indicators/MenuItemFactory.qml+5−5 tests/mocks/QMenuModel/QDBusActionGroup.qml+60 tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+36−5
qml/Panel/Indicators/MenuItemFactory.qml+5−5
@@ -517,11 +517,11 @@ Item {
517517 busName: rootModel.busName
518518 objectPath: rootModel.actions["indicator"]
519519
520− property QtObject activateAction: action("activate-transfer")
521− property QtObject cancelAction: action("cancel-transfer")
522− property QtObject pauseAction: action("pause-transfer")
523− property QtObject resumeAction: action("resume-transfer")
524− property QtObject transferStateAction: uid !== undefined ? action("transfer-state."+uid) : null
520+ property var activateAction: action("activate-transfer")
521+ property var cancelAction: action("cancel-transfer")
522+ property var pauseAction: action("pause-transfer")
523+ property var resumeAction: action("resume-transfer")
524+ property var transferStateAction: uid !== undefined ? action("transfer-state."+uid) : null
525525
526526 Component.onCompleted: actionGroup.start()
527527 }
tests/mocks/QMenuModel/QDBusActionGroup.qml+60
@@ -18,10 +18,70 @@
1818 */
1919
2020import QtQuick 2.0
21+import Ubuntu.Settings.Menus 0.1 as Menus
2122
2223QtObject {
2324 property int busType
2425 property string busName
2526 property string objectPath
2627 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+ }
2787}
tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml+36−5
@@ -99,6 +99,7 @@ Item {
9999 { tag: 'alarm', type: "com.canonical.indicator.alarm", objectName: "alarmMenu" },
100100 { tag: 'appointment', type: "com.canonical.indicator.appointment", objectName: "appointmentMenu" },
101101 { tag: 'transfer', type: "com.canonical.indicator.transfer", objectName: "transferMenu" },
102+ { tag: 'buttonSection', type: "com.canonical.indicator.button-section", objectName: "buttonSectionMenu" },
102103
103104 { tag: 'messageItem', type: "com.canonical.indicator.messages.messageitem", objectName: "messageItem" },
104105 { tag: 'sourceItem', type: "com.canonical.indicator.messages.sourceitem", objectName: "groupedMessage" },
@@ -431,8 +432,12 @@ Item {
431432
432433 function test_create_transferMenu_data() {
433434 return [
434− {label: "testLabel1", enabled: true, active: true, icon: "file:///testIcon1", progress: 0.1 },
435− {label: "testLabel2", enabled: false, active: false, icon: "file:///testIcon2", progress: 0.5 },
435+ {tag: "queued", label: "testLabel1", enabled: true, active: true, icon: "file:///testIcon1", progress: 0, stateText: i18n.tr("In queue...") },
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") },
436441 ];
437442 }
438443
@@ -442,10 +447,8 @@ Item {
442447 menuData.sensitive = data.enabled;
443448 menuData.icon = data.icon;
444449 menuData.ext = {
445− 'xCanonicalActive': data.active,
446− 'maxValue': 1.0
450+ 'xCanonicalUid': data.tag
447451 };
448− menuData.actionState = data.progress;
449452
450453 loader.data = menuData;
451454 loader.sourceComponent = factory.load(menuData);
@@ -454,9 +457,37 @@ Item {
454457
455458 compare(loader.item.text, data.label, "Label does not match data");
456459 compare(loader.item.iconSource, data.icon, "Icon does not match data");
460+ compare(loader.item.enabled, data.enabled, "Enabled does not match data");
457461 compare(loader.item.progress, data.progress, "Icon does not match data");
458462 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");
459489 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");
460491 }
461492
462493 function test_create_wifiSection_data() {