diff options
Diffstat (limited to 'tests/auto')
102 files changed, 887 insertions, 498 deletions
diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index d6e2cb3171..e59746c158 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -1,4 +1,5 @@ CONFIG += testcase parallel_test +TARGET = tst_qresourceengine load(resources) QT = core testlib SOURCES = tst_qresourceengine.cpp diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 2ac0574ec5..f5b4f17732 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -45,6 +45,9 @@ #include "qjsonvalue.h" #include "qjsondocument.h" +#define INVALID_UNICODE "\357\277\277" // "\uffff" +#define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet + class TestQtJson: public QObject { Q_OBJECT @@ -1205,7 +1208,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"foo\uffffbar\"]"; + QByteArray json = "[\n \"foo" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1221,7 +1224,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa\\u12\"]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); @@ -1229,7 +1232,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa\uffffbar\"]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1237,7 +1240,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa ]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::EndOfString); @@ -1378,7 +1381,7 @@ void TestQtJson::parseStrings() "abc\\rabc", "abc\\tabc", "abc\\u0019abc", - "abcЂabc", + "abc" UNICODE_DJE "abc", }; int size = sizeof(strings)/sizeof(const char *); @@ -1404,7 +1407,7 @@ void TestQtJson::parseStrings() }; Pairs pairs [] = { { "abc\\/abc", "abc/abc" }, - { "abc\\u0402abc", "abcЂabc" }, + { "abc\\u0402abc", "abc" UNICODE_DJE "abc" }, { "abc\\u0065abc", "abceabc" } }; size = sizeof(pairs)/sizeof(Pairs); @@ -1547,7 +1550,7 @@ void TestQtJson::validation() // only test the first 1000 bytes. Testing the full file takes too long for (int i = 0; i < 1000; ++i) { QByteArray corrupted = binary; - corrupted[i] = 0xff; + corrupted[i] = char(0xff); QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); if (doc.isNull()) continue; @@ -1567,7 +1570,7 @@ void TestQtJson::validation() for (int i = 0; i < binary.size(); ++i) { QByteArray corrupted = binary; - corrupted[i] = 0xff; + corrupted[i] = char(0xff); QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); if (doc.isNull()) continue; diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 68ff8e4bb6..09fd0a7adb 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -326,6 +326,8 @@ public slots: signals: void sig0(); QString sig1(QString s1); + void sig10(QString s1, QString s2, QString s3, QString s4, QString s5, QString s6, QString s7, + QString s8, QString s9, QString s10); protected: QtTestObject(QVariant) {} @@ -725,6 +727,7 @@ typedef QString CustomString; class QtTestCustomObject: public QObject { Q_OBJECT + friend class tst_QMetaObject; public: QtTestCustomObject(): QObject(), sum(0) {} @@ -1129,11 +1132,9 @@ void tst_QMetaObject::indexOfMethodPMF() } INDEXOFMETHODPMF_HELPER(tst_QMetaObject, value7Changed, (const QString&)) - INDEXOFMETHODPMF_HELPER(tst_QMetaObject, stdSet, ()) - INDEXOFMETHODPMF_HELPER(QtTestObject, sl10, (QString,QString,QString,QString,QString,QString,QString,QString,QString,QString)) INDEXOFMETHODPMF_HELPER(QtTestObject, sig0, ()) - INDEXOFMETHODPMF_HELPER(QtTestObject, testLongLong, (qint64, quint64)) - INDEXOFMETHODPMF_HELPER(QtTestObject, testReference, (QString&)) + INDEXOFMETHODPMF_HELPER(QtTestObject, sig10, (QString,QString,QString,QString,QString,QString,QString,QString,QString,QString)) + INDEXOFMETHODPMF_HELPER(QtTestCustomObject, sig_custom, (const CustomString &)) } QTEST_MAIN(tst_QMetaObject) diff --git a/tests/auto/corelib/kernel/qobject/qobject.pro b/tests/auto/corelib/kernel/qobject/qobject.pro index 0f86408fc9..6a7cf07f51 100644 --- a/tests/auto/corelib/kernel/qobject/qobject.pro +++ b/tests/auto/corelib/kernel/qobject/qobject.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs -SUBDIRS = signalbug -tst_qobject.pro.depends = $$SUBDIRS -SUBDIRS += tst_qobject.pro +CONFIG += ordered + +SUBDIRS += \ + signalbug \ + test diff --git a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro index 19d36a63a1..799ef34559 100644 --- a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro +++ b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro @@ -1,6 +1,3 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . CONFIG -= app_bundle debug_and_release CONFIG += console DESTDIR = ./ @@ -8,7 +5,7 @@ QT -= gui wince*: { LIBS += coredll.lib } -# Input + HEADERS += signalbug.h SOURCES += signalbug.cpp diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.pro b/tests/auto/corelib/kernel/qobject/test/test.pro index 30fd810a2e..9443b2e2c7 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.pro +++ b/tests/auto/corelib/kernel/qobject/test/test.pro @@ -1,11 +1,11 @@ CONFIG += testcase console -TARGET = tst_qobject +TARGET = ../tst_qobject QT = core-private network testlib -SOURCES = tst_qobject.cpp +SOURCES = ../tst_qobject.cpp # this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by # moc from Qt 4.6, and should *not* be generated by the current moc -SOURCES += moc_oldnormalizeobject.cpp +SOURCES += ../moc_oldnormalizeobject.cpp load(testcase) # for target.path and installTestHelperApp() installTestHelperApp("signalbug/signalbug",signalbug,signalbug) diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro index d8551faddc..7a2b8cd3b6 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro +++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro @@ -13,3 +13,11 @@ win32-borland: DEFINES += WIN32_BORLAND # This project is testdata for tst_qlibrary target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary INSTALLS += target + +win32 { + CONFIG(debug, debug|release) { + DESTDIR = ../debug/ + } else { + DESTDIR = ../release/ + } +} diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro index a15393b214..8d5af0ea79 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro +++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro @@ -15,13 +15,20 @@ win32-borland: DEFINES += WIN32_BORLAND # We want to test if we can load a shared library with *any* filename... win32 { + CONFIG(debug, debug|release) { + BUILD_FOLDER = debug + } else { + BUILD_FOLDER = release + } + DESTDIR = ../$$BUILD_FOLDER/ + # vcproj and Makefile generators refer to target differently contains(TEMPLATE,vc.*) { src = $(TargetPath) } else { src = $(DESTDIR_TARGET) } - files = mylib.dl2 system.qt.test.mylib.dll + files = $$BUILD_FOLDER$${QMAKE_DIR_SEP}mylib.dl2 $$BUILD_FOLDER$${QMAKE_DIR_SEP}system.qt.test.mylib.dll } else { src = $(DESTDIR)$(TARGET) files = libmylib.so2 system.qt.test.mylib.so @@ -34,7 +41,7 @@ renamed_target.path = $$target.path for(file, files) { QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file && renamed_target.extra += $$QMAKE_COPY $$src $(INSTALL_ROOT)$${target.path}$$QMAKE_DIR_SEP$$file && - CLEAN_FILES += ../$$file + CLEAN_FILES += ..$$QMAKE_DIR_SEP$$file } renamed_target.extra = $$member(renamed_target.extra, 0, -2) QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2) diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro index ae6cf97891..d59cd738bf 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro +++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro @@ -13,5 +13,3 @@ win32 { } TESTDATA += ../library_path/invalid.so - -win32:CONFIG += insignificant_test # QTBUG-24151 diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp index 057db69174..e27085c293 100644 --- a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include <QtPlugin> +#include <QObject> -Q_EXPORT_PLUGIN2(DebugPlugin, QObject) +class DebugPlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + DebugPlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp index 9542695112..d0875d2902 100644 --- a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include <QtPlugin> +#include <QObject> -Q_EXPORT_PLUGIN2(ReleasePlugin, QObject) +class ReleasePlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + ReleasePlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index e6a83cf3d7..af76fcc4a2 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -55,15 +55,23 @@ public: tst_QPlugin(); private slots: + void initTestCase(); void loadDebugPlugin(); void loadReleasePlugin(); }; tst_QPlugin::tst_QPlugin() - : dir("plugins") + : dir(QFINDTESTDATA("plugins")) { } +void tst_QPlugin::initTestCase() +{ + QVERIFY2(dir.exists(), + qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'"). + arg(QDir::toNativeSeparators(QDir::currentPath())))); +} + void tst_QPlugin::loadDebugPlugin() { foreach (QString fileName, dir.entryList(QStringList() << "*debug*", QDir::Files)) { diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp index 4b2057087a..eaad3ceff5 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp @@ -47,5 +47,3 @@ QString AlmostPlugin::pluginName() const unresolvedSymbol(); return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin) diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h index 6658a5be8d..d64f5985ec 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h @@ -42,11 +42,13 @@ #define ALMOSTPLUGIN_H #include <QObject> +#include <QtPlugin> #include "../theplugin/plugininterface.h" class AlmostPlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: diff --git a/tests/auto/corelib/plugin/qpluginloader/empty.json b/tests/auto/corelib/plugin/qpluginloader/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h index a568dd118d..fe0892c0fe 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h @@ -41,13 +41,19 @@ #ifndef PLUGININTERFACE_H #define PLUGININTERFACE_H +#include <QtCore/QtGlobal> + struct PluginInterface { virtual ~PluginInterface() {} virtual QString pluginName() const = 0; }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(PluginInterface, "com.trolltect.autotests.plugininterface/1.0") + +#define PluginInterface_iid "org.qt-project.Qt.autotests.plugininterface" + +Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid) + QT_END_NAMESPACE #endif // PLUGININTERFACE_H diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp index b064901a4d..8c97956a5f 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp @@ -46,6 +46,3 @@ QString ThePlugin::pluginName() const { return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(theplugin, ThePlugin) - diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h index b769aa6eed..3b8f12140e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h @@ -42,11 +42,13 @@ #define THEPLUGIN_H #include <QObject> +#include <QtPlugin> #include "plugininterface.h" class ThePlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 25e1a0587c..8eccd17376 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -107,6 +107,8 @@ private slots: void customEventDispatcher(); void stressTest(); + + void quitLock(); }; enum { one_minute = 60 * 1000, five_minutes = 5 * one_minute }; @@ -1285,5 +1287,52 @@ void tst_QThread::customEventDispatcher() QVERIFY(weak_ed.isNull()); } +class Job : public QObject +{ + Q_OBJECT +public: + Job(QThread *thread, int deleteDelay, QObject *parent = 0) + : QObject(parent), quitLocker(thread), exitThreadCalled(false) + { + moveToThread(thread); + QTimer::singleShot(deleteDelay, this, SLOT(deleteLater())); + QTimer::singleShot(1000, this, SLOT(exitThread())); + } + +private slots: + void exitThread() + { + exitThreadCalled = true; + thread()->exit(1); + } + +private: + QEventLoopLocker quitLocker; +public: + bool exitThreadCalled; +}; + +void tst_QThread::quitLock() +{ + QThread thread; + + QEventLoop loop; + connect(&thread, SIGNAL(finished()), &loop, SLOT(quit())); + + Job *job; + + thread.start(); + job = new Job(&thread, 500); + QCOMPARE(job->thread(), &thread); + loop.exec(); + QVERIFY(!job->exitThreadCalled); + + thread.start(); + job = new Job(&thread, 2500); + QCOMPARE(job->thread(), &thread); + loop.exec(); + QVERIFY(job->exitThreadCalled); +} + QTEST_MAIN(tst_QThread) #include "tst_qthread.moc" diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro deleted file mode 100644 index 68d0f1202b..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES += crashOnExit.cpp -QT = core -CONFIG-=app_bundle -CONFIG+=console - -# This app is testdata for tst_qthreadstorage -target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage -INSTALLS += target diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp index 388c233d84..388c233d84 100644 --- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro new file mode 100644 index 0000000000..94a0a01e94 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro @@ -0,0 +1,9 @@ +SOURCES += crashOnExit.cpp +DESTDIR = ./ +QT = core +CONFIG -= app_bundle +CONFIG += console + +# This app is testdata for tst_qthreadstorage +target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro index 0dc8d086df..2fa973d2f7 100644 --- a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs SUBDIRS = \ - tst_qthreadstorage.pro \ - crashOnExit.pro -CONFIG += parallel_test + crashonexit \ + test +CONFIG += ordered parallel_test diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro new file mode 100644 index 0000000000..a7d8eb0106 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = ../tst_qthreadstorage +CONFIG -= app_bundle +CONFIG += console +QT = core testlib +SOURCES = ../tst_qthreadstorage.cpp diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index fff361ea2a..0529e67e0f 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -46,6 +46,8 @@ #include <qthread.h> #include <qwaitcondition.h> #include <qthreadstorage.h> +#include <qdir.h> +#include <qfileinfo.h> #ifdef Q_OS_UNIX #include <pthread.h> @@ -61,6 +63,7 @@ class tst_QThreadStorage : public QObject { Q_OBJECT private slots: + void initTestCase(); void hasLocalData(); void localData(); void localData_const(); @@ -72,6 +75,9 @@ private slots: void leakInDestructor(); void resetInDestructor(); void valueBased(); + +private: + QString m_crashOnExit; }; class Pointer @@ -83,6 +89,20 @@ public: }; int Pointer::count = 0; +void tst_QThreadStorage::initTestCase() +{ + const QString crashOnExitDir = QFINDTESTDATA("crashonexit"); + QVERIFY2(!crashOnExitDir.isEmpty(), + qPrintable(QString::fromLatin1("Could not find 'crashonexit' starting from '%1'") + .arg(QDir::toNativeSeparators(QDir::currentPath())))); + m_crashOnExit = crashOnExitDir + QStringLiteral("/crashonexit"); +#ifdef Q_OS_WIN + m_crashOnExit += QStringLiteral(".exe"); +#endif + QVERIFY2(QFileInfo(m_crashOnExit).isExecutable(), + qPrintable(QDir::toNativeSeparators(m_crashOnExit) + QStringLiteral(" does not exist or is not executable."))); +} + void tst_QThreadStorage::hasLocalData() { QThreadStorage<Pointer *> pointers; @@ -285,18 +305,32 @@ void tst_QThreadStorage::ensureCleanupOrder() QVERIFY(First::order < Second::order); } -void tst_QThreadStorage::crashOnExit() +static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) { + const int timeout = 60000; QProcess process; - // crashOnExit is always expected to be in the same directory - // as this test binary -#ifdef Q_OS_MAC - process.start(QCoreApplication::applicationDirPath() + "/../../../crashOnExit"); -#else - process.start(QCoreApplication::applicationDirPath() + "/crashOnExit"); -#endif - QVERIFY(process.waitForFinished()); - QVERIFY(process.exitStatus() != QProcess::CrashExit); + process.start(binary); + if (!process.waitForStarted()) { + *errorMessage = QString::fromLatin1("Could not start '%1': %2").arg(binary, process.errorString()); + return false; + } + if (!process.waitForFinished(timeout)) { + process.kill(); + *errorMessage = QString::fromLatin1("Timeout (%1ms) waiting for %2.").arg(timeout).arg(binary); + return false; + } + if (process.exitStatus() != QProcess::NormalExit) { + *errorMessage = binary + QStringLiteral(" crashed."); + return false; + } + return true; +} + +void tst_QThreadStorage::crashOnExit() +{ + QString errorMessage; + QVERIFY2(runCrashOnExit(m_crashOnExit, &errorMessage), + qPrintable(errorMessage)); } // S stands for thread Safe. diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro deleted file mode 100644 index 15ced107d3..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qthreadstorage -QT = core testlib -SOURCES = tst_qthreadstorage.cpp diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index 81cc66f045..67c15682a2 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -102,6 +102,22 @@ void tst_QCryptographicHash::intermediary_result_data() << QByteArray("abc") << QByteArray("abc") << QByteArray::fromHex("A9993E364706816ABA3E25717850C26C9CD0D89D") << QByteArray::fromHex("F8C1D87006FBF7E5CC4B026C3138BC046883DC71"); + QTest::newRow("sha224") << int(QCryptographicHash::Sha224) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7") + << QByteArray::fromHex("7C9C91FC479626AA1A525301084DEB96716131D146A2DB61B533F4C9"); + QTest::newRow("sha256") << int(QCryptographicHash::Sha256) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD") + << QByteArray::fromHex("BBB59DA3AF939F7AF5F360F2CEB80A496E3BAE1CD87DDE426DB0AE40677E1C2C"); + QTest::newRow("sha384") << int(QCryptographicHash::Sha384) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7") + << QByteArray::fromHex("CAF33A735C9535CE7F5D24FB5B3A4834F0E9316664AD15A9E8221679D4A3B4FB7E962404BA0C10C1D43AB49D03A08B8D"); + QTest::newRow("sha512") << int(QCryptographicHash::Sha512) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F") + << QByteArray::fromHex("F3C41E7B63EE869596FC28BAD64120612C520F65928AB4D126C72C6998B551B8FF1CEDDFED4373E6717554DC89D1EEE6F0AB22FD3675E561ABA9AE26A3EEC53B"); } void tst_QCryptographicHash::intermediary_result() diff --git a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro index d510d82207..a97350ca3f 100644 --- a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro +++ b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro @@ -1,6 +1,7 @@ SOURCES += syslocaleapp.cpp DESTDIR = ./ +CONFIG += console CONFIG -= app_bundle QT = core diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index 5a4fb674c5..eafd8c1699 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -1,5 +1,6 @@ -CONFIG += testcase -QT = core testlib network +CONFIG += console testcase +CONFIG -= app_bundle +QT = core testlib embedded: QT += gui SOURCES = ../tst_qlocale.cpp diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index db7f503f57..02acb00548 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -43,6 +43,9 @@ #include <QtTest/QtTest> #include <math.h> #include <qglobal.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <QScopedArrayPointer> #include <qtextcodec.h> #include <qdatetime.h> #include <float.h> @@ -83,6 +86,7 @@ public: tst_QLocale(); private slots: + void initTestCase(); void windowsDefaultLocale(); void macDefaultLocale(); @@ -131,6 +135,7 @@ private slots: private: QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; + QString m_sysapp; }; tst_QLocale::tst_QLocale() @@ -138,6 +143,22 @@ tst_QLocale::tst_QLocale() qRegisterMetaType<QLocale::FormatType>("QLocale::FormatType"); } +void tst_QLocale::initTestCase() +{ + 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 + m_sysapp += QStringLiteral(".exe"); +#endif + const QFileInfo fi(m_sysapp); + QVERIFY2(fi.exists() && fi.isExecutable(), + qPrintable(QDir::toNativeSeparators(m_sysapp) + + QStringLiteral(" does not exist or is not executable."))); +} + void tst_QLocale::ctor() { QLocale default_locale = QLocale::system(); @@ -346,6 +367,54 @@ void tst_QLocale::ctor() #undef TEST_CTOR } +static inline bool runSysApp(const QString &binary, + const QStringList &env, + QString *output, + QString *errorMessage) +{ + output->clear(); + errorMessage->clear(); + QProcess process; + process.setEnvironment(env); + process.start(binary); + process.closeWriteChannel(); + if (!process.waitForStarted()) { + *errorMessage = QString::fromLatin1("Cannot start '%1': %2").arg(binary, process.errorString()); + return false; + } + if (!process.waitForFinished()) { + process.kill(); + *errorMessage = QStringLiteral("Timeout waiting for ") + binary; + return false; + } + *output = QString::fromLocal8Bit(process.readAllStandardOutput()); + return true; +} + +static inline bool runSysAppTest(const QString &binary, + QStringList baseEnv, + const QString &requestedLocale, + const QString &expectedOutput, + QString *errorMessage) +{ + QString output; + baseEnv.append(QStringLiteral("LANG=") + requestedLocale); + if (!runSysApp(binary, baseEnv, &output, errorMessage)) + return false; + + if (output.isEmpty()) { + *errorMessage = QString::fromLatin1("Empty output received for requested '%1' (expected '%2')"). + arg(requestedLocale, expectedOutput); + return false; + } + if (output != expectedOutput) { + *errorMessage = QString::fromLatin1("Output mismatch for requested '%1': Expected '%2', got '%3'"). + arg(requestedLocale, expectedOutput, output); + return false; + } + return true; +} + void tst_QLocale::emptyCtor() { #if defined(Q_OS_WINCE) @@ -358,15 +427,9 @@ void tst_QLocale::emptyCtor() { \ /* Test constructor without arguments. Needs separate process */ \ /* because of caching of the system locale. */ \ - QProcess process; \ - process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \ - process.start(syslocaleapp_dir + "syslocaleapp"); \ - process.waitForReadyRead(); \ - QString ret = QString(process.readAll()); \ - process.waitForFinished(); \ - QVERIFY2(!ret.isEmpty(), "Cannot launch external process"); \ - QVERIFY2(QString(exp_str) == ret, QString("Expected: " + QString(exp_str) + ", got: " \ - + ret + ". Requested: " + QString(req_lc)).toLatin1().constData()); \ + QString errorMessage; \ + QVERIFY2(runSysAppTest(m_sysapp, env, QLatin1String(req_lc), QLatin1String(exp_str), &errorMessage), \ + qPrintable(errorMessage)); \ } // Get an environment free of any locale-related variables @@ -377,15 +440,11 @@ void tst_QLocale::emptyCtor() env << entry; } - QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp/"); - // Get default locale. - QProcess p; - p.setEnvironment(env); - p.start(syslocaleapp_dir + "syslocaleapp"); - p.waitForReadyRead(); - QString defaultLoc = QString(p.readAll()); - p.waitForFinished(); + QString defaultLoc; + QString errorMessage; + QVERIFY2(runSysApp(m_sysapp, env, &defaultLoc, &errorMessage), + qPrintable(errorMessage)); TEST_CTOR("C", "C") TEST_CTOR("bla", "C") @@ -421,9 +480,9 @@ void tst_QLocale::emptyCtor() TEST_CTOR("DE", "de_DE"); TEST_CTOR("EN", "en_US"); - TEST_CTOR("en/", defaultLoc) - TEST_CTOR("asdfghj", defaultLoc); - TEST_CTOR("123456", defaultLoc); + TEST_CTOR("en/", defaultLoc.toLatin1()) + TEST_CTOR("asdfghj", defaultLoc.toLatin1()); + TEST_CTOR("123456", defaultLoc.toLatin1()); #undef TEST_CTOR #endif @@ -1147,17 +1206,15 @@ static QString getWinLocaleInfo(LCTYPE type) qWarning("QLocale: empty windows locale info (%d)", type); return QString(); } - - QByteArray buff(cnt, 0); - - cnt = GetLocaleInfo(id, type, reinterpret_cast<wchar_t*>(buff.data()), buff.size() / 2); + cnt /= sizeof(wchar_t); + QScopedArrayPointer<wchar_t> buf(new wchar_t[cnt]); + cnt = GetLocaleInfo(id, type, buf.data(), cnt); if (cnt == 0) { qWarning("QLocale: empty windows locale info (%d)", type); return QString(); } - - return QString::fromWCharArray(reinterpret_cast<wchar_t*>(buff.data())); + return QString::fromWCharArray(buf.data()); } static void setWinLocaleInfo(LCTYPE type, const QString &value) @@ -1189,13 +1246,13 @@ public: }; -#endif +#endif // Q_OS_WIN void tst_QLocale::windowsDefaultLocale() { -#ifndef Q_OS_WIN - QSKIP("This is a Windows test"); -#else +#ifdef Q_OS_WIN + QSKIP("This test currently fails - QTBUG-24543"); + RestoreLocaleHelper systemLocale; // set weird system defaults and make sure we're using them setWinLocaleInfo(LOCALE_SDECIMAL, QLatin1String("@")); @@ -1204,7 +1261,6 @@ void tst_QLocale::windowsDefaultLocale() setWinLocaleInfo(LOCALE_SLONGDATE, QLatin1String("d@M@yyyy")); setWinLocaleInfo(LOCALE_STIMEFORMAT, QLatin1String("h^m^s")); QLocale locale = QLocale::system(); - // make sure we are seeing the system's format strings QCOMPARE(locale.decimalPoint(), QChar('@')); QCOMPARE(locale.groupSeparator(), QChar('?')); @@ -1230,7 +1286,7 @@ void tst_QLocale::windowsDefaultLocale() QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::LongFormat), QString("1@12@1974 1^2^3")); QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), QString("1^2^3")); -#endif +#endif // #ifdef Q_OS_WIN } void tst_QLocale::numberOptions() diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 0148e933e4..a697e23270 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -79,6 +79,8 @@ private slots: void posAndCapConsistency_data(); void posAndCapConsistency(); void interval(); + void validityCheck_data(); + void validityCheck(); }; // Testing get/set functions @@ -1344,6 +1346,33 @@ void tst_QRegExp::interval() } } +void tst_QRegExp::validityCheck_data() +{ + QTest::addColumn<QString>("pattern"); + QTest::addColumn<bool>("validity"); + QTest::newRow("validity01") << QString() << true; + QTest::newRow("validity02") << QString("abc.*abc") << true; + QTest::newRow("validity03") << QString("[a-z") << false; + QTest::newRow("validity04") << QString("a(b") << false; +} + +void tst_QRegExp::validityCheck() +{ + QFETCH(QString, pattern); + + QRegExp rx(pattern); + QTEST(rx.isValid(), "validity"); + QCOMPARE(rx.matchedLength(), -1); + QCOMPARE(rx.pos(), -1); + QCOMPARE(rx.cap(), QString("")); + + QRegExp rx2(rx); + QTEST(rx2.isValid(), "validity"); + QCOMPARE(rx2.matchedLength(), -1); + QCOMPARE(rx2.pos(), -1); + QCOMPARE(rx2.cap(), QString("")); +} + QTEST_APPLESS_MAIN(tst_QRegExp) #include "tst_qregexp.moc" diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 3fb253c646..7e4f591f47 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -808,10 +808,7 @@ void tst_QString::constructorQByteArray() QCOMPARE(str1.length(), expected.length()); QCOMPARE( str1, expected ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 QString strBA(src); - QTextCodec::setCodecForCStrings( 0 ); - QCOMPARE( strBA, expected ); } @@ -928,12 +925,7 @@ void tst_QString::sprintf() QCOMPARE(a.sprintf("%-5.5s", "Hello" ),(QString)"Hello"); // Check utf8 conversion for %s - QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString("\366\344\374\326\304\334\370\346\345\330\306\305")); - - // Check codecForCStrings is used to read non-modifier sequences in the format string - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - QCOMPARE(a.sprintf("\303\251\303\250\303\240 %s", "\303\251\303\250\303\240"), QString("\303\251\303\250\303\240 \303\251\303\250\303\240")); - QTextCodec::setCodecForCStrings(0); + QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); int n1; a.sprintf("%s%n%s", "hello", &n1, "goodbye"); @@ -1871,9 +1863,7 @@ void tst_QString::append_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str.append( ba ); - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -1898,9 +1888,7 @@ void tst_QString::operator_pluseq_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str += ba; - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -1960,9 +1948,7 @@ void tst_QString::prepend_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str.prepend( ba ); - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -3211,7 +3197,7 @@ void tst_QString::utf8() QFETCH( QByteArray, utf8 ); QFETCH( QString, res ); - QCOMPARE( utf8, QByteArray(res.toUtf8()) ); + QCOMPARE(res.toUtf8(), utf8); } void tst_QString::stringRef_utf8_data() diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 95e24b22fb..afc16078b8 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -66,10 +66,8 @@ void runScenario() { - // set codec for C strings to 0, enforcing Latin1 - QTextCodec::setCodecForCStrings(0); - QVERIFY(!QTextCodec::codecForCStrings()); - + // this code is latin1. TODO: replace it with the utf8 block below, once + // strings default to utf8. QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); QString string(l1string); @@ -130,7 +128,10 @@ void runScenario() r = string P ba; QCOMPARE(r, r2); +#if 0 // now test with codec for C strings set + // TODO: to be re-enabled once strings default to utf8, in place of the + // latin1 code above. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QVERIFY(QTextCodec::codecForCStrings()); QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8")); @@ -153,6 +154,7 @@ void runScenario() QCOMPARE(r, r3); r = string P ba; QCOMPARE(r, r3); +#endif ba = QByteArray(); // empty r = ba P string; @@ -212,9 +214,12 @@ void runScenario() str += QLatin1String(LITERAL) P str; QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); #ifndef QT_NO_CAST_FROM_ASCII +#if 0 + // TODO: this relies on strings defaulting to utf8, so disable this for now. str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL); QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); #endif +#endif } //operator QByteArray += @@ -229,11 +234,14 @@ void runScenario() ba2 += ba2 P withZero; QCOMPARE(ba2, QByteArray(withZero + withZero + withZero)); #ifndef QT_NO_CAST_TO_ASCII +#if 0 + // TODO: this relies on strings defaulting to utf8, so disable this for now. ba = UTF8_LITERAL; ba2 = (ba += QLatin1String(LITERAL) + QString::fromUtf8(UTF8_LITERAL)); QCOMPARE(ba2, ba); QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL)); #endif +#endif } } diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index 87c434b71e..025641531d 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -581,7 +581,7 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2) qWarning() << "Unexpected QVariant type" << v2.userType() << QByteArray(QDBusMetaType::typeToSignature(v2.userType())) - << QVariant::typeToName(QVariant::Type(v2.userType())); + << QMetaType::typeName(v2.userType()); return false; } diff --git a/tests/auto/gui/kernel/qclipboard/copier/copier.pro b/tests/auto/gui/kernel/qclipboard/copier/copier.pro index 1c188ca7de..def50b6476 100644 --- a/tests/auto/gui/kernel/qclipboard/copier/copier.pro +++ b/tests/auto/gui/kernel/qclipboard/copier/copier.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . CONFIG -= app_bundle win32: DESTDIR = ../copier -# Input -SOURCES += main.cpp +SOURCES += main.cpp diff --git a/tests/auto/gui/kernel/qclipboard/paster/paster.pro b/tests/auto/gui/kernel/qclipboard/paster/paster.pro index 2f50eefb1e..ef91e77b6e 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/paster.pro +++ b/tests/auto/gui/kernel/qclipboard/paster/paster.pro @@ -1,10 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . win32: DESTDIR = ../paster CONFIG -= app_bundle -# Input -SOURCES += main.cpp - +SOURCES += main.cpp diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index e1b0535e2f..7f41f0651e 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -291,19 +291,17 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->clear(QClipboard::Selection); // used to crash on X11 QGuiApplication::clipboard()->clear(QClipboard::FindBuffer); -#if defined(Q_WS_X11) - QCOMPARE(spySelection.count(), 1); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#elif defined(Q_OS_MAC) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 1); -#elif defined(Q_WS_WIN) - QCOMPARE(spySelection.count(), 0); + if (QGuiApplication::clipboard()->supportsSelection()) + QCOMPARE(spySelection.count(), 1); + else + QCOMPARE(spySelection.count(), 0); + + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QCOMPARE(spyFindBuffer.count(), 1); + else + QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#endif // an other crash test data = new QMimeData; @@ -324,19 +322,17 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11 QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); -#if defined(Q_WS_X11) - QCOMPARE(spySelection.count(), 1); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#elif defined(Q_OS_MAC) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 1); -#elif defined(Q_WS_WIN) - QCOMPARE(spySelection.count(), 0); + if (QGuiApplication::clipboard()->supportsSelection()) + QCOMPARE(spySelection.count(), 1); + else + QCOMPARE(spySelection.count(), 0); + + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QCOMPARE(spyFindBuffer.count(), 1); + else + QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#endif } void tst_QClipboard::clearBeforeSetText() diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index c10d954489..bc364e37f1 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -44,90 +44,22 @@ #include <private/qguiapplication_p.h> #include <private/qinputmethod_p.h> #include <qplatforminputcontext_qpa.h> - -class PlatformInputContext : public QPlatformInputContext -{ -public: - PlatformInputContext() : - m_animating(false), - m_visible(false), - m_updateCallCount(0), - m_resetCallCount(0), - m_commitCallCount(0), - m_localeCallCount(0), - m_inputDirectionCallCount(0), - m_lastQueries(Qt::ImhNone), - m_action(QInputMethod::Click), - m_cursorPosition(0), - m_lastEventType(QEvent::None) - {} - - virtual QRectF keyboardRect() const { return m_keyboardRect; } - virtual bool isAnimating() const { return m_animating; } - virtual void reset() { m_resetCallCount++; } - virtual void commit() { m_commitCallCount++; } - - virtual void update(Qt::InputMethodQueries queries) - { - m_updateCallCount++; - m_lastQueries = queries; - } - virtual void invokeAction(QInputMethod::Action action, int cursorPosition) - { - m_action = action; - m_cursorPosition = cursorPosition; - } - virtual bool filterEvent(const QEvent *event) - { - m_lastEventType = event->type(); return false; - } - virtual void showInputPanel() - { - m_visible = true; - } - virtual void hideInputPanel() - { - m_visible = false; - } - virtual bool isInputPanelVisible() const - { - return m_visible; - } - virtual QLocale locale() const - { - m_localeCallCount++; - return QLocale::c(); - } - virtual Qt::LayoutDirection inputDirection() const - { - m_inputDirectionCallCount++; - return Qt::LeftToRight; - } - - bool m_animating; - bool m_visible; - int m_updateCallCount; - int m_resetCallCount; - int m_commitCallCount; - mutable int m_localeCallCount; - mutable int m_inputDirectionCallCount; - Qt::InputMethodQueries m_lastQueries; - QInputMethod::Action m_action; - int m_cursorPosition; - int m_lastEventType; - QRectF m_keyboardRect; -}; +#include "../../../shared/platforminputcontext.h" class InputItem : public QObject { Q_OBJECT public: + InputItem() : cursorRectangle(1, 2, 3, 4), m_enabled(true) {} + bool event(QEvent *event) { if (event->type() == QEvent::InputMethodQuery) { QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(event); + if (query->queries() & Qt::ImEnabled) + query->setValue(Qt::ImEnabled, m_enabled); if (query->queries() & Qt::ImCursorRectangle) - query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4)); + query->setValue(Qt::ImCursorRectangle, cursorRectangle); if (query->queries() & Qt::ImPreferredLanguage) query->setValue(Qt::ImPreferredLanguage, QString("English")); m_lastQueries = query->queries(); @@ -136,9 +68,40 @@ public: } return false; } + + void setEnabled(bool enabled) { + if (enabled != m_enabled) { + m_enabled = enabled; + qApp->inputMethod()->update(Qt::ImEnabled); + } + } + + QRectF cursorRectangle; Qt::InputMethodQueries m_lastQueries; + bool m_enabled; }; + +class DummyWindow : public QWindow +{ +public: + DummyWindow() : m_focusObject(0) {} + + virtual QObject *focusObject() const + { + return m_focusObject; + } + + void setFocusObject(QObject *object) + { + m_focusObject = object; + emit focusObjectChanged(object); + } + + QObject *m_focusObject; +}; + + class tst_qinputmethod : public QObject { Q_OBJECT @@ -258,7 +221,11 @@ void tst_qinputmethod::cursorRectangle() QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); + m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8); + QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1.5, 2, 1, 8))); + // reset + m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4); qApp->inputMethod()->setInputItem(0); qApp->inputMethod()->setInputItemTransform(QTransform()); } @@ -297,7 +264,6 @@ void tst_qinputmethod::commit() void tst_qinputmethod::update() { - qApp->inputMethod()->setInputItem(&m_inputItem); QCOMPARE(m_platformInputContext.m_updateCallCount, 0); QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone)); diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro index 1e0baafd09..cf4337b156 100644 --- a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro +++ b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qkeysequence -QT += widgets widgets-private testlib +QT += widgets testlib QT += core-private gui-private SOURCES += tst_qkeysequence.cpp diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 29588e2ee9..861ad3835d 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -41,9 +41,10 @@ #include <QtTest/QtTest> -#include <private/qapplication_p.h> #include <qkeysequence.h> +#include <qplatformtheme_qpa.h> #include <private/qkeysequence_p.h> +#include <private/qguiapplication_p.h> #include <QTranslator> #include <QLibraryInfo> @@ -142,6 +143,7 @@ private slots: void initTestCase(); private: + int m_keyboardScheme; QTranslator *ourTranslator; QTranslator *qtTranslator; #ifdef Q_OS_MAC @@ -161,8 +163,10 @@ const QString tst_QKeySequence::MacAlt = QString(QChar(0x2325)); const QString tst_QKeySequence::MacShift = QString(QChar(0x21E7)); #endif -tst_QKeySequence::tst_QKeySequence() +tst_QKeySequence::tst_QKeySequence() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } tst_QKeySequence::~tst_QKeySequence() @@ -297,8 +301,7 @@ void tst_QKeySequence::checkMultipleCodes() */ void tst_QKeySequence::ensureSorted() { -//### accessing static members from private classes does not work on msvc at the moment -#if defined(QT_BUILD_INTERNAL) && !defined(Q_WS_WIN) +#if defined(QT_BUILD_INTERNAL) uint N = QKeySequencePrivate::numberOfKeyBindings; uint val = QKeySequencePrivate::keyBindings[0].shortcut; for ( uint i = 1 ; i < N ; ++i) { @@ -322,13 +325,13 @@ void tst_QKeySequence::standardKeys_data() QTest::newRow("delete") << (int)QKeySequence::Delete<< QString("DEL"); QTest::newRow("open") << (int)QKeySequence::Open << QString("CTRL+O"); QTest::newRow("find") << (int)QKeySequence::Find<< QString("CTRL+F"); -#ifdef Q_WS_WIN - QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); - QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); - QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); - QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); - QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); -#endif + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); + QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); + QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); + QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); + QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); + } QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B"); QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I"); QTest::newRow("underline") << (int)QKeySequence::Underline << QString("CTRL+U"); @@ -362,23 +365,33 @@ void tst_QKeySequence::standardKeys() { QFETCH(int, standardKey); QFETCH(QString, expected); - QKeySequence ks((QKeySequence::StandardKey)standardKey); - QKeySequence ks2(expected); - QVERIFY(ks == ks2); + QKeySequence actualKeySequence((QKeySequence::StandardKey)standardKey); + QKeySequence expectedKeySequence(expected); + QVERIFY2(actualKeySequence == expectedKeySequence, + qPrintable(QString::fromLatin1("Key mismatch, expected '%1', got '%2' for standard key %3"). + arg(expected, actualKeySequence.toString()).arg(standardKey))); } void tst_QKeySequence::keyBindings() { - QList<QKeySequence> bindings = QKeySequence::keyBindings(QKeySequence::Copy); + const QList<QKeySequence> bindings = + QKeySequence::keyBindings(QKeySequence::Copy); + QList<QKeySequence> expected; -#if defined(Q_OS_MAC) - expected << QKeySequence("CTRL+C"); -#elif defined Q_WS_X11 - expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); -#else - expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); -#endif - QVERIFY(bindings == expected); + const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); + const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); + switch (m_keyboardScheme) { + case QPlatformTheme::MacKeyboardScheme: + expected << ctrlC; + break; + case QPlatformTheme::WindowsKeyboardScheme: + expected << ctrlC << ctrlInsert; + break; + default: // X11 + expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert; + break; + } + QCOMPARE(bindings, expected); } void tst_QKeySequence::mnemonic_data() diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro index ce2d341e92..36661c7d63 100644 --- a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro +++ b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro @@ -1,11 +1,3 @@ -###################################################################### -# Automatically generated by qmake (1.02a) Thu Apr 18 18:56:53 2002 -###################################################################### - -TEMPLATE = app CONFIG -= moc -# Input SOURCES += main.cpp - - diff --git a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro index 354e0e5cdf..101b7451de 100644 --- a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro +++ b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro @@ -1,14 +1,5 @@ -###################################################################### -# Automatically generated by qmake (1.07a) Fri Sep 30 15:20:45 2005 -###################################################################### - -TEMPLATE = app CONFIG -= moc INCLUDEPATH += . /usr/include/freetype2 INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src -# Input SOURCES += main.cpp -CONFIG += qt warn_on debug thread create_prl link_prl - - diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index cf02d1af50..7c9a83eaa4 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -104,6 +104,7 @@ private slots: void mirroredChars(); void thaiIsolatedSaraAm(); + void thaiWithZWJ(); private: bool haveTestFonts; @@ -1280,5 +1281,46 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm() QSKIP("Cannot find Waree."); } +void tst_QTextScriptEngine::thaiWithZWJ() +{ + QString s(QString::fromUtf8("รร.ร.“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); + QTextLayout layout(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QTextEngine *e = layout.engine(); + e->width(0, s.length()); //force itemize and shape + + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. + // But make sure that we don't hide anything else + QCOMPARE(e->layoutData->items.size(), 11); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script + QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a seperate item + QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis + QCOMPARE(e->layoutData->items[4].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[5].num_glyphs, ushort(1)); // Common: Smart quote + QCOMPARE(e->layoutData->items[6].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[7].num_glyphs, ushort(1)); // Common: \xA0 = non-breaking space. Could be useful to have in thai, but not currently implemented + QCOMPARE(e->layoutData->items[8].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[9].num_glyphs, ushort(1)); // Japanese: Kanji for tree + QCOMPARE(e->layoutData->items[10].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type + + //A quick sanity check - check all the characters are individual clusters + unsigned short *logClusters = e->layoutData->logClustersPtr; + for (int i = 0; i < 7; i++) + QCOMPARE(logClusters[i], ushort(i)); + for (int i = 0; i < 10; i++) + QCOMPARE(logClusters[i+7], ushort(0)); + QCOMPARE(logClusters[17], ushort(1)); + + // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 + // and 3. + for (int i = 0; i < 18; i++) + QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 671d03cf84..5b34fa7c29 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -79,6 +79,11 @@ #ifdef QT_BUILD_INTERNAL #include <QtNetwork/private/qnetworkaccessmanager_p.h> #endif + +#ifdef Q_OS_UNIX +# include <sys/types.h> +# include <unistd.h> // for getuid() +#endif #include <time.h> #include "../../../network-settings.h" @@ -1295,19 +1300,17 @@ QString tst_QNetworkReply::runCustomRequest(const QNetworkRequest &request, int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) { - int code = Success; int count = 0; connect(reply, SIGNAL(finished()), SLOT(finished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(gotError())); - + returnCode = Success; loop = new QEventLoop; QSignalSpy spy(reply, SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { - QTimer::singleShot(10000, loop, SLOT(quit())); - code = loop->exec(); - if (count == spy.count() && !reply->isFinished()) { - code = Timeout; + QTimer::singleShot(5000, loop, SLOT(quit())); + if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + returnCode = Timeout; break; } count = spy.count(); @@ -1315,7 +1318,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) delete loop; loop = 0; - return code; + return returnCode; } void tst_QNetworkReply::finished() diff --git a/tests/auto/network/socket/qlocalsocket/example/client/client.pro b/tests/auto/network/socket/qlocalsocket/example/client/client.pro index 84f20d6ec0..4b6585ff10 100644 --- a/tests/auto/network/socket/qlocalsocket/example/client/client.pro +++ b/tests/auto/network/socket/qlocalsocket/example/client/client.pro @@ -1,10 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . CONFIG += console QT = core network SOURCES += main.cpp - - diff --git a/tests/auto/network/socket/qlocalsocket/example/server/server.pro b/tests/auto/network/socket/qlocalsocket/example/server/server.pro index bfd14d2bb7..b78e63d0a7 100644 --- a/tests/auto/network/socket/qlocalsocket/example/server/server.pro +++ b/tests/auto/network/socket/qlocalsocket/example/server/server.pro @@ -1,13 +1,5 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - CONFIG += console QT = core network -# Input SOURCES += main.cpp - - diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 70da67455e..2715bfc5dc 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -50,6 +50,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> +#include <unistd.h> // for unlink() #endif Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError) diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro index 5dcbdb98ce..9de320b364 100644 --- a/tests/auto/other/atwrapper/atWrapper.pro +++ b/tests/auto/other/atwrapper/atWrapper.pro @@ -1,9 +1,6 @@ -# -*- Mode: makefile -*- - ARTHUR=$$QT_SOURCE_TREE/tests/arthur COMMON_FOLDER = $$ARTHUR/common include($$ARTHUR/arthurtester.pri) -TEMPLATE = app INCLUDEPATH += $$ARTHUR DEFINES += SRCDIR=\\\"$$PWD\\\" @@ -15,7 +12,6 @@ include($$ARTHUR/datagenerator/datagenerator.pri) CONFIG += testcase -# Input HEADERS += atWrapper.h SOURCES += atWrapperAutotest.cpp atWrapper.cpp diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 9bfed15fc4..dc6d7f4b55 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -2124,11 +2124,10 @@ void tst_Collections::qstring() QVERIFY(s.toAscii().isNull()); s = "ascii"; - s += (uchar) 0xb0; + s += QChar((uchar) 0xb0); QVERIFY(s.toUtf8() != s.toLatin1()); - QString sa = s.toLatin1().constData(); - QVERIFY(sa[sa.length()-1] == (ushort) 0xb0); - QVERIFY(sa.left(sa.length()-1) == "ascii"); + QCOMPARE(s[s.length()-1].unicode(), (ushort)0xb0); + QVERIFY(s.left(s.length()-1) == "ascii"); QVERIFY(s == QString::fromUtf8(s.toUtf8().constData())); diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index 43e3788098..d72a04c8aa 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -268,9 +268,7 @@ namespace QtTestInternal struct Getter { static QMetaType::SaveOperator saveOp() { - typedef void(*SavePtr)(QDataStream &, const T *); - SavePtr op = ::qMetaTypeSaveHelper<T>; - return reinterpret_cast<QMetaType::SaveOperator>(op); + return ::qMetaTypeSaveHelper<T>; } }; diff --git a/tests/auto/other/languagechange/languagechange.pro b/tests/auto/other/languagechange/languagechange.pro index efbc524556..b115c01641 100644 --- a/tests/auto/other/languagechange/languagechange.pro +++ b/tests/auto/other/languagechange/languagechange.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_languagechange -QT += widgets core-private testlib +QT += widgets core-private gui-private testlib SOURCES += tst_languagechange.cpp diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index b4bd766df7..663f2ef798 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -43,13 +43,16 @@ #include <QtTest/QtTest> #include <qapplication.h> +#include <private/qguiapplication_p.h> #include <QtCore/QSet> #include <QtCore/QFile> #include <QtCore/QTranslator> #include <QtCore/QTemporaryDir> #include <private/qthread_p.h> +#include <QtGui/QPlatformTheme> #include <QtWidgets/QInputDialog> #include <QtWidgets/QColorDialog> +#include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QFileDialog> #include <QtWidgets/QDesktopWidget> @@ -66,12 +69,16 @@ private slots: void retranslatability_data(); void retranslatability(); +private: + QDialogButtonBox::ButtonLayout m_layout; }; -tst_languageChange::tst_languageChange() - +tst_languageChange::tst_languageChange() : + m_layout(QDialogButtonBox::WinLayout) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_layout = static_cast<QDialogButtonBox::ButtonLayout>(theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt()); } void tst_languageChange::initTestCase() @@ -240,6 +247,9 @@ void tst_languageChange::retranslatability() QFETCH( int, dialogType); QFETCH( TranslationSet, expected); + if (m_layout == QDialogButtonBox::GnomeLayout) + QSKIP("The input data are not suitable for this layout (QDialogButtonBox::GnomeLayout)"); + // This will always be queried for when a language changes expected.insert("QCoreApplication::QT_LAYOUT_DIRECTION::Translate this string to the string 'LTR' in left-to-right " "languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to " diff --git a/tests/auto/other/macgui/macgui.pro b/tests/auto/other/macgui/macgui.pro index 5632450a3a..b7adbb470e 100644 --- a/tests/auto/other/macgui/macgui.pro +++ b/tests/auto/other/macgui/macgui.pro @@ -1,10 +1,6 @@ CONFIG += testcase TARGET = tst_macgui -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . -# Input SOURCES += tst_macgui.cpp guitest.cpp HEADERS += guitest.h diff --git a/tests/auto/other/macnativeevents/macnativeevents.pro b/tests/auto/other/macnativeevents/macnativeevents.pro index efe091f9f0..6ec0942222 100644 --- a/tests/auto/other/macnativeevents/macnativeevents.pro +++ b/tests/auto/other/macnativeevents/macnativeevents.pro @@ -1,7 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 29 22:24:47 2006 -###################################################################### - CONFIG += testcase TARGET = tst_macnativeevents TEMPLATE = app diff --git a/tests/auto/other/macplist/app/app.pro b/tests/auto/other/macplist/app/app.pro index b4b895197c..9ccac831d0 100644 --- a/tests/auto/other/macplist/app/app.pro +++ b/tests/auto/other/macplist/app/app.pro @@ -1,12 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Jan 7 13:01:11 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . +QT += widgets -# Input SOURCES += main.cpp -QT += widgets diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 69fe00dc19..9ec5ea8e34 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -26,6 +26,8 @@ SUBDIRS=\ qtokenautomaton \ windowsmobile \ +testcocoon: SUBDIRS -= headersclean + cross_compile: SUBDIRS -= \ atwrapper \ compiler \ diff --git a/tests/auto/widgets/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h index 759123a4a6..cddeca3945 100644 --- a/tests/auto/widgets/shared/platforminputcontext.h +++ b/tests/auto/shared/platforminputcontext.h @@ -50,8 +50,10 @@ public: m_updateCallCount(0), m_resetCallCount(0), m_commitCallCount(0), + m_localeCallCount(0), + m_inputDirectionCallCount(0), m_lastQueries(Qt::ImhNone), - m_action(QInputPanel::Click), + m_action(QInputMethod::Click), m_cursorPosition(0), m_lastEventType(QEvent::None) {} @@ -66,7 +68,7 @@ public: m_updateCallCount++; m_lastQueries = queries; } - virtual void invokeAction(QInputPanel::Action action, int cursorPosition) + virtual void invokeAction(QInputMethod::Action action, int cursorPosition) { m_action = action; m_cursorPosition = cursorPosition; @@ -87,14 +89,26 @@ public: { return m_visible; } + virtual QLocale locale() const + { + m_localeCallCount++; + return QLocale::c(); + } + virtual Qt::LayoutDirection inputDirection() const + { + m_inputDirectionCallCount++; + return Qt::LeftToRight; + } bool m_animating; bool m_visible; int m_updateCallCount; int m_resetCallCount; int m_commitCallCount; + mutable int m_localeCallCount; + mutable int m_inputDirectionCallCount; Qt::InputMethodQueries m_lastQueries; - QInputPanel::Action m_action; + QInputMethod::Action m_action; int m_cursorPosition; int m_lastEventType; QRectF m_keyboardRect; diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index 45b9c26824..ddafeea427 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -1406,8 +1406,7 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() QCOMPARE(model.data(model.index(0, 1)).toString(), QString("Washington")); QCOMPARE(model.data(model.index(0, 2)).toInt(), 7); - //TODO: For some reson setting a record using manual submit fails - //model.setEditStrategy(QSqlTableModel::OnManualSubmit); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); QSqlRecord recNew; QSqlField f1New("id", QVariant::Int); diff --git a/tests/auto/testlib/selftests/expected_silent.txt b/tests/auto/testlib/selftests/expected_silent.txt new file mode 100644 index 0000000000..39e0bfc601 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_silent.txt @@ -0,0 +1,9 @@ +Testing tst_Silent +FAIL! : tst_Silent::fail() 'false' returned FALSE. (This test should fail) + Loc: [/home/jasmcdon/depot/qt5-test/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp(73)] +XPASS : tst_Silent::xpass() 'true' returned TRUE unexpectedly. (This test should XPASS) + Loc: [/home/jasmcdon/depot/qt5-test/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp(85)] +QFATAL : tst_Silent::messages() This is a fatal error message that should still appear in silent test output +FAIL! : tst_Silent::messages() Received a fatal error. + Loc: [Unknown file(0)] +Totals: 3 passed, 3 failed, 1 skipped diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 0809c4d497..1fc66e6364 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -30,6 +30,7 @@ SUBPROGRAMS = \ printdatatags \ printdatatagswithglobaltags \ qexecstringlist \ + silent \ singleskip \ skip \ skipcleanup \ diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index baa539a259..d05ac2a516 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -93,6 +93,7 @@ <file>expected_printdatatags.txt</file> <file>expected_printdatatagswithglobaltags.txt</file> <file>expected_qexecstringlist.txt</file> + <file>expected_silent.txt</file> <file>expected_singleskip.lightxml</file> <file>expected_singleskip.txt</file> <file>expected_singleskip.xml</file> diff --git a/tests/auto/testlib/selftests/silent/silent.pro b/tests/auto/testlib/selftests/silent/silent.pro new file mode 100644 index 0000000000..3150f65a5e --- /dev/null +++ b/tests/auto/testlib/selftests/silent/silent.pro @@ -0,0 +1,7 @@ +SOURCES += tst_silent.cpp +QT = core testlib-private + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = silent diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp new file mode 100644 index 0000000000..ec280f9f1a --- /dev/null +++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QCoreApplication> +#include <QtTest/QtTest> +#include <private/qtestlog_p.h> + +class tst_Silent : public QObject +{ + Q_OBJECT + +private slots: + void pass(); + void skip(); + void fail(); + void xfail(); + void xpass(); + + // This test function must be last, as it calls qFatal(). + void messages(); +}; + +void tst_Silent::pass() +{ + QVERIFY(true); +} + +void tst_Silent::skip() +{ + QSKIP("This test should skip"); +} + +void tst_Silent::fail() +{ + QVERIFY2(false, "This test should fail"); +} + +void tst_Silent::xfail() +{ + QEXPECT_FAIL("", "This test should XFAIL", Abort); + QVERIFY(false); +} + +void tst_Silent::xpass() +{ + QEXPECT_FAIL("", "This test should XPASS", Abort); + QVERIFY2(true, "This test should XPASS"); +} + +void tst_Silent::messages() +{ + qWarning("This is a warning that should not appear in silent test output"); + QWARN("This is an internal testlib warning that should not appear in silent test output"); + qDebug("This is a debug message that should not appear in silent test output"); + qCritical("This is a critical message that should not appear in silent test output"); + QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); + qFatal("This is a fatal error message that should still appear in silent test output"); +} + +QTEST_MAIN(tst_Silent) +#include "tst_silent.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index decaa55386..2b90bdb389 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -155,7 +155,7 @@ static inline QString logFormat(const QString &logger) // Return the log file name, or an empty string if the log goes to stdout. static inline QString logName(const QString &logger) { - return (logger.startsWith("stdout") ? "" : "test_output." + logger); + return (logger.startsWith("stdout") ? "" : QString("test_output." + logger)); } // Load the expected test output for the nominated test (subdir) and logger @@ -354,6 +354,7 @@ void tst_Selftests::runSubTest_data() << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" + << "silent" << "singleskip" << "skip" << "skipcleanup" @@ -409,6 +410,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "printdatatagswithglobaltags") { arguments << "-datatags"; } + else if (subtest == "silent") { + arguments << "-silent"; + } // These tests don't work right unless logging plain text to @@ -434,6 +438,9 @@ void tst_Selftests::runSubTest_data() if (subtest == "printdatatagswithglobaltags") { continue; } + if (subtest == "silent") { + continue; + } // `crashes' will not output valid XML on platforms without a crash handler if (subtest == "crashes") { continue; diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index d2cb9f2435..97c640b28f 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -126,7 +126,13 @@ TestCompiler::~TestCompiler() { } -bool TestCompiler::runCommand( QString cmdline ) +bool TestCompiler::errorOut() +{ + qDebug(qPrintable(testOutput_.join("\n"))); + return false; +} + +bool TestCompiler::runCommand( QString cmdline, bool expectFail ) { testOutput_.append("Running command: " + cmdline); @@ -137,21 +143,21 @@ bool TestCompiler::runCommand( QString cmdline ) child.start(cmdline); if (!child.waitForStarted(-1)) { testOutput_.append( "Unable to start child process." ); - return false; + return errorOut(); } - bool failed = false; child.setReadChannel(QProcess::StandardError); child.waitForFinished(-1); + bool ok = child.exitStatus() == QProcess::NormalExit && (expectFail ^ (child.exitCode() == 0)); foreach (const QByteArray &output, child.readAllStandardError().split('\n')) { testOutput_.append(QString::fromLocal8Bit(output)); if (output.startsWith("Project MESSAGE: FAILED")) - failed = true; + ok = false; } - return !failed && child.exitStatus() == QProcess::NormalExit && child.exitCode() == 0; + return ok ? true : errorOut(); } void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) @@ -160,6 +166,18 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) qmakeCmd_ = qmakeCmd; } +void TestCompiler::resetArguments() +{ + makeArgs_.clear(); + qmakeArgs_.clear(); +} + +void TestCompiler::setArguments( QString makeArgs, QString qmakeArgs ) +{ + makeArgs_ = makeArgs; + qmakeArgs_ = qmakeArgs; +} + void TestCompiler::resetEnvironment() { environment_.clear(); @@ -175,7 +193,7 @@ bool TestCompiler::makeClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return false; + return errorOut(); } D.setCurrent(workPath); @@ -192,7 +210,7 @@ bool TestCompiler::makeDistClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return false; + return errorOut(); } D.setCurrent(workPath); @@ -222,21 +240,21 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const makeFile += "Makefile"; // Now start qmake and generate the makefile - return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile ); + return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile ); } -bool TestCompiler::make( const QString &workPath, const QString &target ) +bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail ) { QDir D; D.setCurrent( workPath ); - QString cmdline = makeCmd_; + QString cmdline = makeCmd_ + " " + makeArgs_; if ( cmdline.contains("nmake", Qt::CaseInsensitive) ) cmdline.append(" /NOLOGO"); if ( !target.isEmpty() ) cmdline += " " + target; - return runCommand( cmdline ); + return runCommand( cmdline, expectFail ); } bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ) diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h index 116e424551..8aed3a9987 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -55,6 +55,10 @@ public: virtual ~TestCompiler(); void setBaseCommands( QString makeCmd, QString qmakeCmd ); + + void resetArguments(); + void setArguments( QString makeArgs, QString qmakeArgs ); + void resetEnvironment(); void addToEnvironment( QString varAssignment ); @@ -65,7 +69,7 @@ public: // executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null bool qmake( const QString &workDir, const QString &proName, const QString &buildDir = QString() ); // executes a make in the specified workPath, with an optional target (eg. install) - bool make( const QString &workPath, const QString &target = QString() ); + bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false ); // checks if the executable exists in destDir bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ); // removes the makefile @@ -76,13 +80,13 @@ public: void clearCommandOutput(); private: - bool runCommand( QString cmdLine ); + bool runCommand( QString cmdLine, bool expectFail = false ); + bool errorOut(); - QString makeCmd_; - QString qmakeCmd_; + QString makeCmd_, makeArgs_; + QString qmakeCmd_, qmakeArgs_; QStringList environment_; - // need to make this available somewhere QStringList testOutput_; }; diff --git a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro index 644a817a8e..e4f81e6e1e 100644 --- a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro +++ b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro @@ -1,9 +1,3 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp QWERTY_BUNDLE.version = Bogus.78 diff --git a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro index 43577b5122..442c9c767f 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro @@ -1,10 +1,5 @@ -TEMPLATE = app -TARGET = findDeps -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h \ object2.h \ object3.h \ diff --git a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro index 1469b4c5c3..a4a7dc987d 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = findMocs -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h SOURCES += main.cpp diff --git a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro index 7f22f437c2..13d4d6c4ad 100644 --- a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro +++ b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro @@ -6,7 +6,9 @@ SOURCES = main.cpp RCCINPUT = "rc folder/test.qrc" RCCOUTPUT = test.cpp -rcc_test.commands = rcc -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} +qtPrepareTool(QMAKE_RCC, rcc) + +rcc_test.commands = $$QMAKE_RCC -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} rcc_test.output = $$RCCOUTPUT rcc_test.input = RCCINPUT rcc_test.variable_out = SOURCES diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 4da781f763..88ff10a764 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -57,7 +57,6 @@ public: public slots: void initTestCase(); void cleanupTestCase(); - void init(); void cleanup(); private slots: @@ -131,13 +130,10 @@ void tst_qmake::cleanupTestCase() { } -void tst_qmake::init() -{ - test_compiler.clearCommandOutput(); -} - void tst_qmake::cleanup() { + test_compiler.resetArguments(); + test_compiler.resetEnvironment(); test_compiler.clearCommandOutput(); } @@ -305,7 +301,6 @@ void tst_qmake::export_across_file_boundaries() test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - test_compiler.resetEnvironment(); } void tst_qmake::include_dir() @@ -448,31 +443,30 @@ void tst_qmake::bundle_spaces() { QString workDir = base_path + "/testdata/bundle-spaces"; - // We set up alternate commands here, to make sure we're testing Mac + // We set up alternate arguments here, to make sure we're testing Mac // Bundles and since this might be the wrong output we rely on dry-running // make (-n). - TestCompiler local_tc; - local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++"); + test_compiler.setArguments("-n", "-spec macx-g++"); - QVERIFY( local_tc.qmake(workDir, "bundle-spaces") ); + QVERIFY( test_compiler.qmake(workDir, "bundle-spaces") ); TempFile non_existing_file(workDir + "/non-existing file"); QVERIFY( !non_existing_file.exists() ); // Make fails: no rule to make "non-existing file" - QVERIFY( !local_tc.make(workDir) ); + QVERIFY( test_compiler.make(workDir, QString(), true) ); QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); QVERIFY( non_existing_file.exists() ); // Aha! - QVERIFY( local_tc.make(workDir) ); + QVERIFY( test_compiler.make(workDir) ); // Cleanup QVERIFY( non_existing_file.remove() ); QVERIFY( !non_existing_file.exists() ); - QVERIFY( local_tc.removeMakefile(workDir) ); + QVERIFY( test_compiler.removeMakefile(workDir) ); } #endif // Q_OS_WIN diff --git a/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro b/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro index 730932d83d..b4cf05e347 100644 --- a/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro +++ b/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro @@ -1,10 +1,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qerrormessage -DEPENDPATH += . -INCLUDEPATH += . QT += widgets testlib -# Input SOURCES += tst_qerrormessage.cpp diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 7ab3100cab..4a6f714a7c 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -489,6 +489,9 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() { +#ifdef Q_OS_MAC + QSKIP("This test currently fails on Mac OS X, see QTBUG-23602"); +#endif QDir current = QDir::currentPath(); current.mkdir("test"); current.cd("test"); @@ -515,9 +518,6 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Return); QTest::qWait(200); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "This test currently fails on Mac OS X, see QTBUG-23602", Continue); -#endif QCOMPARE(fd.isVisible(), true); QTest::qWait(200); file.close(); diff --git a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro index f25ed650c3..91848fee24 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro +++ b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro @@ -1,9 +1,6 @@ -CONFIG += testcase TEMPLATE = app TARGET = tst_qmessagebox -QT += widgets testlib -DEPENDPATH += . -INCLUDEPATH += . +QT += gui-private core-private widgets testlib +CONFIG += testcase -# Input SOURCES += tst_qmessagebox.cpp diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 7fc752488d..1d391a1c09 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -48,6 +48,8 @@ #include <QApplication> #include <QPushButton> #include <QDialogButtonBox> +#include <QPlatformTheme> +#include <private/qguiapplication_p.h> #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) #include <QMacStyle> #endif @@ -407,15 +409,12 @@ void tst_QMessageBox::staticSourceCompat() sendKeySoon(); ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No); int expectedButton = int(QMessageBox::Yes); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - if (qobject_cast<QMacStyle *>(qApp->style())) - expectedButton = int(QMessageBox::No); -#elif !defined(QT_NO_STYLE_CLEANLOOKS) - if (qobject_cast<QCleanlooksStyle *>(qApp->style())) { - QEXPECT_FAIL("", "Special handling of QMessageBox::information buttons for Cleanlooks not implemented yet, QTBUG-24315", Continue); - expectedButton = int(QMessageBox::No); + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + const int dialogButtonBoxLayout = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt(); + if (dialogButtonBoxLayout == QDialogButtonBox::MacLayout + || dialogButtonBoxLayout == QDialogButtonBox::GnomeLayout) + expectedButton = int(QMessageBox::No); } -#endif QCOMPARE(ret, expectedButton); QCOMPARE(keyToSend, -1); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 3257e7efea..220c89ec2f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -51,7 +51,7 @@ #include <private/qgraphicssceneindex_p.h> #include <math.h> #include "../../../gui/painting/qpathclipper/pathcompare.h" -#include "../../shared/platforminputcontext.h" +#include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7ceeaaa0d3..84dea04c45 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -71,7 +71,7 @@ #include <QtWidgets/QDesktopWidget> #include <private/qgraphicsview_p.h> #include "../../../platformquirks.h" -#include "../../shared/platforminputcontext.h" +#include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> Q_DECLARE_METATYPE(QList<int>) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 4dd57e1b90..3edc125b5a 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -205,6 +205,7 @@ private slots: void QTBUG12268_hiddenMovedSectionSorting(); void QTBUG14242_hideSectionAutoSize(); void ensureNoIndexAtLength(); + void offsetConsistent(); void initialSortOrderRole(); @@ -2168,6 +2169,33 @@ void tst_QHeaderView::ensureNoIndexAtLength() QVERIFY(hv->visualIndexAt(hv->length()) == -1); } +void tst_QHeaderView::offsetConsistent() +{ + // Ensure that a hidden section 'far away' + // does not affect setOffsetToSectionPosition .. + const int sectionToHide = 513; + QTableView qtv; + QStandardItemModel amodel(1000, 4); + qtv.setModel(&amodel); + QHeaderView *hv = qtv.verticalHeader(); + for (int u = 0; u < 100; u += 2) + hv->resizeSection(u, 0); + hv->setOffsetToSectionPosition(150); + int offset1 = hv->offset(); + hv->hideSection(sectionToHide); + hv->setOffsetToSectionPosition(150); + int offset2 = hv->offset(); + QVERIFY(offset1 == offset2); + // Ensure that hidden indexes (still) is considered. + hv->resizeSection(sectionToHide, hv->sectionSize(200) * 2); + hv->setOffsetToSectionPosition(800); + offset1 = hv->offset(); + hv->showSection(sectionToHide); + hv->setOffsetToSectionPosition(800); + offset2 = hv->offset(); + QVERIFY(offset2 > offset1); +} + void tst_QHeaderView::initialSortOrderRole() { QTableView view; // ### Shadowing member view (of type QHeaderView) diff --git a/tests/auto/widgets/itemviews/qtableview/qtableview.pro b/tests/auto/widgets/itemviews/qtableview/qtableview.pro index 528fa7d014..889caaf3c8 100644 --- a/tests/auto/widgets/itemviews/qtableview/qtableview.pro +++ b/tests/auto/widgets/itemviews/qtableview/qtableview.pro @@ -1,5 +1,5 @@ CONFIG += testcase - +TARGET = tst_qtableview QT += widgets widgets-private testlib QT += core-private gui-private diff --git a/tests/auto/widgets/kernel/qaction/qaction.pro b/tests/auto/widgets/kernel/qaction/qaction.pro index e6f0735394..c57107b1b0 100644 --- a/tests/auto/widgets/kernel/qaction/qaction.pro +++ b/tests/auto/widgets/kernel/qaction/qaction.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qaction -QT += widgets testlib +QT += gui-private core-private widgets testlib SOURCES += tst_qaction.cpp diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 47aad21074..51123af953 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -46,6 +46,8 @@ #include <qevent.h> #include <qaction.h> #include <qmenu.h> +#include <qplatformtheme_qpa.h> +#include <private/qguiapplication_p.h> class tst_QAction : public QObject { @@ -77,6 +79,7 @@ private slots: private: int m_lastEventType; + int m_keyboardScheme; QAction *m_lastAction; QWidget *m_tstWidget; }; @@ -121,8 +124,10 @@ private: tst_QAction *tst; }; -tst_QAction::tst_QAction() +tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } tst_QAction::~tst_QAction() @@ -237,13 +242,21 @@ void tst_QAction::setStandardKeys() QVERIFY(act.shortcut() == act.shortcuts().first()); QList<QKeySequence> expected; -#if defined(Q_OS_MAC) - expected << QKeySequence("CTRL+C"); -#else - expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); -#endif -// Qt/Embedded on Windows: expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); - QVERIFY(act.shortcuts() == expected); + const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); + const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); + switch (m_keyboardScheme) { + case QPlatformTheme::MacKeyboardScheme: + expected << ctrlC; + break; + case QPlatformTheme::WindowsKeyboardScheme: + expected << ctrlC << ctrlInsert; + break; + default: // X11 + expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert; + break; + } + + QCOMPARE(act.shortcuts(), expected); } diff --git a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro index 3b229e31cb..97768eac74 100644 --- a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro +++ b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro @@ -1,15 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.00a) Mon Jul 11 11:30:34 2005 -###################################################################### +QT += widgets +CONFIG -= app_bundle -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input -QT += widgets SOURCES += main.cpp -CONFIG += qt warn_on create_prl link_prl -CONFIG -= app_bundle - diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 5a18a70d9e..842fd11062 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -1,4 +1,5 @@ CONFIG += testcase +TARGET = tst_qstyle TARGET.EPOCHEAPSIZE = 0x200000 0x800000 QT += widgets testlib SOURCES += tst_qstyle.cpp diff --git a/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro b/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro index cadc6d6ddc..bf12a6b30f 100644 --- a/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro +++ b/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro @@ -1,12 +1,7 @@ -###################################################################### -# Automatically generated by qmake (2.00a) ti 8. mar 16:20:21 2005 -###################################################################### +TEMPLATE = app +TARGET = tst_qstyleoption CONFIG += testcase -TARGET = tst_qstyleoption -TEMPLATE = app QT += widgets testlib -# Input -SOURCES += tst_qstyleoption.cpp - +SOURCES += tst_qstyleoption.cpp diff --git a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro index f908c3ab7d..dd17183b30 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,10 +1,10 @@ CONFIG += testcase TARGET = tst_qstylesheetstyle -QT += widgets widgets-private testlib -QT += gui-private -# Input +QT += widgets widgets-private gui-private testlib + SOURCES += tst_qstylesheetstyle.cpp RESOURCES += resources.qrc + requires(contains(QT_CONFIG,private_tests)) win32:CONFIG += insignificant_test # QTBUG-24323 diff --git a/tests/auto/widgets/util/qcompleter/qcompleter.pro b/tests/auto/widgets/util/qcompleter/qcompleter.pro index 63b137eb7c..6a817a89ac 100644 --- a/tests/auto/widgets/util/qcompleter/qcompleter.pro +++ b/tests/auto/widgets/util/qcompleter/qcompleter.pro @@ -2,10 +2,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qcompleter QT += widgets testlib -DEPENDPATH += . -INCLUDEPATH += . .. -# Input SOURCES += tst_qcompleter.cpp CONFIG += insignificant_test # QTBUG-21424 diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 7cc043e247..f9eb8b6159 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -43,6 +43,8 @@ #include "qcombobox.h" #include <private/qcombobox_p.h> +#include <private/qguiapplication_p.h> +#include <qplatformtheme_qpa.h> #include <qfontcombobox.h> #include <qdesktopwidget.h> @@ -1915,19 +1917,15 @@ void tst_QComboBox::itemListPosition() QWidget topLevel; QFontComboBox combo(&topLevel); - //the code to get the avaialbe screen space is copied from QComboBox code + //the code to get the available screen space is copied from QComboBox code const int scrNumber = QApplication::desktop()->screenNumber(&combo); - QRect screen; -#ifdef Q_WS_WIN - screen = QApplication::desktop()->screenGeometry(scrNumber); -#elif defined Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) - screen = QApplication::desktop()->screenGeometry(scrNumber); - else - screen = QApplication::desktop()->availableGeometry(scrNumber); -#else - screen = QApplication::desktop()->availableGeometry(scrNumber); -#endif + + bool useFullScreenForPopupMenu = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); + const QRect screen = useFullScreenForPopupMenu ? + QApplication::desktop()->screenGeometry(scrNumber) : + QApplication::desktop()->availableGeometry(scrNumber); combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index 77b2ae537c..83f93f0ba0 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -1,6 +1,7 @@ CONFIG += testcase TARGET = tst_qlineedit -QT += widgets testlib +QT += gui-private core-private widgets testlib SOURCES += tst_qlineedit.cpp -CONFIG += insignificant_test # QTBUG-21402 +# QTBUG-24518 - unstable test +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 645f47fc72..81dc940c00 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -48,6 +48,8 @@ #include "qvalidator.h" #include "qcompleter.h" #include "qstandarditemmodel.h" +#include "qplatformtheme_qpa.h" +#include <private/qguiapplication_p.h> #ifndef QT_NO_CLIPBOARD #include "qclipboard.h" @@ -300,6 +302,7 @@ private: int lastCursorPos; int newCursorPos; QLineEdit *testWidget; + int m_keyboardScheme; }; typedef QList<int> IntList; @@ -327,9 +330,16 @@ void tst_QLineEdit::getSetCheck() QCOMPARE(true, obj1.dragEnabled()); } -tst_QLineEdit::tst_QLineEdit() +tst_QLineEdit::tst_QLineEdit() : validInput(false), m_keyboardScheme(0) { - validInput = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); + // Generalize for X11 + if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) { + m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; + } } tst_QLineEdit::~tst_QLineEdit() @@ -1071,25 +1081,26 @@ void tst_QLineEdit::undo() QVERIFY(!testWidget->isUndoAvailable()); QVERIFY(testWidget->text().isEmpty()); -#ifdef Q_WS_WIN - // Repeat the test using shortcut instead of undo() - for (i=0; i<insertString.size(); ++i) { - if (insertIndex[i] > -1) - testWidget->setCursorPosition(insertIndex[i]); - if (insertMode[i] == REPLACE_UNTIL_END) { - testWidget->setSelection(insertIndex[i], 8); + + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + // Repeat the test using shortcut instead of undo() + for (i=0; i<insertString.size(); ++i) { + if (insertIndex[i] > -1) + testWidget->setCursorPosition(insertIndex[i]); + if (insertMode[i] == REPLACE_UNTIL_END) + testWidget->setSelection(insertIndex[i], 8); + if (use_keys) + QTest::keyClicks(testWidget, insertString[i]); + else + testWidget->insert(insertString[i]); + } + for (i=0; i<expectedString.size()-1; ++i) { + QCOMPARE(testWidget->text(), expectedString[i]); + QVERIFY(testWidget->isUndoAvailable()); + QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); } - if (use_keys) - QTest::keyClicks(testWidget, insertString[i]); - else - testWidget->insert(insertString[i]); - } - for (i=0; i<expectedString.size()-1; ++i) { - QCOMPARE(testWidget->text(), expectedString[i]); - QVERIFY(testWidget->isUndoAvailable()); - QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); } -#endif + } void tst_QLineEdit::redo_data() @@ -1152,21 +1163,22 @@ void tst_QLineEdit::redo() QVERIFY(!testWidget->isRedoAvailable()); -#ifdef Q_WS_WIN - // repeat test, this time using shortcuts instead of undo()/redo() - while (!testWidget->text().isEmpty()) - QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + // repeat test, this time using shortcuts instead of undo()/redo() - for (i = 0; i < expectedString.size(); ++i) { - QVERIFY(testWidget->isRedoAvailable()); - QTest::keyClick(testWidget, Qt::Key_Backspace, - Qt::ShiftModifier | Qt::AltModifier); - QCOMPARE(testWidget->text() , expectedString[i]); - } + while (!testWidget->text().isEmpty()) + QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); - QVERIFY(!testWidget->isRedoAvailable()); -#endif + for (i = 0; i < expectedString.size(); ++i) { + QVERIFY(testWidget->isRedoAvailable()); + QTest::keyClick(testWidget, Qt::Key_Backspace, + Qt::ShiftModifier | Qt::AltModifier); + QCOMPARE(testWidget->text() , expectedString[i]); + } + + QVERIFY(!testWidget->isRedoAvailable()); + } } void tst_QLineEdit::undo_keypressevents_data() @@ -1263,7 +1275,7 @@ void tst_QLineEdit::undo_keypressevents_data() // unselect any current selection keys.addKeyClick(Qt::Key_Right); -#ifdef Q_WS_WIN //Mac has a specialcase to handle jumping to the end of a selection +#ifdef Q_OS_WIN //Mac has a specialcase to handle jumping to the end of a selection keys.addKeyClick(Qt::Key_Left); #endif @@ -3080,6 +3092,7 @@ void tst_QLineEdit::leftKeyOnSelectedText() #ifdef Q_OS_WIN QCOMPARE(testWidget->cursorPosition(), 1); #else + // Selection is cleared ands cursor remains at position 2. // X11 used to behave like window prior to 4.2. Changes caused by QKeySequence // resulted in an inadvertant change in behavior QCOMPARE(testWidget->cursorPosition(), 2); @@ -3603,6 +3616,9 @@ void tst_QLineEdit::taskQTBUG_7902_contextMenuCrash() void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() { +#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) + QSKIP("QTBUG-24518 - Unstable test for Ubuntu 11.10"); +#endif //ReadOnly QLineEdit should not intercept shortcut. QLineEdit le; le.setReadOnly(true); @@ -3624,9 +3640,8 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() { -#ifndef Q_WS_X11 - QSKIP("Only tested on X11"); -#endif + if (m_keyboardScheme != QPlatformTheme::X11KeyboardScheme) + QSKIP("Only tested on X11"); QLineEdit le; le.setText(" "); QPalette p = le.palette(); diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 13540355c7..0f07546559 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -101,6 +101,7 @@ private slots: void centralWidgetSize(); void dockWidgetSize(); void QTBUG2774_stylechange(); + void QTBUG15080_restoreState(); void toggleUnifiedTitleAndToolBarOnMac(); }; @@ -1705,6 +1706,41 @@ void tst_QMainWindow::QTBUG2774_stylechange() } } +void tst_QMainWindow::QTBUG15080_restoreState() +{ + QByteArray state; + + //save state + { + QMainWindow mw1; + QDockWidget * dw1 = new QDockWidget(); + dw1->setObjectName("Left DockWidget"); + mw1.addDockWidget(Qt::LeftDockWidgetArea, dw1); + mw1.setCentralWidget(new QTextEdit()); + mw1.show(); + QApplication::processEvents(); + dw1->setFixedWidth(101); + QApplication::processEvents(); + + state = mw1.saveState(); + } + + //restore state + + QMainWindow mw2; + QDockWidget * dw2 = new QDockWidget(); + dw2->setObjectName("Left DockWidget"); + mw2.addDockWidget(Qt::LeftDockWidgetArea, dw2); + mw2.setCentralWidget(new QTextEdit()); + mw2.restoreState(state); + //QTBUG15080 caused by setStyleSheet + mw2.setStyleSheet("color:red"); + mw2.show(); + QApplication::processEvents(); + + QCOMPARE(dw2->width(), 101); +} + void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac() { #ifdef Q_OS_MAC diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro index 55099f1c54..9efd0302bf 100644 --- a/tests/auto/widgets/widgets/qmenu/qmenu.pro +++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro @@ -3,4 +3,3 @@ TARGET = tst_qmenu QT += widgets testlib SOURCES += tst_qmenu.cpp -win32:CONFIG += insignificant_test # QTBUG-24325 diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 9989e5e7aa..6a1f418739 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -50,10 +50,6 @@ #include <qaction.h> #include <qstyleoption.h> -#ifdef Q_WS_WIN -#include <windows.h> -#endif - #include <qobject.h> QT_FORWARD_DECLARE_CLASS(QMainWindow) diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png Binary files differindex ced6eb6e5b..b9df19eeb3 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png Binary files differindex 481b99c7fc..792593ff12 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png Binary files differindex 292d3f9d4c..02e5e93380 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png Binary files differindex 69b72ede09..5ef32d2d19 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png Binary files differindex 467b91e6e0..d877e1b656 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png Binary files differindex cce921b0cc..411c0859aa 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png Binary files differindex 937494ac3c..55d060af1f 100644 --- a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png +++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index d79044157a..1533e6a139 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1845,7 +1845,7 @@ void tst_QDom::checkIntOverflow() const QVERIFY(doc.setContent(xmlMessage)); const QDomNodeList nl(doc.elementsByTagName(QLatin1String("test"))); - QCOMPARE(nl.length(), uint(1)); + QCOMPARE(nl.length(), 1); } } diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro index 93167f81c8..f801200942 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro +++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro @@ -1,15 +1,4 @@ -###################################################################### -# Automatically generated by qmake (1.06a) Thu Jun 5 19:00:42 2003 -###################################################################### - -TEMPLATE = app -INCLUDEPATH += . +QT += xml -# Input HEADERS += parser.h SOURCES += main.cpp parser.cpp - -CONFIG += qt warn_on debug -QT += xml - - diff --git a/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro b/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro index cec33ded18..dc579ab742 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro +++ b/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro @@ -4,7 +4,6 @@ TEMPLATE = app DEPENDPATH += parser INCLUDEPATH += . parser -# Input HEADERS += parser/parser.h SOURCES += tst_qxmlsimplereader.cpp parser/parser.cpp |