diff options
Diffstat (limited to 'tests')
7 files changed, 227 insertions, 251 deletions
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 8725c934b3..eee3a6258e 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -299,6 +299,8 @@ void tst_QMetaObject::connectSlotsByName() QCOMPARE(obj2.invokeCount2, 1); } +struct MyUnregisteredType { }; + class QtTestObject: public QObject { friend class tst_QMetaObject; @@ -335,6 +337,8 @@ public slots: void moveToThread(QThread *t) { QObject::moveToThread(t); } + void slotWithUnregisteredParameterType(MyUnregisteredType); + signals: void sig0(); QString sig1(QString s1); @@ -402,6 +406,9 @@ void QtTestObject::testSender() slotResult.sprintf("%p", sender()); } +void QtTestObject::slotWithUnregisteredParameterType(MyUnregisteredType) +{ slotResult = "slotWithUnregisteredReturnType"; } + void tst_QMetaObject::invokeMetaMember() { @@ -582,6 +589,14 @@ void tst_QMetaObject::invokeQueuedMetaMember() Q_ARG(quint64, ll2))); qApp->processEvents(QEventLoop::AllEvents); QCOMPARE(obj.slotResult, QString("testLongLong:-1,0")); + + obj.slotResult.clear(); + { + MyUnregisteredType t; + QTest::ignoreMessage(QtWarningMsg, "QMetaMethod::invoke: Unable to handle unregistered datatype 'MyUnregisteredType'"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "slotWithUnregisteredParameterType", Qt::QueuedConnection, Q_ARG(MyUnregisteredType, t))); + QVERIFY(obj.slotResult.isEmpty()); + } } void tst_QMetaObject::invokeBlockingQueuedMetaMember() diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index 1c8c515f22..f83e2064c8 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -47,7 +47,6 @@ class tst_QDate : public QObject { Q_OBJECT private slots: - void toString(); void isNull_data(); void isNull(); void isValid_data(); @@ -86,6 +85,8 @@ private slots: void fromStringFormat(); void toStringFormat_data(); void toStringFormat(); + void toStringDateFormat_data(); + void toStringDateFormat(); void isLeapYear(); void yearsZeroToNinetyNine(); void negativeYear() const; @@ -106,6 +107,7 @@ private: }; Q_DECLARE_METATYPE(QDate) +Q_DECLARE_METATYPE(Qt::DateFormat) void tst_QDate::isNull_data() { @@ -960,6 +962,33 @@ void tst_QDate::toStringFormat() QCOMPARE( t.toString( format ), str ); } +void tst_QDate::toStringDateFormat_data() +{ + QTest::addColumn<QDate>("date"); + QTest::addColumn<Qt::DateFormat>("format"); + QTest::addColumn<QString>("expectedStr"); + + QTest::newRow("data0") << QDate(1,1,1) << Qt::ISODate << QString("0001-01-01"); + QTest::newRow("data1") << QDate(11,1,1) << Qt::ISODate << QString("0011-01-01"); + QTest::newRow("data2") << QDate(111,1,1) << Qt::ISODate << QString("0111-01-01"); + QTest::newRow("data3") << QDate(1974,12,1) << Qt::ISODate << QString("1974-12-01"); +} + +void tst_QDate::toStringDateFormat() +{ + QFETCH(QDate, date); + QFETCH(Qt::DateFormat, format); + QFETCH(QString, expectedStr); + + QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); + QCOMPARE(date.toString(Qt::LocaleDate), QLocale().toString(date, QLocale::ShortFormat)); + QLocale::setDefault(QLocale::German); + QCOMPARE(date.toString(Qt::SystemLocaleShortDate), QLocale::system().toString(date, QLocale::ShortFormat)); + QCOMPARE(date.toString(Qt::LocaleDate), QLocale().toString(date, QLocale::ShortFormat)); + + QCOMPARE(date.toString(format), expectedStr); +} + void tst_QDate::isLeapYear() { QVERIFY(QDate::isLeapYear(-4801)); @@ -1053,19 +1082,6 @@ void tst_QDate::yearsZeroToNinetyNine() } } -void tst_QDate::toString() -{ - QDate date(1974,12,1); - QCOMPARE(date.toString(Qt::SystemLocaleDate), - QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::LocaleDate), - QLocale().toString(date, QLocale::ShortFormat)); - QLocale::setDefault(QLocale::German); - QCOMPARE(date.toString(Qt::SystemLocaleDate), - QLocale::system().toString(date, QLocale::ShortFormat)); - QCOMPARE(date.toString(Qt::LocaleDate), - QLocale().toString(date, QLocale::ShortFormat)); -} void tst_QDate::negativeYear() const { diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index f7925e849f..b54bf60908 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -108,12 +108,13 @@ private slots: void currentDateTime(); void currentDateTimeUtc(); void currentDateTimeUtc2(); - void fromStringTextDate_data(); - void fromStringTextDate(); - void dateTimeFromStringFormat_data(); - void dateTimeFromStringFormat(); + void fromStringDateFormat_data(); + void fromStringDateFormat(); + void fromStringStringFormat_data(); + void fromStringStringFormat(); void fromString_LOCALE_ILDATE(); - void fromString(); + void fromStringToStringLocale_data(); + void fromStringToStringLocale(); void utcOffset(); void setUtcOffset(); @@ -138,7 +139,7 @@ private: Q_DECLARE_METATYPE(QDateTime) Q_DECLARE_METATYPE(QDate) Q_DECLARE_METATYPE(QTime) - +Q_DECLARE_METATYPE(Qt::TimeSpec) tst_QDateTime::tst_QDateTime() { @@ -1214,116 +1215,146 @@ void tst_QDateTime::toString_strformat() QCOMPARE( dt.toString( format ), str ); } -void tst_QDateTime::fromStringTextDate_data() -{ - QTest::addColumn<QString>("dateTime"); - QTest::addColumn<int>("dateFormat"); - QTest::addColumn<int>("day"); - QTest::addColumn<int>("month"); - QTest::addColumn<int>("year"); - QTest::addColumn<int>("hour"); - QTest::addColumn<int>("minute"); - QTest::addColumn<int>("second"); - QTest::addColumn<int>("msec"); - QTest::addColumn<int>("timeSpec"); - - QTest::newRow("text date") << QString("Tue Jun 17 08:00:10 2003") - << int(Qt::TextDate) - << 17 << 6 << 2003 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - QTest::newRow("ISO date") << QString("2005-06-28T07:57:30.0010000000Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 1 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 1") << QString("2005-06-28T07:57:30,0040000000Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 4 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 2") << QString("2005-06-28T07:57:30,0015Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 2 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 3") << QString("2005-06-28T07:57:30,0014Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 1 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 4") << QString("2005-06-28T07:57:30,1Z") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 100 - << int(Qt::UTC); - - QTest::newRow("ISO date with comma 5") << QString("2005-06-28T07:57:30,11") - << int(Qt::ISODate) - << 28 << 6 << 2005 << 7 << 57 << 30 << 110 - << int(Qt::LocalTime); - - // Should be next day according to ISO 8601 section 4.2.3. - QTest::newRow("ISO date 24:00") << QString("2012-06-04T24:00:00") - << int(Qt::ISODate) - << 5 << 6 << 2012 << 0 << 0 << 0 << 0 - << int(Qt::LocalTime); - - QTest::newRow("ISO date 24:00 end of month") << QString("2012-06-30T24:00:00") - << int(Qt::ISODate) - << 1 << 7 << 2012 << 0 << 0 << 0 << 0 - << int(Qt::LocalTime); - - QTest::newRow("ISO date 24:00 end of month and year") << QString("2012-12-31T24:00:00") - << int(Qt::ISODate) - << 1 << 1 << 2013 << 0 << 0 << 0 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year 0999") << QString("Tue Jun 17 08:00:10 0999") - << int(Qt::TextDate) - << 17 << 6 << 999 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year 999") << QString("Tue Jun 17 08:00:10 999") - << int(Qt::TextDate) - << 17 << 6 << 999 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year 12345") << QString("Tue Jun 17 08:00:10 12345") - << int(Qt::TextDate) - << 17 << 6 << 12345 << 8 << 0 << 10 << 0 - << int(Qt::LocalTime); - - QTest::newRow("Year -4712") << QString("Tue Jan 1 00:01:02 -4712") - << int(Qt::TextDate) - << 1 << 1 << -4712 << 0 << 01 << 02 << 0 - << int(Qt::LocalTime); +void tst_QDateTime::fromStringDateFormat_data() +{ + QTest::addColumn<QString>("dateTimeStr"); + QTest::addColumn<Qt::DateFormat>("dateFormat"); + QTest::addColumn<QDateTime>("expected"); + QTest::addColumn<Qt::TimeSpec>("timeSpec"); + + // Test Qt::TextDate format. + QTest::newRow("text date") << QString::fromLatin1("Tue Jun 17 08:00:10 2003") + << Qt::TextDate << QDateTime(QDate(2003, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year 0999") << QString::fromLatin1("Tue Jun 17 08:00:10 0999") + << Qt::TextDate << QDateTime(QDate(999, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year 999") << QString::fromLatin1("Tue Jun 17 08:00:10 999") + << Qt::TextDate << QDateTime(QDate(999, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year 12345") << QString::fromLatin1("Tue Jun 17 08:00:10 12345") + << Qt::TextDate << QDateTime(QDate(12345, 6, 17), QTime(8, 0, 10, 0)) << Qt::LocalTime; + QTest::newRow("text date Year -4712") << QString::fromLatin1("Tue Jan 1 00:01:02 -4712") + << Qt::TextDate << QDateTime(QDate(-4712, 1, 1), QTime(0, 1, 2, 0)) << Qt::LocalTime; + QTest::newRow("data0") << QString::fromLatin1("Thu Jan 1 00:00:00 1970") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)) << Qt::LocalTime; + QTest::newRow("data1") << QString::fromLatin1("Thu Jan 2 12:34 1970") + << Qt::TextDate << QDateTime(QDate(1970, 1, 2), QTime(12, 34, 0)) << Qt::LocalTime; + QTest::newRow("data2") << QString::fromLatin1("Thu Jan 1 00 1970") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data3") << QString::fromLatin1("Thu Jan 1 00:00:00:00 1970") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data4") << QString::fromLatin1("Thu Jan 1 00:00:00:00 1970") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data5") << QString::fromLatin1(" Thu Jan 1 00:00:00 1970 ") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)) << Qt::LocalTime; + QTest::newRow("data6") << QString::fromLatin1("Thu Jan 1 00:00:00") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data7") << QString::fromLatin1("Thu Jan 1 1970 00:00:00") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0)) << Qt::LocalTime; + QTest::newRow("data8") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT+foo") + << Qt::TextDate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("data9") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34)) << Qt::UTC; + QTest::newRow("data10") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT-0300") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(3, 12, 34)) << Qt::UTC; + QTest::newRow("data11") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 GMT+0300") + << Qt::TextDate << QDateTime(QDate(1969, 12, 31), QTime(21, 12, 34)) << Qt::UTC; + QTest::newRow("data12") << QString::fromLatin1("Thu Jan 1 00:12:34 1970 gmt") + << Qt::TextDate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34)) << Qt::UTC; + QTest::newRow("data13") << QString::fromLatin1("Thu Jan 1 1970 00:12:34 GMT+0100") + << Qt::TextDate << QDateTime(QDate(1969, 12, 31), QTime(23, 12, 34)) << Qt::UTC; + + // Test Qt::ISODate format. + QTest::newRow("data14") << QString::fromLatin1("1987-02-13T13:24:51+01:00") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51)) << Qt::UTC; + QTest::newRow("data15") << QString::fromLatin1("1987-02-13T13:24:51-01:00") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51)) << Qt::UTC; + // No time specified - defaults to Qt::LocalTime. + QTest::newRow("data16") << QString::fromLatin1("2002-10-01") + << Qt::ISODate << QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO") << QString::fromLatin1("2005-06-28T07:57:30.0010000000Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 1)) << Qt::UTC; + QTest::newRow("ISO with comma 1") << QString::fromLatin1("2005-06-28T07:57:30,0040000000Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 4)) << Qt::UTC; + QTest::newRow("ISO with comma 2") << QString::fromLatin1("2005-06-28T07:57:30,0015Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 2)) << Qt::UTC; + QTest::newRow("ISO with comma 3") << QString::fromLatin1("2005-06-28T07:57:30,0014Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 1)) << Qt::UTC; + QTest::newRow("ISO with comma 4") << QString::fromLatin1("2005-06-28T07:57:30,1Z") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 100)) << Qt::UTC; + QTest::newRow("ISO with comma 5") << QString::fromLatin1("2005-06-28T07:57:30,11") + << Qt::ISODate << QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 110)) << Qt::LocalTime; + // 24:00:00 Should be next day according to ISO 8601 section 4.2.3. + QTest::newRow("ISO 24:00") << QString::fromLatin1("2012-06-04T24:00:00") + << Qt::ISODate << QDateTime(QDate(2012, 6, 5), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00 end of month") << QString::fromLatin1("2012-06-30T24:00:00") + << Qt::ISODate << QDateTime(QDate(2012, 7, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00 end of year") << QString::fromLatin1("2012-12-31T24:00:00") + << Qt::ISODate << QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00, fract ms") << QString::fromLatin1("2012-01-01T24:00:00.000") + << Qt::ISODate << QDateTime(QDate(2012, 1, 2), QTime(0, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO 24:00 end of year, fract ms") << QString::fromLatin1("2012-12-31T24:00:00.000") + << Qt::ISODate << QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0, 0)) << Qt::LocalTime; + // Test fractional seconds. + QTest::newRow("ISO .0 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.0") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .00 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.00") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .000 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.000") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .1 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,1") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 100)) << Qt::LocalTime; + QTest::newRow("ISO .99 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,99") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 990)) << Qt::LocalTime; + QTest::newRow("ISO .998 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,998") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 998)) << Qt::LocalTime; + QTest::newRow("ISO .999 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,999") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 999)) << Qt::LocalTime; + QTest::newRow("ISO .3335 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,3335") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 334)) << Qt::LocalTime; + QTest::newRow("ISO .333333 of a second (comma)") << QString::fromLatin1("2012-01-01T08:00:00,333333") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 333)) << Qt::LocalTime; + QTest::newRow("ISO .00009 of a second (period)") << QString::fromLatin1("2012-01-01T08:00:00.00009") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO no fract specified") << QString::fromLatin1("2012-01-01T08:00:00.") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + // Test invalid characters (should ignore invalid characters at end of string). + QTest::newRow("ISO invalid character at end") << QString::fromLatin1("2012-01-01T08:00:00!") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO invalid character at front") << QString::fromLatin1("!2012-01-01T08:00:00") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("ISO invalid character both ends") << QString::fromLatin1("!2012-01-01T08:00:00!") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("ISO invalid character at front, 2 at back") << QString::fromLatin1("!2012-01-01T08:00:00..") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + QTest::newRow("ISO invalid character 2 at front") << QString::fromLatin1("!!2012-01-01T08:00:00") + << Qt::ISODate << invalidDateTime() << Qt::LocalTime; + // Test fractional minutes. + QTest::newRow("ISO .0 of a minute (period)") << QString::fromLatin1("2012-01-01T08:00.0") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .8 of a minute (period)") << QString::fromLatin1("2012-01-01T08:00.8") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 48, 0)) << Qt::LocalTime; + QTest::newRow("ISO .99999 of a minute (period)") << QString::fromLatin1("2012-01-01T08:00.99999") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 59, 999)) << Qt::LocalTime; + QTest::newRow("ISO .0 of a minute (comma)") << QString::fromLatin1("2012-01-01T08:00,0") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 0, 0)) << Qt::LocalTime; + QTest::newRow("ISO .8 of a minute (comma)") << QString::fromLatin1("2012-01-01T08:00,8") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 48, 0)) << Qt::LocalTime; + QTest::newRow("ISO .99999 of a minute (comma)") << QString::fromLatin1("2012-01-01T08:00,99999") + << Qt::ISODate << QDateTime(QDate(2012, 1, 1), QTime(8, 0, 59, 999)) << Qt::LocalTime; } -void tst_QDateTime::fromStringTextDate() -{ - QFETCH(QString, dateTime); - QFETCH(int, dateFormat); - QFETCH(int, day); - QFETCH(int, month); - QFETCH(int, year); - QFETCH(int, hour); - QFETCH(int, minute); - QFETCH(int, second); - QFETCH(int, msec); - QFETCH(int, timeSpec); - - QDateTime dt = QDateTime::fromString(dateTime, (Qt::DateFormat)dateFormat); - QCOMPARE(dt.date().day(), day); - QCOMPARE(dt.date().month(), month); - QCOMPARE(dt.date().year(), year); - QCOMPARE(dt.time().hour(), hour); - QCOMPARE(dt.time().minute(), minute); - QCOMPARE(dt.time().second(), second); - QCOMPARE(dt.time().msec(), msec); - QCOMPARE(int(dt.timeSpec()), timeSpec); -} +void tst_QDateTime::fromStringDateFormat() +{ + QFETCH(QString, dateTimeStr); + QFETCH(Qt::DateFormat, dateFormat); + QFETCH(QDateTime, expected); + QFETCH(Qt::TimeSpec, timeSpec); + QDateTime dateTime = QDateTime::fromString(dateTimeStr, dateFormat); + expected.setTimeSpec(timeSpec); + QCOMPARE(dateTime, expected); +} -void tst_QDateTime::dateTimeFromStringFormat_data() +void tst_QDateTime::fromStringStringFormat_data() { QTest::addColumn<QString>("string"); QTest::addColumn<QString>("format"); @@ -1357,10 +1388,9 @@ void tst_QDateTime::dateTimeFromStringFormat_data() QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z") << QString("yyyy-MM-ddThh:mm:ss.zZ") << QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1)); - } -void tst_QDateTime::dateTimeFromStringFormat() +void tst_QDateTime::fromStringStringFormat() { QFETCH(QString, string); QFETCH(QString, format); @@ -1371,110 +1401,44 @@ void tst_QDateTime::dateTimeFromStringFormat() QCOMPARE(dt, expected); } -void tst_QDateTime::fromString() +void tst_QDateTime::fromString_LOCALE_ILDATE() { - QDateTime dt = QDateTime::fromString("Thu Jan 1 00:00:00 1970"); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))); - - dt = QDateTime::fromString("Thu Jan 2 12:34 1970"); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 2), QTime(12, 34, 0))); - - dt = QDateTime::fromString("Thu Jan 1 00 1970"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString("Thu Jan 1 00:00:00:00 1970"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString(" Thu Jan 1 00:00:00 1970 "); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))); - - dt = QDateTime::fromString("Thu Jan 1 00:00:00"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString("2002-10-01", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(2002, 10, 1), QTime(0, 0, 0, 0))); - - dt = QDateTime::fromString("1987-02-13T13:24:51+01:00", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC)); - - dt = QDateTime::fromString("1987-02-13T13:24:51-01:00", Qt::ISODate); - QCOMPARE(dt, QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT-0300"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(3, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT+0300"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1969, 12, 31), QTime(21, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 GMT+foo"); - QCOMPARE(dt, QDateTime()); - - dt = QDateTime::fromString("Thu Jan 1 00:12:34 1970 gmt"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC)); - - dt = QDateTime::fromString("Thu Jan 1 1970 00:00:00"); - QCOMPARE(dt, QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0))); - - dt = QDateTime::fromString("Thu Jan 1 1970 00:12:34 GMT+0100"); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1969, 12, 31), QTime(23, 12, 34), Qt::UTC)); +#ifdef Q_OS_WIN + QString date1 = QLatin1String("Sun 1. Dec 13:02:00 1974"); + QString date2 = QLatin1String("Sun Dec 1 13:02:00 1974"); - QDate d = QDate::fromString("Thu Jan 1 1970"); - QCOMPARE(d, QDate(1970, 1, 1)); + QDateTime ref(QDate(1974, 12, 1), QTime(13, 2)); + QCOMPARE(ref, QDateTime::fromString(date2, Qt::TextDate)); + QCOMPARE(ref, QDateTime::fromString(date1, Qt::TextDate)); +#else + QSKIP("Windows only"); +#endif +} - d = QDate::fromString(" Thu Jan 1 1970 "); - QCOMPARE(d, QDate(1970, 1, 1)); +void tst_QDateTime::fromStringToStringLocale_data() +{ + QTest::addColumn<QDateTime>("dateTime"); - d = QDate::fromString("Thu Jan 1"); - QCOMPARE(d, QDate()); + QTest::newRow("data0") << QDateTime(QDate(1999, 1, 18), QTime(11, 49, 00)); +} - QDateTime dt2(QDate(1999, 1, 18), QTime(11, 49, 00)); +void tst_QDateTime::fromStringToStringLocale() +{ + QFETCH(QDateTime, dateTime); QLocale def; QLocale::setDefault(QLocale(QLocale::French, QLocale::France)); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dateTime); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dateTime); // obsolete - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dt2); - QCOMPARE(QDateTime::fromString(dt2.toString(Qt::LocaleDate), Qt::LocaleDate), dt2); - -// cannot have these because of bug in datetime parser -// QCOMPARE(QDateTime::fromString(dt2.toString(Qt::DefaultLocaleLongDate), Qt::DefaultLocaleLongDate), dt2); -// QCOMPARE(QDateTime::fromString(dt2.toString(Qt::SystemLocaleLongDate), Qt::SystemLocaleLongDate), dt2); - - - // same thing for QDate and QTime - - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::LocaleDate), Qt::LocaleDate), dt2.date()); - QCOMPARE(QDate::fromString(dt2.date().toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dt2.date()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::DefaultLocaleShortDate), Qt::DefaultLocaleShortDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::SystemLocaleShortDate), Qt::SystemLocaleShortDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::LocaleDate), Qt::LocaleDate), dt2.time()); - QCOMPARE(QTime::fromString(dt2.time().toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dt2.time()); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::SystemLocaleDate), Qt::SystemLocaleDate), dateTime); + QCOMPARE(QDateTime::fromString(dateTime.toString(Qt::LocaleDate), Qt::LocaleDate), dateTime); QLocale::setDefault(def); } -void tst_QDateTime::fromString_LOCALE_ILDATE() -{ -#ifdef Q_OS_WIN - QString date1 = QLatin1String("Sun 1. Dec 13:02:00 1974"); - QString date2 = QLatin1String("Sun Dec 1 13:02:00 1974"); - - QDateTime ref(QDate(1974, 12, 1), QTime(13, 2)); - QCOMPARE(ref, QDateTime::fromString(date2, Qt::TextDate)); - QCOMPARE(ref, QDateTime::fromString(date1, Qt::TextDate)); -#else - QSKIP("Windows only"); -#endif -} - void tst_QDateTime::utcOffset() { /* Check default value. */ diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp index 1e000a1b40..1d6b0d2a01 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp @@ -562,21 +562,22 @@ void tst_QTime::fromStringDateFormat_data() QTest::addColumn<Qt::DateFormat>("format"); QTest::addColumn<QTime>("expected"); - QTest::newRow("valid, start of day, omit seconds") << QString::fromLatin1("00:00") << Qt::ISODate << QTime(0, 0, 0); - QTest::newRow("valid, omit seconds") << QString::fromLatin1("22:21") << Qt::ISODate << QTime(22, 21, 0); - QTest::newRow("valid, omit seconds (2)") << QString::fromLatin1("23:59") << Qt::ISODate << QTime(23, 59, 0); - QTest::newRow("valid, end of day") << QString::fromLatin1("23:59:59") << Qt::ISODate << QTime(23, 59, 59); - - QTest::newRow("invalid, empty string") << QString::fromLatin1("") << Qt::ISODate << invalidTime(); - QTest::newRow("invalid, too many hours") << QString::fromLatin1("25:00") << Qt::ISODate << invalidTime(); - QTest::newRow("invalid, too many minutes") << QString::fromLatin1("10:70") << Qt::ISODate << invalidTime(); - QTest::newRow("invalid, too many seconds") << QString::fromLatin1("23:59:60") << Qt::ISODate << invalidTime(); - QTest::newRow("TextDate - data0") << QString("00:00:00") << Qt::TextDate << QTime(0,0,0,0); QTest::newRow("TextDate - data1") << QString("10:12:34") << Qt::TextDate << QTime(10,12,34,0); QTest::newRow("TextDate - data2") << QString("19:03:54.998601") << Qt::TextDate << QTime(19, 3, 54, 999); QTest::newRow("TextDate - data3") << QString("19:03:54.999601") << Qt::TextDate << QTime(19, 3, 54, 999); + QTest::newRow("IsoDate - valid, start of day, omit seconds") << QString::fromLatin1("00:00") << Qt::ISODate << QTime(0, 0, 0); + QTest::newRow("IsoDate - valid, omit seconds") << QString::fromLatin1("22:21") << Qt::ISODate << QTime(22, 21, 0); + QTest::newRow("IsoDate - valid, omit seconds (2)") << QString::fromLatin1("23:59") << Qt::ISODate << QTime(23, 59, 0); + QTest::newRow("IsoDate - valid, end of day") << QString::fromLatin1("23:59:59") << Qt::ISODate << QTime(23, 59, 59); + + QTest::newRow("IsoDate - invalid, empty string") << QString::fromLatin1("") << Qt::ISODate << invalidTime(); + QTest::newRow("IsoDate - invalid, too many hours") << QString::fromLatin1("25:00") << Qt::ISODate << invalidTime(); + QTest::newRow("IsoDate - invalid, too many minutes") << QString::fromLatin1("10:70") << Qt::ISODate << invalidTime(); + // This is a valid time if it happens on June 30 or December 31 (leap seconds). + QTest::newRow("IsoDate - invalid, too many seconds") << QString::fromLatin1("23:59:60") << Qt::ISODate << invalidTime(); + QTest::newRow("IsoDate - data0") << QString("00:00:00") << Qt::ISODate << QTime(0,0,0,0); QTest::newRow("IsoDate - data1") << QString("10:12:34") << Qt::ISODate << QTime(10,12,34,0); QTest::newRow("IsoDate - data2") << QString("19:03:54.998601") << Qt::ISODate << QTime(19, 3, 54, 999); diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 26e3ccfce4..f9905ce669 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -2556,6 +2556,9 @@ void testContainer() c1 = newInstance<Container>(); QVERIFY(c1.size() == 4); QVERIFY(c1 == newInstance<Container>()); + Container c2 = qMove(c1); + QVERIFY(c2.size() == 4); + QVERIFY(c2 == newInstance<Container>()); } } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4607be4a7a..2a4013347e 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -906,30 +906,6 @@ void tst_QAccessibility::buttonTest() toggletool.setText("Toggle"); toggletool.setMinimumSize(20,20); - // test Controller/Controlled relations - { - QCheckBox toggler("Toggle me!", &window); - bool ok = connect(&pushButton, SIGNAL(clicked()), &toggler, SLOT(toggle())); - QCOMPARE(ok, true); - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&toggler); - QVERIFY(iface); - QCOMPARE(iface->role(), QAccessible::CheckBox); - QAccessibleInterface *buttonIFace = relatedInterface(iface, QAccessible::Controller); - QVERIFY(buttonIFace); - QCOMPARE(buttonIFace->role(), QAccessible::Button); - QCOMPARE(buttonIFace->object(), &pushButton); - delete buttonIFace; - delete iface; - - buttonIFace = QAccessible::queryAccessibleInterface(&pushButton); - QVERIFY(buttonIFace); - QCOMPARE(buttonIFace->role(), QAccessible::Button); - iface = relatedInterface(buttonIFace, QAccessible::Controlled); - QVERIFY(iface); - QCOMPARE(iface->object(), &toggler); - - } - // test push button QAccessibleInterface* interface = QAccessible::queryAccessibleInterface(&pushButton); QAccessibleActionInterface* actionInterface = interface->actionInterface(); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro index 076025e325..4e575483af 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro @@ -1,5 +1,6 @@ CONFIG += testcase CONFIG += parallel_test +win32:testcase.timeout = 900 # this testcase can be slow on Windows QT += widgets widgets-private QT += core-private gui testlib |