~mterry/+junk/u8

« back to all changes in this revision

Viewing changes to tests/qmltests/Panel/Indicators/tst_MenuItemFactory.qml

  • Committer: Michael Zanetti
  • Date: 2016-11-30 13:28:07 UTC
  • mfrom: (2704 unity8)
  • mto: This revision was merged to the branch mainline in revision 2739.
  • Revision ID: michael.zanetti@canonical.com-20161130132807-c314dqdxenzwy69c
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
            menuData.isCheck = false;
81
81
            menuData.isRadio = false;
82
82
            menuData.isToggled = false;
 
83
        }
83
84
 
84
 
            loader.sourceComponent = null;
 
85
        function cleanup() {
85
86
            loader.data = undefined;
 
87
            loader.sourceComponent = undefined;
86
88
 
87
89
            verify(loader.item == null);
88
90
        }
116
118
                { tag: 'accesspoint', type: "unity.widgets.systemsettings.tablet.accesspoint", objectName: "accessPoint" },
117
119
                { tag: 'modeminfoitem', type: "com.canonical.indicator.network.modeminfoitem", objectName: "modemInfoItem" },
118
120
 
 
121
                { tag: 'calendar', type: "com.canonical.indicator.calendar", objectName: "calendarMenu" },
 
122
 
119
123
                { tag: 'unknown', type: "", objectName: "standardMenu"}
120
124
            ];
121
125
        }
140
144
        }
141
145
 
142
146
        function test_create_radio() {
143
 
            skip("No radio component");
144
147
            menuData.isRadio = true;
145
148
 
146
149
            loader.data = menuData;
147
150
            loader.sourceComponent = factory.load(menuData);
148
151
            tryCompareFunction(function() { return loader.item != undefined; }, true);
149
 
            compare(loader.item.objectName, "checkableMenu", "Should have created a checkable menu");
 
152
            compare(loader.item.objectName, "radioMenu", "Should have created a radio menu");
150
153
        }
151
154
 
152
155
        function test_create_separator() {
340
343
            compare(loader.item.enabled, data.enabled, "Enabled does not match data");
341
344
        }
342
345
 
 
346
        function test_create_radioMenu_data() {
 
347
            return [
 
348
                {label: "testLabel1", enabled: true, checked: false },
 
349
                {label: "testLabel2", enabled: false, checked: true },
 
350
            ];
 
351
        }
 
352
 
 
353
        function test_create_radioMenu(data) {
 
354
            menuData.type = "";
 
355
            menuData.label = data.label;
 
356
            menuData.sensitive = data.enabled;
 
357
            menuData.isRadio = true;
 
358
            menuData.isToggled = data.checked;
 
359
 
 
360
            loader.data = menuData;
 
361
            loader.sourceComponent = factory.load(menuData);
 
362
            tryCompareFunction(function() { return loader.item != undefined; }, true);
 
363
            compare(loader.item.objectName, "radioMenu", "Should have created a radio menu");
 
364
 
 
365
            compare(loader.item.text, data.label, "Label does not match data");
 
366
            compare(loader.item.checked, data.checked, "Checked does not match data");
 
367
            compare(loader.item.enabled, data.enabled, "Enabled does not match data");
 
368
        }
 
369
 
343
370
        function test_create_switchMenu_data() {
344
371
            return [
345
372
                {label: "testLabel1", enabled: true, checked: false, icon: "file:///testIcon1" },
396
423
 
397
424
        function test_create_appointmentMenu_data() {
398
425
            return [
399
 
                {label: "testLabel1", enabled: true, icon: "file:///testIcon1", color: Qt.rgba(0, 0, 0, 0),
 
426
                {label: "testLabel1", enabled: true, icon: "file:///testIcon1", color: Qt.rgba(1, 2, 3, 0),
400
427
                            time: new Date(2014, 04, 14), timeFormat: "%a %d %b %l:%M %p"},
401
428
                {label: "testLabel2", enabled: false, icon: "file:///testIcon2", color: Qt.rgba(1, 0, 0, 0),
402
429
                            time: new Date(2015, 11, 31), timeFormat: "%A" },
409
436
            menuData.sensitive = data.enabled;
410
437
            menuData.icon = data.icon;
411
438
            menuData.ext = {
412
 
                'xCanonicalColor': data.colour,
 
439
                'xCanonicalColor': data.color,
413
440
                'xCanonicalTime': data.time.getTime() / 1000 // expected in seconds
414
441
            };
415
442
 
533
560
            compare(loader.item.iconSource, data.icon, "Icon does not match data");
534
561
            compare(loader.item.enabled, data.enabled, "Enabled does not match data");
535
562
 
536
 
            var button = findChild(loader.item, "buttonSectionMenuControl");
537
 
            verify(button !== null);
538
 
            compare(button.text, data.buttonText, "Button text does not match data");
 
563
            compare(loader.item.buttonText, data.buttonText, "Button text does not match data");
539
564
        }
540
565
 
541
566
        function test_create_wifiSection_data() {
594
619
            // ModemInfoItem gets all it's data through the actions.
595
620
            return [
596
621
                        {
597
 
                            label: "",
598
622
                            enabled: true,
599
 
                            checked: false,
600
623
                            statusLabelAction: "action::statusLabel",
601
624
                            statusIconAction: "action::statusIcon",
602
625
                            connectivityIconAction: "action::connectivityIcon",
609
632
 
610
633
        function test_create_modemInfoItem(data) {
611
634
            menuData.type = "com.canonical.indicator.network.modeminfoitem";
612
 
            menuData.label = data.label;
613
635
            menuData.sensitive = data.enabled;
614
 
            menuData.isToggled = data.checked;
615
636
            menuData.ext = {
616
637
                'xCanonicalModemStatusLabelAction': data.statusLabelAction,
617
638
                'xCanonicalModemStatusIconAction': data.statusIconAction,
625
646
            loader.sourceComponent = factory.load(menuData);
626
647
            tryCompareFunction(function() { return loader.item != undefined; }, true);
627
648
            compare(loader.item.objectName, "modemInfoItem", "Should have created a modem info item.");
628
 
            compare(loader.item.text, data.label, "Label does not match data");
629
649
 
630
650
            compare(loader.item.statusLabelAction.name, data.statusLabelAction, "StatusLabel action incorrect");
631
651
            compare(loader.item.statusIconAction.name, data.statusIconAction, "StatusIcon action incorrect");
817
837
            compare(loader.item.checked, true, "Clicking switch menu should toggle check");
818
838
            tryCompare(loader.item, "checked", false);
819
839
        }
 
840
 
 
841
        function test_create_calendar_data() {
 
842
            return [
 
843
                { calendarDay: new Date(), showWeekNumbers: false, eventDays: new Array() },
 
844
                { calendarDay: new Date(2016, 8), showWeekNumbers: true, eventDays: [31] },
 
845
                { calendarDay: new Date(), showWeekNumbers: false, eventDays: [1, 5, 10] },
 
846
            ];
 
847
        }
 
848
 
 
849
        function test_create_calendar(data) {
 
850
            menuData.type = "com.canonical.indicator.calendar";
 
851
            menuData.actionState = {
 
852
                "calendar-day": data.calendarDay.getTime() / 1000 | 0,
 
853
                "show-week-numbers": data.showWeekNumbers,
 
854
                "appointment-days": data.eventDays
 
855
            }
 
856
 
 
857
            loader.data = menuData;
 
858
            loader.sourceComponent = factory.load(menuData);
 
859
            tryCompareFunction(function() { return loader.item != undefined; }, true);
 
860
            compare(loader.item.objectName, "calendarMenu", "Should have created a calendar menu")
 
861
 
 
862
            compare(loader.item.currentDate.getFullYear(), data.calendarDay.getFullYear(), "Calendar year does not match data")
 
863
            compare(loader.item.currentDate.getMonth(), data.calendarDay.getMonth(), "Calendar month does not match data")
 
864
            compare(loader.item.currentDate.getDate(), data.calendarDay.getDate(), "Calendar day does not match data")
 
865
            compare(loader.item.showWeekNumbers, data.showWeekNumbers, "Week numbers visibility does not match data")
 
866
            compare(loader.item.eventDays, data.eventDays, "Event days do not match data")
 
867
        }
820
868
    }
821
869
}