diff options
author | Liang Qi <liang.qi@qt.io> | 2018-06-30 22:59:21 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-07-02 11:23:45 +0200 |
commit | e3ed2281c0c891cf3b15c95f9f7cdae42e9f233a (patch) | |
tree | aae8da6ce616eae02b69fb1fcdcb4383c8fe6811 /tests/auto | |
parent | 3be141d5bc199080b524d8f6f5ce514e8f74d23a (diff) | |
parent | e75e4b39b78ba05ea2cd45dc96acf99fc89c5915 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/plugins/platforms/cocoa/qnsview.mm
src/plugins/platforms/cocoa/qnsview_dragging.mm
src/plugins/platforms/ios/qiosinputcontext.mm
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp
src/tools/androiddeployqt/main.cpp
Was moved from qttools into qtbase in 5.11.
So re-apply 32398e4d here.
tests/auto/corelib/global/qlogging/test/test.pro
tests/auto/corelib/global/qlogging/tst_qlogging.cpp
tests/auto/corelib/io/qfile/tst_qfile.cpp
tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
tests/auto/corelib/thread/qthreadstorage/test/test.pro
tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
tests/auto/widgets/kernel/qapplication/test/test.pro
Done-with: Gatis Paeglis <gatis.paeglis@qt.io>
Done-with: Mårten Nordheim <marten.nordheim@qt.io>
Done-with: Oliver Wolff <oliver.wolff@qt.io>
Change-Id: Id970486c5315a1718c540f00deb2633533e8fc7b
Diffstat (limited to 'tests/auto')
46 files changed, 916 insertions, 385 deletions
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 <stephen.kelly@kdab.com> +** 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 <QtTest> +#include <QWindow> + +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/compilerwarnings/data/test_cpp.txt b/tests/auto/cmake/test_use_modules_function/two.cpp index 6ea63f56fd..44eb7fe96e 100644 --- a/tests/auto/compilerwarnings/data/test_cpp.txt +++ b/tests/auto/cmake/test_use_modules_function/two.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -26,29 +26,18 @@ ** ****************************************************************************/ +#include <QtTest> -#include <QtCore/QtCore> -#include <QtNetwork/QtNetwork> -#include <QtXml/QtXml> -#include <QtSql/QtSql> - -#ifndef QT_NO_GUI -#include <QtGui/QtGui> -#endif - -#ifndef QT_NO_OPENGL -#include <QtOpenGL/QtOpenGL> -#endif +class Two : public QObject +{ + Q_OBJECT +public: + Two(QObject *parent = 0) + { -#include <QtTest/QtTest> + } +}; -#if !defined(QT_NO_DBUS) && defined(Q_OS_UNIX) -#include <QtDBus/QtDBus> -#endif +QTEST_MAIN(Two) -#ifndef Q_OS_MAC -int main(int, char **) -{ - return 0; -} -#endif +#include "two.moc" diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro index 8dafc4509c..91896d4494 100644 --- a/tests/auto/corelib/global/qlogging/test/test.pro +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -4,14 +4,14 @@ qtConfig(c++14): CONFIG += c++14 debug_and_release { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qlogging - !winrt: TEST_HELPER_INSTALLS = ../debug/helper + !android:!winrt: TEST_HELPER_INSTALLS = ../debug/helper } else { TARGET = ../../release/tst_qlogging - !winrt: TEST_HELPER_INSTALLS = ../release/helper + !android:!winrt: TEST_HELPER_INSTALLS = ../release/helper } } else { TARGET = ../tst_qlogging - !winrt: TEST_HELPER_INSTALLS = ../helper + !android:!winrt: TEST_HELPER_INSTALLS = ../helper } QT = core testlib diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index 863582f498..d3ed1a6d0d 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -813,12 +813,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<QByteArray>, expected); QProcess process; +#ifndef Q_OS_ANDROID const QString appExe(QLatin1String("helper")); +#else + const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so")); +#endif // // test QT_MESSAGE_PATTERN @@ -855,13 +862,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; +#ifndef Q_OS_ANDROID const QString appExe(QLatin1String("helper")); +#else + const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so")); +#endif // make sure there is no QT_MESSAGE_PATTERN in the environment QStringList environment = m_baseEnvironment; 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/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 @@ <!DOCTYPE RCC><RCC version="1.0"> -<qresource> +<qresource prefix="/testdata/"> <file>entrylist/file</file> <file>entrylist/directory/dummy</file> </qresource> 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<QStringList>("nameFilters"); QTest::addColumn<QStringList>("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() diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index a61b7cc573..41c9871e26 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 <stdio.h> #include <errno.h> +#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 @@ -442,10 +448,12 @@ void tst_QFile::initTestCase() { QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); #if QT_CONFIG(process) -#ifndef Q_OS_WIN - m_stdinProcess = QFINDTESTDATA("stdinprocess_helper"); -#else +#if defined(Q_OS_ANDROID) + m_stdinProcess = QCoreApplication::applicationDirPath() + QLatin1String("/libstdinprocess_helper.so"); +#elif defined(Q_OS_WIN) m_stdinProcess = QFINDTESTDATA("stdinprocess_helper.exe"); +#else + m_stdinProcess = QFINDTESTDATA("stdinprocess_helper"); #endif QVERIFY(!m_stdinProcess.isEmpty()); #endif @@ -962,6 +970,9 @@ 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; @@ -985,6 +996,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) @@ -1026,6 +1040,9 @@ 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); 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 <QtTest/QtTest> -#include <QtCore/QCoreApplication> -#include <QtGui/QStandardItemModel> +#include <QAbstractItemModelTester> +#include <QCoreApplication> +#include <QSignalSpy> +#include <QStandardItemModel> +#include <QStringListModel> +#include <QTest> #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<QVector<int> >(); 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() diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 9bc558580b..a9138a6505 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -1898,6 +1898,7 @@ void tst_QSortFilterProxyModel::changeSourceData_data() QTest::addColumn<QStringList>("sourceItems"); QTest::addColumn<int>("sortOrder"); QTest::addColumn<QString>("filter"); + QTest::addColumn<QStringList>("expectedInitialProxyItems"); QTest::addColumn<bool>("dynamic"); QTest::addColumn<int>("row"); QTest::addColumn<QString>("newValue"); @@ -1905,10 +1906,11 @@ void tst_QSortFilterProxyModel::changeSourceData_data() QTest::addColumn<IntPairList>("insertIntervals"); QTest::addColumn<QStringList>("proxyItems"); - QTest::newRow("changeSourceData (1)") + QTest::newRow("move_to_end_ascending") << (QStringList() << "c" << "b" << "a") // sourceItems << static_cast<int>(Qt::AscendingOrder) // sortOrder << "" // filter + << (QStringList() << "a" << "b" << "c") // expectedInitialProxyItems << true // dynamic << 2 // row << "z" // newValue @@ -1917,10 +1919,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<int>(Qt::DescendingOrder) // sortOrder << "" // filter + << (QStringList() << "z" << "c" << "b") // expectedInitialProxyItems << true // dynamic << 1 // row << "a" // newValue @@ -1929,10 +1932,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<int>(Qt::DescendingOrder) // sortOrder << "" // filter + << (QStringList() << "b" << "a") // expectedInitialProxyItems << true // dynamic << 0 // row << "a" // newValue @@ -1941,10 +1945,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<int>(Qt::AscendingOrder) // sortOrder << "a|c" // filter + << (QStringList() << "a" << "c") // expectedInitialProxyItems << true // dynamic << 1 // row << "x" // newValue @@ -1953,10 +1958,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<int>(Qt::AscendingOrder) // sortOrder << "a|c|x" // filter + << (QStringList() << "a" << "c") // expectedInitialProxyItems << true // dynamic << 1 // row << "x" // newValue @@ -1965,10 +1971,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<int>(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<int>(Qt::AscendingOrder) // sortOrder << "" // filter + << (QStringList() << "a" << "b" << "c") // expectedInitialProxyItems << false // dynamic << 2 // row << "x" // newValue @@ -1983,6 +2003,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); @@ -2008,6 +2029,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); 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/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*>() << &MyGadget::staticMetaObject << false << true << false; QTest::newRow("MyEnum") << ::qMetaTypeId<MyGadget::MyEnum>() << &MyGadget::staticMetaObject << false << false << false; QTest::newRow("Qt::ScrollBarPolicy") << ::qMetaTypeId<Qt::ScrollBarPolicy>() << &QObject::staticQtMetaObject << false << false << false; + QTest::newRow("MyQObjectFromGadget*") << ::qMetaTypeId<MyQObjectFromGadget*>() << &MyQObjectFromGadget::staticMetaObject << false << false << true; QTest::newRow("GadgetDerivedAndTyped<int>") << ::qMetaTypeId<GadgetDerivedAndTyped<int>>() << &GadgetDerivedAndTyped<int>::staticMetaObject << true << false << false; QTest::newRow("GadgetDerivedAndTyped<int>*") << ::qMetaTypeId<GadgetDerivedAndTyped<int>*>() << &GadgetDerivedAndTyped<int>::staticMetaObject << false << true << false; diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 2d34aceab8..f004ec7856 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -78,102 +78,65 @@ private slots: void connectTo(); }; -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<QTimer *>(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(); @@ -183,7 +146,7 @@ void tst_QTimer::remainingTime() void tst_QTimer::remainingTimeDuringActivation_data() { QTest::addColumn<bool>("singleShot"); - QTest::newRow("repeating") << true; + QTest::newRow("repeating") << false; QTest::newRow("single-shot") << true; } @@ -191,29 +154,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))); } } @@ -234,47 +199,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 } @@ -449,47 +411,40 @@ signals: void tst_QTimer::recurringTimer_data() { QTest::addColumn<int>("interval"); - QTest::newRow("zero timer") << 0; - QTest::newRow("non-zero timer") << 1; + QTest::addColumn<bool>("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<QTimer> pointer = timer; - QTestEventLoop::instance().enterLoop(5); + QVERIFY(destroyedSpy.wait()); QVERIFY(pointer.isNull()); } @@ -691,23 +646,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 @@ -808,8 +774,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(); @@ -834,12 +799,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; @@ -850,8 +814,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(); @@ -862,8 +825,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; @@ -876,26 +838,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); @@ -903,12 +866,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 @@ -986,16 +947,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 { @@ -1024,7 +983,7 @@ void tst_QTimer::crossThreadSingleShotToFunctor() void tst_QTimer::connectTo() { QTimer timer; - TimerHelper timerHelper; + QSignalSpy timeoutSpy(&timer, &QTimer::timeout); timer.setInterval(0); timer.start(); @@ -1033,13 +992,12 @@ void tst_QTimer::connectTo() int count = 0; timer.connectTo([&count] { count++; }); QMetaObject::Connection connection = timer.connectTo(context, [&count] { count++; }); - timer.connectTo(&timerHelper, &TimerHelper::timeout); timer.connectTo(&timer, &QTimer::stop); QTest::qWait(100); QCOMPARE(count, 2); - QCOMPARE(timerHelper.count, 1); + QCOMPARE(timeoutSpy.count(), 1); // Test that connection is bound to context lifetime QVERIFY(connection); 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<QTemporaryDir> 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<QString>("lib"); QTest::addColumn<int>("loadversion"); QTest::addColumn<int>("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<QString>("lib"); QTest::addColumn<bool>("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<QString>("lib"); QTest::addColumn<bool>("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<QString>("symbol"); QTest::addColumn<bool>("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<bool>("success"); QTest::addColumn<QString>("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); 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 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; 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 <qstring.h> #include <qmutex.h> +#ifdef Q_OS_UNIX +#include <unistd.h> +#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 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 79ac2e5405..d2f21f48f0 100644 --- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -2,17 +2,15 @@ CONFIG += testcase debug_and_release { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qthreadstorage - !winrt: TEST_HELPER_INSTALLS = ../../debug/crashonexit_helper + !android:!winrt: TEST_HELPER_INSTALLS = ../../debug/crashonexit_helper } else { TARGET = ../../release/tst_qthreadstorage - !winrt: TEST_HELPER_INSTALLS = ../../release/crashonexit_helper + !android:!winrt: TEST_HELPER_INSTALLS = ../../release/crashonexit_helper } } else { TARGET = ../tst_qthreadstorage - !winrt: TEST_HELPER_INSTALLS = ../crashonexit_helper + !android:!winrt: TEST_HELPER_INSTALLS = ../crashonexit_helper } CONFIG += console QT = core testlib SOURCES = ../tst_qthreadstorage.cpp - - diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index f8432b8472..10856a4d57 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(); @@ -1864,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), @@ -1877,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() @@ -2651,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. @@ -2697,29 +2713,37 @@ 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 - QCOMPARE(dt4.timeZoneAbbreviation(), QString("CET")); + QEXPECT_FAIL("", "Windows only reports long name (QTBUG-32759)", Continue); +#endif + 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 returns long name (QTBUG-32759)", Continue); -#endif // Q_OS_WIN - QCOMPARE(dt5.timeZoneAbbreviation(), QString("CEST")); + QEXPECT_FAIL("", "Windows only reports long name (QTBUG-32759)", Continue); +#endif + 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("", "QTimeZone windows backend only returns long name", Continue); + 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("", "QTimeZone windows backend only returns long name", Continue); + QEXPECT_FAIL("", "Windows only reports long names (QTBUG-32759)", Continue); #endif - QCOMPARE(dt6.timeZoneAbbreviation(), QString("CEST")); + QCOMPARE(dt6.timeZoneAbbreviation(), cest); } void tst_QDateTime::getDate() @@ -2889,38 +2913,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 @@ -2942,7 +2968,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 @@ -2964,8 +2990,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); @@ -3171,12 +3197,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 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/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"), diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 47ccfb8b8a..cdabd51d43 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -518,6 +518,7 @@ private slots: void toUcs4(); void arg(); void number(); + void doubleOut(); void arg_fillChar_data(); void arg_fillChar(); void capacity_data(); @@ -4922,6 +4923,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(); 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 diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index d040f3bafd..d335dae7bc 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -513,6 +513,10 @@ void tst_QTimeZone::transitionEachZone() 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); qint64 stamp = when.toMSecsSinceEpoch(); @@ -887,7 +891,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/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 diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index bd2f6b5d60..d1f14de794 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -8,14 +8,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 @@ -25,3 +33,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 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 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 @@ +<RCC> + <qresource prefix="/android_testdata"> + <file>data/BidiCharacterTest.txt</file> + <file>data/BidiTest.txt</file> + </qresource> +</RCC> 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/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<QString>("data"); - QTest::addColumn<int>("paragraphDirection"); - QTest::addColumn<QVector<int>>("resolvedLevels"); - QTest::addColumn<QVector<int>>("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<QByteArray> parts = line.split(';'); - QVERIFY(parts.size() == 5); - - QString data; - QList<QByteArray> 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<int> resolvedLevels; - QList<QByteArray> 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<int> visualOrder; - QList<QByteArray> 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<int> &resolvedLevels, const QVector<int> &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<int>, resolvedLevels); - QFETCH(QVector<int>, 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<QByteArray> parts = line.split(';'); + QVERIFY(parts.size() == 5); - testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); + QString data; + QList<QByteArray> 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<int> resolvedLevels; + QList<QByteArray> 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<int> visualOrder; + QList<QByteArray> 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<QString>("data"); - QTest::addColumn<int>("paragraphDirection"); - QTest::addColumn<QVector<int>>("resolvedLevels"); - QTest::addColumn<QVector<int>>("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<int>, resolvedLevels); - QFETCH(QVector<int>, visualOrder); - - testBidiString(data, paragraphDirection, resolvedLevels, visualOrder); } 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) diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro index a348ea9ad5..ec1633ebff 100644 --- a/tests/auto/testlib/selftests/test/test.pro +++ b/tests/auto/testlib/selftests/test/test.pro @@ -17,5 +17,5 @@ expected_files.base = $$PWD/.. RESOURCES += expected_files 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/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index eee227fc2f..eee649847f 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1048,12 +1048,12 @@ void tst_QFiledialog::setMimeTypeFilters_data() QTest::addColumn<QString>("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() @@ -1067,6 +1067,10 @@ void tst_QFiledialog::setMimeTypeFilters() fd.selectMimeTypeFilter(targetMimeTypeFilter); QCOMPARE(fd.selectedMimeTypeFilter(), expectedSelectedMimeTypeFilter); + + auto *filters = fd.findChild<QComboBox*>("fileTypeCombo"); + filters->setCurrentIndex(filters->count() - 1); + QCOMPARE(fd.selectedMimeTypeFilter(), mimeTypeFilters.last()); } void tst_QFiledialog::setEmptyNameFilter() diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 8ec8f0e3c8..e880640b6b 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -43,6 +43,7 @@ #include <qtreewidget.h> #include <qdebug.h> #include <qscreen.h> +#include <qdesktopwidget.h> typedef QList<int> IntList; @@ -244,6 +245,7 @@ private slots: void testMinMaxSectionSize(); void sizeHintCrash(); void testResetCachedSizeHint(); + void statusTips(); protected: void setupTestData(bool use_reset_model = false); @@ -270,12 +272,20 @@ public: int rowCount(const QModelIndex&) const override { return rows; } int columnCount(const QModelIndex&) const override { return cols; } bool isEditable(const QModelIndex &) const { return true; } - - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const { - if (role == Qt::DisplayRole) - return m_bMultiLine ? QString("%1\n%1").arg(section) : QString::number(section); - return QAbstractTableModel::headerData(section, orientation, role); + 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(); + if (m_bMultiLine) + return QString("%1\n%1").arg(section); + return QLatin1Char('[') + QString::number(row) + QLatin1Char(',') + + QString::number(col) + QLatin1String(",0] -- Header"); } QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override { @@ -3368,5 +3378,54 @@ void tst_QHeaderView::testResetCachedSizeHint() } +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<QStatusTipEvent *>(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" diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro index 76411a9ebe..8ade4d8364 100644 --- a/tests/auto/widgets/kernel/qapplication/test/test.pro +++ b/tests/auto/widgets/kernel/qapplication/test/test.pro @@ -9,20 +9,20 @@ builtin_testdata: DEFINES += BUILTIN_TESTDATA TESTDATA = ../test/test.pro ../tmp/README ../modal -!winrt: SUBPROGRAMS = desktopsettingsaware modal +!android:!winrt: SUBPROGRAMS = desktopsettingsaware modal debug_and_release { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qapplication - !winrt: TEST_HELPER_INSTALLS = ../debug/helper + !android:!winrt: TEST_HELPER_INSTALLS = ../debug/helper for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../debug/$${file}" } else { TARGET = ../../release/tst_qapplication - !winrt: TEST_HELPER_INSTALLS = ../release/helper + !android:!winrt: TEST_HELPER_INSTALLS = ../release/helper for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../release/$${file}" } } else { TARGET = ../tst_qapplication - !winrt: TEST_HELPER_INSTALLS = ../helper + !android:!winrt: TEST_HELPER_INSTALLS = ../helper for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}" } 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 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 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 |