author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 7 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
||
45 |
#include <qcalendarwidget.h> |
|
46 |
#include <qtoolbutton.h> |
|
47 |
#include <qspinbox.h> |
|
48 |
#include <qmenu.h> |
|
49 |
#include <qdebug.h> |
|
50 |
#include <qdatetime.h> |
|
51 |
#include <qtextformat.h> |
|
52 |
||
53 |
||
54 |
//TESTED_CLASS= |
|
55 |
//TESTED_FILES= |
|
56 |
||
57 |
class tst_QCalendarWidget : public QObject |
|
58 |
{ |
|
59 |
Q_OBJECT |
|
60 |
||
61 |
public: |
|
62 |
tst_QCalendarWidget(); |
|
63 |
virtual ~tst_QCalendarWidget(); |
|
64 |
public slots: |
|
65 |
void initTestCase(); |
|
66 |
void cleanupTestCase(); |
|
67 |
void init(); |
|
68 |
void cleanup(); |
|
69 |
||
70 |
private slots: |
|
71 |
void getSetCheck(); |
|
72 |
void buttonClickCheck(); |
|
73 |
||
74 |
void setTextFormat(); |
|
75 |
void resetTextFormat(); |
|
76 |
||
77 |
void setWeekdayFormat(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
void showPrevNext_data(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
void showPrevNext(); |
0 | 80 |
}; |
81 |
||
82 |
// Testing get/set functions |
|
83 |
void tst_QCalendarWidget::getSetCheck() |
|
84 |
{ |
|
85 |
QCalendarWidget object; |
|
86 |
||
87 |
//horizontal header formats |
|
88 |
object.setHorizontalHeaderFormat(QCalendarWidget::NoHorizontalHeader); |
|
89 |
QCOMPARE(QCalendarWidget::NoHorizontalHeader, object.horizontalHeaderFormat()); |
|
90 |
object.setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames); |
|
91 |
QCOMPARE(QCalendarWidget::SingleLetterDayNames, object.horizontalHeaderFormat()); |
|
92 |
object.setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames); |
|
93 |
QCOMPARE(QCalendarWidget::ShortDayNames, object.horizontalHeaderFormat()); |
|
94 |
object.setHorizontalHeaderFormat(QCalendarWidget::LongDayNames); |
|
95 |
QCOMPARE(QCalendarWidget::LongDayNames, object.horizontalHeaderFormat()); |
|
96 |
//vertical header formats |
|
97 |
object.setVerticalHeaderFormat(QCalendarWidget::ISOWeekNumbers); |
|
98 |
QCOMPARE(QCalendarWidget::ISOWeekNumbers, object.verticalHeaderFormat()); |
|
99 |
object.setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader); |
|
100 |
QCOMPARE(QCalendarWidget::NoVerticalHeader, object.verticalHeaderFormat()); |
|
101 |
//maximum Date |
|
102 |
QDate maxDate(2006, 7, 3); |
|
103 |
object.setMaximumDate(maxDate); |
|
104 |
QCOMPARE(maxDate, object.maximumDate()); |
|
105 |
//minimum date |
|
106 |
QDate minDate(2004, 7, 3); |
|
107 |
object.setMinimumDate(minDate); |
|
108 |
QCOMPARE(minDate, object.minimumDate()); |
|
109 |
//day of week |
|
110 |
object.setFirstDayOfWeek(Qt::Thursday); |
|
111 |
QCOMPARE(Qt::Thursday, object.firstDayOfWeek()); |
|
112 |
//grid visible |
|
113 |
object.setGridVisible(true); |
|
114 |
QVERIFY(object.isGridVisible()); |
|
115 |
object.setGridVisible(false); |
|
116 |
QVERIFY(!object.isGridVisible()); |
|
117 |
//header visible |
|
118 |
object.setHeaderVisible(true); |
|
119 |
QVERIFY(object.isHeaderVisible()); |
|
120 |
object.setHeaderVisible(false); |
|
121 |
QVERIFY(!object.isHeaderVisible()); |
|
122 |
//selection mode |
|
123 |
QCOMPARE(QCalendarWidget::SingleSelection, object.selectionMode()); |
|
124 |
object.setSelectionMode(QCalendarWidget::NoSelection); |
|
125 |
QCOMPARE(QCalendarWidget::NoSelection, object.selectionMode()); |
|
126 |
object.setSelectionMode(QCalendarWidget::SingleSelection); |
|
127 |
QCOMPARE(QCalendarWidget::SingleSelection, object.selectionMode()); |
|
128 |
//selected date |
|
129 |
QDate selectedDate(2005, 7, 3); |
|
130 |
QSignalSpy spy(&object, SIGNAL(selectionChanged())); |
|
131 |
object.setSelectedDate(selectedDate); |
|
132 |
QCOMPARE(spy.count(), 1); |
|
133 |
QCOMPARE(selectedDate, object.selectedDate()); |
|
134 |
//month and year |
|
135 |
object.setCurrentPage(2004, 1); |
|
136 |
QCOMPARE(1, object.monthShown()); |
|
137 |
QCOMPARE(2004, object.yearShown()); |
|
138 |
object.showNextMonth(); |
|
139 |
QCOMPARE(2, object.monthShown()); |
|
140 |
object.showPreviousMonth(); |
|
141 |
QCOMPARE(1, object.monthShown()); |
|
142 |
object.showNextYear(); |
|
143 |
QCOMPARE(2005, object.yearShown()); |
|
144 |
object.showPreviousYear(); |
|
145 |
QCOMPARE(2004, object.yearShown()); |
|
146 |
//date range |
|
147 |
minDate = QDate(2006,1,1); |
|
148 |
maxDate = QDate(2010,12,31); |
|
149 |
object.setDateRange(minDate, maxDate); |
|
150 |
QCOMPARE(maxDate, object.maximumDate()); |
|
151 |
QCOMPARE(minDate, object.minimumDate()); |
|
152 |
||
153 |
//date should not go beyond the minimum. |
|
154 |
selectedDate = minDate.addDays(-10); |
|
155 |
object.setSelectedDate(selectedDate); |
|
156 |
QCOMPARE(minDate, object.selectedDate()); |
|
157 |
QVERIFY(selectedDate != object.selectedDate()); |
|
158 |
//date should not go beyond the maximum. |
|
159 |
selectedDate = maxDate.addDays(10); |
|
160 |
object.setSelectedDate(selectedDate); |
|
161 |
QCOMPARE(maxDate, object.selectedDate()); |
|
162 |
QVERIFY(selectedDate != object.selectedDate()); |
|
163 |
//show today |
|
164 |
QDate today = QDate::currentDate(); |
|
165 |
object.showToday(); |
|
166 |
QCOMPARE(today.month(), object.monthShown()); |
|
167 |
QCOMPARE(today.year(), object.yearShown()); |
|
168 |
//slect a different date and move. |
|
169 |
object.setSelectedDate(minDate); |
|
170 |
object.showSelectedDate(); |
|
171 |
QCOMPARE(minDate.month(), object.monthShown()); |
|
172 |
QCOMPARE(minDate.year(), object.yearShown()); |
|
173 |
} |
|
174 |
||
175 |
void tst_QCalendarWidget::buttonClickCheck() |
|
176 |
{ |
|
177 |
QCalendarWidget object; |
|
178 |
QSize size = object.sizeHint(); |
|
179 |
object.setGeometry(0,0,size.width(), size.height()); |
|
180 |
object.show(); |
|
181 |
||
182 |
QRect rect = object.geometry(); |
|
183 |
QDate selectedDate(2005, 1, 1); |
|
184 |
//click on the month buttons |
|
185 |
int month = object.monthShown(); |
|
186 |
QToolButton *button = qFindChild<QToolButton *>(&object, "qt_calendar_prevmonth"); |
|
187 |
QTest::mouseClick(button, Qt::LeftButton); |
|
188 |
QCOMPARE(month > 1 ? month-1 : 12, object.monthShown()); |
|
189 |
button = qFindChild<QToolButton *>(&object, "qt_calendar_nextmonth"); |
|
190 |
QTest::mouseClick(button, Qt::LeftButton); |
|
191 |
QCOMPARE(month, object.monthShown()); |
|
192 |
||
193 |
button = qFindChild<QToolButton *>(&object, "qt_calendar_yearbutton"); |
|
194 |
QTest::mouseClick(button, Qt::LeftButton); |
|
195 |
QVERIFY(!button->isVisible()); |
|
196 |
QSpinBox *spinbox = qFindChild<QSpinBox *>(&object, "qt_calendar_yearedit"); |
|
197 |
QTest::qWait(500); |
|
198 |
QTest::keyClick(spinbox, '2'); |
|
199 |
QTest::keyClick(spinbox, '0'); |
|
200 |
QTest::keyClick(spinbox, '0'); |
|
201 |
QTest::keyClick(spinbox, '6'); |
|
202 |
QTest::qWait(500); |
|
203 |
QWidget *widget = qFindChild<QWidget *>(&object, "qt_calendar_calendarview"); |
|
204 |
QTest::mouseMove(widget); |
|
205 |
QTest::mouseClick(widget, Qt::LeftButton); |
|
206 |
QCOMPARE(2006, object.yearShown()); |
|
207 |
object.setSelectedDate(selectedDate); |
|
208 |
object.showSelectedDate(); |
|
209 |
QTest::keyClick(widget, Qt::Key_Down); |
|
210 |
QVERIFY(selectedDate != object.selectedDate()); |
|
211 |
||
212 |
object.setDateRange(QDate(2006,1,1), QDate(2006,2,28)); |
|
213 |
object.setSelectedDate(QDate(2006,1,1)); |
|
214 |
object.showSelectedDate(); |
|
215 |
button = qFindChild<QToolButton *>(&object, "qt_calendar_prevmonth"); |
|
216 |
QTest::mouseClick(button, Qt::LeftButton); |
|
217 |
QCOMPARE(1, object.monthShown()); |
|
218 |
||
219 |
button = qFindChild<QToolButton *>(&object, "qt_calendar_nextmonth"); |
|
220 |
QTest::mouseClick(button, Qt::LeftButton); |
|
221 |
QCOMPARE(2, object.monthShown()); |
|
222 |
QTest::mouseClick(button, Qt::LeftButton); |
|
223 |
QCOMPARE(2, object.monthShown()); |
|
224 |
||
225 |
} |
|
226 |
||
227 |
void tst_QCalendarWidget::setTextFormat() |
|
228 |
{ |
|
229 |
QCalendarWidget calendar; |
|
230 |
QTextCharFormat format; |
|
231 |
format.setFontItalic(true); |
|
232 |
format.setForeground(Qt::green); |
|
233 |
||
234 |
const QDate date(1984, 10, 20); |
|
235 |
calendar.setDateTextFormat(date, format); |
|
236 |
QCOMPARE(calendar.dateTextFormat(date), format); |
|
237 |
} |
|
238 |
||
239 |
void tst_QCalendarWidget::resetTextFormat() |
|
240 |
{ |
|
241 |
QCalendarWidget calendar; |
|
242 |
QTextCharFormat format; |
|
243 |
format.setFontItalic(true); |
|
244 |
format.setForeground(Qt::green); |
|
245 |
||
246 |
const QDate date(1984, 10, 20); |
|
247 |
calendar.setDateTextFormat(date, format); |
|
248 |
||
249 |
calendar.setDateTextFormat(QDate(), QTextCharFormat()); |
|
250 |
QCOMPARE(calendar.dateTextFormat(date), QTextCharFormat()); |
|
251 |
} |
|
252 |
||
253 |
void tst_QCalendarWidget::setWeekdayFormat() |
|
254 |
{ |
|
255 |
QCalendarWidget calendar; |
|
256 |
||
257 |
QTextCharFormat format; |
|
258 |
format.setFontItalic(true); |
|
259 |
format.setForeground(Qt::green); |
|
260 |
||
261 |
calendar.setWeekdayTextFormat(Qt::Wednesday, format); |
|
262 |
||
263 |
// check the format of the a given month |
|
264 |
for (int i = 1; i <= 31; ++i) { |
|
265 |
const QDate date(1984, 10, i); |
|
266 |
const Qt::DayOfWeek dayOfWeek = static_cast<Qt::DayOfWeek>(date.dayOfWeek()); |
|
267 |
if (dayOfWeek == Qt::Wednesday) |
|
268 |
QCOMPARE(calendar.weekdayTextFormat(dayOfWeek), format); |
|
269 |
else |
|
270 |
QVERIFY(calendar.weekdayTextFormat(dayOfWeek) != format); |
|
271 |
} |
|
272 |
} |
|
273 |
||
274 |
tst_QCalendarWidget::tst_QCalendarWidget() |
|
275 |
{ |
|
276 |
} |
|
277 |
||
278 |
tst_QCalendarWidget::~tst_QCalendarWidget() |
|
279 |
{ |
|
280 |
} |
|
281 |
||
282 |
void tst_QCalendarWidget::initTestCase() |
|
283 |
{ |
|
284 |
} |
|
285 |
||
286 |
void tst_QCalendarWidget::cleanupTestCase() |
|
287 |
{ |
|
288 |
} |
|
289 |
||
290 |
void tst_QCalendarWidget::init() |
|
291 |
{ |
|
292 |
} |
|
293 |
||
294 |
void tst_QCalendarWidget::cleanup() |
|
295 |
{ |
|
296 |
} |
|
297 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
typedef void (QCalendarWidget::*ShowFunc)(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
Q_DECLARE_METATYPE(ShowFunc) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
302 |
void tst_QCalendarWidget::showPrevNext_data() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
304 |
QTest::addColumn<ShowFunc>("function"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
QTest::addColumn<QDate>("dateOrigin"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
QTest::addColumn<QDate>("expectedDate"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
308 |
QTest::newRow("showNextMonth") << &QCalendarWidget::showNextMonth << QDate(1984,7,30) << QDate(1984,8,30); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
QTest::newRow("showPrevMonth") << &QCalendarWidget::showPreviousMonth << QDate(1984,7,30) << QDate(1984,6,30); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
QTest::newRow("showNextYear") << &QCalendarWidget::showNextYear << QDate(1984,7,30) << QDate(1985,7,30); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
QTest::newRow("showPrevYear") << &QCalendarWidget::showPreviousYear << QDate(1984,7,30) << QDate(1983,7,30); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
312 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
QTest::newRow("showNextMonth limit") << &QCalendarWidget::showNextMonth << QDate(2007,12,4) << QDate(2008,1,4); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
QTest::newRow("showPreviousMonth limit") << &QCalendarWidget::showPreviousMonth << QDate(2006,1,23) << QDate(2005,12,23); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
QTest::newRow("showNextMonth now") << &QCalendarWidget::showNextMonth << QDate() << QDate::currentDate().addMonths(1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
317 |
QTest::newRow("showNextYear now") << &QCalendarWidget::showNextYear << QDate() << QDate::currentDate().addYears(1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
QTest::newRow("showPrevieousMonth now") << &QCalendarWidget::showPreviousMonth << QDate() << QDate::currentDate().addMonths(-1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
QTest::newRow("showPreviousYear now") << &QCalendarWidget::showPreviousYear << QDate() << QDate::currentDate().addYears(-1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
QTest::newRow("showToday now") << &QCalendarWidget::showToday << QDate(2000,1,31) << QDate::currentDate(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
QTest::newRow("showNextMonth 31") << &QCalendarWidget::showNextMonth << QDate(2000,1,31) << QDate(2000,2,28); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
QTest::newRow("selectedDate") << &QCalendarWidget::showSelectedDate << QDate(2008,2,29) << QDate(2008,2,29); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
324 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
void tst_QCalendarWidget::showPrevNext() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
329 |
QFETCH(ShowFunc, function); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
QFETCH(QDate, dateOrigin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
QFETCH(QDate, expectedDate); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
QCalendarWidget calWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
calWidget.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
335 |
QTest::qWaitForWindowShown(&calWidget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
if(!dateOrigin.isNull()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
calWidget.setSelectedDate(dateOrigin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
338 |
calWidget.setCurrentPage(dateOrigin.year(), dateOrigin.month()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
340 |
QCOMPARE(calWidget.yearShown(), dateOrigin.year()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
341 |
QCOMPARE(calWidget.monthShown(), dateOrigin.month()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
343 |
QCOMPARE(calWidget.yearShown(), QDate::currentDate().year()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
QCOMPARE(calWidget.monthShown(), QDate::currentDate().month()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
347 |
(calWidget.*function)(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
QCOMPARE(calWidget.yearShown(), expectedDate.year()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
350 |
QCOMPARE(calWidget.monthShown(), expectedDate.month()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
351 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
352 |
// QTBUG-4058 |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
QTest::qWait(20); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
QToolButton *button = qFindChild<QToolButton *>(&calWidget, "qt_calendar_prevmonth"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
QTest::mouseClick(button, Qt::LeftButton); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
356 |
expectedDate = expectedDate.addMonths(-1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
357 |
QCOMPARE(calWidget.yearShown(), expectedDate.year()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
358 |
QCOMPARE(calWidget.monthShown(), expectedDate.month()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
360 |
if(!dateOrigin.isNull()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
361 |
//the selectedDate should not have changed |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
QCOMPARE(calWidget.selectedDate(), dateOrigin); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
363 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
364 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
365 |
|
0 | 366 |
QTEST_MAIN(tst_QCalendarWidget) |
367 |
#include "tst_qcalendarwidget.moc" |