~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-zesty-2106

« back to all changes in this revision

Viewing changes to tests/qmltests/Components/tst_Calendar.qml

  • Committer: Marco Trevisan (Treviño)
  • Date: 2016-10-27 11:23:24 UTC
  • mto: This revision was merged to the branch mainline in revision 171.
  • Revision ID: mail@3v1n0.net-20161027112324-9r7n75hxccy17bd6
OtherComponents: move RadioMenu components to a different location not to clash with calendar

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
        function init() {
57
57
            calendar.selectedDate = new Date(2013, 4, 10);
 
58
            calendar.maximumDate = undefined;
 
59
            calendar.minimumDate = undefined;
 
60
        }
 
61
 
 
62
        function test_collapsed() {
 
63
            calendar.collapsed = true;
 
64
            compare(calendar.interactive, false, "Calendar should not be interactive");
 
65
            var collapsedHeight = calendar.height;
 
66
            calendar.collapsed = false;
 
67
            verify(calendar.height > collapsedHeight * 4 && calendar.height < collapsedHeight * 6, "Height did not expand properly");
 
68
            compare(calendar.interactive, true, "Calendar should be interactive");
58
69
        }
59
70
 
60
71
        function test_selectedDate_data() {
68
79
        function test_selectedDate(data) {
69
80
            calendar.selectedDate = data.date;
70
81
 
71
 
            compare(calendar.currentItem.month.firstDay().year, data.date.getFullYear(), "Current year does no correspond to set date");
72
 
            compare(calendar.currentItem.month.firstDay().month, data.date.getMonth(), "Current month does no correspond to set date");
 
82
            compare(calendar.currentItem.monthStart.year, data.date.getFullYear(), "Current year does no correspond to set date");
 
83
            compare(calendar.currentItem.monthStart.month, data.date.getMonth(), "Current month does no correspond to set date");
73
84
        }
74
85
 
75
86
        function test_firstDayOfWeek_data() {
91
102
            }
92
103
        }
93
104
 
94
 
        function test_selectedDateUpdatesCurrent_data() {
 
105
        function test_minMaxDate_data() {
95
106
            return [
96
 
                { date: new Date(2010, 4, 10) },
97
 
                { date: new Date() },
98
 
                { date: new Date(2020, 10, 31)},
 
107
                {tag: "Min=-0", date: new Date(), minDate: new Date(), maxDate: undefined, count: 3},
 
108
                {tag: "Min=-1", date: new Date(), minDate: new Date().addMonths(-1), maxDate: undefined, count: 4},
 
109
                {tag: "Min=-22", date: new Date(), minDate: new Date().addMonths(-22), maxDate: undefined, count: 5}, // max out at +-2
 
110
 
 
111
                {tag: "Max=+0", date: new Date(), minDate: undefined, maxDate: new Date(), count: 3},
 
112
                {tag: "Max=+1", date: new Date(), minDate: undefined, maxDate: new Date().addMonths(1), count: 4},
 
113
                {tag: "Max=+22", date: new Date(), minDate: undefined, maxDate: new Date().addMonths(22), count: 5}, // max out at +-2
 
114
 
 
115
                {tag: "Min=-0,Max=+0", date: new Date(), minDate: new Date(), maxDate: new Date(), count: 1},
 
116
                {tag: "Min=-1,Max=+1", date: new Date(), minDate: new Date().addMonths(-1), maxDate: new Date().addMonths(1), count: 3},
 
117
                {tag: "Min=-22,Max=+1", date: new Date(), minDate: new Date().addMonths(-22), maxDate: new Date().addMonths(1), count: 4}, // max out at +-2
 
118
                {tag: "Min=-1,Max=+22", date: new Date(), minDate: new Date().addMonths(-1), maxDate: new Date().addMonths(22), count: 4}, // max out at +-2
 
119
                {tag: "Min=-22,Max=+22", date: new Date(), minDate: new Date().addMonths(-22), maxDate: new Date().addMonths(22), count: 5}, // max out at +-2
99
120
            ];
100
121
        }
101
122
 
102
 
        function test_selectedDateUpdatesCurrent(data) {
103
 
            calendar.selectedDate = data.date
104
 
            compare(calendar.currentDate, data.date)
105
 
        }
106
 
 
107
 
        function test_eventsMarker_data()
108
 
        {
109
 
            var values = []
110
 
            for (var i = 0; i < 20; ++i) {
111
 
                values.push({tag: "eventDay "+i+": "+(i % 2 != 0), idx: i, dayEvent: (i % 2 != 0)})
112
 
            }
113
 
 
114
 
            return values
115
 
        }
116
 
 
117
 
        function test_eventsMarker(data) {
118
 
            var eventMarkerLoader = findChild(calendar, "eventMarkerLoader"+data.idx)
119
 
            verify(eventMarkerLoader)
120
 
 
121
 
            var expected = data.dayEvent
122
 
 
123
 
            if (data.dayEvent) {
124
 
                var dayItem = findChild(calendar, "dayItem"+data.idx)
125
 
                verify(dayItem)
126
 
 
127
 
                calendar.eventDays = [dayItem.dayStart.day]
128
 
                expected = dayItem.isCurrentMonth
129
 
            }
130
 
 
131
 
            compare(eventMarkerLoader.visible, expected)
132
 
            var eventMarker = findChild(eventMarkerLoader, "eventMarker"+data.idx)
133
 
            verify(expected ? eventMarker : eventMarker === undefined)
134
 
        }
135
 
 
136
 
        function test_showWeeksNumber_data() {
137
 
            return [{tag: "visible", visible: true}, {tag: "not visible", visible: false}]
138
 
        }
139
 
 
140
 
        function test_showWeeksNumber(data) {
141
 
            var weekNumbersLoader = findChild(calendar, "weekNumbersLoader"+calendar.currentIndex)
142
 
            verify(weekNumbersLoader)
143
 
 
144
 
            calendar.showWeekNumbers = data.visible
145
 
            var weekNumbersColumn = findChild(weekNumbersLoader, "weekNumbersColumn"+calendar.currentIndex)
146
 
            verify(data.visible ? weekNumbersColumn !== undefined : weekNumbersColumn === undefined)
147
 
        }
148
 
 
149
 
        function test_isToday() {
150
 
            for (var i = 0; i < 7*6; ++i) {
151
 
                var dayItem = findChild(calendar, "dayItem"+i)
152
 
                verify(dayItem)
153
 
                var todayMarkerLoader = findChild(dayItem, "todayMarkerLoader"+i)
154
 
                verify(todayMarkerLoader)
155
 
 
156
 
                compare(todayMarkerLoader.visible, dayItem.isToday)
157
 
                compare(todayMarkerLoader.active, dayItem.isToday)
158
 
            }
 
123
        function test_minMaxDate(data) {
 
124
            calendar.selectedDate = data.date;
 
125
            calendar.minimumDate = data.minDate;
 
126
            calendar.maximumDate = data.maxDate;
 
127
            compare(calendar.count, data.count, "The number of months should have changed");
159
128
        }
160
129
    }
161
130
}