summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@nokia.com>2012-06-21 17:44:04 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-28 17:15:17 +0200
commitab536c3c71deaaa3b67ca87c47628355d9f348e8 (patch)
treea3a7bff9a2f3f0ecc61da1d5f265cdc1502231ab /tests/auto
parent50dfd15dcc49d12c5335a37999aef041d7fdfaae (diff)
Make QCalendarWidget use its locale's firstDayOfWeek.
QCalendarWidget currently uses Qt::Sunday as the default first day of the week. It has been suggested that a better user experience would see the calendar's locale be used instead. Task-number: QTBUG-19811 Change-Id: I4441bf9ffd52213ef622a4a7f498530b7cc9e110 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
index 4857900dc8..1b48278b0a 100644
--- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -73,6 +73,8 @@ private slots:
void setWeekdayFormat();
void showPrevNext_data();
void showPrevNext();
+
+ void firstDayOfWeek();
};
// Testing get/set functions
@@ -361,5 +363,41 @@ void tst_QCalendarWidget::showPrevNext()
}
}
+void tst_QCalendarWidget::firstDayOfWeek()
+{
+ // Ensure the default locale is chosen.
+ QCalendarWidget calendar;
+ QLocale locale;
+ QCOMPARE(calendar.firstDayOfWeek(), locale.firstDayOfWeek());
+
+ QLocale germanLocale(QLocale::German);
+ QLocale::setDefault(germanLocale);
+ QCalendarWidget germanLocaleCalendar;
+ QCOMPARE(germanLocaleCalendar.firstDayOfWeek(), germanLocale.firstDayOfWeek());
+
+ // Ensure calling setLocale works as well.
+ QLocale frenchLocale(QLocale::French);
+ calendar.setLocale(frenchLocale);
+ QCOMPARE(calendar.firstDayOfWeek(), frenchLocale.firstDayOfWeek());
+
+ // Ensure that widget-specific locale takes precedence over default.
+ QLocale::setDefault(QLocale::English);
+ QCOMPARE(calendar.firstDayOfWeek(), frenchLocale.firstDayOfWeek());
+
+ // Ensure that setting the locale of parent widget has an effect.
+ QWidget* parent = new QWidget;
+ calendar.setParent(parent);
+ QLocale hausaLocale(QLocale::Hausa);
+ parent->setLocale(hausaLocale);
+ QCOMPARE(calendar.firstDayOfWeek(), hausaLocale.firstDayOfWeek());
+
+ // Ensure that widget-specific locale takes precedence over parent.
+ calendar.setLocale(germanLocale);
+ // Sanity check...
+ QCOMPARE(calendar.locale(), germanLocale);
+ QCOMPARE(parent->locale(), hausaLocale);
+ QCOMPARE(calendar.firstDayOfWeek(), germanLocale.firstDayOfWeek());
+}
+
QTEST_MAIN(tst_QCalendarWidget)
#include "tst_qcalendarwidget.moc"