From b32d16d468db81a1ba1049cad2d336e2ce8d7472 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Fri, 23 Mar 2018 12:59:40 +0200 Subject: tst_QLocale: Avoid manual deletes Also use data-driven test to reduce duplication. Change-Id: I9516e52267cb3c7b239030fd73dbbf23ac8f52f7 Reviewed-by: Sami Nurmenniemi Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 33 ++++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index c6c16a5982..375cecd521 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -137,6 +137,7 @@ private slots: void formattedDataSize(); void bcp47Name(); + void systemLocale_data(); void systemLocale(); // *** ORDER-DEPENDENCY *** (This Is Bad.) @@ -2682,27 +2683,31 @@ private: const QLocale m_locale; }; +void tst_QLocale::systemLocale_data() +{ + QTest::addColumn("name"); + QTest::addColumn("language"); + QTest::addRow("catalan") << QString("ca") << QLocale::Catalan; + QTest::addRow("ukrainian") << QString("uk") << QLocale::Ukrainian; + QTest::addRow("german") << QString("de") << QLocale::German; +} + void tst_QLocale::systemLocale() { QLocale originalLocale; + QLocale originalSystemLocale = QLocale::system(); - MySystemLocale *sLocale = new MySystemLocale(QLocale("uk")); - QCOMPARE(QLocale().language(), QLocale::Ukrainian); - QCOMPARE(QLocale::system().language(), QLocale::Ukrainian); - delete sLocale; - - sLocale = new MySystemLocale(QLocale("ca")); - QCOMPARE(QLocale().language(), QLocale::Catalan); - QCOMPARE(QLocale::system().language(), QLocale::Catalan); - delete sLocale; + QFETCH(QString, name); + QFETCH(QLocale::Language, language); - sLocale = new MySystemLocale(QLocale("de")); - QCOMPARE(QLocale().language(), QLocale::German); - QCOMPARE(QLocale::system().language(), QLocale::German); - delete sLocale; + { + MySystemLocale sLocale(name); + QCOMPARE(QLocale().language(), language); + QCOMPARE(QLocale::system().language(), language); + } QCOMPARE(QLocale(), originalLocale); - QCOMPARE(QLocale::system(), originalLocale); + QCOMPARE(QLocale::system(), originalSystemLocale); } QTEST_MAIN(tst_QLocale) -- cgit v1.2.3 From e729ac6dc5efd2d68e1a98f63b9cfec83d349ea7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 6 Apr 2018 09:05:40 +0200 Subject: QSqlDatabase: Skip confusing thread warning on invalid QSqlDatabase If the db isn't valid, then that's the actual issue, not the fact that we're getting the same invalid db (with the same driver QSqlNullDriver) in multiple threads. Change-Id: I95490818ed78e741c3823e115f139c2cff01b0b1 Reviewed-by: Andy Shaw --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 4130b364f4..1f055e9c33 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2374,6 +2374,9 @@ public slots: "QSqlDatabasePrivate::database: requested database does not belong to the calling thread."); QSqlDatabase db = QSqlDatabase::database(dbName); QVERIFY(!db.isValid()); + + QSqlDatabase invalidDb = QSqlDatabase::database("invalid"); + QVERIFY(!invalidDb.isValid()); QThread::currentThread()->exit(); } private: -- cgit v1.2.3 From a1b1dd3b84bc53eab7e93245f89e25d7c2f3330e Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 5 Apr 2018 17:49:24 +0200 Subject: QMimeDatabase: fix assert when fetching data for invalid mimetype The Q_ASSERT(mimePrivate.fromCache) at qmimedatabase.cpp:218 which I added in commit 7a5644d648, was being triggered when calling comment() for invalid mimetypes such as db.mimeTypeForName(""). Change-Id: I8037041a4b435d2a5ba24ec94b7858e38b2f0bf2 Reviewed-by: Thiago Macieira --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index abc06bfe85..3144c3071c 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -214,6 +214,8 @@ void tst_QMimeDatabase::mimeTypeForName() QMimeType doesNotExist = db.mimeTypeForName(QString::fromLatin1("foobar/x-doesnot-exist")); QVERIFY(!doesNotExist.isValid()); + QCOMPARE(doesNotExist.comment(), QString()); + QCOMPARE(doesNotExist.aliases(), QStringList()); // TODO move to findByFile #ifdef Q_OS_LINUX -- cgit v1.2.3 From fd87c8da82b4bf52d395a5f9a2687e4eb7a22221 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Tue, 3 Apr 2018 10:21:24 +0300 Subject: tests/auto/other: Avoid unconditional qWait()s There is no need to qWait() before a QTRY_VERIFY. qWait() will also intermittently handle events while waiting, so calling it in a loop isn't necessary. Change-Id: Ica7fbf18c03e673213dd9b72f31f71937cdcb145 Reviewed-by: Friedemann Kleint --- tests/auto/other/qfocusevent/tst_qfocusevent.cpp | 5 +---- tests/auto/other/qobjectrace/tst_qobjectrace.cpp | 12 ++---------- 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index 70e696e703..37521a64aa 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -196,7 +196,6 @@ void tst_QFocusEvent::checkReason_BackTab() // Now test the backtab key QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab ); - QTest::qWait(200); QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved); QVERIFY(childFocusWidgetTwo->focusInEventRecieved); @@ -217,7 +216,6 @@ void tst_QFocusEvent::checkReason_Popup() QMenu* popupMenu = new QMenu( testFocusWidget ); popupMenu->addMenu( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(50); QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); @@ -308,7 +306,7 @@ void tst_QFocusEvent::checkReason_focusWidget() window1.show(); edit1.setFocus(); - QTest::qWait(100); + QTRY_VERIFY(edit1.hasFocus()); edit2.setFocus(); QVERIFY(frame1.focusWidget() != 0); @@ -344,7 +342,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow() QVERIFY( !childFocusWidgetOne->hasFocus() ); d->hide(); - QTest::qWait(100); if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive) || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) { diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp index aa78d70716..e6eb51500b 100644 --- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp @@ -420,11 +420,7 @@ void tst_QObjectRace::disconnectRace() threads[i]->start(); } - QTime timeLimiter; - timeLimiter.start(); - - while (timeLimiter.elapsed() < TimeLimit) - QTest::qWait(10); + QTest::qWait(TimeLimit); for (int i = 0; i < ThreadCount; ++i) { threads[i]->requestInterruption(); @@ -450,11 +446,7 @@ void tst_QObjectRace::disconnectRace() threads[i]->start(); } - QTime timeLimiter; - timeLimiter.start(); - - while (timeLimiter.elapsed() < TimeLimit) - QTest::qWait(10); + QTest::qWait(TimeLimit); senderThread->requestInterruption(); QVERIFY(senderThread->wait(300)); -- cgit v1.2.3 From ec23d96c86b43046cd2456829aca763ea6ba9935 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 4 Apr 2018 10:47:30 +0200 Subject: oci: Use OCIBindByPos2 to accommodate data longer than USHRT_MAX OCIBindByPos2 is only needed when using execBatch(), binding data that is longer than USHRT_MAX works for exec() so this is left unchanged. Change-Id: Ifdcf91939d184f225d24c13052ea0b81611ecf91 Reviewed-by: Edward Welbourne --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 9093485c40..23c8460133 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -128,6 +128,8 @@ private slots: void mysql_outValues(); void oraClob_data() { generic_data("QOCI"); } void oraClob(); + void oraClobBatch_data() { generic_data("QOCI"); } + void oraClobBatch(); void oraLong_data() { generic_data("QOCI"); } void oraLong(); void oraOCINumber_data() { generic_data("QOCI"); } @@ -810,6 +812,28 @@ void tst_QSqlQuery::oraClob() QVERIFY( q.value( 1 ).toByteArray() == loong.toLatin1() ); } +void tst_QSqlQuery::oraClobBatch() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + const QString clobBatch(qTableName("clobBatch", __FILE__, db)); + tst_Databases::safeDropTables(db, { clobBatch }); + QSqlQuery q(db); + QVERIFY_SQL(q, exec("create table " + clobBatch + "(cl clob)")); + + const QString longString(USHRT_MAX + 1, QLatin1Char('A')); + QVERIFY_SQL(q, prepare("insert into " + clobBatch + " (cl) values(:cl)")); + const QVariantList vars = { longString }; + q.addBindValue(vars); + QVERIFY_SQL(q, execBatch()); + + QVERIFY_SQL(q, exec("select cl from " + clobBatch)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toString().count(), longString.size()); + QVERIFY(q.value(0).toString() == longString); +} + void tst_QSqlQuery::storedProceduresIBase() { QFETCH( QString, dbName ); -- cgit v1.2.3 From 28c9ad199c313444149471e854bfa6cc7c708549 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 5 Apr 2018 17:07:23 +0200 Subject: Revise dates of Pacific/Kiritimati's day-skip transition The TZ database has recently revised its ccount of when they skipped a day to cross the international date line, from skipping Jan 1st 1995 to skipping December 31st 1994. So Move the before-days check to December 30th; and correct the Feb 2nd that was meant to be Jan 2nd (and does need to remain so, for compatibility with systems with out of date data). Task-number: QTBUG-67497 Change-Id: I5b9483c553205817f995f91793662a5a85e03192 Reviewed-by: Liang Qi --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 919f9cb718..f8432b8472 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2658,8 +2658,8 @@ void tst_QDateTime::zoneAtTime_data() ADDROW("before:NPT", "Asia/Kathmandu", QDate(1985, 12, 31), 19800); // 5:30 ADDROW("after:NPT", "Asia/Kathmandu", QDate(1986, 1, 1), 20700); // 5:45 // The two that have skipped a day (each): - ADDROW("before:LINT", "Pacific/Kiritimati", QDate(1994, 12, 31), -36000); - ADDROW("after:LINT", "Pacific/Kiritimati", QDate(1995, 2, 1), 14 * 3600); + ADDROW("before:LINT", "Pacific/Kiritimati", QDate(1994, 12, 30), -36000); + ADDROW("after:LINT", "Pacific/Kiritimati", QDate(1995, 1, 2), 14 * 3600); ADDROW("after:WST", "Pacific/Apia", QDate(2011, 12, 31), 14 * 3600); #endif // MS lacks ACWST, NPT; doesn't grok date-line crossings; and Windows 7 lacks LINT. ADDROW("before:WST", "Pacific/Apia", QDate(2011, 12, 29), -36000); -- cgit v1.2.3