diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-05-20 16:43:10 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-05-20 16:43:10 (GMT) |
commit | bfde87dcc8d0f363ecf1da59482c15445b00484c (patch) | |
tree | 0d0c01b1611caf91ba900bd2b67a8806590254cc /tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp | |
parent | 27fadaa7eb2d58b47e7f0f508e3402e7a8de3894 (diff) | |
parent | f9d26f0bebd5bcc32d15c4a627251c44cf78389e (diff) | |
download | Qt-bfde87dcc8d0f363ecf1da59482c15445b00484c.zip Qt-bfde87dcc8d0f363ecf1da59482c15445b00484c.tar.gz Qt-bfde87dcc8d0f363ecf1da59482c15445b00484c.tar.bz2 |
Merge commit 'qt/master'
Diffstat (limited to 'tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp')
-rw-r--r-- | tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp index 67a822f..617832b 100644 --- a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp +++ b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp @@ -47,6 +47,8 @@ #include <qspinbox.h> #include <qmenu.h> #include <qdebug.h> +#include <qdatetime.h> +#include <qtextformat.h> //TESTED_CLASS= @@ -68,6 +70,11 @@ public slots: private slots: void getSetCheck(); void buttonClickCheck(); + + void setTextFormat(); + void resetTextFormat(); + + void setWeekdayFormat(); }; // Testing get/set functions @@ -215,6 +222,52 @@ void tst_QCalendarWidget::buttonClickCheck() } +void tst_QCalendarWidget::setTextFormat() +{ + QCalendarWidget calendar; + QTextCharFormat format; + format.setFontItalic(true); + format.setForeground(Qt::green); + + const QDate date(1984, 10, 20); + calendar.setDateTextFormat(date, format); + QCOMPARE(calendar.dateTextFormat(date), format); +} + +void tst_QCalendarWidget::resetTextFormat() +{ + QCalendarWidget calendar; + QTextCharFormat format; + format.setFontItalic(true); + format.setForeground(Qt::green); + + const QDate date(1984, 10, 20); + calendar.setDateTextFormat(date, format); + + calendar.setDateTextFormat(QDate(), QTextCharFormat()); + QCOMPARE(calendar.dateTextFormat(date), QTextCharFormat()); +} + +void tst_QCalendarWidget::setWeekdayFormat() +{ + QCalendarWidget calendar; + + QTextCharFormat format; + format.setFontItalic(true); + format.setForeground(Qt::green); + + calendar.setWeekdayTextFormat(Qt::Wednesday, format); + + // check the format of the a given month + for (int i = 1; i <= 31; ++i) { + const QDate date(1984, 10, i); + const Qt::DayOfWeek dayOfWeek = static_cast<Qt::DayOfWeek>(date.dayOfWeek()); + if (dayOfWeek == Qt::Wednesday) + QCOMPARE(calendar.weekdayTextFormat(dayOfWeek), format); + else + QVERIFY(calendar.weekdayTextFormat(dayOfWeek) != format); + } +} tst_QCalendarWidget::tst_QCalendarWidget() { |