From f9b11bcf786eb3ab189f0402fd1b0f023910c2df Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 4 Jun 2018 15:57:05 +0200 Subject: QHeaderView: Send the StatusTip events to itself if there is no parent If there is a parent (typically an itemview) then StatusTip events should be sent to that. However in the case of there not being a parent then the event should be sent to the QHeaderView itself. Task-number: QTBUG-68458 Change-Id: I2a8c11c973210c7adf1bf29443f224f968a357a9 Reviewed-by: Richard Moe Gustavsen --- .../itemviews/qheaderview/tst_qheaderview.cpp | 65 +++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index fd83228c8b..0dd98cf61c 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -43,6 +43,7 @@ #include #include #include +#include typedef QList IntList; @@ -243,7 +244,7 @@ private slots: void testMinMaxSectionSize_data(); void testMinMaxSectionSize(); void sizeHintCrash(); - + void statusTips(); protected: void setupTestData(bool use_reset_model = false); void additionalInit(); @@ -269,7 +270,19 @@ public: int rowCount(const QModelIndex&) const { return rows; } int columnCount(const QModelIndex&) const { return cols; } bool isEditable(const QModelIndex &) const { return true; } - + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const + { + if (section < 0 || (role != Qt::DisplayRole && role != Qt::StatusTipRole)) + return QVariant(); + const int row = (orientation == Qt::Vertical ? section : 0); + const int col = (orientation == Qt::Horizontal ? section : 0); + if (orientation == Qt::Vertical && row >= rows) + return QVariant(); + if (orientation == Qt::Horizontal && col >= cols) + return QVariant(); + return QLatin1Char('[') + QString::number(row) + QLatin1Char(',') + + QString::number(col) + QLatin1String(",0] -- Header"); + } QVariant data(const QModelIndex &idx, int) const { if (idx.row() < 0 || idx.column() < 0 || idx.column() >= cols || idx.row() >= rows) { @@ -3325,6 +3338,54 @@ void tst_QHeaderView::testMinMaxSectionSize() QTRY_COMPARE(header.sectionSize(0), defaultSectionSize); } +class StatusTipHeaderView : public QHeaderView +{ +public: + StatusTipHeaderView(Qt::Orientation orientation = Qt::Horizontal, QWidget *parent = 0) : + QHeaderView(orientation, parent), gotStatusTipEvent(false) {} + bool gotStatusTipEvent; + QString statusTipText; +protected: + bool event(QEvent *e) + { + if (e->type() == QEvent::StatusTip) { + gotStatusTipEvent = true; + statusTipText = static_cast(e)->tip(); + } + return QHeaderView::event(e); + } +}; + +void tst_QHeaderView::statusTips() +{ + StatusTipHeaderView headerView; + QtTestModel model; + model.rows = model.cols = 5; + headerView.setModel(&model); + headerView.viewport()->setMouseTracking(true); + headerView.setGeometry(QRect(QPoint(QApplication::desktop()->geometry().center() - QPoint(250, 250)), + QSize(500, 500))); + headerView.show(); + qApp->setActiveWindow(&headerView); + QVERIFY(QTest::qWaitForWindowActive(&headerView)); + + // Ensure it is moved away first and then moved to the relevant section + QTest::mouseMove(QApplication::desktop(), + headerView.rect().bottomLeft() + QPoint(20, 20)); + QPoint centerPoint = QRect(headerView.sectionPosition(0), headerView.y(), + headerView.sectionSize(0), headerView.height()).center(); + QTest::mouseMove(headerView.windowHandle(), centerPoint); + QTRY_VERIFY(headerView.gotStatusTipEvent); + QCOMPARE(headerView.statusTipText, QLatin1String("[0,0,0] -- Header")); + + headerView.gotStatusTipEvent = false; + headerView.statusTipText.clear(); + centerPoint = QRect(headerView.sectionPosition(1), headerView.y(), + headerView.sectionSize(1), headerView.height()).center(); + QTest::mouseMove(headerView.windowHandle(), centerPoint); + QTRY_VERIFY(headerView.gotStatusTipEvent); + QCOMPARE(headerView.statusTipText, QLatin1String("[0,1,0] -- Header")); +} QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" -- cgit v1.2.3 From 91f3687ee51db83d9018bd61c3fbc736c6e9912e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 8 Jun 2018 17:37:49 +0200 Subject: Make QString's formatting of doubles be consistent with other places QString::sprintf(), like the C printf-family, always includes two digits in any exponent it outputs. Up to 5.6, number() and arg() taking a double did the same; but changes at 5.7 to enable opting out of the leading zero this implies for a single-digit exponent accidentally opted out of it in args() and number(). This commit fixes number() and arg() to include QLocaleData::ZeroPadExponent in the flags they pass down to the C locale's doubleToString(), restoring the prior behavior, including consistency with sprintf(). [ChangeLog][QtCore][QString] Formatting of doubles with single-digit exponent, by number() or args(), now includes a leading zero in that exponent, consistently with sprintf(), as it did up to 5.6. Task-number: QTBUG-63620 Change-Id: I10c491902b8556e9f19e605177ead8d9fd32abd9 Reviewed-by: Thiago Macieira Reviewed-by: Ulf Hermann --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 28014840a3..2074c9789a 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -516,6 +516,7 @@ private slots: void toUcs4(); void arg(); void number(); + void doubleOut(); void arg_fillChar_data(); void arg_fillChar(); void capacity_data(); @@ -4882,6 +4883,28 @@ void tst_QString::number() #endif } +void tst_QString::doubleOut() +{ + // Regression test for QTBUG-63620; the first two paths lost the exponent's + // leading 0 at 5.7; C's printf() family guarantee a two-digit exponent (in + // contrast with ECMAScript, which forbids leading zeros). + const QString expect(QStringLiteral("1e-06")); + const double micro = 1e-6; + QCOMPARE(QString::number(micro), expect); + QCOMPARE(QString("%1").arg(micro), expect); + { + QString text; + text.sprintf("%g", micro); + QCOMPARE(text, expect); + } + { + QString text; + QTextStream stream(&text); + stream << micro; + QCOMPARE(text, expect); + } +} + void tst_QString::capacity_data() { length_data(); -- cgit v1.2.3 From a834b4d24582ef318ea1de51b6707e9605e6c52f Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 14 Jun 2018 14:50:39 +0200 Subject: CMake: Restore qt5_use_modules() function It appears that in the 5 years since we deprecated this function, people have not stopped using it. The removal of qt5_use_modules() caused lots of troubles in packages still using it when they were compiled against Qt 5.11.0. Instead, let's revive this function and keep it for the Qt5 life time. See discussion on qt-development mailing list: http://lists.qt-project.org/pipermail/development/2018-June/032837.html Change-Id: Ic263e3bb6706268cb9ea38a0711665f166a3aa9e Reviewed-by: David Faure Reviewed-by: Thiago Macieira --- tests/auto/cmake/CMakeLists.txt | 1 + .../cmake/test_use_modules_function/CMakeLists.txt | 18 +++++++++ .../auto/cmake/test_use_modules_function/three.cpp | 45 ++++++++++++++++++++++ tests/auto/cmake/test_use_modules_function/two.cpp | 43 +++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 tests/auto/cmake/test_use_modules_function/CMakeLists.txt create mode 100644 tests/auto/cmake/test_use_modules_function/three.cpp create mode 100644 tests/auto/cmake/test_use_modules_function/two.cpp (limited to 'tests/auto') diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index f1d8657091..ec75ec7caf 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -47,6 +47,7 @@ find_package(Qt5Core REQUIRED) include("${_Qt5CTestMacros}") +expect_pass(test_use_modules_function) expect_pass(test_umbrella_config) expect_pass(test_wrap_cpp_and_resources) if (NOT NO_WIDGETS) diff --git a/tests/auto/cmake/test_use_modules_function/CMakeLists.txt b/tests/auto/cmake/test_use_modules_function/CMakeLists.txt new file mode 100644 index 0000000000..be05c75054 --- /dev/null +++ b/tests/auto/cmake/test_use_modules_function/CMakeLists.txt @@ -0,0 +1,18 @@ + +cmake_minimum_required(VERSION 2.8) + +project(test_use_modules_function) + +set(CMAKE_AUTOMOC ON) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_executable(two two.cpp) +add_executable(three three.cpp) + +find_package(Qt5Core) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + +qt5_use_modules(two Test) +qt5_use_modules(three Gui Test) diff --git a/tests/auto/cmake/test_use_modules_function/three.cpp b/tests/auto/cmake/test_use_modules_function/three.cpp new file mode 100644 index 0000000000..507cc8479d --- /dev/null +++ b/tests/auto/cmake/test_use_modules_function/three.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class Three : public QObject +{ + Q_OBJECT +public: + Three(QObject *parent = 0) + { + QWindow *w = new QWindow; + w->show(); + } +}; + +QTEST_MAIN(Three) + +#include "three.moc" diff --git a/tests/auto/cmake/test_use_modules_function/two.cpp b/tests/auto/cmake/test_use_modules_function/two.cpp new file mode 100644 index 0000000000..44eb7fe96e --- /dev/null +++ b/tests/auto/cmake/test_use_modules_function/two.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class Two : public QObject +{ + Q_OBJECT +public: + Two(QObject *parent = 0) + { + + } +}; + +QTEST_MAIN(Two) + +#include "two.moc" -- cgit v1.2.3 From 67bbe59a373b169b550400187891f6f73a1c00b5 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 14 Jun 2018 14:05:12 +0200 Subject: Make some QEXPECT_FAIL()s consistent in form and content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They used different messages for the same excuse, which weren't well worded in any case; and their #if-ery was differently decorated. Change-Id: I28f5032693aff1036cb086ac4032c669110a5cb5 Reviewed-by: Mårten Nordheim --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index f8432b8472..7d16ec7fbb 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2697,14 +2697,14 @@ void tst_QDateTime::timeZoneAbbreviation() // Time definitely in Standard Time QDateTime dt4(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::LocalTime); #ifdef Q_OS_WIN - QEXPECT_FAIL("", "Windows only returns long name (QTBUG-32759)", Continue); -#endif // Q_OS_WIN + QEXPECT_FAIL("", "Windows only reports long name (QTBUG-32759)", Continue); +#endif QCOMPARE(dt4.timeZoneAbbreviation(), QString("CET")); // Time definitely in Daylight Time QDateTime dt5(QDate(2013, 6, 1), QTime(0, 0, 0), Qt::LocalTime); #ifdef Q_OS_WIN - QEXPECT_FAIL("", "Windows only returns long name (QTBUG-32759)", Continue); -#endif // Q_OS_WIN + QEXPECT_FAIL("", "Windows only reports long name (QTBUG-32759)", Continue); +#endif QCOMPARE(dt5.timeZoneAbbreviation(), QString("CEST")); } else { QSKIP("You must test using Central European (CET/CEST) time zone, e.g. TZ=Europe/Oslo"); @@ -2712,12 +2712,12 @@ void tst_QDateTime::timeZoneAbbreviation() QDateTime dt5(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin")); #ifdef Q_OS_WIN - QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue); + QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue); #endif QCOMPARE(dt5.timeZoneAbbreviation(), QString("CET")); QDateTime dt6(QDate(2013, 6, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin")); #ifdef Q_OS_WIN - QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue); + QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue); #endif QCOMPARE(dt6.timeZoneAbbreviation(), QString("CEST")); } -- cgit v1.2.3 From e08ba34f26197fb9893fd48a38bdd0dfff7d4a60 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 14 Jun 2018 14:07:23 +0200 Subject: Cope with Android's lack of time-zone abbreviations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Have a test expect what it does produce rather than fail what we can't fix. Task-number: QTBUG-68837 Change-Id: Icda7bd9968682daf97d46d597f8bb0433560cde2 Reviewed-by: Mårten Nordheim Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 7d16ec7fbb..867ca52d6f 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2699,27 +2699,35 @@ void tst_QDateTime::timeZoneAbbreviation() #ifdef Q_OS_WIN QEXPECT_FAIL("", "Windows only reports long name (QTBUG-32759)", Continue); #endif - QCOMPARE(dt4.timeZoneAbbreviation(), QString("CET")); + QCOMPARE(dt4.timeZoneAbbreviation(), QStringLiteral("CET")); // Time definitely in Daylight Time QDateTime dt5(QDate(2013, 6, 1), QTime(0, 0, 0), Qt::LocalTime); #ifdef Q_OS_WIN QEXPECT_FAIL("", "Windows only reports long name (QTBUG-32759)", Continue); #endif - QCOMPARE(dt5.timeZoneAbbreviation(), QString("CEST")); + QCOMPARE(dt5.timeZoneAbbreviation(), QStringLiteral("CEST")); } else { QSKIP("You must test using Central European (CET/CEST) time zone, e.g. TZ=Europe/Oslo"); } +#ifdef Q_OS_ANDROID // Only reports (general) zones as offsets (QTBUG-68837) + const QString cet(QStringLiteral("GMT+01:00")); + const QString cest(QStringLiteral("GMT+02:00")); +#else + const QString cet(QStringLiteral("CET")); + const QString cest(QStringLiteral("CEST")); +#endif + QDateTime dt5(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin")); #ifdef Q_OS_WIN QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue); #endif - QCOMPARE(dt5.timeZoneAbbreviation(), QString("CET")); + QCOMPARE(dt5.timeZoneAbbreviation(), cet); QDateTime dt6(QDate(2013, 6, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin")); #ifdef Q_OS_WIN QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue); #endif - QCOMPARE(dt6.timeZoneAbbreviation(), QString("CEST")); + QCOMPARE(dt6.timeZoneAbbreviation(), cest); } void tst_QDateTime::getDate() -- cgit v1.2.3 From b248a35a090585dc81b52b3113a3a6a2926b9c50 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 14 Jun 2018 12:36:41 +0200 Subject: Add Android to exceptions in tst_QDateTime::toString_textDate_extra() Android doesn't use the proper zone-abbreviation, so just check it starts with the right date-time. Revised the way the #if-ery for that is handled, to avoid repetition of the (now more complex) condition in the two tests affected. Task-number: QTBUG-68833 Change-Id: Iceb5469f46c69ba5cdbaf7ca050ad70f2bb74f44 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 867ca52d6f..e9d2fba47f 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -924,12 +924,16 @@ void tst_QDateTime::toString_textDate_extra() else QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 00:00:00 1970")); #if QT_CONFIG(timezone) +# if defined Q_OS_UNIX && !defined Q_OS_DARWIN && !defined Q_OS_ANDROID +# define CORRECT_ZONE_ABBREV +# endif // QTBUG-57320, QTBUG-57298, QTBUG-68833 + QTimeZone PST("America/Vancouver"); if (PST.isValid()) { dt = QDateTime::fromMSecsSinceEpoch(0, PST); -# if defined Q_OS_UNIX && !defined Q_OS_DARWIN +# ifdef CORRECT_ZONE_ABBREV QCOMPARE(dt.toString(), QLatin1String("Wed Dec 31 16:00:00 1969 PST")); -# else // QTBUG-57320, QTBUG-57298 +# else QVERIFY(dt.toString().startsWith(QLatin1String("Wed Dec 31 16:00:00 1969 "))); # endif dt = dt.toLocalTime(); @@ -940,9 +944,9 @@ void tst_QDateTime::toString_textDate_extra() QTimeZone CET("Europe/Berlin"); if (CET.isValid()) { dt = QDateTime::fromMSecsSinceEpoch(0, CET); -# if defined Q_OS_UNIX && !defined Q_OS_DARWIN +# ifdef CORRECT_ZONE_ABBREV QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 01:00:00 1970 CET")); -# else // QTBUG-57320, QTBUG-57298 +# else QVERIFY(dt.toString().startsWith(QLatin1String("Thu Jan 1 01:00:00 1970 "))); # endif dt = dt.toLocalTime(); -- cgit v1.2.3 From 9f8938b89a67ff8da148b7b865576a3d5584c610 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 14 Jun 2018 12:18:20 +0200 Subject: Cope if mktime() deems times in a spring forward gap to be invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In tst_QDateTime::springForward(), we test correct handling of times in the gap; these are formally invalid and a mktime() implementation may reasonably reject them causing our date-time code to produce an invalid result. So handle that case gracefully in the tests, only insisting on consistency between the two ways of preparing the date. In one test, package the repeated code I was going to adapt into a macro to save repeitition. Task-number: QTBUG-68832 Task-number: QTBUG-68839 Change-Id: Ib8a16ff007f4e75ab2ccff05b1ccf00a45e50dc8 Reviewed-by: Thiago Macieira Reviewed-by: Mårten Nordheim --- .../auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 62 ++++++++++++---------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index e9d2fba47f..4e77ff9461 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -1868,12 +1868,14 @@ void tst_QDateTime::springForward() QFETCH(int, adjust); QDateTime direct = QDateTime(day.addDays(-step), time, Qt::LocalTime).addDays(step); - QCOMPARE(direct.date(), day); - QCOMPARE(direct.time().minute(), time.minute()); - QCOMPARE(direct.time().second(), time.second()); - int off = direct.time().hour() - time.hour(); - QVERIFY(off == 1 || off == -1); - // Note: function doc claims always +1, but this should be reviewed ! + if (direct.isValid()) { // mktime() may deem a time in the gap invalid + QCOMPARE(direct.date(), day); + QCOMPARE(direct.time().minute(), time.minute()); + QCOMPARE(direct.time().second(), time.second()); + int off = direct.time().hour() - time.hour(); + QVERIFY(off == 1 || off == -1); + // Note: function doc claims always +1, but this should be reviewed ! + } // Repeat, but getting there via .toLocalTime(): QDateTime detour = QDateTime(day.addDays(-step), @@ -1881,7 +1883,11 @@ void tst_QDateTime::springForward() Qt::UTC).toLocalTime(); QCOMPARE(detour.time(), time); detour = detour.addDays(step); - QCOMPARE(detour, direct); // Insist on consistency. + // Insist on consistency: + if (direct.isValid()) + QCOMPARE(detour, direct); + else + QVERIFY(!detour.isValid()); } void tst_QDateTime::operator_eqeq_data() @@ -2901,38 +2907,40 @@ void tst_QDateTime::daylightTransitions() const QCOMPARE(utc.date(), QDate(2012, 3, 25)); QCOMPARE(utc.time(), QTime(2, 0, 0)); - // Test date maths, if result falls in missing hour then becomes next hour + // Test date maths, if result falls in missing hour then becomes next + // hour (or is always invalid; mktime() may reject gap-times). QDateTime test(QDate(2011, 3, 25), QTime(2, 0, 0)); QVERIFY(test.isValid()); test = test.addYears(1); - QVERIFY(test.isValid()); - QCOMPARE(test.date(), QDate(2012, 3, 25)); - QCOMPARE(test.time(), QTime(3, 0, 0)); + const bool handled = test.isValid(); +#define CHECK_SPRING_FORWARD(test) \ + if (test.isValid()) { \ + QCOMPARE(test.date(), QDate(2012, 3, 25)); \ + QCOMPARE(test.time(), QTime(3, 0, 0)); \ + } else { \ + QVERIFY(!handled); \ + } + CHECK_SPRING_FORWARD(test); test = QDateTime(QDate(2012, 2, 25), QTime(2, 0, 0)); QVERIFY(test.isValid()); test = test.addMonths(1); - QVERIFY(test.isValid()); - QCOMPARE(test.date(), QDate(2012, 3, 25)); - QCOMPARE(test.time(), QTime(3, 0, 0)); + CHECK_SPRING_FORWARD(test); test = QDateTime(QDate(2012, 3, 24), QTime(2, 0, 0)); QVERIFY(test.isValid()); test = test.addDays(1); - QVERIFY(test.isValid()); - QCOMPARE(test.date(), QDate(2012, 3, 25)); - QCOMPARE(test.time(), QTime(3, 0, 0)); + CHECK_SPRING_FORWARD(test); test = QDateTime(QDate(2012, 3, 25), QTime(1, 0, 0)); QVERIFY(test.isValid()); QCOMPARE(test.toMSecsSinceEpoch(), daylight2012 - msecsOneHour); test = test.addMSecs(msecsOneHour); - QVERIFY(test.isValid()); - QCOMPARE(test.date(), QDate(2012, 3, 25)); - QCOMPARE(test.time(), QTime(3, 0, 0)); - QCOMPARE(test.toMSecsSinceEpoch(), daylight2012); - + CHECK_SPRING_FORWARD(test); + if (handled) + QCOMPARE(test.toMSecsSinceEpoch(), daylight2012); +#undef CHECK_SPRING_FORWARD // Test for correct behviour for DaylightTime -> StandardTime transition, i.e. second occurrence @@ -2954,7 +2962,7 @@ void tst_QDateTime::daylightTransitions() const QVERIFY(msecBefore.isValid()); QCOMPARE(msecBefore.date(), QDate(2012, 10, 28)); QCOMPARE(msecBefore.time(), QTime(2, 59, 59, 999)); -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(Q_OS_QNX) +#if defined(Q_OS_DARWIN) || defined(Q_OS_WIN) || defined(Q_OS_QNX) || defined(Q_OS_ANDROID) // Win and Mac uses SecondOccurrence here QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_MAC @@ -2976,8 +2984,8 @@ void tst_QDateTime::daylightTransitions() const QVERIFY(afterTran.isValid()); QCOMPARE(afterTran.date(), QDate(2012, 10, 28)); QCOMPARE(afterTran.time(), QTime(2, 59, 59, 999)); -#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_QNX) - // Linux mktime bug uses last calculation +#ifdef __GLIBCXX__ + // Linux (i.e. glibc) mktime bug reuses last calculation QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_UNIX QCOMPARE(afterTran.toMSecsSinceEpoch(), standard2012 + msecsOneHour - 1); @@ -3183,12 +3191,12 @@ void tst_QDateTime::daylightTransitions() const test = test.addMSecs(msecsOneHour); QVERIFY(test.isValid()); QCOMPARE(test.date(), QDate(2012, 10, 28)); -#if defined(Q_OS_MAC) || defined(Q_OS_QNX) +#if defined(Q_OS_DARWIN) || defined(Q_OS_QNX) || defined(Q_OS_ANDROID) // Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_WIN QCOMPARE(test.time(), QTime(3, 0, 0)); -#if defined(Q_OS_MAC) || defined(Q_OS_QNX) +#if defined(Q_OS_DARWIN) || defined(Q_OS_QNX) || defined(Q_OS_ANDROID) // Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); #endif // Q_OS_WIN -- cgit v1.2.3 From ee3ed1a0abce55c92efc36d4e6c26e83720f9c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 20 Jun 2018 16:53:41 +0200 Subject: Android: Blacklist tst_qkeyevent Task-number: QTBUG-68974 Change-Id: I9178f91b44bc27a055a4bb743374a8bd1dfa5599 Reviewed-by: Frederik Gladhorn --- tests/auto/gui/kernel/qkeyevent/BLACKLIST | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/auto/gui/kernel/qkeyevent/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qkeyevent/BLACKLIST b/tests/auto/gui/kernel/qkeyevent/BLACKLIST new file mode 100644 index 0000000000..e55a200f4d --- /dev/null +++ b/tests/auto/gui/kernel/qkeyevent/BLACKLIST @@ -0,0 +1,6 @@ +# QTBUG-68974 +[basicEventDelivery] +android +# QTBUG-68974 +[modifiers] +android -- cgit v1.2.3 From 06044df0e3d881bcfa2537ad1301468d49ad544c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 8 Jun 2018 12:42:58 +0200 Subject: Android: tst_qthread: terminate is not supported "terminate" and "terminated" both fail on Android since QThread::terminate not supported on Android. So we should skip them. Task-number: QTBUG-68596 Change-Id: Id0d1dde2cfa02bb2978e5dd16087bf8f3bf112b0 Reviewed-by: Thiago Macieira --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index aee243d880..d73dcc1b6d 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -465,8 +465,8 @@ void tst_QThread::start() void tst_QThread::terminate() { -#if defined(Q_OS_WINRT) - QSKIP("Thread termination is not supported on WinRT."); +#if defined(Q_OS_WINRT) || defined(Q_OS_ANDROID) + QSKIP("Thread termination is not supported on WinRT or Android."); #endif Terminate_Thread thread; { @@ -531,8 +531,8 @@ void tst_QThread::finished() void tst_QThread::terminated() { -#if defined(Q_OS_WINRT) - QSKIP("Thread termination is not supported on WinRT."); +#if defined(Q_OS_WINRT) || defined(Q_OS_ANDROID) + QSKIP("Thread termination is not supported on WinRT or Android."); #endif SignalRecorder recorder; Terminate_Thread thread; -- cgit v1.2.3 From 06996e1d0e90fa89d3f18456da91d80c9a6a95f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 6 Jun 2018 14:54:41 +0200 Subject: Android: fix qdiriterator test ... by adding a prefix to the resource. On android there is a resource ("qpdf") which gets included in the root in all applications, included from "src/gui/painting/painting.pri". So we move the test data to a sub-folder. Task-number: QTBUG-68596 Change-Id: I67f2ed79a32c68d9a76cafba8ef23fe0da7c0fe8 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qdiriterator/qdiriterator.qrc | 2 +- .../auto/corelib/io/qdiriterator/tst_qdiriterator.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc b/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc index 058d474780..af9998bdb4 100644 --- a/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc +++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc @@ -1,5 +1,5 @@ - + entrylist/file entrylist/directory/dummy diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index a55989aacd..0b125925bb 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -120,7 +120,7 @@ void tst_QDirIterator::initTestCase() { #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) QString testdata_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - QString resourceSourcePath = QStringLiteral(":/"); + QString resourceSourcePath = QStringLiteral(":/testdata"); QDirIterator it(resourceSourcePath, QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); @@ -141,7 +141,7 @@ void tst_QDirIterator::initTestCase() testdata_dir += QStringLiteral("/entrylist"); #elif defined(BUILTIN_TESTDATA) - m_dataDir = QEXTRACTTESTDATA("/"); + m_dataDir = QEXTRACTTESTDATA("/testdata"); QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data")); QString testdata_dir = m_dataDir->path(); #else @@ -399,18 +399,18 @@ void tst_QDirIterator::iterateResource_data() QTest::addColumn("nameFilters"); QTest::addColumn("entries"); - QTest::newRow("invalid") << QString::fromLatin1(":/burpaburpa") << QDirIterator::IteratorFlags(0) + QTest::newRow("invalid") << QString::fromLatin1(":/testdata/burpaburpa") << QDirIterator::IteratorFlags(0) << QDir::Filters(QDir::NoFilter) << QStringList(QLatin1String("*")) << QStringList(); - QTest::newRow(":/") << QString::fromLatin1(":/") << QDirIterator::IteratorFlags(0) + QTest::newRow(":/testdata") << QString::fromLatin1(":/testdata/") << QDirIterator::IteratorFlags(0) << QDir::Filters(QDir::NoFilter) << QStringList(QLatin1String("*")) - << QString::fromLatin1(":/entrylist").split(QLatin1String(",")); - QTest::newRow(":/entrylist") << QString::fromLatin1(":/entrylist") << QDirIterator::IteratorFlags(0) + << QString::fromLatin1(":/testdata/entrylist").split(QLatin1String(",")); + QTest::newRow(":/testdata/entrylist") << QString::fromLatin1(":/testdata/entrylist") << QDirIterator::IteratorFlags(0) << QDir::Filters(QDir::NoFilter) << QStringList(QLatin1String("*")) - << QString::fromLatin1(":/entrylist/directory,:/entrylist/file").split(QLatin1String(",")); - QTest::newRow(":/ recursive") << QString::fromLatin1(":/") << QDirIterator::IteratorFlags(QDirIterator::Subdirectories) + << QString::fromLatin1(":/testdata/entrylist/directory,:/testdata/entrylist/file").split(QLatin1String(",")); + QTest::newRow(":/testdata recursive") << QString::fromLatin1(":/testdata") << QDirIterator::IteratorFlags(QDirIterator::Subdirectories) << QDir::Filters(QDir::NoFilter) << QStringList(QLatin1String("*")) - << QString::fromLatin1(":/entrylist,:/entrylist/directory,:/entrylist/directory/dummy,:/entrylist/file").split(QLatin1String(",")); + << QString::fromLatin1(":/testdata/entrylist,:/testdata/entrylist/directory,:/testdata/entrylist/directory/dummy,:/testdata/entrylist/file").split(QLatin1String(",")); } void tst_QDirIterator::iterateResource() -- cgit v1.2.3 From 4361c0ee846fb5574a05534186a01779a5e0bb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 18 Jun 2018 15:14:19 +0200 Subject: findtestdata: test 'relative to test source'-fix Before the fix is applied this test fails because QFINDTESTDATA will return "/usr/" instead of the folder with the same name in the current directory. The 'usr' folder can't be located 'next to' the application since this does not trigger the issue (QFINDTESTDATA looks for the folder next to the executable early on). So we put it in a subdirectory and change the current working directory to its parent directory. Change-Id: I627679dcb6f2f6954264e23bfc1a71de3bff7203 Reviewed-by: Jesus Fernandez --- .../selftests/findtestdata/findtestdata.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp b/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp index a775bc1ee5..7d5857faa0 100644 --- a/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp +++ b/tests/auto/testlib/selftests/findtestdata/findtestdata.cpp @@ -134,6 +134,30 @@ void FindTestData::paths() #endif QVERIFY(QFile(testfile_path3).remove()); +#if !defined(Q_OS_WIN) + struct ChdirOnReturn + { + ~ChdirOnReturn() { QDir::setCurrent(dir); } + QString dir; + }; + + // When cross-compiling from Windows to a *nix system the __FILE__ path's canonical path is an + // empty string, which, when used as a prefix, would cause QFINDTESTDATA to look for files in + // root ('/') when trying to look for files relative to the test source. + QString usrPath = app_path + "/temp/usr/"; + QVERIFY(QDir().mkpath(usrPath)); + { + ChdirOnReturn chdirObject{QDir::currentPath()}; + QDir::setCurrent(app_path + "/temp"); + QCOMPARE(QTest::qFindTestData("usr/", + "C:\\path\\to\\source\\source.cpp", + __LINE__, + "C:\\path\\to\\build\\").toLower(), + usrPath.toLower()); + } + QVERIFY(QDir().rmpath(usrPath)); +#endif + // Note, this is expected to generate a warning. // We can't use ignoreMessage, because the warning comes from testlib, // not via a "normal" qWarning. But it's OK, our caller (tst_selftests) -- cgit v1.2.3 From 0e88882fee659f8720c63e067be734e5247af90f Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 21 Jun 2018 16:50:49 +0200 Subject: Remove dead test - compilerwarnings A follow-up of 9d078c8f147ea875e862360b0d7480201fbbcff7 in qtqa repo. Change-Id: Ib7c1f5cf325e9ad0066aae139b0dc72bc0184b32 Reviewed-by: Jarek Kobus --- tests/auto/compilerwarnings/data/test_cpp.txt | 54 --------------------------- 1 file changed, 54 deletions(-) delete mode 100644 tests/auto/compilerwarnings/data/test_cpp.txt (limited to 'tests/auto') diff --git a/tests/auto/compilerwarnings/data/test_cpp.txt b/tests/auto/compilerwarnings/data/test_cpp.txt deleted file mode 100644 index 6ea63f56fd..0000000000 --- a/tests/auto/compilerwarnings/data/test_cpp.txt +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include - -#ifndef QT_NO_GUI -#include -#endif - -#ifndef QT_NO_OPENGL -#include -#endif - -#include - -#if !defined(QT_NO_DBUS) && defined(Q_OS_UNIX) -#include -#endif - -#ifndef Q_OS_MAC -int main(int, char **) -{ - return 0; -} -#endif -- cgit v1.2.3 From c3059391fea326b7115cf038ecdad8e820a0c2d5 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 9 May 2018 13:38:34 +0200 Subject: Make tests compile for Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This only enables compilation, it doesn't fix any test. Qt on Android supports process, but not TEST_HELPER_INSTALLS. See also acdd57cb for winrt. android-ndk-r10e is used to compile, see http://doc-snapshots.qt.io/qt5-5.11/androidgs.html . corelib/io/{qdir,qresourceengine} need to be fixed later. Done-with: Frederik Gladhorn Done-with: Mårten Nordheim Change-Id: I34b924c8ae5d46d6835b8f0a6606450920f4423b Reviewed-by: Thiago Macieira Reviewed-by: Frederik Gladhorn --- tests/auto/corelib/global/qlogging/qlogging.pro | 2 +- tests/auto/corelib/global/qlogging/test/test.pro | 2 +- tests/auto/corelib/io/io.pro | 5 +++++ tests/auto/corelib/io/qfile/tst_qfile.cpp | 6 ++++++ tests/auto/corelib/kernel/kernel.pro | 2 +- tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro | 2 +- tests/auto/corelib/thread/qthreadstorage/test/test.pro | 2 +- tests/auto/corelib/tools/qlocale/test/test.pro | 2 +- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 2 +- tests/auto/gui/kernel/kernel.pro | 2 +- tests/auto/gui/kernel/qclipboard/test/test.pro | 2 +- tests/auto/network/access/qnetworkreply/test/test.pro | 2 +- tests/auto/network/bearer/qnetworksession/test/test.pro | 2 +- tests/auto/other/qcomplextext/android_testdata.qrc | 6 ++++++ tests/auto/other/qcomplextext/qcomplextext.pro | 4 +++- tests/auto/testlib/selftests/test/test.pro | 2 +- tests/auto/widgets/kernel/qapplication/test/test.pro | 2 +- 17 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 tests/auto/other/qcomplextext/android_testdata.qrc (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qlogging/qlogging.pro b/tests/auto/corelib/global/qlogging/qlogging.pro index bbe75297d5..3f7c0a4074 100644 --- a/tests/auto/corelib/global/qlogging/qlogging.pro +++ b/tests/auto/corelib/global/qlogging/qlogging.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -!winrt { +!android:!winrt { test.depends = app SUBDIRS += app } diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro index 7c46ae9d16..b48bf82cf9 100644 --- a/tests/auto/corelib/global/qlogging/test/test.pro +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -7,5 +7,5 @@ QT = core testlib SOURCES = ../tst_qlogging.cpp DEFINES += QT_MESSAGELOGCONTEXT -!winrt: TEST_HELPER_INSTALLS = ../app/app +!android:!winrt: TEST_HELPER_INSTALLS = ../app/app DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index 5618a42203..5eab944fe4 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -64,3 +64,8 @@ win32:!qtConfig(private_tests): SUBDIRS -= \ winrt: SUBDIRS -= \ qstorageinfo + +android: SUBDIRS -= \ + qprocess \ + qdir \ + qresourceengine diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index ad00e25e7d..c202923898 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -85,6 +85,12 @@ QT_END_NAMESPACE #include #include +#ifdef Q_OS_ANDROID +// Android introduces a braindamaged fileno macro that isn't +// compatible with the POSIX fileno or its own FILE type. +# undef fileno +#endif + #if defined(Q_OS_WIN) #include "../../../network-settings.h" #endif diff --git a/tests/auto/corelib/kernel/kernel.pro b/tests/auto/corelib/kernel/kernel.pro index b5b64973d3..09074a9e8a 100644 --- a/tests/auto/corelib/kernel/kernel.pro +++ b/tests/auto/corelib/kernel/kernel.pro @@ -40,7 +40,7 @@ SUBDIRS=\ # This test is only applicable on Windows !win32*|winrt: SUBDIRS -= qwineventnotifier -android|uikit: SUBDIRS -= qclipboard qobject qsharedmemory qsystemsemaphore +android|uikit: SUBDIRS -= qobject qsharedmemory qsystemsemaphore !qtConfig(systemsemaphore): SUBDIRS -= \ qsystemsemaphore diff --git a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro index 75898f6add..432c564ba1 100644 --- a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -!winrt { +!android:!winrt { test.depends = crashonexit SUBDIRS += crashonexit } diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro index 1a1fede186..d7190f7e7b 100644 --- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -5,5 +5,5 @@ CONFIG += console QT = core testlib SOURCES = ../tst_qthreadstorage.cpp -!winrt: TEST_HELPER_INSTALLS = ../crashonexit/crashonexit +!android:!winrt: TEST_HELPER_INSTALLS = ../crashonexit/crashonexit diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index c87e29e764..f7243e99a7 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -16,4 +16,4 @@ win32 { } } -!winrt: TEST_HELPER_INSTALLS = ../syslocaleapp/syslocaleapp +!android:!winrt: TEST_HELPER_INSTALLS = ../syslocaleapp/syslocaleapp diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index cb963ceeb6..29efd8fb4a 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -882,7 +882,7 @@ void tst_QTimeZone::icuTest() void tst_QTimeZone::tzTest() { -#if defined QT_BUILD_INTERNAL && defined Q_OS_UNIX && !defined Q_OS_DARWIN +#if defined QT_BUILD_INTERNAL && defined Q_OS_UNIX && !defined Q_OS_DARWIN && !defined Q_OS_ANDROID // Known datetimes qint64 std = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); qint64 dst = QDateTime(QDate(2012, 6, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 46786262c0..fbd3b1b371 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -37,4 +37,4 @@ win32:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop !qtConfig(opengl): SUBDIRS -= qopenglwindow -uikit: SUBDIRS -= qclipboard +android|uikit: SUBDIRS -= qclipboard diff --git a/tests/auto/gui/kernel/qclipboard/test/test.pro b/tests/auto/gui/kernel/qclipboard/test/test.pro index 59b77b11ba..84e80d62e6 100644 --- a/tests/auto/gui/kernel/qclipboard/test/test.pro +++ b/tests/auto/gui/kernel/qclipboard/test/test.pro @@ -13,6 +13,6 @@ win32 { } } -!winrt: TEST_HELPER_INSTALLS = \ +!android:!winrt: TEST_HELPER_INSTALLS = \ ../copier/copier \ ../paster/paster diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 1f45ac0c49..e8464e81af 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -13,4 +13,4 @@ RESOURCES += ../qnetworkreply.qrc TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \ ../index.html ../smb-file.txt -!winrt: TEST_HELPER_INSTALLS = ../echo/echo +!android:!winrt: TEST_HELPER_INSTALLS = ../echo/echo diff --git a/tests/auto/network/bearer/qnetworksession/test/test.pro b/tests/auto/network/bearer/qnetworksession/test/test.pro index c95baa2b81..bfc1ec7727 100644 --- a/tests/auto/network/bearer/qnetworksession/test/test.pro +++ b/tests/auto/network/bearer/qnetworksession/test/test.pro @@ -15,4 +15,4 @@ CONFIG(debug_and_release) { DESTDIR = .. } -!winrt: TEST_HELPER_INSTALLS = ../lackey/lackey +!android:!winrt: TEST_HELPER_INSTALLS = ../lackey/lackey diff --git a/tests/auto/other/qcomplextext/android_testdata.qrc b/tests/auto/other/qcomplextext/android_testdata.qrc new file mode 100644 index 0000000000..828176df4a --- /dev/null +++ b/tests/auto/other/qcomplextext/android_testdata.qrc @@ -0,0 +1,6 @@ + + + data/BidiCharacterTest.txt + data/BidiTest.txt + + diff --git a/tests/auto/other/qcomplextext/qcomplextext.pro b/tests/auto/other/qcomplextext/qcomplextext.pro index d51dcb4cff..5135b48fee 100644 --- a/tests/auto/other/qcomplextext/qcomplextext.pro +++ b/tests/auto/other/qcomplextext/qcomplextext.pro @@ -8,5 +8,7 @@ TESTDATA += data android { RESOURCES += \ - testdata.qrc + android_testdata.qrc } + +builtin_testdata: DEFINES += BUILTIN_TESTDATA diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro index a7487736b3..bd2366f3e8 100644 --- a/tests/auto/testlib/selftests/test/test.pro +++ b/tests/auto/testlib/selftests/test/test.pro @@ -15,5 +15,5 @@ win32 { RESOURCES += ../selftests.qrc include(../selftests.pri) -!winrt: for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" +!android:!winrt: for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro index 7f75501474..41aad02a1b 100644 --- a/tests/auto/widgets/kernel/qapplication/test/test.pro +++ b/tests/auto/widgets/kernel/qapplication/test/test.pro @@ -9,7 +9,7 @@ TARGET = ../tst_qapplication TESTDATA = ../test/test.pro ../tmp/README -!winrt { +!android:!winrt { SUBPROGRAMS = desktopsettingsaware modal win32:SUBPROGRAMS += wincmdline -- cgit v1.2.3 From 1049d3f9db2b9bbdf5438b9f53849b82a2286848 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Tue, 27 Mar 2018 16:19:07 +0300 Subject: tst_QTimer: Replace unconditional qWait()s with QSignalSpy Where possible. Sometimes the replacement is QTRY_COMPARE instead. Also don't use QTestEventLoop directly when it can also be replaced with QSignalSpy use. Remove the TimerHelper class, since its uses can be done with QSignalSpy (and a lambda when remainingTime is checked). Although checking static single-shot timers still needs a target object, so use a stripped down version in those tests. remainingTimeDuringActivation() was not actually testing the repeating case, but single-shot case twice, so fix that. In the repeating case the remaining time is exactly 20 ms on my machine, but QEMU emulation seems to be slow enough for time to advance before the lambda is executed, so relax the conditions. Task-number: QTBUG-63992 Change-Id: Iae92ff7862a13d36e695eec63b54403ec872f2b4 Reviewed-by: Sami Nurmenniemi Reviewed-by: Frederik Gladhorn Reviewed-by: Gatis Paeglis --- tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp | 263 ++++++++++-------------- 1 file changed, 111 insertions(+), 152 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 2c6d9ea7c0..5b2d77a02c 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -77,102 +77,65 @@ private slots: void postedEventsShouldNotStarveTimers(); }; -class TimerHelper : public QObject -{ - Q_OBJECT -public: - TimerHelper() : QObject(), count(0), remainingTime(-1) - { - } - - int count; - int remainingTime; - -public slots: - void timeout(); - void fetchRemainingTime(); -}; - -void TimerHelper::timeout() -{ - ++count; -} - -void TimerHelper::fetchRemainingTime() -{ - QTimer *timer = static_cast(sender()); - remainingTime = timer->remainingTime(); -} - void tst_QTimer::zeroTimer() { - TimerHelper helper; QTimer timer; timer.setInterval(0); - timer.start(); - connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); + timer.start(); QCoreApplication::processEvents(); - QCOMPARE(helper.count, 1); + QCOMPARE(timeoutSpy.count(), 1); } void tst_QTimer::singleShotTimeout() { - TimerHelper helper; QTimer timer; timer.setSingleShot(true); - connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.start(100); + QVERIFY(timeoutSpy.wait(500)); + QCOMPARE(timeoutSpy.count(), 1); QTest::qWait(500); - QCOMPARE(helper.count, 1); - QTest::qWait(500); - QCOMPARE(helper.count, 1); + QCOMPARE(timeoutSpy.count(), 1); } #define TIMEOUT_TIMEOUT 200 void tst_QTimer::timeout() { - TimerHelper helper; QTimer timer; - - connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.start(100); - QCOMPARE(helper.count, 0); + QCOMPARE(timeoutSpy.count(), 0); - QTRY_VERIFY_WITH_TIMEOUT(helper.count > 0, TIMEOUT_TIMEOUT); - int oldCount = helper.count; + QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > 0, TIMEOUT_TIMEOUT); + int oldCount = timeoutSpy.count(); - QTRY_VERIFY_WITH_TIMEOUT(helper.count > oldCount, TIMEOUT_TIMEOUT); + QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > oldCount, TIMEOUT_TIMEOUT); } void tst_QTimer::remainingTime() { - TimerHelper helper; QTimer timer; - - connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.setTimerType(Qt::PreciseTimer); timer.start(200); - QCOMPARE(helper.count, 0); - + QCOMPARE(timeoutSpy.count(), 0); QTest::qWait(50); - QCOMPARE(helper.count, 0); + QCOMPARE(timeoutSpy.count(), 0); int remainingTime = timer.remainingTime(); QVERIFY2(qAbs(remainingTime - 150) < 50, qPrintable(QString::number(remainingTime))); - // wait for the timer to actually fire now - connect(&timer, SIGNAL(timeout()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(helper.count, 1); + QVERIFY(timeoutSpy.wait()); + QCOMPARE(timeoutSpy.count(), 1); // the timer is still active, so it should have a non-zero remaining time remainingTime = timer.remainingTime(); @@ -182,7 +145,7 @@ void tst_QTimer::remainingTime() void tst_QTimer::remainingTimeDuringActivation_data() { QTest::addColumn("singleShot"); - QTest::newRow("repeating") << true; + QTest::newRow("repeating") << false; QTest::newRow("single-shot") << true; } @@ -190,29 +153,31 @@ void tst_QTimer::remainingTimeDuringActivation() { QFETCH(bool, singleShot); - TimerHelper helper; QTimer timer; + timer.setSingleShot(singleShot); - const int timeout = 20; // 20 ms is short enough and should not round down to 0 in any timer mode - - connect(&timer, SIGNAL(timeout()), &helper, SLOT(fetchRemainingTime())); - connect(&timer, SIGNAL(timeout()), &QTestEventLoop::instance(), SLOT(exitLoop())); + int remainingTime = 0; // not the expected value in either case + connect(&timer, &QTimer::timeout, + [&]() { + remainingTime = timer.remainingTime(); + }); + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); + const int timeout = 20; // 20 ms is short enough and should not round down to 0 in any timer mode timer.start(timeout); - timer.setSingleShot(singleShot); - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(timeoutSpy.wait()); if (singleShot) - QCOMPARE(helper.remainingTime, -1); // timer not running + QCOMPARE(remainingTime, -1); // timer not running else - QCOMPARE(helper.remainingTime, timeout); + QVERIFY2(remainingTime <= timeout && remainingTime > 0, + qPrintable(QString::number(remainingTime))); if (!singleShot) { // do it again - see QTBUG-46940 - helper.remainingTime = -1; - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(helper.remainingTime, timeout); + remainingTime = -1; + QVERIFY(timeoutSpy.wait()); + QVERIFY2(remainingTime <= timeout && remainingTime > 0, + qPrintable(QString::number(remainingTime))); } } @@ -233,47 +198,44 @@ void tst_QTimer::basic_chrono() #else // duplicates zeroTimer, singleShotTimeout, interval and remainingTime using namespace std::chrono; - TimerHelper helper; QTimer timer; + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.setInterval(to_ms(nanoseconds(0))); timer.start(); QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(0)); QCOMPARE(timer.remainingTimeAsDuration().count(), milliseconds::rep(0)); - connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); - QCoreApplication::processEvents(); - QCOMPARE(helper.count, 1); + QCOMPARE(timeoutSpy.count(), 1); - helper.count = 0; + timeoutSpy.clear(); timer.start(milliseconds(100)); - QCOMPARE(helper.count, 0); + QCOMPARE(timeoutSpy.count(), 0); - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > 0); - int oldCount = helper.count; + QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT)); + QVERIFY(timeoutSpy.count() > 0); + int oldCount = timeoutSpy.count(); - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > oldCount); + QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT)); + QVERIFY(timeoutSpy.count() > oldCount); - helper.count = 0; + timeoutSpy.clear(); timer.start(to_ms(microseconds(200000))); QCOMPARE(timer.intervalAsDuration().count(), milliseconds::rep(200)); QTest::qWait(50); - QCOMPARE(helper.count, 0); + QCOMPARE(timeoutSpy.count(), 0); milliseconds rt = timer.remainingTimeAsDuration(); QVERIFY2(qAbs(rt.count() - 150) < 50, qPrintable(QString::number(rt.count()))); - helper.count = 0; + timeoutSpy.clear(); timer.setSingleShot(true); timer.start(milliseconds(100)); + QVERIFY(timeoutSpy.wait(TIMEOUT_TIMEOUT)); + QCOMPARE(timeoutSpy.count(), 1); QTest::qWait(500); - QCOMPARE(helper.count, 1); - QTest::qWait(500); - QCOMPARE(helper.count, 1); - helper.count = 0; + QCOMPARE(timeoutSpy.count(), 1); #endif } @@ -448,47 +410,40 @@ signals: void tst_QTimer::recurringTimer_data() { QTest::addColumn("interval"); - QTest::newRow("zero timer") << 0; - QTest::newRow("non-zero timer") << 1; + QTest::addColumn("recurse"); + // make sure that eventloop recursion doesn't affect timer recurrence + QTest::newRow("zero timer, don't recurse") << 0 << false; + QTest::newRow("zero timer, recurse") << 0 << true; + QTest::newRow("non-zero timer, don't recurse") << 1 << false; + QTest::newRow("non-zero timer, recurse") << 1 << true; } void tst_QTimer::recurringTimer() { const int target = 5; QFETCH(int, interval); + QFETCH(bool, recurse); - { - RecurringTimerObject object(target); - QObject::connect(&object, SIGNAL(done()), &QTestEventLoop::instance(), SLOT(exitLoop())); - (void) object.startTimer(interval); - QTestEventLoop::instance().enterLoop(5); - - QCOMPARE(object.times, target); - } - - { - // make sure that eventloop recursion doesn't effect timer recurrance - RecurringTimerObject object(target); - object.recurse = true; + RecurringTimerObject object(target); + object.recurse = recurse; + QSignalSpy doneSpy(&object, &RecurringTimerObject::done); - QObject::connect(&object, SIGNAL(done()), &QTestEventLoop::instance(), SLOT(exitLoop())); - (void) object.startTimer(interval); - QTestEventLoop::instance().enterLoop(5); + (void) object.startTimer(interval); + QVERIFY(doneSpy.wait()); - QCOMPARE(object.times, target); - } + QCOMPARE(object.times, target); } void tst_QTimer::deleteLaterOnQTimer() { QTimer *timer = new QTimer; connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); - connect(timer, SIGNAL(destroyed()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QSignalSpy destroyedSpy(timer, &QObject::destroyed); timer->setInterval(1); timer->setSingleShot(true); timer->start(); QPointer pointer = timer; - QTestEventLoop::instance().enterLoop(5); + QVERIFY(destroyedSpy.wait()); QVERIFY(pointer.isNull()); } @@ -690,23 +645,34 @@ void tst_QTimer::cancelLongTimer() QVERIFY(!timer.isActive()); } +class TimeoutCounter : public QObject +{ + Q_OBJECT +public slots: + void timeout() { ++count; }; +public: + int count = 0; +}; + void tst_QTimer::singleShotStaticFunctionZeroTimeout() { - TimerHelper helper; + { + TimeoutCounter counter; - QTimer::singleShot(0, &helper, SLOT(timeout())); - QTest::qWait(500); - QCOMPARE(helper.count, 1); - QTest::qWait(500); - QCOMPARE(helper.count, 1); + QTimer::singleShot(0, &counter, SLOT(timeout())); + QTRY_COMPARE(counter.count, 1); + QTest::qWait(500); + QCOMPARE(counter.count, 1); + } - TimerHelper nhelper; + { + TimeoutCounter counter; - QTimer::singleShot(0, &nhelper, &TimerHelper::timeout); - QCoreApplication::processEvents(); - QCOMPARE(nhelper.count, 1); - QCoreApplication::processEvents(); - QCOMPARE(nhelper.count, 1); + QTimer::singleShot(0, &counter, &TimeoutCounter::timeout); + QTRY_COMPARE(counter.count, 1); + QTest::qWait(500); + QCOMPARE(counter.count, 1); + } } class RecursOnTimeoutAndStopTimerTimer : public QObject @@ -807,8 +773,7 @@ void tst_QTimer::singleShotToFunctors() QCOMPARE(e.exec(), 0); QTimer::singleShot(0, &c1, CountedStruct(&count, &t1)); - QTest::qWait(500); - QCOMPARE(count, 2); + QTRY_COMPARE(count, 2); t1.quit(); t1.wait(); @@ -833,12 +798,11 @@ void tst_QTimer::singleShotToFunctors() QObject c3; QTimer::singleShot(500, &c3, CountedStruct(&count)); } - QTest::qWait(800); + QTest::qWait(800); // Wait until the singleshot timer would have timed out QCOMPARE(count, 2); QTimer::singleShot(0, [&count] { ++count; }); - QCoreApplication::processEvents(); - QCOMPARE(count, 3); + QTRY_COMPARE(count, 3); QObject context; QThread thread; @@ -849,8 +813,7 @@ void tst_QTimer::singleShotToFunctors() QCOMPARE(e.exec(), 0); QTimer::singleShot(0, &context, [&count, &thread] { ++count; QCOMPARE(QThread::currentThread(), &thread); }); - QTest::qWait(500); - QCOMPARE(count, 4); + QTRY_COMPARE(count, 4); thread.quit(); thread.wait(); @@ -861,8 +824,7 @@ void tst_QTimer::singleShotToFunctors() MoveOnly(int *c) : CountedStruct(c) {} }; QTimer::singleShot(0, MoveOnly(&count)); - QCoreApplication::processEvents(); - QCOMPARE(count, 5); + QTRY_COMPARE(count, 5); _e.reset(); _t = nullptr; @@ -875,26 +837,27 @@ void tst_QTimer::singleShot_chrono() #else // duplicates singleShotStaticFunctionZeroTimeout and singleShotToFunctors using namespace std::chrono; - TimerHelper helper; + { + TimeoutCounter counter; - QTimer::singleShot(hours(0), &helper, SLOT(timeout())); - QTest::qWait(500); - QCOMPARE(helper.count, 1); - QTest::qWait(500); - QCOMPARE(helper.count, 1); + QTimer::singleShot(hours(0), &counter, SLOT(timeout())); + QTRY_COMPARE(counter.count, 1); + QTest::qWait(500); + QCOMPARE(counter.count, 1); + } - TimerHelper nhelper; + { + TimeoutCounter counter; - QTimer::singleShot(seconds(0), &nhelper, &TimerHelper::timeout); - QCoreApplication::processEvents(); - QCOMPARE(nhelper.count, 1); - QCoreApplication::processEvents(); - QCOMPARE(nhelper.count, 1); + QTimer::singleShot(hours(0), &counter, &TimeoutCounter::timeout); + QTRY_COMPARE(counter.count, 1); + QTest::qWait(500); + QCOMPARE(counter.count, 1); + } int count = 0; QTimer::singleShot(to_ms(microseconds(0)), CountedStruct(&count)); - QCoreApplication::processEvents(); - QCOMPARE(count, 1); + QTRY_COMPARE(count, 1); _e.reset(new QEventLoop); QTimer::singleShot(0, &StaticEventLoop::quitEventLoop); @@ -902,12 +865,10 @@ void tst_QTimer::singleShot_chrono() QObject c3; QTimer::singleShot(milliseconds(500), &c3, CountedStruct(&count)); - QTest::qWait(800); - QCOMPARE(count, 2); + QTRY_COMPARE(count, 2); QTimer::singleShot(0, [&count] { ++count; }); - QCoreApplication::processEvents(); - QCOMPARE(count, 3); + QTRY_COMPARE(count, 3); _e.reset(); #endif @@ -985,16 +946,14 @@ public slots: void tst_QTimer::postedEventsShouldNotStarveTimers() { - TimerHelper timerHelper; QTimer timer; - connect(&timer, SIGNAL(timeout()), &timerHelper, SLOT(timeout())); timer.setInterval(0); timer.setSingleShot(false); + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.start(); SlotRepeater slotRepeater; slotRepeater.repeatThisSlot(); - QTest::qWait(100); - QVERIFY(timerHelper.count > 5); + QTRY_VERIFY_WITH_TIMEOUT(timeoutSpy.count() > 5, 100); } struct DummyFunctor { -- cgit v1.2.3 From cffa010d42b5103aada292c8e1e5b57760d7bdb7 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 14 Jun 2018 13:48:37 +0200 Subject: Kludge round Android's ignorance of some esoteric time-zone transitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip a few tests that Android's time-zone information doesn't suffice to get right. Task-number: QTBUG-68835 Change-Id: Ibf8d213c96b29d74fc478a0ede686ae52b5200fb Reviewed-by: Mårten Nordheim Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 4e77ff9461..10856a4d57 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2661,14 +2661,20 @@ void tst_QDateTime::zoneAtTime_data() ADDROW("summer70:EST", "America/New_York", summer70, -4 * 3600); } +#ifdef Q_OS_ANDROID // QTBUG-68835; gets offset 0 for the affected tests. +# define NONANDROIDROW(name, zone, date, offset) +#else +# define NONANDROIDROW(name, zone, date, offset) ADDROW(name, zone, date, offset) +#endif + #ifndef Q_OS_WIN // Bracket a few noteworthy transitions: ADDROW("before:ACWST", "Australia/Eucla", QDate(1974, 10, 26), 31500); // 8:45 - ADDROW("after:ACWST", "Australia/Eucla", QDate(1974, 10, 27), 35100); // 9:45 - ADDROW("before:NPT", "Asia/Kathmandu", QDate(1985, 12, 31), 19800); // 5:30 + NONANDROIDROW("after:ACWST", "Australia/Eucla", QDate(1974, 10, 27), 35100); // 9:45 + NONANDROIDROW("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, 30), -36000); + NONANDROIDROW("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. -- cgit v1.2.3 From afa2d38a89e07dad292c82c6d739d7a17bce4111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 21 Jun 2018 14:33:23 +0200 Subject: Android: Blacklist tst_qframe::testPainting It causes most of the fails seen on Android. Task-number: QTBUG-69064 Change-Id: I2f97fea41ee78e7962b8c34ed996bbe4bcb88732 Reviewed-by: Jesus Fernandez --- tests/auto/widgets/widgets/qframe/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/widgets/widgets/qframe/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qframe/BLACKLIST b/tests/auto/widgets/widgets/qframe/BLACKLIST new file mode 100644 index 0000000000..3a28dd1239 --- /dev/null +++ b/tests/auto/widgets/widgets/qframe/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-69064 +[testPainting] +android -- cgit v1.2.3 From 531f950226a84bdf439c09c2acf4c327586d27c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 22 Jun 2018 16:07:52 +0200 Subject: Android: Blacklist a few cases in tst_qgroupbox Task-number: QTBUG-69084 Task-number: QTBUG-69083 Change-Id: Icf218795f81f01a559094cf2088f53a9fd597c24 Reviewed-by: Jesus Fernandez --- tests/auto/widgets/widgets/qgroupbox/BLACKLIST | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/auto/widgets/widgets/qgroupbox/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qgroupbox/BLACKLIST b/tests/auto/widgets/widgets/qgroupbox/BLACKLIST new file mode 100644 index 0000000000..62ba05797e --- /dev/null +++ b/tests/auto/widgets/widgets/qgroupbox/BLACKLIST @@ -0,0 +1,13 @@ +# QTBUG-69083 +[clicked:hit nothing, checkable] +android +[clicked:hit frame, checkable] +android +[clicked:hit nothing, checkable, but unchecked] +android +[clicked:hit frame, checkable, but unchecked] +android + +# QTBUG-69084 +[task_QTBUG_15519_propagateMouseEvents] +android -- cgit v1.2.3 From 6934be03fef97ca1e1c0051b19f98523a907f520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 25 Jun 2018 15:32:45 +0200 Subject: Android: Blacklist various cases in tst_QLineEdit Task-number: QTBUG-69111 Task-number: QTBUG-69112 Task-number: QTBUG-69113 Task-number: QTBUG-69114 Task-number: QTBUG-69115 Task-number: QTBUG-69116 Task-number: QTBUG-69118 Task-number: QTBUG-69119 Change-Id: I424cb472e97bd427e800ee230e0e57d763d1b8a6 Reviewed-by: Jesus Fernandez --- tests/auto/widgets/widgets/qlineedit/BLACKLIST | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/auto/widgets/widgets/qlineedit/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qlineedit/BLACKLIST b/tests/auto/widgets/widgets/qlineedit/BLACKLIST new file mode 100644 index 0000000000..537c81413e --- /dev/null +++ b/tests/auto/widgets/widgets/qlineedit/BLACKLIST @@ -0,0 +1,31 @@ +# QTBUG-69111 +[undo_keypressevents:Inserts,moving,selection, delete and undo] +android + +# QTBUG-69112 +[inlineCompletion] +android + +# QTBUG-69116 +[leftKeyOnSelectedText] +android + +# QTBUG-69113 +[textMargin] +android + +# QTBUG-69119 +[task174640_editingFinished] +android + +# QTBUG-69118 +[task210502_caseInsensitiveInlineCompletion] +android + +# QTBUG-69114 +[QTBUG697_paletteCurrentColorGroup] +android + +# QTBUG-69115 +[testQuickSelectionWithMouse] +android -- cgit v1.2.3 From da82bfd8230cf1e8b2719e6eca27df5a73dc0cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Jun 2018 12:56:37 +0200 Subject: Android: tst_QTimeZone::transitionEachZone: skip 2 zones When testing zones "America/Mazatlan" and "Mexico/BajaSur" the test crashes from an assert. Skip testing the zones for now. Task-number: QTBUG-69132 Change-Id: I595089647792e9a2c094d63cb837584b8cdc9cb9 Reviewed-by: Jesus Fernandez --- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index 29efd8fb4a..ed80d4528d 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -507,6 +507,10 @@ void tst_QTimeZone::transitionEachZone() && zone == "Europe/Samara" && i == -3) { continue; } +#endif +#ifdef Q_OS_ANDROID + if (zone == "America/Mazatlan" || zone == "Mexico/BajaSur") + QSKIP("Crashes on Android, see QTBUG-69132"); #endif qint64 here = secs + i * 3600; QDateTime when = QDateTime::fromMSecsSinceEpoch(here * 1000, named); -- cgit v1.2.3 From 3079b3433d770833949d998f96800ad4e7c63aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Jun 2018 12:26:39 +0200 Subject: Android: tst_qtimezone: Blacklist a bunch Task-number: QTBUG-69122 Task-number: QTBUG-69128 Task-number: QTBUG-69129 Task-number: QTBUG-69131 Change-Id: Ida626a6675764e9554785b5e56cfba3ab7206f17 Reviewed-by: Jesus Fernandez --- tests/auto/corelib/tools/qtimezone/BLACKLIST | 171 +++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 tests/auto/corelib/tools/qtimezone/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/tools/qtimezone/BLACKLIST new file mode 100644 index 0000000000..840c3b1181 --- /dev/null +++ b/tests/auto/corelib/tools/qtimezone/BLACKLIST @@ -0,0 +1,171 @@ +# QTBUG-69122 +[dataStreamTest] +android + +# QTBUG-69128 +[isTimeZoneIdAvailable] +android + +# QTBUG-69129 +[specificTransition] +android + +# QTBUG-69131 +[transitionEachZone:America/Cancun@2010] +android +[transitionEachZone:America/Eirunepe@2010] +android +[transitionEachZone:America/Montevideo@2010] +android +[transitionEachZone:America/Porto_Acre@2010] +android +[transitionEachZone:America/Rio_Branco@2010] +android +[transitionEachZone:Asia/Anadyr@2010] +android +[transitionEachZone:Asia/Chita@2010] +android +[transitionEachZone:Asia/Kamchatka@2010] +android +[transitionEachZone:Asia/Khandyga@2010] +android +[transitionEachZone:Asia/Magadan@2010] +android +[transitionEachZone:Asia/Novokuznetsk@2010] +android +[transitionEachZone:Asia/Pyongyang@2010] +android +[transitionEachZone:Asia/Ust-Nera@2010] +android +[transitionEachZone:Asia/Yerevan@2010] +android +[transitionEachZone:Europe/Kaliningrad@2010] +android +[transitionEachZone:Europe/Minsk@2010] +android +[transitionEachZone:Europe/Moscow@2010] +android +[transitionEachZone:Europe/Samara@2010] +android +[transitionEachZone:Europe/Simferopol@2010] +android +[transitionEachZone:Europe/Volgograd@2010] +android +[transitionEachZone:W-SU@2010] +android +[transitionEachZone:Africa/Bissau@1970] +android +[transitionEachZone:Africa/Juba@1970] +android +[transitionEachZone:Africa/Khartoum@1970] +android +[transitionEachZone:America/Metlakatla@1970] +android +[transitionEachZone:America/Montevideo@1970] +android +[transitionEachZone:America/Paramaribo@1970] +android +[transitionEachZone:America/Santarem@1970] +android +[transitionEachZone:America/Santo_Domingo@1970] +android +[transitionEachZone:Asia/Anadyr@1970] +android +[transitionEachZone:Asia/Bahrain@1970] +android +[transitionEachZone:Asia/Chita@1970] +android +[transitionEachZone:Asia/Dushanbe@1970] +android +[transitionEachZone:Asia/Ho_Chi_Minh@1970] +android +[transitionEachZone:Asia/Kathmandu@1970] +android +[transitionEachZone:Asia/Katmandu@1970] +android +[transitionEachZone:Asia/Kuala_Lumpur@1970] +android +[transitionEachZone:Asia/Magadan@1970] +android +[transitionEachZone:Asia/Novosibirsk@1970] +android +[transitionEachZone:Asia/Pontianak@1970] +android +[transitionEachZone:Asia/Pyongyang@1970] +android +[transitionEachZone:Asia/Qatar@1970] +android +[transitionEachZone:Asia/Qyzylorda@1970] +android +[transitionEachZone:Asia/Saigon@1970] +android +[transitionEachZone:Asia/Sakhalin@1970] +android +[transitionEachZone:Asia/Singapore@1970] +android +[transitionEachZone:Asia/Tashkent@1970] +android +[transitionEachZone:Asia/Thimbu@1970] +android +[transitionEachZone:Asia/Thimphu@1970] +android +[transitionEachZone:Asia/Ust-Nera@1970] +android +[transitionEachZone:Atlantic/Cape_Verde@1970] +android +[transitionEachZone:Chile/EasterIsland@1970] +android +[transitionEachZone:Europe/Kaliningrad@1970] +android +[transitionEachZone:Pacific/Bougainville@1970] +android +[transitionEachZone:Pacific/Easter@1970] +android +[transitionEachZone:Pacific/Enderbury@1970] +android +[transitionEachZone:Pacific/Galapagos@1970] +android +[transitionEachZone:Pacific/Kiritimati@1970] +android +[transitionEachZone:Pacific/Kosrae@1970] +android +[transitionEachZone:Pacific/Kwajalein@1970] +android +[transitionEachZone:Pacific/Nauru@1970] +android +[transitionEachZone:Pacific/Niue@1970] +android +[transitionEachZone:Singapore@1970] +android +[transitionEachZone:Brazil/Acre@2010] +android +[transitionEachZone:Pacific/Bougainville@2010] +android +[transitionEachZone:Africa/Algiers@1970] +android +[transitionEachZone:Africa/Monrovia@1970] +android +[transitionEachZone:Kwajalein@1970] +android +[transitionEachZone:Indian/Chagos@1970] +android +[transitionEachZone:Europe/Volgograd@1970] +android +[transitionEachZone:Atlantic/Stanley@1970] +android +[transitionEachZone:Antarctica/Mawson@1970] +android +[transitionEachZone:America/Swift_Current@1970] +android +[transitionEachZone:America/Guyana@1970] +android +[transitionEachZone:America/Grand_Turk@1970] +android +[transitionEachZone:America/Dawson_Creek@1970] +android +[transitionEachZone:America/Cancun@1970] +android +[transitionEachZone:America/Caracas@1970] +android +[transitionEachZone:America/Danmarkshavn@1970] +android -- cgit v1.2.3 From 27ea5a65dd3fdabdad1569f5330f90248cdca4f5 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 25 Jun 2018 15:50:35 +0200 Subject: QAbstractItemModelTester: fix out-of-bounds index() calls When removing rows, the tester is looking at the data of the row "just before" and the row "just after" the removed rows, to see if they are still the same at the end of the removal operation. Guard this with bounds check, in case there is no row just before or just after. This is the opportunity to use modeltester in tst_qidentityproxymodel, which was already a testcase for removing the only row in a given parent. Change-Id: Iec8228c16b9c670b794e2665356d153679178494 Reviewed-by: Giuseppe D'Angelo --- .../qidentityproxymodel/tst_qidentityproxymodel.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index f8c5c92677..262c6dd9c8 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -26,9 +26,12 @@ ** ****************************************************************************/ -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "dynamictreemodel.h" #include "qidentityproxymodel.h" @@ -76,6 +79,7 @@ protected: private: QStandardItemModel *m_model; QIdentityProxyModel *m_proxy; + QAbstractItemModelTester *m_modelTest; }; tst_QIdentityProxyModel::tst_QIdentityProxyModel() @@ -88,12 +92,14 @@ void tst_QIdentityProxyModel::initTestCase() qRegisterMetaType >(); m_model = new QStandardItemModel(0, 1); m_proxy = new QIdentityProxyModel(); + m_modelTest = new QAbstractItemModelTester(m_proxy, this); } void tst_QIdentityProxyModel::cleanupTestCase() { delete m_proxy; delete m_model; + delete m_modelTest; } void tst_QIdentityProxyModel::cleanup() -- cgit v1.2.3 From 4d73ab73c81fff83e4423f0d3c918781587f14bf Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 23 Apr 2018 14:10:01 +0300 Subject: Return a correct filter from QFileDialog::selectedMimeTypeFilter() QFileDialog::selectedMimeTypeFilter() returns either an empty filter in the case when a platform file dialog doesn't implement mime type filters, or initiallySelectedMimeTypeFilter() in the case of Qt's file dialog. In both cases the result is incorrect. Make it return a mime type filter corresponding to a selected name filter. As a result, tst_QFiledialog::setMimeTypeFilters() has to be fixed: QFileDialog::selectMimeTypeFilter() can't select a name filter for an invalid mime type, and "application/json" is not supported by RHEL 6.6, so replace it by "application/pdf". Change-Id: I58d3be860a9b5e8a72cba86d74b520178115a812 Reviewed-by: David Faure --- tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index c3bdf3701f..47d63b7d53 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1049,12 +1049,12 @@ void tst_QFiledialog::setMimeTypeFilters_data() QTest::addColumn("expectedSelectedMimeTypeFilter"); const auto headerMime = QStringLiteral("text/x-chdr"); - const auto jsonMime = QStringLiteral("application/json"); + const auto pdfMime = QStringLiteral("application/pdf"); const auto zipMime = QStringLiteral("application/zip"); QTest::newRow("single mime filter (C header file)") << QStringList {headerMime} << headerMime << headerMime; - QTest::newRow("single mime filter (JSON file)") << QStringList {jsonMime} << jsonMime << jsonMime; - QTest::newRow("multiple mime filters") << QStringList {jsonMime, zipMime} << jsonMime << jsonMime; + QTest::newRow("single mime filter (JSON file)") << QStringList {pdfMime} << pdfMime << pdfMime; + QTest::newRow("multiple mime filters") << QStringList {pdfMime, zipMime} << pdfMime << pdfMime; } void tst_QFiledialog::setMimeTypeFilters() @@ -1068,6 +1068,10 @@ void tst_QFiledialog::setMimeTypeFilters() fd.selectMimeTypeFilter(targetMimeTypeFilter); QCOMPARE(fd.selectedMimeTypeFilter(), expectedSelectedMimeTypeFilter); + + auto *filters = fd.findChild("fileTypeCombo"); + filters->setCurrentIndex(filters->count() - 1); + QCOMPARE(fd.selectedMimeTypeFilter(), mimeTypeFilters.last()); } void tst_QFiledialog::setEmptyNameFilter() -- cgit v1.2.3 From 79955402924ea21b564cc5eadb624eaa60bdaa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Jun 2018 15:50:28 +0200 Subject: tst_qthreadpool: Skip "stackSize" if unsupported If you're on a Unix platform which don't have the necessary defines then the thread will never be launched due to an error. Skip the test instead. Change-Id: I83159988b8f330a750c7aa328a8805e4fa478070 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 1092216fb7..838431cd5a 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -32,6 +32,10 @@ #include #include +#ifdef Q_OS_UNIX +#include +#endif + typedef void (*FunctionPointer)(); class FunctionPointerTask : public QRunnable @@ -1145,6 +1149,10 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish() // stack size used by the native thread. void tst_QThreadPool::stackSize() { +#if defined(Q_OS_UNIX) && !(defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0 > 0)) + QSKIP("Setting stack size is unsupported on this platform."); +#endif + uint targetStackSize = 512 * 1024; uint threadStackSize = 1; // impossible value -- cgit v1.2.3 From 8a73085a0dc1bdb6d25ac4afcd5429018b55b967 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 25 Jun 2018 17:55:54 +0200 Subject: QSortFilterProxyModel unittest: add test for filtered-out-after-setData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The row names for this test were very unspecific. After reverse-engineering what they are testing, I gave them proper descriptive names, which allowed me to notice that there were tests for "filtered in after sourceModel->setData" but not for "filtered out after sourceModel->setData". Change-Id: Ib79108db803ae77fb65d29cf0c0ef96c26655980 Reviewed-by: Christian Ehrlicher Reviewed-by: Thorbjørn Lund Martsum --- .../tst_qsortfilterproxymodel.cpp | 39 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 296442b0c7..a7ab1e20d9 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -1894,6 +1894,7 @@ void tst_QSortFilterProxyModel::changeSourceData_data() QTest::addColumn("sourceItems"); QTest::addColumn("sortOrder"); QTest::addColumn("filter"); + QTest::addColumn("expectedInitialProxyItems"); QTest::addColumn("dynamic"); QTest::addColumn("row"); QTest::addColumn("newValue"); @@ -1901,10 +1902,11 @@ void tst_QSortFilterProxyModel::changeSourceData_data() QTest::addColumn("insertIntervals"); QTest::addColumn("proxyItems"); - QTest::newRow("changeSourceData (1)") + QTest::newRow("move_to_end_ascending") << (QStringList() << "c" << "b" << "a") // sourceItems << static_cast(Qt::AscendingOrder) // sortOrder << "" // filter + << (QStringList() << "a" << "b" << "c") // expectedInitialProxyItems << true // dynamic << 2 // row << "z" // newValue @@ -1913,10 +1915,11 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << (QStringList() << "b" << "c" << "z") // proxyItems ; - QTest::newRow("changeSourceData (2)") + QTest::newRow("move_to_end_descending") << (QStringList() << "b" << "c" << "z") // sourceItems << static_cast(Qt::DescendingOrder) // sortOrder << "" // filter + << (QStringList() << "z" << "c" << "b") // expectedInitialProxyItems << true // dynamic << 1 // row << "a" // newValue @@ -1925,10 +1928,11 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << (QStringList() << "z" << "b" << "a") // proxyItems ; - QTest::newRow("changeSourceData (3)") + QTest::newRow("no_op_change") << (QStringList() << "a" << "b") // sourceItems << static_cast(Qt::DescendingOrder) // sortOrder << "" // filter + << (QStringList() << "b" << "a") // expectedInitialProxyItems << true // dynamic << 0 // row << "a" // newValue @@ -1937,10 +1941,11 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << (QStringList() << "b" << "a") // proxyItems ; - QTest::newRow("changeSourceData (4)") + QTest::newRow("filtered_out_value_stays_out") << (QStringList() << "a" << "b" << "c" << "d") // sourceItems << static_cast(Qt::AscendingOrder) // sortOrder << "a|c" // filter + << (QStringList() << "a" << "c") // expectedInitialProxyItems << true // dynamic << 1 // row << "x" // newValue @@ -1949,10 +1954,11 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << (QStringList() << "a" << "c") // proxyItems ; - QTest::newRow("changeSourceData (5)") + QTest::newRow("filtered_out_now_matches") << (QStringList() << "a" << "b" << "c" << "d") // sourceItems << static_cast(Qt::AscendingOrder) // sortOrder << "a|c|x" // filter + << (QStringList() << "a" << "c") // expectedInitialProxyItems << true // dynamic << 1 // row << "x" // newValue @@ -1961,10 +1967,24 @@ void tst_QSortFilterProxyModel::changeSourceData_data() << (QStringList() << "a" << "c" << "x") // proxyItems ; - QTest::newRow("changeSourceData (6)") + QTest::newRow("value_is_now_filtered_out") + << (QStringList() << "a" << "b" << "c" << "d") // sourceItems + << static_cast(Qt::AscendingOrder) // sortOrder + << "a|c" // filter + << (QStringList() << "a" << "c") // expectedInitialProxyItems + << true // dynamic + << 2 // row + << "x" // newValue + << (IntPairList() << IntPair(1, 1)) // removeIntervals + << IntPairList() // insertIntervals + << (QStringList() << "a") // proxyItems + ; + + QTest::newRow("non_dynamic_filter_does_not_update_sort") << (QStringList() << "c" << "b" << "a") // sourceItems << static_cast(Qt::AscendingOrder) // sortOrder << "" // filter + << (QStringList() << "a" << "b" << "c") // expectedInitialProxyItems << false // dynamic << 2 // row << "x" // newValue @@ -1979,6 +1999,7 @@ void tst_QSortFilterProxyModel::changeSourceData() QFETCH(QStringList, sourceItems); QFETCH(int, sortOrder); QFETCH(QString, filter); + QFETCH(QStringList, expectedInitialProxyItems); QFETCH(bool, dynamic); QFETCH(int, row); QFETCH(QString, newValue); @@ -2004,6 +2025,12 @@ void tst_QSortFilterProxyModel::changeSourceData() proxy.setFilterRegExp(filter); + QCOMPARE(proxy.rowCount(), expectedInitialProxyItems.count()); + for (int i = 0; i < expectedInitialProxyItems.count(); ++i) { + const QModelIndex index = proxy.index(i, 0, QModelIndex()); + QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), expectedInitialProxyItems.at(i)); + } + QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); -- cgit v1.2.3 From 6ee26c543ef0d74110c296c73384e1461aa017da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 26 Jun 2018 16:50:50 +0200 Subject: Android: Pass tst_QUuid Same issue as has been seen a few other places: path to executable being wrong, and then a crash when the paths are fixed. Change-Id: I77a596c6e52d2a02a69a6b9dfe91f878b3ffe07c Reviewed-by: Thiago Macieira --- tests/auto/corelib/plugin/quuid/tst_quuid.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index bad72c081b..16552059dd 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -94,7 +94,11 @@ void tst_QUuid::initTestCase() #if QT_CONFIG(process) // chdir to the directory containing our testdata, then refer to it with relative paths +#ifdef Q_OS_ANDROID + QString testdata_dir = QCoreApplication::applicationDirPath(); +#else // !Q_OS_ANDROID QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath(); +#endif QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); #endif @@ -401,6 +405,9 @@ void tst_QUuid::processUniqueness() #if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else +#ifdef Q_OS_ANDROID + QSKIP("This test crashes on Android"); +#endif QProcess process; QString processOneOutput; QString processTwoOutput; @@ -408,6 +415,8 @@ void tst_QUuid::processUniqueness() // Start it once #ifdef Q_OS_MAC process.start("testProcessUniqueness/testProcessUniqueness.app"); +#elif defined(Q_OS_ANDROID) + process.start("libtestProcessUniqueness.so"); #else process.start("testProcessUniqueness/testProcessUniqueness"); #endif @@ -417,6 +426,8 @@ void tst_QUuid::processUniqueness() // Start it twice #ifdef Q_OS_MAC process.start("testProcessUniqueness/testProcessUniqueness.app"); +#elif defined(Q_OS_ANDROID) + process.start("libtestProcessUniqueness.so"); #else process.start("testProcessUniqueness/testProcessUniqueness"); #endif -- cgit v1.2.3 From 568ee7da5ad603c65704c33cfea9526d61fb4c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 25 Jun 2018 16:45:39 +0200 Subject: Android: Pass tst_qlocale To make it run we make sure it finds the syslocaleapp, however since it causes a crash we skip the test that uses it... "formatTimeZone" was failing, but it is the exact same issue as in e08ba34f26197fb9893fd48a38bdd0dfff7d4a60, so we solve it the exact same way. Change-Id: Ifd5c796735775dad94acf55210cf18c0f4d375ca Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 375cecd521..884cff553c 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -168,14 +168,18 @@ tst_QLocale::tst_QLocale() void tst_QLocale::initTestCase() { #if QT_CONFIG(process) +# ifdef Q_OS_ANDROID + m_sysapp = QCoreApplication::applicationDirPath() + "/libsyslocaleapp.so"; +# else // !defined(Q_OS_ANDROID) const QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp"); QVERIFY2(!syslocaleapp_dir.isEmpty(), qPrintable(QStringLiteral("Cannot find 'syslocaleapp' starting from ") + QDir::toNativeSeparators(QDir::currentPath()))); m_sysapp = syslocaleapp_dir + QStringLiteral("/syslocaleapp"); -#ifdef Q_OS_WIN +# ifdef Q_OS_WIN m_sysapp += QStringLiteral(".exe"); -#endif +# endif +# endif // Q_OS_ANDROID const QFileInfo fi(m_sysapp); QVERIFY2(fi.exists() && fi.isExecutable(), qPrintable(QDir::toNativeSeparators(m_sysapp) @@ -502,6 +506,9 @@ void tst_QLocale::emptyCtor() #if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else +#ifdef Q_OS_ANDROID + QSKIP("This test crashes on Android"); +#endif #define TEST_CTOR(req_lc, exp_str) \ { \ /* Test constructor without arguments. Needs separate process */ \ @@ -1542,17 +1549,25 @@ void tst_QLocale::formatTimeZone() QSKIP("You must test using Central European (CET/CEST) time zone, e.g. TZ=Europe/Oslo"); } +#ifdef Q_OS_ANDROID // Only reports (general) zones as offsets (QTBUG-68837) + const QString cet(QStringLiteral("GMT+01:00")); + const QString cest(QStringLiteral("GMT+02:00")); +#else + const QString cet(QStringLiteral("CET")); + const QString cest(QStringLiteral("CEST")); +#endif + QDateTime dt6(QDate(2013, 1, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin")); #ifdef Q_OS_WIN QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue); #endif - QCOMPARE(enUS.toString(dt6, "t"), QLatin1String("CET")); + QCOMPARE(enUS.toString(dt6, "t"), cet); QDateTime dt7(QDate(2013, 6, 1), QTime(0, 0, 0), QTimeZone("Europe/Berlin")); #ifdef Q_OS_WIN QEXPECT_FAIL("", "QTimeZone windows backend only returns long name", Continue); #endif - QCOMPARE(enUS.toString(dt7, "t"), QLatin1String("CEST")); + QCOMPARE(enUS.toString(dt7, "t"), cest); // Current datetime should return current abbreviation QCOMPARE(enUS.toString(QDateTime::currentDateTime(), "t"), -- cgit v1.2.3 From d420987d54342e6933251e7db1012b8df8a83384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 5 Jun 2018 15:54:07 +0200 Subject: Android: fix tst_qlogging The "app" subfolder was already excluded in the .pro-file but Android supports QProcess, so lets include it in the build. Unfortunately it currently has trouble and crashes (the child process or both processes). So we skip those tests. Task-number: QTBUG-68596 Change-Id: I2e6d0869c408bf08b22c02145db8ce522c64c617 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/corelib/global/qlogging/qlogging.pro | 2 +- tests/auto/corelib/global/qlogging/tst_qlogging.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qlogging/qlogging.pro b/tests/auto/corelib/global/qlogging/qlogging.pro index 3f7c0a4074..bbe75297d5 100644 --- a/tests/auto/corelib/global/qlogging/qlogging.pro +++ b/tests/auto/corelib/global/qlogging/qlogging.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -!android:!winrt { +!winrt { test.depends = app SUBDIRS += app } diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 3465385ba7..e7a3748c30 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -101,7 +101,11 @@ tst_qmessagehandler::tst_qmessagehandler() void tst_qmessagehandler::initTestCase() { #if QT_CONFIG(process) +# ifdef Q_OS_ANDROID + m_appDir = QCoreApplication::applicationDirPath(); +# else // !android m_appDir = QFINDTESTDATA("app"); +# endif QVERIFY2(!m_appDir.isEmpty(), qPrintable( QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath()))); @@ -818,12 +822,19 @@ void tst_qmessagehandler::qMessagePattern() #if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else +#ifdef Q_OS_ANDROID + QSKIP("This test crashes on Android"); +#endif QFETCH(QString, pattern); QFETCH(bool, valid); QFETCH(QList, expected); QProcess process; +#ifdef Q_OS_ANDROID + const QString appExe = m_appDir + "/libapp.so"; +#else // !android const QString appExe = m_appDir + "/app"; +#endif // // test QT_MESSAGE_PATTERN @@ -860,13 +871,20 @@ void tst_qmessagehandler::setMessagePattern() #if !QT_CONFIG(process) QSKIP("This test requires QProcess support"); #else +#ifdef Q_OS_ANDROID + QSKIP("This test crashes on Android"); +#endif // // test qSetMessagePattern // QProcess process; +#ifdef Q_OS_ANDROID + const QString appExe = m_appDir + "/libapp.so"; +#else // !android const QString appExe = m_appDir + "/app"; +#endif // make sure there is no QT_MESSAGE_PATTERN in the environment QStringList environment = m_baseEnvironment; -- cgit v1.2.3 From 8757e6fee11fbd72c1a3ade1aea0800f63b966ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 6 Jun 2018 16:13:48 +0200 Subject: Android: Make tst_qfile pass By disabling the "stdinprocess"-related tests/code... ... but differently. After fixing my earlier mistakes I'm getting segmentation faults when it executes a couple different library calls after the QProcess object has started. Task-number: QTBUG-68596 Change-Id: Id42a1f939c000754a187dee90c4a4cdfec816232 Reviewed-by: Frederik Gladhorn Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index c202923898..6665200585 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -379,6 +379,12 @@ private: QString m_noEndOfLineFile; }; +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + #define STDINPROCESS_NAME "libstdinprocess.so" +#else // !android || android_embedded + #define STDINPROCESS_NAME "stdinprocess" +#endif // android && !android_embededd + static const char noReadFile[] = "noreadfile"; static const char readOnlyFile[] = "readonlyfile"; @@ -448,7 +454,11 @@ void tst_QFile::initTestCase() { QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); #if QT_CONFIG(process) +#if defined(Q_OS_ANDROID) + m_stdinProcessDir = QCoreApplication::applicationDirPath(); +#else m_stdinProcessDir = QFINDTESTDATA("stdinprocess"); +#endif QVERIFY(!m_stdinProcessDir.isEmpty()); #endif m_testLogFile = QFINDTESTDATA("testlog.txt"); @@ -964,11 +974,14 @@ void tst_QFile::readAllStdin() #if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else +#if defined(Q_OS_ANDROID) + QSKIP("This test crashes when doing nanosleep. See QTBUG-69034."); +#endif QByteArray lotsOfData(1024, '@'); // 10 megs QProcess process; StdinReaderProcessGuard processGuard(&process); - process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"), QStringList(QStringLiteral("all"))); + process.start(m_stdinProcessDir + QStringLiteral("/" STDINPROCESS_NAME), QStringList(QStringLiteral("all"))); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); for (int i = 0; i < 5; ++i) { QTest::qWait(1000); @@ -987,6 +1000,9 @@ void tst_QFile::readLineStdin() #if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else +#if defined(Q_OS_ANDROID) + QSKIP("This test crashes when doing nanosleep. See QTBUG-69034."); +#endif QByteArray lotsOfData(1024, '@'); // 10 megs for (int i = 0; i < lotsOfData.size(); ++i) { if ((i % 32) == 31) @@ -998,7 +1014,7 @@ void tst_QFile::readLineStdin() for (int i = 0; i < 2; ++i) { QProcess process; StdinReaderProcessGuard processGuard(&process); - process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"), + process.start(m_stdinProcessDir + QStringLiteral("/" STDINPROCESS_NAME), QStringList() << QStringLiteral("line") << QString::number(i), QIODevice::Text | QIODevice::ReadWrite); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); @@ -1028,10 +1044,13 @@ void tst_QFile::readLineStdin_lineByLine() #if !QT_CONFIG(process) QSKIP("No qprocess support", SkipAll); #else +#if defined(Q_OS_ANDROID) + QSKIP("This test crashes when calling ::poll. See QTBUG-69034."); +#endif for (int i = 0; i < 2; ++i) { QProcess process; StdinReaderProcessGuard processGuard(&process); - process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"), + process.start(m_stdinProcessDir + QStringLiteral("/" STDINPROCESS_NAME), QStringList() << QStringLiteral("line") << QString::number(i), QIODevice::Text | QIODevice::ReadWrite); QVERIFY2(process.waitForStarted(), qPrintable(process.errorString())); -- cgit v1.2.3 From 626ab2ab89f17c219c567009b4f3fb6fbae8477f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 27 Jun 2018 14:28:48 +0200 Subject: Android: Blacklist some cases in tst_qwindow Task-number: QTBUG-69154 Task-number: QTBUG-69155 Task-number: QTBUG-69156 Task-number: QTBUG-69157 Task-number: QTBUG-69159 Task-number: QTBUG-69160 Task-number: QTBUG-69161 Task-number: QTBUG-69162 Task-number: QTBUG-69163 Change-Id: Ie44de7fd3f4871bebcaadcc4a8735bf47692ea49 Reviewed-by: Jesus Fernandez --- tests/auto/gui/kernel/qwindow/BLACKLIST | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index 70091121bc..df02b5b33e 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -7,14 +7,22 @@ osx-10.12 ci ubuntu-16.04 # QTBUG-66851 opensuse +# QTBUG-69160 +android [setVisible] +# QTBUG-69154 +android [modalWindowEnterEventOnHide_QTBUG35109] ubuntu-16.04 osx ci +# QTBUG-69162 +android [modalDialogClosingOneOfTwoModal] osx [modalWindowModallity] osx +# QTBUG-69163 +android [visibility] osx-10.11 ci osx-10.12 ci @@ -24,3 +32,18 @@ rhel-7.4 [isActive] # QTBUG-67768 ubuntu +# QTBUG-69157 +android + +[exposeEventOnShrink_QTBUG54040] +# QTBUG-69155 +android +[initialSize] +# QTBUG-69159 +android +[modalWindowPosition] +# QTBUG-69161 +android +[childWindowPositioning:show] +# QTBUG-69156 +android -- cgit v1.2.3 From d5fd308d1fdd15339590def21a1dde7c36def018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 27 Jun 2018 15:05:14 +0200 Subject: Android: Blacklist tst_QPainter::textOnTransparentImage Task-number: QTBUG-69166 Change-Id: I16289801ff64b09894a5379a584270b53ad7e105 Reviewed-by: Jesus Fernandez --- tests/auto/gui/painting/qpainter/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/gui/painting/qpainter/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/gui/painting/qpainter/BLACKLIST b/tests/auto/gui/painting/qpainter/BLACKLIST new file mode 100644 index 0000000000..b828cbc75e --- /dev/null +++ b/tests/auto/gui/painting/qpainter/BLACKLIST @@ -0,0 +1,3 @@ +[textOnTransparentImage] +# QTBUG-69166 +android -- cgit v1.2.3 From 0ac09c40f28987169786b3063af423e9fe93c6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 28 Jun 2018 11:55:42 +0200 Subject: Android: Pass tst_qlibrary To make the minimum amount of changes: - Extract the library files into the expected hierarchy. - Introduce a variable with the path to the directory. - Make the static function a member function so it can use the variable Change-Id: Ibf3106c3606d198a8deb8cb2a5cbde57207221c7 Reviewed-by: Thiago Macieira --- tests/auto/corelib/plugin/qlibrary/tst/tst.pro | 11 ++++ .../auto/corelib/plugin/qlibrary/tst_qlibrary.cpp | 61 ++++++++++++++++------ 2 files changed, 57 insertions(+), 15 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro index 6e71ec8ff9..56bef14405 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro +++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro @@ -12,3 +12,14 @@ win32 { } TESTDATA += ../library_path/invalid.so + +android { + libs.prefix = android_test_data + libs.base = $$OUT_PWD/.. + libs.files += $$OUT_PWD/../libmylib.so \ + $$OUT_PWD/../libmylib.so2 \ + $$OUT_PWD/../libmylib.prl \ + $$OUT_PWD/../system.qt.test.mylib.so + + RESOURCES += libs +} diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index 72d60d71c7..c9c9202a80 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -88,12 +88,6 @@ # define PREFIX "lib" #endif -static QString sys_qualifiedLibraryName(const QString &fileName) -{ - QString appDir = QCoreApplication::applicationDirPath(); - return appDir + QLatin1Char('/') + PREFIX + fileName + SUFFIX; -} - QT_FORWARD_DECLARE_CLASS(QLibrary) class tst_QLibrary : public QObject { @@ -106,6 +100,13 @@ enum QLibraryOperation { OperationMask = 7, DontSetFileName = 0x100 }; + + QString sys_qualifiedLibraryName(const QString &fileName); + + QString directory; +#ifdef Q_OS_ANDROID + QSharedPointer temporaryDir; +#endif private slots: void initTestCase(); @@ -130,19 +131,49 @@ private slots: void multipleInstancesForOneLibrary(); }; +QString tst_QLibrary::sys_qualifiedLibraryName(const QString &fileName) +{ + return directory + QLatin1Char('/') + PREFIX + fileName + SUFFIX; +} + typedef int (*VersionFunction)(void); void tst_QLibrary::initTestCase() { -#ifndef Q_OS_WINRT +#ifdef Q_OS_ANDROID + auto tempDir = QEXTRACTTESTDATA("android_test_data"); + + QVERIFY2(QDir::setCurrent(tempDir->path()), qPrintable("Could not chdir to " + tempDir->path())); + + // copy :/library_path into ./library_path + QVERIFY(QDir().mkdir("library_path")); + QDirIterator iterator(":/library_path", QDirIterator::Subdirectories); + while (iterator.hasNext()) { + iterator.next(); + QFileInfo sourceFileInfo(iterator.path()); + QFileInfo targetFileInfo("./library_path/" + sourceFileInfo.fileName()); + if (!targetFileInfo.exists()) { + QDir().mkpath(targetFileInfo.path()); + QVERIFY(QFile::copy(sourceFileInfo.filePath(), targetFileInfo.filePath())); + } + } + directory = tempDir->path(); + temporaryDir = std::move(tempDir); +#elif !defined(Q_OS_WINRT) // chdir to our testdata directory, and use relative paths in some tests. QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath(); QVERIFY2(QDir::setCurrent(testdatadir), qPrintable("Could not chdir to " + testdatadir)); + directory = QCoreApplication::applicationDirPath(); +#elif defined(Q_OS_WINRT) + directory = QCoreApplication::applicationDirPath(); #endif } void tst_QLibrary::version_data() { +#ifdef Q_OS_ANDROID + QSKIP("Versioned .so files are not generated for Android, so this test is not applicable."); +#endif QTest::addColumn("lib"); QTest::addColumn("loadversion"); QTest::addColumn("resultversion"); @@ -159,7 +190,7 @@ void tst_QLibrary::version() QFETCH( int, resultversion ); #if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) - QString appDir = QCoreApplication::applicationDirPath(); + QString appDir = directory; QLibrary library( appDir + QLatin1Char('/') + lib, loadversion ); QVERIFY2(library.load(), qPrintable(library.errorString())); @@ -179,7 +210,7 @@ void tst_QLibrary::load_data() QTest::addColumn("lib"); QTest::addColumn("result"); - QString appDir = QCoreApplication::applicationDirPath(); + QString appDir = directory; QTest::newRow( "ok00" ) << appDir + "/mylib" << true; QTest::newRow( "notexist" ) << appDir + "/nolib" << false; @@ -220,7 +251,7 @@ void tst_QLibrary::unload_data() QTest::addColumn("lib"); QTest::addColumn("result"); - QString appDir = QCoreApplication::applicationDirPath(); + QString appDir = directory; QTest::newRow( "mylib" ) << appDir + "/mylib" << true; QTest::newRow( "ok01" ) << appDir + "/nolib" << false; @@ -243,7 +274,7 @@ void tst_QLibrary::unload() void tst_QLibrary::unload_after_implicit_load() { - QLibrary library( QCoreApplication::applicationDirPath() + "/mylib" ); + QLibrary library( directory + "/mylib" ); QFunctionPointer p = library.resolve("mylibversion"); QVERIFY(p); // Check if it was loaded QVERIFY(library.isLoaded()); @@ -257,7 +288,7 @@ void tst_QLibrary::resolve_data() QTest::addColumn("symbol"); QTest::addColumn("goodPointer"); - QString appDir = QCoreApplication::applicationDirPath(); + QString appDir = directory; QTest::newRow( "ok00" ) << appDir + "/mylib" << QString("mylibversion") << true; QTest::newRow( "bad00" ) << appDir + "/mylib" << QString("nosym") << false; @@ -333,7 +364,7 @@ void tst_QLibrary::errorString_data() QTest::addColumn("success"); QTest::addColumn("errorString"); - QString appDir = QCoreApplication::applicationDirPath(); + QString appDir = directory; QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); @@ -398,7 +429,7 @@ void tst_QLibrary::loadHints_data() QLibrary::LoadHints lh; - QString appDir = QCoreApplication::applicationDirPath(); + QString appDir = directory; lh |= QLibrary::ResolveAllSymbolsHint; # if defined(Q_OS_WIN32) || defined(Q_OS_WINRT) @@ -477,7 +508,7 @@ void tst_QLibrary::fileName() void tst_QLibrary::multipleInstancesForOneLibrary() { - QString lib = QCoreApplication::applicationDirPath() + "/mylib"; + QString lib = directory + "/mylib"; { QLibrary lib1(lib); -- cgit v1.2.3 From 35e005bc4fd790d41a5b5248e85bbdac33fbf043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= Date: Sat, 30 Jun 2018 13:53:03 +0200 Subject: Fix metatype trait for types that are both QObject and Q_GADGET Fixes ambiguous template instantiation for types that derive from both a QObject and Q_GADGET. For such types we treat them only as QObjects as they extend the functionality of the gadget. Task-number: QTBUG-68803 Change-Id: Ic42766034e14e5df43c4e6f7811e2c0be1dc7e74 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index c6fd5d17c2..e312199980 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1696,11 +1696,21 @@ public: Q_ENUM(MyEnum) }; +class MyQObjectFromGadget : public QObject, public MyGadget +{ + Q_OBJECT +public: + MyQObjectFromGadget(QObject *parent = 0) + : QObject(parent) + {} +}; + Q_DECLARE_METATYPE(MyGadget); Q_DECLARE_METATYPE(MyGadget*); Q_DECLARE_METATYPE(const QMetaObject *); Q_DECLARE_METATYPE(Qt::ScrollBarPolicy); Q_DECLARE_METATYPE(MyGadget::MyEnum); +Q_DECLARE_METATYPE(MyQObjectFromGadget*); void tst_QMetaType::metaObject_data() { @@ -1719,6 +1729,7 @@ void tst_QMetaType::metaObject_data() QTest::newRow("MyGadget*") << ::qMetaTypeId() << &MyGadget::staticMetaObject << false << true << false; QTest::newRow("MyEnum") << ::qMetaTypeId() << &MyGadget::staticMetaObject << false << false << false; QTest::newRow("Qt::ScrollBarPolicy") << ::qMetaTypeId() << &QObject::staticQtMetaObject << false << false << false; + QTest::newRow("MyQObjectFromGadget*") << ::qMetaTypeId() << &MyQObjectFromGadget::staticMetaObject << false << false << true; QTest::newRow("GadgetDerivedAndTyped") << ::qMetaTypeId>() << &GadgetDerivedAndTyped::staticMetaObject << true << false << false; QTest::newRow("GadgetDerivedAndTyped*") << ::qMetaTypeId*>() << &GadgetDerivedAndTyped::staticMetaObject << false << true << false; -- cgit v1.2.3 From e75e4b39b78ba05ea2cd45dc96acf99fc89c5915 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 30 Jun 2018 19:03:48 +0200 Subject: Reduce amount of log output of the qcomplextext autotest Writing out one test result per line in the test data files is excessive and only bloats the log, given that this algorithm is rarely changed. Task-number: QTQAINFRA-2037 Change-Id: Ib9e568c7ded73d45e4b64671e97d5581a74f8f93 Reviewed-by: Thiago Macieira --- tests/auto/other/qcomplextext/tst_qcomplextext.cpp | 144 ++++++++------------- 1 file changed, 56 insertions(+), 88 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp index 812cd8f369..0116e546a0 100644 --- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp @@ -48,9 +48,7 @@ private slots: void bidiInvalidCursorNoMovement_data(); void bidiInvalidCursorNoMovement(); - void bidiCharacterTest_data(); void bidiCharacterTest(); - void bidiTest_data(); void bidiTest(); }; @@ -279,67 +277,6 @@ void tst_QComplexText::bidiCursor_PDF() QVERIFY(line.cursorToX(size) == line.cursorToX(size - 1)); } -void tst_QComplexText::bidiCharacterTest_data() -{ - QTest::addColumn("data"); - QTest::addColumn("paragraphDirection"); - QTest::addColumn>("resolvedLevels"); - QTest::addColumn>("visualOrder"); - - QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt"); - QFile f(testFile); - QVERIFY(f.exists()); - - f.open(QIODevice::ReadOnly); - - int linenum = 0; - while (!f.atEnd()) { - linenum++; - - QByteArray line = f.readLine().simplified(); - if (line.startsWith('#') || line.isEmpty()) - continue; - QVERIFY(!line.contains('#')); - - QList parts = line.split(';'); - QVERIFY(parts.size() == 5); - - QString data; - QList dataParts = parts.at(0).split(' '); - for (const auto &p : dataParts) { - bool ok; - data += QChar((ushort)p.toInt(&ok, 16)); - QVERIFY(ok); - } - - int paragraphDirection = parts.at(1).toInt(); -// int resolvedParagraphLevel = parts.at(2).toInt(); - - QVector resolvedLevels; - QList levelParts = parts.at(3).split(' '); - for (const auto &p : levelParts) { - if (p == "x") { - resolvedLevels += -1; - } else { - bool ok; - resolvedLevels += p.toInt(&ok); - QVERIFY(ok); - } - } - - QVector visualOrder; - QList orderParts = parts.at(4).split(' '); - for (const auto &p : orderParts) { - bool ok; - visualOrder += p.toInt(&ok); - QVERIFY(ok); - } - - const QByteArray nm = "line #" + QByteArray::number(linenum); - QTest::newRow(nm.constData()) << data << paragraphDirection << resolvedLevels << visualOrder; - } -} - static void testBidiString(const QString &data, int paragraphDirection, const QVector &resolvedLevels, const QVector &visualOrder) { Q_UNUSED(resolvedLevels); @@ -421,12 +358,59 @@ static void testBidiString(const QString &data, int paragraphDirection, const QV void tst_QComplexText::bidiCharacterTest() { - QFETCH(QString, data); - QFETCH(int, paragraphDirection); - QFETCH(QVector, resolvedLevels); - QFETCH(QVector, visualOrder); + QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt"); + QFile f(testFile); + QVERIFY(f.exists()); + + f.open(QIODevice::ReadOnly); + + int linenum = 0; + while (!f.atEnd()) { + linenum++; + + QByteArray line = f.readLine().simplified(); + if (line.startsWith('#') || line.isEmpty()) + continue; + QVERIFY(!line.contains('#')); + + QList parts = line.split(';'); + QVERIFY(parts.size() == 5); - testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); + QString data; + QList dataParts = parts.at(0).split(' '); + for (const auto &p : dataParts) { + bool ok; + data += QChar((ushort)p.toInt(&ok, 16)); + QVERIFY(ok); + } + + int paragraphDirection = parts.at(1).toInt(); +// int resolvedParagraphLevel = parts.at(2).toInt(); + + QVector resolvedLevels; + QList levelParts = parts.at(3).split(' '); + for (const auto &p : levelParts) { + if (p == "x") { + resolvedLevels += -1; + } else { + bool ok; + resolvedLevels += p.toInt(&ok); + QVERIFY(ok); + } + } + + QVector visualOrder; + QList orderParts = parts.at(4).split(' '); + for (const auto &p : orderParts) { + bool ok; + visualOrder += p.toInt(&ok); + QVERIFY(ok); + } + + const QByteArray nm = "line #" + QByteArray::number(linenum); + + testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); + } } ushort unicodeForDirection(const QByteArray &direction) @@ -466,13 +450,8 @@ ushort unicodeForDirection(const QByteArray &direction) Q_UNREACHABLE(); } -void tst_QComplexText::bidiTest_data() +void tst_QComplexText::bidiTest() { - QTest::addColumn("data"); - QTest::addColumn("paragraphDirection"); - QTest::addColumn>("resolvedLevels"); - QTest::addColumn>("visualOrder"); - QString testFile = QFINDTESTDATA("data/BidiTest.txt"); QFile f(testFile); QVERIFY(f.exists()); @@ -534,24 +513,13 @@ void tst_QComplexText::bidiTest_data() const QByteArray nm = "line #" + QByteArray::number(linenum); if (paragraphDirections & 1) - QTest::newRow((nm + " (Auto)").constData()) << data << 2 << resolvedLevels << visualOrder; + testBidiString(data, 2, resolvedLevels, visualOrder); if (paragraphDirections & 2) - QTest::newRow((nm + " (LTR)").constData()) << data << 0 << resolvedLevels << visualOrder; + testBidiString(data, 0, resolvedLevels, visualOrder); if (paragraphDirections & 4) - QTest::newRow((nm + " (RTL)").constData()) << data << 1 << resolvedLevels << visualOrder; + testBidiString(data, 1, resolvedLevels, visualOrder); } - -} - -void tst_QComplexText::bidiTest() -{ - QFETCH(QString, data); - QFETCH(int, paragraphDirection); - QFETCH(QVector, resolvedLevels); - QFETCH(QVector, visualOrder); - - testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); } -- cgit v1.2.3