From ddf4b378f1e7eac62bd504a1e453cb7b894e21f2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 12:40:20 +0100 Subject: Inline and mark as deprecated images's serialNumber() These function are marked as obsolete since Qt 4.3 The motivation here was too fix QPixmap::serialNumber which is marked as QT_DEPRECATED_SINCE but was not inlined. But then I took the oportunity to do the same with all the other functions. Change-Id: Ic50a7857461fc402b2f2b4528c83e53e8e28ea30 Reviewed-by: Lars Knoll --- tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp | 2 +- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 50ae22c530..7ca4fc981b 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -2938,7 +2938,7 @@ void tst_QTextDocumentFragment::backgroundImage() doc.setHtml("

Hello

"); QBrush bg = doc.begin().blockFormat().background(); QVERIFY(bg.style() == Qt::TexturePattern); - QVERIFY(bg.texture().serialNumber() == doc.testPixmap.serialNumber()); + QCOMPARE(bg.texture().cacheKey(), doc.testPixmap.cacheKey()); } void tst_QTextDocumentFragment::dontMergePreAndNonPre() diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 907a239912..7cc043e247 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1333,7 +1333,7 @@ void tst_QComboBox::textpixmapdata() for (int i = 0; iitemIcon(i); - QVERIFY(icon.serialNumber() == icons.at(i).serialNumber()); + QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey()); QPixmap original = icons.at(i).pixmap(1024); QPixmap pixmap = icon.pixmap(1024); QVERIFY(pixmap.toImage() == original.toImage()); -- cgit v1.2.3 From 5bb1408927b4eb5a03e8ab9f7cbc68f80d8a3962 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 23 Feb 2012 11:12:58 +1000 Subject: Allow moc to handle symbols that have been redefined. Allow moc to produce the desired identifiers when used with C++ symbol names that have been redefined, for example by -Dfoo=bar. Two changes are required: firstly, when encoding a type name, the components of the name must be checked for substitutions that have been defined for that token (note that this is not done here by correct pre-processing, but only by processing the resultant table of definitions). Secondly, the arguments to the SIGNAL, SLOT and METHOD macros must be allowed to be substituted during macro expansion rather than stringized directly. This is a temporary change to prevent breaking existing projects that depend on the declarative module. After clients have had an opportunity to update their code to the use the new interfaces, it can be removed. Task-number: QTBUG-23737 Change-Id: I39e6844cebf6ca7984af6028160b8a3797ac44a5 Reviewed-by: Martin Jones --- tests/auto/tools/moc/tst_moc.cpp | 152 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 27db6cc59c..49095048bf 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -535,6 +535,7 @@ private slots: void cxx11Enums_data(); void cxx11Enums(); void returnRefs(); + void redefinedNames(); signals: void sigWithUnsignedArg(unsigned foo); @@ -1762,6 +1763,157 @@ void tst_Moc::returnRefs() // they used to cause miscompilation of the moc generated file. } +struct ActualInterfaceName +{ + virtual ~ActualInterfaceName() {} + virtual void foo() = 0; +}; + +QT_BEGIN_NAMESPACE +Q_DECLARE_INTERFACE(ActualInterfaceName, "foo.bar.ActualInterfaceName") +QT_END_NAMESPACE + +#define DefinedInterfaceName ActualInterfaceName +#define RedefinedInterfaceName DefinedInterfaceName + +struct ActualName {}; +#define DefinedName ActualName +#define RedefinedName DefinedName + +template +struct ActualTemplateName {}; + +#define DefinedTemplateName ActualTemplateName +#define RedefinedTemplateName DefinedTemplateName + +#define ActualName ActualName + +class RedefinitionTest : public QObject, public RedefinedInterfaceName +{ + Q_OBJECT + Q_INTERFACES(RedefinedInterfaceName) + + Q_PROPERTY(ActualName p1 READ getP1) + + Q_PROPERTY(DefinedName p2 READ getP2) + Q_PROPERTY(RedefinedName p3 READ getP3) + + Q_PROPERTY(DefinedName * p4 READ getP4) + Q_PROPERTY(RedefinedName * p5 READ getP5) + + Q_PROPERTY(DefinedName ** p6 READ getP6) + Q_PROPERTY(RedefinedName ** p7 READ getP7) + + Q_PROPERTY(DefinedName const ** p8 READ getP8) + Q_PROPERTY(RedefinedName const ** p9 READ getP9) + + Q_PROPERTY(DefinedName const * const * p10 READ getP10) + Q_PROPERTY(RedefinedName const * const * p11 READ getP11) + + Q_PROPERTY(DefinedTemplateName p16 READ getP16) + Q_PROPERTY(RedefinedTemplateName p17 READ getP17) + + Q_PROPERTY(DefinedTemplateName p18 READ getP18) + Q_PROPERTY(RedefinedTemplateName p19 READ getP19) + + Q_PROPERTY(DefinedTemplateName p20 READ getP20) + Q_PROPERTY(RedefinedTemplateName p21 READ getP21) + +signals: + void signal1(ActualName); + void signal2(DefinedName); + void signal3(RedefinedName); + +public slots: + void slot1(ActualName x) { v = x; } + void slot2(DefinedName x) { v = x; } + void slot3(RedefinedName x) { v = x; } + +public: + void foo() {} + + ActualName v; + + ActualName *vp; + ActualName const *vcp; + + ActualTemplateName tv; + ActualTemplateName tvpp; + ActualTemplateName tvcpc; + + ActualName getP0() { return v; } + ActualName getP1() { return v; } + + DefinedName getP2() { return v; } + RedefinedName getP3() { return v; } + + DefinedName * getP4() { return &v; } + RedefinedName * getP5() { return &v; } + + DefinedName ** getP6() { return &vp; } + RedefinedName ** getP7() { return &vp; } + + DefinedName const ** getP8() { return &vcp; } + RedefinedName const ** getP9() { return &vcp; } + + DefinedName const * const * getP10() const { return &vcp; } + RedefinedName const * const * getP11() const { return &vcp; } + + DefinedTemplateName getP16() { return tv; } + RedefinedTemplateName getP17() { return tv; } + + DefinedTemplateName getP18() { return tvpp; } + RedefinedTemplateName getP19() { return tvpp; } + + DefinedTemplateName getP20() { return tvcpc; } + RedefinedTemplateName getP21() { return tvcpc; } +}; + +void tst_Moc::redefinedNames() +{ + RedefinitionTest tst; + const QMetaObject *mobj = tst.metaObject(); + QVERIFY(mobj->indexOfProperty("p1") != -1); + + // Use the true slot name rather than the declared name + QVERIFY(QObject::connect(&tst, SIGNAL(signal1(ActualName)), + &tst, SLOT(slot1(ActualName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(ActualName)), + &tst, SLOT(slot2(ActualName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(ActualName)), + &tst, SLOT(slot3(ActualName)))); + + // Use the declared slot name rather than the true name + QVERIFY(QObject::connect(&tst, SIGNAL(signal1(ActualName)), + &tst, SLOT(slot2(DefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal1(ActualName)), + &tst, SLOT(slot3(RedefinedName)))); + + // Use the declared signal name rather than the true name + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(DefinedName)), + &tst, SLOT(slot1(ActualName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(RedefinedName)), + &tst, SLOT(slot1(ActualName)))); + + // Use both declared names + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(DefinedName)), + &tst, SLOT(slot2(DefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(DefinedName)), + &tst, SLOT(slot3(RedefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(RedefinedName)), + &tst, SLOT(slot2(DefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(RedefinedName)), + &tst, SLOT(slot3(RedefinedName)))); +} + + QTEST_APPLESS_MAIN(tst_Moc) #include "tst_moc.moc" -- cgit v1.2.3 From b804b81288772b64dbd633c1e320f6e71a00b473 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 28 Feb 2012 14:57:29 +1000 Subject: Remove unused selftest data file. The private git history shows that the test program associated with this data file was missing from the original commit and was never subsequently added. Change-Id: I3401724ac04168158a48eb06436db83d3557711f Reviewed-by: Rohan McGovern --- tests/auto/testlib/selftests/expected_fatal.txt | 6 ------ tests/auto/testlib/selftests/selftests.qrc | 1 - 2 files changed, 7 deletions(-) delete mode 100644 tests/auto/testlib/selftests/expected_fatal.txt (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/expected_fatal.txt b/tests/auto/testlib/selftests/expected_fatal.txt deleted file mode 100644 index a525fee0a1..0000000000 --- a/tests/auto/testlib/selftests/expected_fatal.txt +++ /dev/null @@ -1,6 +0,0 @@ -********* Start testing of tst_Fatal ********* -Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ -PASS : tst_Fatal::initTestCase() -QFATAL : tst_Fatal::testFunction() A fatal error occured! Ouuiieee!! The world is coming to an end and I will die! Buhu! -Totals: 1 passed, 0 failed, 0 skipped -********* Finished testing of tst_Fatal ********* diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index d05ac2a516..e39515e5be 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -71,7 +71,6 @@ expected_failinitdata.txt expected_failinitdata.xml expected_failinitdata.xunitxml - expected_fatal.txt expected_fetchbogus.lightxml expected_fetchbogus.txt expected_fetchbogus.xml -- cgit v1.2.3 From e1cc0d6bbc2c65b10f23b2935a68a3a34b7c26a0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 11:54:29 +0100 Subject: Allow QChar::SpecialCharacter with QStringBuilder. Change-Id: I3c91fd516bb13e5534aa6f26ee9df745c990dfb5 Reviewed-by: Olivier Goffart --- .../corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index afc16078b8..556b9ac16a 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -73,6 +73,7 @@ void runScenario() QString string(l1string); QStringRef stringref(&string, 2, 10); QLatin1Char achar('c'); + QChar::SpecialCharacter special(QChar::Nbsp); QString r2(QLatin1String(LITERAL LITERAL)); QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); QString r; @@ -97,6 +98,8 @@ void runScenario() QCOMPARE(r, QString(string P achar)); r = achar + string; QCOMPARE(r, QString(achar P string)); + r = special + string; + QCOMPARE(r, QString(special P string)); #ifdef Q_COMPILER_UNICODE_STRINGS r = QStringLiteral(UNICODE_LITERAL); -- cgit v1.2.3 From e28be90dea1414e875d9f45f6a1d3e3f7c9ab7ec Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 12:49:00 +0100 Subject: Fix build of QWizard tests with QT_USE_QSTRINGBUILDER Change-Id: Id276cdb9b84c61bf75a5bde149142f39f52f563e Reviewed-by: Olivier Goffart --- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 872c13216f..9d9b55cafd 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -562,8 +562,8 @@ void tst_QWizard::setDefaultProperty() // make sure the data structure is reasonable for (int i = 0; i < 200000; ++i) { - wizard.setDefaultProperty("QLineEdit", "x" + QByteArray::number(i), 0); - wizard.setDefaultProperty("QLabel", "y" + QByteArray::number(i), 0); + wizard.setDefaultProperty("QLineEdit", QByteArray("x" + QByteArray::number(i)).constData(), 0); + wizard.setDefaultProperty("QLabel", QByteArray("y" + QByteArray::number(i)).constData(), 0); } } -- cgit v1.2.3 From 98ecbf1f50c829f55effc012aeb835f99cb7fcdf Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 12:50:23 +0100 Subject: Fix build of QImageReader tests with QT_USE_QSTRINGBUILDER. Change-Id: I789d99d0741bc178d2d7fd82558edc684eb6daf8 Reviewed-by: Olivier Goffart --- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 96171740e2..dd839ec0ae 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1368,7 +1368,7 @@ void tst_QImageReader::readFromResources() SKIP_IF_UNSUPPORTED(format); for (int i = 0; i < 2; ++i) { - QString file = i ? (":/images/" + fileName) : (prefix + fileName); + QString file = i ? QString(QStringLiteral(":/images/") + fileName) : QString(prefix + fileName); { // suppress warnings if we expect them if (!message.isEmpty()) { -- cgit v1.2.3 From 9b5cdccc02e3a3f173359f4a71d6143c290a1342 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 Feb 2012 08:31:41 +0100 Subject: Skip test tst_QTextScriptEngine::thaiWithZWJ on Windows. Change-Id: I9286ae8b1200b2d6638d1257a872450a9886fce0 Reviewed-by: Friedemann Kleint Reviewed-by: Sergio Ahumada --- tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 7c9a83eaa4..a88e93c93e 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1283,6 +1283,9 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm() void tst_QTextScriptEngine::thaiWithZWJ() { +#ifdef Q_OS_WIN + QSKIP("This test currently fails on Windows - QTBUG-24565"); +#endif QString s(QString::fromUtf8("ร‍ร‌.ร.“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); QTextLayout layout(s); layout.beginLayout(); -- cgit v1.2.3 From bcb0f28a4d8625e546ae6d43e1365cc1f8b5373c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 24 Feb 2012 14:18:08 +0100 Subject: Fix tests of QMimeDatabase. - Use temporary directories to avoid instabilities due to remains of previous failed tests and locked directories. - Replace SRCDIR by QFINDTESTDATA(), reference only the freedesktop.org.xml contained in the Qt source tree by $$QT.corelib.sources. - Improve some error messages, test suite instructions for Windows. Change-Id: Idee8e3767ef0a8299df3bdaaac20334164878db0 Reviewed-by: Friedemann Kleint Reviewed-by: David Faure --- .../qmimedatabase-cache/qmimedatabase-cache.pro | 2 +- .../tst_qmimedatabase-cache.cpp | 9 +- .../qmimedatabase-xml/qmimedatabase-xml.pro | 2 +- .../qmimedatabase-xml/tst_qmimedatabase-xml.cpp | 4 +- .../mimetypes/qmimedatabase/qmimedatabase.pro | 2 +- .../mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 157 ++++++++++++++------- .../mimetypes/qmimedatabase/tst_qmimedatabase.h | 10 +- 7 files changed, 121 insertions(+), 65 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro index 815401ce1e..ba68167a6f 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro @@ -7,6 +7,6 @@ QT = core testlib concurrent SOURCES = tst_qmimedatabase-cache.cpp HEADERS = ../tst_qmimedatabase.h -DEFINES += SRCDIR='"\\"$$PWD/../\\""' +DEFINES += CORE_SOURCES='"\\"$$QT.core.sources\\""' *-g++*:QMAKE_CXXFLAGS += -W -Wall -Wextra -Werror -Wshadow -Wno-long-long -Wnon-virtual-dtor diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp index 205331d4dd..5ef04dc01d 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/tst_qmimedatabase-cache.cpp @@ -47,10 +47,9 @@ #include "../tst_qmimedatabase.cpp" -tst_QMimeDatabase::tst_QMimeDatabase() +void tst_QMimeDatabase::init() { - QDir here = QDir::currentPath(); - const QString tempMime = here.absolutePath() + QString::fromLatin1("/mime"); - runUpdateMimeDatabase(tempMime); - QVERIFY(QFile::exists(tempMime + QString::fromLatin1("/mime.cache"))); + const QString mimeDirName = m_globalXdgDir + QStringLiteral("/mime"); + runUpdateMimeDatabase(mimeDirName); + QVERIFY(QFile::exists(mimeDirName + QStringLiteral("/mime.cache"))); } diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro index ac7515f781..4c00e84fc1 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro @@ -9,6 +9,6 @@ CONFIG += depend_includepath SOURCES += tst_qmimedatabase-xml.cpp HEADERS += ../tst_qmimedatabase.h -DEFINES += SRCDIR='"\\"$$PWD/../\\""' +DEFINES += CORE_SOURCES='"\\"$$QT.core.sources\\""' *-g++*:QMAKE_CXXFLAGS += -W -Wall -Wextra -Werror -Wshadow -Wno-long-long -Wnon-virtual-dtor diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp index 13ca372290..30c7677198 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/tst_qmimedatabase-xml.cpp @@ -40,10 +40,8 @@ ****************************************************************************/ #include "../tst_qmimedatabase.h" -#include -#include -tst_QMimeDatabase::tst_QMimeDatabase() +void tst_QMimeDatabase::init() { qputenv("QT_NO_MIME_CACHE", "1"); } diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro index 876b4377dd..1ff5546e5c 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro +++ b/tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS = qmimedatabase-xml -unix: SUBDIRS += qmimedatabase-cache +unix:!mac: SUBDIRS += qmimedatabase-cache diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 858f977a72..200944d198 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -44,49 +44,85 @@ #include "qstandardpaths.h" #include +#include +#include #include #include #include +static const char yastFileName[] ="yast2-metapackage-handler-mimetypes.xml"; + void initializeLang() { qputenv("LC_ALL", ""); qputenv("LANG", "en_US"); + QCoreApplication::setApplicationName("tst_qmimedatabase"); // temporary directory pattern +} + +static inline QString testSuiteWarning() +{ + + QString result; + QTextStream str(&result); + str << "\nCannot find the shared-mime-info test suite\nstarting from: " + << QDir::toNativeSeparators(QDir::currentPath()) << "\n" + "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n" + "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-0.zip\n" + "unzip Release-1-0.zip\n"; +#ifdef Q_OS_WIN + str << "mkdir testfiles\nxcopy /s Release-1-0\\tests testfiles\n"; +#else + str << "ln -s Release-1-0/tests testfiles\n"; +#endif + return result; } // Set LANG before QCoreApplication is created Q_CONSTRUCTOR_FUNCTION(initializeLang) +tst_QMimeDatabase::tst_QMimeDatabase() +{ +} + void tst_QMimeDatabase::initTestCase() { + QVERIFY(m_temporaryDir.isValid()); + // Create a "global" and a "local" XDG data dir, right here. // The local dir will be empty initially, while the global dir will contain a copy of freedesktop.org.xml - QDir here = QDir::currentPath(); + const QDir here = QDir(m_temporaryDir.path()); - qputenv("XDG_DATA_DIRS", QFile::encodeName(here.absolutePath())); - QDir(here.absolutePath() + "/mime").removeRecursively(); - here.mkpath(QString::fromLatin1("mime/packages")); + m_globalXdgDir = m_temporaryDir.path() + QStringLiteral("/global"); + m_localXdgDir = m_temporaryDir.path() + QStringLiteral("/local"); - QFile xml(QFile::decodeName(SRCDIR "../../../src/mimetypes/mime/packages/freedesktop.org.xml")); - const QString mimeDir = here.absolutePath() + QLatin1String("/mime"); - xml.copy(mimeDir + QLatin1String("/packages/freedesktop.org.xml")); + const QString globalPackageDir = m_globalXdgDir + QStringLiteral("/mime/packages"); + QVERIFY(here.mkpath(globalPackageDir) && here.mkpath(m_localXdgDir)); - m_dataHome = here.absolutePath() + QLatin1String("/../datahome"); - qputenv("XDG_DATA_HOME", QFile::encodeName(m_dataHome)); - //qDebug() << "XDG_DATA_HOME=" << m_dataHome; + qputenv("XDG_DATA_DIRS", QFile::encodeName(m_globalXdgDir)); + qputenv("XDG_DATA_HOME", QFile::encodeName(m_localXdgDir)); + qDebug() << "\nLocal XDG_DATA_HOME: " << m_localXdgDir + << "\nGlobal XDG_DATA_DIRS: " << m_globalXdgDir; - // Make sure we start clean - cleanupTestCase(); -} + const QString freeDesktopXml = QStringLiteral("freedesktop.org.xml"); + const QString xmlFileName = QLatin1String(CORE_SOURCES) + + QStringLiteral("/mimetypes/mime/packages/") + + freeDesktopXml; + QVERIFY2(QFileInfo(xmlFileName).exists(), qPrintable(xmlFileName + QStringLiteral(" does not exist"))); + QFile xml(xmlFileName); + QVERIFY(xml.copy(globalPackageDir + '/' + freeDesktopXml)); -void tst_QMimeDatabase::cleanupTestCase() -{ - QDir here = QDir::currentPath(); - here.remove(QString::fromLatin1("mime/packages/yast2-metapackage-handler-mimetypes.xml")); + m_testSuite = QFINDTESTDATA("testfiles"); + if (m_testSuite.isEmpty()) + qWarning("%s", qPrintable(testSuiteWarning())); + + m_yastMimeTypes = QFINDTESTDATA(yastFileName); + QVERIFY2(!m_yastMimeTypes.isEmpty(), + qPrintable(QString::fromLatin1("Cannot find '%1' starting from '%2'"). + arg(yastFileName, QDir::currentPath()))); - QDir(m_dataHome).removeRecursively(); + init(); } void tst_QMimeDatabase::mimeTypeForName() @@ -173,6 +209,19 @@ void tst_QMimeDatabase::mimeTypeForFileName_data() QTest::newRow("doesn't exist but has known extension") << "IDontExist.txt" << "text/plain"; } +static inline QByteArray msgMimeTypeForFileNameFailed(const QList &actual, + const QString &expected) +{ + QByteArray result = "Actual ("; + foreach (const QMimeType &m, actual) { + result += m.name().toLocal8Bit(); + result += ' '; + } + result += ") , expected: "; + result += expected.toLocal8Bit(); + return result; +} + void tst_QMimeDatabase::mimeTypeForFileName() { QFETCH(QString, fileName); @@ -186,8 +235,8 @@ void tst_QMimeDatabase::mimeTypeForFileName() if (expectedMimeType == "application/octet-stream") { QVERIFY(mimes.isEmpty()); } else { - QVERIFY(!mimes.isEmpty()); - QCOMPARE(mimes.count(), 1); + QVERIFY2(!mimes.isEmpty(), msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData()); + QVERIFY2(mimes.count() == 1, msgMimeTypeForFileNameFailed(mimes, expectedMimeType).constData()); QCOMPARE(mimes.first().name(), expectedMimeType); } } @@ -549,20 +598,14 @@ void tst_QMimeDatabase::findByFileName_data() QTest::addColumn("mimeTypeName"); QTest::addColumn("xFail"); - QString prefix = QLatin1String(SRCDIR "testfiles/"); - - QFile f(prefix + QLatin1String("list")); - if (!f.open(QIODevice::ReadOnly)) { - const QString warning = QString::fromLatin1( - "Please download the shared-mime-info test suite:\n" - "cd tests/auto/corelib/mimetypes/qmimedatabase\n" - "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-0.zip\n" - "unzip Release-1-0.zip\n" - "ln -s Release-1-0/tests testfiles\n" - ); - qWarning() << warning; + if (m_testSuite.isEmpty()) QSKIP("shared-mime-info test suite not available."); - } + + const QString prefix = m_testSuite + QLatin1Char('/'); + const QString fileName = prefix + QLatin1String("list"); + QFile f(fileName); + QVERIFY2(f.open(QIODevice::ReadOnly|QIODevice::Text), + qPrintable(QString::fromLatin1("Cannot open %1: %2").arg(fileName, f.errorString()))); QByteArray line(1024, Qt::Uninitialized); @@ -582,7 +625,9 @@ void tst_QMimeDatabase::findByFileName_data() if (list.size() >= 3) xFail = list.at(2); - QTest::newRow(filePath.toLatin1().constData()) << QString(prefix + filePath) << mimeTypeType << xFail; + QTest::newRow(filePath.toLatin1().constData()) + << QString(prefix + filePath) + << mimeTypeType << xFail; } } @@ -717,13 +762,21 @@ void tst_QMimeDatabase::fromThreads() static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDatabase method? { - const QString umd = QStandardPaths::findExecutable(QString::fromLatin1("update-mime-database")); - if (umd.isEmpty()) + const QString umdCommand = QString::fromLatin1("update-mime-database"); + const QString umd = QStandardPaths::findExecutable(umdCommand); + if (umd.isEmpty()) { + qWarning("%s does not exist.", qPrintable(umdCommand)); return false; + } QProcess proc; proc.setProcessChannelMode(QProcess::MergedChannels); // silence output - proc.start(umd, QStringList() << path); + proc.start(umd, QStringList(path)); + if (!proc.waitForStarted()) { + qWarning("Cannot start %s: %s", + qPrintable(umd), qPrintable(proc.errorString())); + return false; + } proc.waitForFinished(); //qDebug() << "runUpdateMimeDatabase" << path; return true; @@ -733,7 +786,7 @@ static bool waitAndRunUpdateMimeDatabase(const QString &path) { QFileInfo mimeCacheInfo(path + QString::fromLatin1("/mime.cache")); if (mimeCacheInfo.exists()) { - // Wait until the begining of the next second + // Wait until the beginning of the next second while (mimeCacheInfo.lastModified().secsTo(QDateTime::currentDateTime()) == 0) { QTest::qSleep(200); } @@ -767,16 +820,15 @@ void tst_QMimeDatabase::installNewGlobalMimeType() QMimeDatabase db; QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); - const QString fileName = QLatin1String("yast2-metapackage-handler-mimetypes.xml"); - const QString srcFile = QFile::decodeName(SRCDIR) + fileName; - - QDir here = QDir::currentPath(); - const QString mimeDir = here.absolutePath() + QLatin1String("/mime"); + const QString mimeDir = m_globalXdgDir + QLatin1String("/mime"); const QString destDir = mimeDir + QLatin1String("/packages/"); - const QString destFile = destDir + fileName; + const QString destFile = destDir + QLatin1String(yastFileName); QFile::remove(destFile); //qDebug() << destFile; - QVERIFY(QFile::copy(srcFile, destFile)); + + if (!QFileInfo(destDir).isDir()) + QVERIFY(QDir(m_globalXdgDir).mkpath(destDir)); + QVERIFY(QFile::copy(m_yastMimeTypes, destFile)); if (!waitAndRunUpdateMimeDatabase(mimeDir)) QSKIP("shared-mime-info not found, skipping mime.cache test"); @@ -801,16 +853,17 @@ void tst_QMimeDatabase::installNewLocalMimeType() QMimeDatabase db; QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); - const QString fileName = QLatin1String("yast2-metapackage-handler-mimetypes.xml"); - const QString srcFile = QFile::decodeName(SRCDIR) + fileName; - const QString mimeDir = m_dataHome + QLatin1String("/mime"); + const QString mimeDir = m_localXdgDir + QLatin1String("/mime"); const QString destDir = mimeDir + QLatin1String("/packages/"); QDir().mkpath(destDir); - const QString destFile = destDir + fileName; + const QString destFile = destDir + QLatin1String(yastFileName); QFile::remove(destFile); - QVERIFY(QFile::copy(srcFile, destFile)); - if (!runUpdateMimeDatabase(mimeDir)) - QSKIP("shared-mime-info not found, skipping mime.cache test");; + QVERIFY(QFile::copy(m_yastMimeTypes, destFile)); + if (!runUpdateMimeDatabase(mimeDir)) { + const QString skipWarning = QStringLiteral("shared-mime-info not found, skipping mime.cache test (") + + QDir::toNativeSeparators(mimeDir) + QLatin1Char(')'); + QSKIP(qPrintable(skipWarning)); + } QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("text/x-suse-ymu")); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h index 869990401c..94baf77ee9 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.h @@ -43,6 +43,7 @@ #define TST_QMIMEDATABASE_H #include +#include class tst_QMimeDatabase : public QObject { @@ -53,7 +54,6 @@ public: private slots: void initTestCase(); - void cleanupTestCase(); void mimeTypeForName(); void mimeTypeForFileName_data(); @@ -93,7 +93,13 @@ private slots: void installNewLocalMimeType(); private: - QString m_dataHome; + void init(); // test-specific + + QString m_globalXdgDir; + QString m_localXdgDir; + QString m_yastMimeTypes; + QTemporaryDir m_temporaryDir; + QString m_testSuite; }; #endif // TST_QMIMEDATABASE_H -- cgit v1.2.3 From d87edf4e3e850d36c9d091b7bb62d9d0a481ad9f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 29 Feb 2012 12:28:03 +0200 Subject: Remove internal class QVolatileImage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This made sense only for Symbian where there was a special CFbsBitmap-based backend present and it was used from the Symbian-specific VG and GL pixmap implementations. The generic version is merely a useless wrapper over QImage and is not in use anywhere in the codebase. Change-Id: I1dabe22dfb8cbbc35dce8e22703a3aff810fb5f9 Reviewed-by: Samuel Rødal Reviewed-by: Gunnar Sletta Reviewed-by: Lars Knoll --- tests/auto/gui/image/image.pro | 1 - .../gui/image/qvolatileimage/qvolatileimage.pro | 6 - .../image/qvolatileimage/tst_qvolatileimage.cpp | 206 --------------------- 3 files changed, 213 deletions(-) delete mode 100644 tests/auto/gui/image/qvolatileimage/qvolatileimage.pro delete mode 100644 tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp (limited to 'tests/auto') diff --git a/tests/auto/gui/image/image.pro b/tests/auto/gui/image/image.pro index fe089f5e75..fa8f8df29d 100644 --- a/tests/auto/gui/image/image.pro +++ b/tests/auto/gui/image/image.pro @@ -9,7 +9,6 @@ SUBDIRS=\ qimageiohandler \ qimagewriter \ qmovie \ - qvolatileimage \ qicon \ qpicture \ diff --git a/tests/auto/gui/image/qvolatileimage/qvolatileimage.pro b/tests/auto/gui/image/qvolatileimage/qvolatileimage.pro deleted file mode 100644 index 3d982d7951..0000000000 --- a/tests/auto/gui/image/qvolatileimage/qvolatileimage.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qvolatileimage - -QT += gui-private widgets testlib - -SOURCES += tst_qvolatileimage.cpp diff --git a/tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp b/tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp deleted file mode 100644 index f203cfec0f..0000000000 --- a/tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include - -class tst_QVolatileImage : public QObject -{ - Q_OBJECT - -public: - tst_QVolatileImage() { } - -private slots: - void create(); - void ensureFormat(); - void dataAccess(); - void sharing(); - void fill(); - void copy(); -}; - -void tst_QVolatileImage::create() -{ - QVolatileImage nullImg; - QVERIFY(nullImg.isNull()); - - QVolatileImage img(100, 200, QImage::Format_ARGB32); - QVERIFY(!img.isNull()); - QCOMPARE(img.width(), 100); - QCOMPARE(img.height(), 200); - QCOMPARE(img.format(), QImage::Format_ARGB32); - QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height()); - QCOMPARE(img.hasAlphaChannel(), true); - QCOMPARE(img.depth(), 32); - - QImage source(12, 23, QImage::Format_ARGB32_Premultiplied); - img = QVolatileImage(source); - QVERIFY(!img.isNull()); - QCOMPARE(img.width(), 12); - QCOMPARE(img.height(), 23); - QCOMPARE(img.format(), source.format()); - QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height()); - QVERIFY(img.imageRef() == source); - QVERIFY(img.toImage() == source); - QCOMPARE(img.hasAlphaChannel(), true); - QCOMPARE(img.hasAlphaChannel(), img.imageRef().hasAlphaChannel()); - QCOMPARE(img.hasAlphaChannel(), img.toImage().hasAlphaChannel()); - QCOMPARE(img.depth(), 32); -} - -void tst_QVolatileImage::ensureFormat() -{ - QImage source(12, 23, QImage::Format_ARGB32_Premultiplied); - QVolatileImage img(source); - QVERIFY(!img.isNull()); - QVERIFY(img.imageRef() == source); - QVERIFY(img.toImage() == source); - - QVERIFY(img.ensureFormat(QImage::Format_ARGB32_Premultiplied)); // no-op - QVERIFY(img.imageRef() == source); - QVERIFY(img.toImage() == source); - QVERIFY(img.format() == QImage::Format_ARGB32_Premultiplied); - - QVERIFY(img.ensureFormat(QImage::Format_RGB32)); // new data under-the-hood - QVERIFY(img.imageRef() != source); - QVERIFY(img.toImage() != source); - QVERIFY(img.format() == QImage::Format_RGB32); -} - -void tst_QVolatileImage::dataAccess() -{ - QImage source(12, 23, QImage::Format_ARGB32_Premultiplied); - QVolatileImage img(source); - QVERIFY(!img.isNull()); - img.beginDataAccess(); - QVERIFY(img.constBits()); - QVERIFY(img.imageRef().constBits()); - QVERIFY(img.bits()); - QVERIFY(img.imageRef().bits()); - img.endDataAccess(); - - img = QVolatileImage(12, 23, QImage::Format_ARGB32); - img.beginDataAccess(); - QVERIFY(img.constBits() && img.bits()); - img.endDataAccess(); -} - -void tst_QVolatileImage::sharing() -{ - QVolatileImage img1(100, 100, QImage::Format_ARGB32); - QVolatileImage img2 = img1; - img1.beginDataAccess(); - img2.beginDataAccess(); - QVERIFY(img1.constBits() == img2.constBits()); - img2.endDataAccess(); - img1.endDataAccess(); - img1.imageRef(); // non-const call, should detach - img1.beginDataAccess(); - img2.beginDataAccess(); - QVERIFY(img1.constBits() != img2.constBits()); - img2.endDataAccess(); - img1.endDataAccess(); - - // toImage() should return a copy of the internal QImage. - // imageRef() is a reference to the internal QImage. - QVERIFY(img1.imageRef().constBits() != img1.toImage().constBits()); -} - -bool fuzzyCompareImages(const QImage &image1, const QImage &image2, int tolerance) -{ - if (image1.bytesPerLine() != image2.bytesPerLine() - || image1.width() != image2.width() - || image1.height() != image2.height()) { - return false; - } - for (int i = 0; i < image1.height(); i++) { - const uchar *line1 = image1.scanLine(i); - const uchar *line2 = image2.scanLine(i); - int bytes = image1.bytesPerLine(); - for (int j = 0; j < bytes; j++) { - int delta = line1[j] - line2[j]; - if (qAbs(delta) > tolerance) - return false; - } - } - return true; -} - -void tst_QVolatileImage::fill() -{ - QVolatileImage img(100, 100, QImage::Format_ARGB32_Premultiplied); - QColor col = QColor(10, 20, 30); - img.fill(col.rgba()); - QVERIFY(img.imageRef().pixel(1, 1) == col.rgba()); - QVERIFY(img.toImage().pixel(1, 1) == col.rgba()); -} - -void tst_QVolatileImage::copy() -{ - QVolatileImage img(100, 100, QImage::Format_RGB32); - img.beginDataAccess(); - img.imageRef().fill(QColor(Qt::green).rgba()); - QPainter p(&img.imageRef()); - p.drawRect(10, 10, 50, 50); - p.end(); - img.endDataAccess(); - - QVolatileImage img2(100, 100, QImage::Format_RGB32); - img2.copyFrom(&img, QRect()); - QImage imgA = img.toImage(); - QImage imgB = img2.toImage(); - QCOMPARE(imgA.size(), imgB.size()); - QVERIFY(fuzzyCompareImages(imgA, imgB, 0)); - - img2 = QVolatileImage(20, 20, QImage::Format_RGB32); - img2.copyFrom(&img, QRect(5, 5, 20, 20)); - imgA = img.toImage().copy(5, 5, 20, 20); - imgB = img2.toImage(); - QCOMPARE(imgA.size(), imgB.size()); - QVERIFY(fuzzyCompareImages(imgA, imgB, 0)); -} - -QTEST_MAIN(tst_QVolatileImage) -#include "tst_qvolatileimage.moc" -- cgit v1.2.3 From 7d5b0e2b042c5f6c3074cd20ba9baf9dfd733203 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 28 Feb 2012 14:53:42 +0000 Subject: network cookies: check "example.com" != "example.com." Only test code change, we already have the correct behaviour Task-number: QTBUG-20001 Change-Id: I2296f405f47f9c8d15796e69f9d1854063e38d6a Reviewed-by: Richard J. Moore --- .../access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 0e046ad6f9..5dffe68386 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -278,6 +278,8 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QTest::newRow("no-match-5") << allCookies << "http://qt.nokia.com" << result; QTest::newRow("no-match-6") << allCookies << "http://nokia.com/webinar" << result; QTest::newRow("no-match-7") << allCookies << "http://qt.nokia.com/webinar" << result; + QTest::newRow("no-match-8") << allCookies << "http://qt.nokia.com./web" << result; + QTest::newRow("no-match-9") << allCookies << "http://nokia.com./web" << result; result = allCookies; QTest::newRow("match-1") << allCookies << "http://nokia.com/web" << result; @@ -350,6 +352,16 @@ void tst_QNetworkCookieJar::cookiesForUrl_data() QTest::newRow("match-secure-1") << allCookies << "https://nokia.com/web" << result; QTest::newRow("match-secure-2") << allCookies << "https://qt.nokia.com/web" << result; + // domain ending in . + allCookies.clear(); + result.clear(); + QNetworkCookie cookieDot; + cookieDot.setDomain(".example.com."); + cookieDot.setName("a"); + allCookies += cookieDot; + QTest::newRow("no-match-domain-dot") << allCookies << "http://example.com" << result; + result += cookieDot; + QTest::newRow("match-domain-dot") << allCookies << "http://example.com." << result; } void tst_QNetworkCookieJar::cookiesForUrl() -- cgit v1.2.3 From 70784b9069fbd1c73eddbbfc83ffb44b2ca15854 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 29 Feb 2012 15:21:24 +0200 Subject: QFileSystemModel autotest fixes For some reason, hiding files via executing "attrib +h filename" process didn't work realiably, so changed the file hiding to be done via Windows native API. Also changed the test to use QTemporaryDir to simplify temporary directory handling a bit. Task-number: QTBUG-24291 Change-Id: I4f02b16e2f9105bcf5e6c5bf136f55434a26e2f4 Reviewed-by: Friedemann Kleint --- .../dialogs/qfilesystemmodel/qfilesystemmodel.pro | 2 - .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 90 ++++++++-------------- 2 files changed, 33 insertions(+), 59 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro index 6e08e2d02b..166306757c 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro @@ -5,5 +5,3 @@ QT += core-private gui testlib SOURCES += tst_qfilesystemmodel.cpp TARGET = tst_qfilesystemmodel - -win32:CONFIG += insignificant_test # QTBUG-24291 diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 8724bf63c8..fe374b1e8d 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -51,6 +51,10 @@ #include #include #include +#include +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +# include // for SetFileAttributes +#endif #define WAITTIME 1000 @@ -69,13 +73,13 @@ class tst_QFileSystemModel : public QObject { public: tst_QFileSystemModel(); - virtual ~tst_QFileSystemModel(); public Q_SLOTS: void init(); void cleanup(); private slots: + void initTestCase(); void indexPath(); void rootPath(); @@ -122,29 +126,17 @@ private slots: void roleNames(); protected: - bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList(), const QString &baseDir = QDir::temp().absolutePath()); + bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList()); private: QFileSystemModel *model; QString flatDirTestPath; + QTemporaryDir m_tempDir; }; tst_QFileSystemModel::tst_QFileSystemModel() : model(0) { qRegisterMetaType("QModelIndex"); - - QTime midnight(0, 0, 0); - qsrand(midnight.secsTo(QTime::currentTime())); - // generating unique temporary directory name - flatDirTestPath = QDir::temp().path() + '/' + QString("flatdirtest.") + QString::number(qrand()); -} - -tst_QFileSystemModel::~tst_QFileSystemModel() -{ - QString tmp = flatDirTestPath; - QDir dir(tmp); - if (dir.exists() && !dir.rmdir(tmp)) - qWarning("failed to remove tmp dir %s", dir.dirName().toAscii().data()); } void tst_QFileSystemModel::init() @@ -178,6 +170,12 @@ void tst_QFileSystemModel::cleanup() } } +void tst_QFileSystemModel::initTestCase() +{ + QVERIFY(m_tempDir.isValid()); + flatDirTestPath = m_tempDir.path(); +} + void tst_QFileSystemModel::indexPath() { #if !defined(Q_OS_WIN) @@ -367,15 +365,8 @@ void tst_QFileSystemModel::iconProvider() delete custom; } -bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount, const QStringList &initial_dirs, const QString &dir) +bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount, const QStringList &initial_dirs) { - QDir baseDir(dir); - if (!baseDir.exists(test_path)) { - if (!baseDir.mkdir(test_path) && false) { - qDebug() << "failed to create dir" << test_path; - return false; - } - } //qDebug() << (model->rowCount(model->index(test_path))) << existingFileCount << initial_files; TRY_WAIT((model->rowCount(model->index(test_path)) == existingFileCount)); for (int i = 0; i < initial_dirs.count(); ++i) { @@ -406,8 +397,21 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi } file.close(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - if (initial_files.at(i)[0] == '.') - QProcess::execute(QString("attrib +h %1").arg(file.fileName())); + if (initial_files.at(i)[0] == '.') { + QString hiddenFile = QDir::toNativeSeparators(file.fileName()); + wchar_t nativeHiddenFile[MAX_PATH]; + qMemSet(nativeHiddenFile, 0, sizeof(nativeHiddenFile)); + hiddenFile.toWCharArray(nativeHiddenFile); + DWORD currentAttributes = ::GetFileAttributes(nativeHiddenFile); + if (currentAttributes == 0xFFFFFFFF) { + qErrnoWarning("failed to get file attributes: %s", qPrintable(hiddenFile)); + return false; + } + if (!::SetFileAttributes(nativeHiddenFile, currentAttributes | FILE_ATTRIBUTE_HIDDEN)) { + qErrnoWarning("failed to set file hidden: %s", qPrintable(hiddenFile)); + return false; + } + } #endif //qDebug() << test_path + '/' + initial_files.at(i) << (QFile::exists(test_path + '/' + initial_files.at(i))); } @@ -818,16 +822,8 @@ void tst_QFileSystemModel::sort() myModel->d_func()->disableRecursiveSort = true; #endif - QDir dir(QDir::tempPath()); - //initialize the randomness - qsrand(QDateTime::currentDateTime().toTime_t()); - QString tempName = QLatin1String("sortTemp.") + QString::number(qrand()); - dir.mkdir(tempName); - dir.cd(tempName); - QTRY_VERIFY(dir.exists()); - + QDir dir(flatDirTestPath); const QString dirPath = dir.absolutePath(); - QVERIFY(dir.exists()); //Create a file that will be at the end when sorting by name (For Mac, the default) //but if we sort by size descending it will be the first @@ -889,14 +885,6 @@ void tst_QFileSystemModel::sort() delete tree; delete myModel; - - dir.setPath(QDir::tempPath()); - dir.cd(tempName); - tempFile.remove(); - tempFile2.remove(); - dir.cdUp(); - dir.rmdir(tempName); - } void tst_QFileSystemModel::mkdir() @@ -978,29 +966,17 @@ void tst_QFileSystemModel::drives() void tst_QFileSystemModel::dirsBeforeFiles() { - const QString dirPath = QString("%1/task221717_sortedOrder_test_dir").arg(QDir::tempPath()); - QDir dir(dirPath); - // clean up from last time - if (dir.exists()) { - for (int i = 0; i < 3; ++i) { - QLatin1Char c('a' + i); - dir.rmdir(QString("%1-dir").arg(c)); - QFile::remove(dirPath + QString("/%1-file").arg(c)); - } - dir.rmdir(dirPath); - } - QVERIFY(dir.mkpath(dirPath)); - QVERIFY(QDir(dirPath).exists()); + QDir dir(flatDirTestPath); for (int i = 0; i < 3; ++i) { QLatin1Char c('a' + i); dir.mkdir(QString("%1-dir").arg(c)); - QFile file(dirPath + QString("/%1-file").arg(c)); + QFile file(flatDirTestPath + QString("/%1-file").arg(c)); file.open(QIODevice::ReadWrite); file.close(); } - QModelIndex root = model->setRootPath(dirPath); + QModelIndex root = model->setRootPath(flatDirTestPath); QTest::qWait(1000); // allow model to be notified by the file system watcher // ensure that no file occurs before a directory -- cgit v1.2.3 From ff004175bcd5dc23f8c080cd390b04117c9f51df Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 26 Feb 2012 23:01:46 +0100 Subject: QFlags: mark as Q_PRIMITIVE_TYPE I originally tried to put Q_DECLARE_TYPEINFOs into Q_DECLARE_OPERATORS_FOR_FLAGS, to declare not only the flags type, but also the underlying enum as primitive, but too many users (arguably correctly) used Q_DECLARE_OPERATORS_FOR_FLAGS at (non-global) namespace scope where QTypeInfo would have been specialised in the wrong namespace. So specialise QTypeInfo for QFlags only. Change-Id: I4af6e29aefbd9460a3d2bc6405f03cdf6b1096bc Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly Reviewed-by: Olivier Goffart --- tests/auto/corelib/global/qflags/tst_qflags.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index d466d7b8d8..2794c174ba 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -123,6 +123,15 @@ void tst_QFlags::constExpr() #endif } +// (statically) check QTypeInfo for QFlags instantiations: +enum MyEnum { Zero, One, Two, Four=4 }; +Q_DECLARE_FLAGS( MyFlags, MyEnum ); +Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags ); + +Q_STATIC_ASSERT( !QTypeInfo::isComplex ); +Q_STATIC_ASSERT( !QTypeInfo::isStatic ); +Q_STATIC_ASSERT( !QTypeInfo::isLarge ); +Q_STATIC_ASSERT( !QTypeInfo::isPointer ); QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" -- cgit v1.2.3 From 46e4a9d5231e2d9e35424259858713ca539b8e30 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 20 Feb 2012 18:48:10 +0000 Subject: Windows - fix getsockopt calls for narrower than int options Windows unhelpfully writes to only one byte of the output buffer when getsockopt is called for a boolean option. Therefore we have to zero initialise the int rather than initialising to -1 as was done before. This in general only works for little endian architecture, because the word would look like 0x01000000 on big endian. So I have added some compile time asserts in the assumption that windows is always little endian. This is ok for comparisons with 0/false, but not comparisons with true or nonzero values. In the case of IPV6_V6ONLY, it is documented as DWORD (unsigned int) but on some windows versions it is returned as a boolean triggering the warning. I removed the warning, as the conversion to int works on both LE and BE since it is only compared with zero. Task-number: QTBUG-23488 Change-Id: I3c586d1ada76465fc045a82661f289920c657a4c Reviewed-by: Richard J. Moore Reviewed-by: Friedemann Kleint Reviewed-by: Andreas Holzammer --- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 2c2b551257..8b65c312bc 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -201,6 +201,8 @@ private slots: void qtbug14268_peek(); + void setSocketOption(); + protected slots: void nonBlockingIMAP_hostFound(); @@ -2699,7 +2701,41 @@ void tst_QTcpSocket::qtbug14268_peek() QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n")); } +void tst_QTcpSocket::setSocketOption() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SocketPair socketPair; + QVERIFY(socketPair.create()); + QTcpSocket *outgoing = socketPair.endPoints[0]; + QTcpSocket *incoming = socketPair.endPoints[1]; + + QVERIFY(incoming->state() == QTcpSocket::ConnectedState); + QVERIFY(outgoing->state() == QTcpSocket::ConnectedState); + + outgoing->setSocketOption(QAbstractSocket::LowDelayOption, true); + QVariant v = outgoing->socketOption(QAbstractSocket::LowDelayOption); + QVERIFY(v.isValid() && v.toBool()); + outgoing->setSocketOption(QAbstractSocket::KeepAliveOption, true); + v = outgoing->socketOption(QAbstractSocket::KeepAliveOption); + QVERIFY(v.isValid() && v.toBool()); + outgoing->setSocketOption(QAbstractSocket::LowDelayOption, false); + v = outgoing->socketOption(QAbstractSocket::LowDelayOption); + QVERIFY(v.isValid() && !v.toBool()); + outgoing->setSocketOption(QAbstractSocket::KeepAliveOption, false); + v = outgoing->socketOption(QAbstractSocket::KeepAliveOption); + QVERIFY(v.isValid() && !v.toBool()); + +#ifdef Q_OS_WIN + QEXPECT_FAIL("", "QTBUG-23323", Abort); +#endif + outgoing->setSocketOption(QAbstractSocket::TypeOfServiceOption, 32); //high priority + v = outgoing->socketOption(QAbstractSocket::TypeOfServiceOption); + QVERIFY(v.isValid() && v.toInt() == 32); +} QTEST_MAIN(tst_QTcpSocket) #include "tst_qtcpsocket.moc" -- cgit v1.2.3 From eafc667136c28fdde28d5dbc775ad978f888aa71 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 29 Feb 2012 00:02:53 +0000 Subject: QRegExp: fix \i \I \c \C \p \P escape sequences Those escape sequences have a special meaning in the XML Schema 1.1 regular expressions, but not in Perl-compatible ones. An escape sequence that has no special meaning should match the escaped character itself; this patch fixes QRegExp's behaviour in that regard (previously, it added a character class matching nothing). Change-Id: I983f923baa7c2ec19938b96353f3a205e6c06d58 Reviewed-by: Andy Shaw Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qregexp/tst_qregexp.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index a697e23270..2995c18dc9 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -81,6 +81,7 @@ private slots: void interval(); void validityCheck_data(); void validityCheck(); + void escapeSequences(); }; // Testing get/set functions @@ -1373,6 +1374,29 @@ void tst_QRegExp::validityCheck() QCOMPARE(rx2.cap(), QString("")); } +void tst_QRegExp::escapeSequences() +{ + QString perlSyntaxSpecialChars("0123456789afnrtvbBdDwWsSx\\|[]{}()^$?+*"); + QString w3cXmlSchema11SyntaxSpecialChars("cCiIpP"); // as well as the perl ones + for (int i = ' '; i <= 127; ++i) { + QLatin1Char c(i); + if (perlSyntaxSpecialChars.indexOf(c) == -1) { + QRegExp rx(QString("\\%1").arg(c), Qt::CaseSensitive, QRegExp::RegExp); + // we'll never have c == 'a' since it's a special character + QString s = QString("aaa%1aaa").arg(c); + QCOMPARE(rx.indexIn(s), 3); + + rx.setPatternSyntax(QRegExp::RegExp2); + QCOMPARE(rx.indexIn(s), 3); + + if (w3cXmlSchema11SyntaxSpecialChars.indexOf(c) == -1) { + rx.setPatternSyntax(QRegExp::W3CXmlSchema11); + QCOMPARE(rx.indexIn(s), 3); + } + } + } +} + QTEST_APPLESS_MAIN(tst_QRegExp) #include "tst_qregexp.moc" -- cgit v1.2.3 From 5dd470aca683e93976b314388e0d9f7d959db7a4 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 1 Mar 2012 09:06:13 +1000 Subject: Fixed qdir unittest rename() test to skip if run as root - subtest not valid if run as root so added a check and skip Change-Id: Iae993e20f272f9303a75062ef00d22b49df5e84a Reviewed-by: Rohan McGovern --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 04967d8313..ca01a1ec80 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1231,7 +1231,13 @@ void tst_QDir::rename() QVERIFY(!dir.rename("rename-test", "/etc/rename-test-renamed")); #elif !defined(Q_OS_WIN) // on windows this is possible - maybe make the test a bit better +#ifdef Q_OS_UNIX + // not valid if run as root so skip if needed + if (::getuid() != 0) + QVERIFY(!dir.rename("rename-test", "/rename-test-renamed")); +#else QVERIFY(!dir.rename("rename-test", "/rename-test-renamed")); +#endif #endif QTest::ignoreMessage(QtWarningMsg, "QDir::rename: Empty or null file name(s)"); QVERIFY(!dir.rename("rename-test", "")); -- cgit v1.2.3 From bc323b6fd3e80fd0c9d6a856b0a55c03d08164db Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 1 Mar 2012 12:46:34 +1000 Subject: Changed qlogging unittest to install subprogram - Added install of app sub program so it works from install directory Change-Id: Ia83643519752a3cbb59d6da2aed132d683a94bee Reviewed-by: Rohan McGovern --- tests/auto/corelib/global/qlogging/test/test.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro index 6e4939ffc9..6e9b86d753 100644 --- a/tests/auto/corelib/global/qlogging/test/test.pro +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -2,3 +2,6 @@ CONFIG += testcase parallel_test TARGET = ../tst_qlogging QT = core testlib SOURCES = ../tst_qlogging.cpp + +load(testcase) # for target.path and installTestHelperApp() +installTestHelperApp("../app/app",app,app) -- cgit v1.2.3 From 41b29924227214424e526386f11dd0dcca1ebb11 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 1 Mar 2012 12:57:37 +1000 Subject: Changed qdir unittest remove() to check actual file removed - Changed remove() test to check the file just removed is gone. Change-Id: I0b6c176e624134402b5547866064f436ce063f16 Reviewed-by: Rohan McGovern --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index ca01a1ec80..b7fc366a39 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1214,7 +1214,8 @@ void tst_QDir::remove() f.close(); QDir dir; QVERIFY(dir.remove("remove-test")); - QVERIFY(!dir.remove("/remove-test")); + // Test that the file just removed is gone + QVERIFY(!dir.remove("remove-test")); QTest::ignoreMessage(QtWarningMsg, "QDir::remove: Empty or null file name"); QVERIFY(!dir.remove("")); } -- cgit v1.2.3 From c5b928207ec33417933ee8c03ece8e79db9934f4 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 1 Mar 2012 13:33:40 +1000 Subject: Fixed qlocale unittest to install subprogram syslocaleapp correctly - It was trying to install syslocaleapp sub program as TESTDATA instead of an application. Change-Id: I2117d11335bc2fd37a8ccc9a03b0337382f0177f Reviewed-by: Rohan McGovern --- tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro | 3 --- tests/auto/corelib/tools/qlocale/test/test.pro | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro index a97350ca3f..b61f51d53a 100644 --- a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro +++ b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro @@ -6,6 +6,3 @@ CONFIG -= app_bundle QT = core -# This app is testdata for tst_qlocale -target.path = $$[QT_INSTALL_TESTS]/tst_qlocale/$$TARGET -INSTALLS += target diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index eafd8c1699..24dcc0638a 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -12,6 +12,8 @@ win32 { TARGET = ../../release/tst_qlocale } } -TESTDATA += syslocaleapp + +load(testcase) # for target.path and installTestHelperApp() +installTestHelperApp("../syslocaleapp/syslocaleapp",syslocaleapp,syslocaleapp) mac: CONFIG += insignificant_test # QTBUG-22769 -- cgit v1.2.3 From 95c5be8bc1c8f9ff8e7f95e52a8abd3cd7976ba1 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 1 Mar 2012 13:18:21 +1000 Subject: Changed qchar unittest to check return from QFINDTESTDATA - Changed qchar unittest to check string QFINDTESTDATA returns is not empty. Change-Id: Idb3997aaa5d5220272915c1e2538175205b3d6e8 Reviewed-by: Rohan McGovern --- tests/auto/corelib/tools/qchar/tst_qchar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index 1732f628ea..e72af11fbb 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -580,7 +580,9 @@ void tst_QChar::normalization_data() int linenum = 0; int part = 0; - QFile f(QFINDTESTDATA("NormalizationTest.txt")); + QString testFile = QFINDTESTDATA("NormalizationTest.txt"); + QVERIFY2(!testFile.isEmpty(), "NormalizationTest.txt not found!"); + QFile f(testFile); QVERIFY(f.exists()); f.open(QIODevice::ReadOnly); -- cgit v1.2.3 From 1cd4d6b1819f67b70dd359c7fc43ab06182cc34b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 29 Feb 2012 00:00:27 +0100 Subject: QEvent (and subclasses): make ctors explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do this regardless of whether the event subclass is public API or only used in examples. Examples are examples, used by others as templates or even copied verbatim, so they should also follow sound engineering rules. Anyway, there's only one in examples/... Change-Id: I586ff16407a956c9e89288fdd4377eed73f45c0f Reviewed-by: Samuel Rødal --- tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp | 2 +- tests/auto/other/gestures/tst_gestures.cpp | 2 +- tests/auto/testlib/selftests/alive/qtestalive.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index e2144134d9..61484c1736 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -132,7 +132,7 @@ public: class StartStopEvent: public QEvent { public: - StartStopEvent(int type, QEventLoop *loop = 0) + explicit StartStopEvent(int type, QEventLoop *loop = 0) : QEvent(Type(type)), el(loop) { } diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 01e26b6608..81881fc700 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -87,7 +87,7 @@ class CustomEvent : public QEvent public: static int EventType; - CustomEvent(int serial_ = 0) + explicit CustomEvent(int serial_ = 0) : QEvent(QEvent::Type(CustomEvent::EventType)), serial(serial_), hasHotSpot(false) { diff --git a/tests/auto/testlib/selftests/alive/qtestalive.cpp b/tests/auto/testlib/selftests/alive/qtestalive.cpp index c2e597ac18..d962b7801f 100644 --- a/tests/auto/testlib/selftests/alive/qtestalive.cpp +++ b/tests/auto/testlib/selftests/alive/qtestalive.cpp @@ -50,7 +50,7 @@ public: enum { AliveEventType = QEvent::User + 422 }; - inline QTestAliveEvent(int aSequenceId) + explicit inline QTestAliveEvent(int aSequenceId) : QEvent(QEvent::Type(AliveEventType)), seqId(aSequenceId) {} inline int sequenceId() const { return seqId; } -- cgit v1.2.3 From 9e893f68104689b057bffeb57e892163e2561b20 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Mar 2012 09:38:45 +0100 Subject: Skip the network SSL test on Windows. For SSL, this would require an OpenSSL library to be installed. Change-Id: I2a320e7faf40ef925c90dbe539f912e4a8fc13fc Reviewed-by: Miikka Heikkinen Reviewed-by: Sergio Ahumada --- tests/auto/other/networkselftest/tst_networkselftest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 841df6e1f0..ebb8443748 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -938,7 +938,7 @@ void tst_NetworkSelfTest::socks5ProxyAuth() void tst_NetworkSelfTest::supportsSsl() { #ifdef QT_NO_SSL - QFAIL("SSL not compiled in"); + QSKIP("SSL not compiled in"); #else QVERIFY2(QSslSocket::supportsSsl(), "Could not load SSL libraries"); #endif -- cgit v1.2.3 From e17440586252551c6de169d9141daef1c31a1e7e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 23:53:20 +0100 Subject: Make some tests and benchmarks pass with QT_NO_QSTRINGBUILDER Change-Id: I6c91a613007043d0f26ac11e98353a0b9ce646ae Reviewed-by: Olivier Goffart --- tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp | 6 +++--- tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 9c1b8c32f6..7cb5dfd5cd 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -93,7 +93,7 @@ void tst_QAuthenticator::basicAuth() QVERIFY(priv->phase == QAuthenticatorPrivate::Start); QList > headers; - headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); + headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); priv->parseHttpResponse(headers, /*isProxy = */ false); QCOMPARE(auth.realm(), realm); @@ -104,7 +104,7 @@ void tst_QAuthenticator::basicAuth() QVERIFY(priv->phase == QAuthenticatorPrivate::Start); - QCOMPARE(priv->calculateResponse("GET", "/").constData(), ("Basic " + expectedReply).constData()); + QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData()); } void tst_QAuthenticator::ntlmAuth_data() @@ -138,7 +138,7 @@ void tst_QAuthenticator::ntlmAuth() // NTLM phase 2: challenge headers.clear(); - headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8()); + headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8()); priv->parseHttpResponse(headers, /*isProxy = */ false); QEXPECT_FAIL("with-realm", "NTLM authentication code doesn't extract the realm", Continue); diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 2c2b551257..08938be4d1 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -2240,7 +2240,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() QString::fromLatin1("Could not start %1: %2").arg(processExe, serverProcess.errorString()))); while (!serverProcess.canReadLine()) QVERIFY(serverProcess.waitForReadyRead(10000)); - QCOMPARE(serverProcess.readLine().data(), (server.toLatin1() + "\n").data()); + QCOMPARE(serverProcess.readLine().data(), QByteArray(server.toLatin1() + "\n").data()); // Start client QProcess clientProcess; @@ -2250,7 +2250,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() QString::fromLatin1("Could not start %1: %2").arg(processExe, clientProcess.errorString()))); while (!clientProcess.canReadLine()) QVERIFY(clientProcess.waitForReadyRead(10000)); - QCOMPARE(clientProcess.readLine().data(), (client.toLatin1() + "\n").data()); + QCOMPARE(clientProcess.readLine().data(), QByteArray(client.toLatin1() + "\n").data()); // Let them play for a while qDebug("Running stress test for 5 seconds"); -- cgit v1.2.3 From 5cd56df0f2ac09572a90a07ffa1cda02d5d2d2f8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Mar 2012 10:37:58 +0100 Subject: qmake-test: Fix jom/nmake handling on Windows. The test fails if MAKEFLAGS is set up for jom since the test always uses nmake. Remove MAKEFLAGS from the process environment. Change-Id: Idaed3cc964832b83c282a59fc5257572c520b882 Reviewed-by: Joerg Bornemann Reviewed-by: Sergio Ahumada --- tests/auto/tools/qmake/testcompiler.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index 97c640b28f..4e5dc26eac 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -132,13 +132,34 @@ bool TestCompiler::errorOut() return false; } +// Return the system environment, remove MAKEFLAGS variable in +// case the CI uses jom passing flags incompatible to nmake +// or vice versa. +static inline QStringList systemEnvironment() +{ +#ifdef Q_OS_WIN + static QStringList result; + if (result.isEmpty()) { + foreach (const QString &variable, QProcess::systemEnvironment()) { + if (variable.startsWith(QStringLiteral("MAKEFLAGS="), Qt::CaseInsensitive)) { + qWarning("Removing environment setting '%s'", qPrintable(variable)); + } else { + result.push_back(variable); + } + } + } +#else + static const QStringList result = QProcess::systemEnvironment(); +#endif // ifdef Q_OS_WIN + return result; +} + bool TestCompiler::runCommand( QString cmdline, bool expectFail ) { testOutput_.append("Running command: " + cmdline); QProcess child; - if (!environment_.empty()) - child.setEnvironment(QProcess::systemEnvironment() + environment_); + child.setEnvironment(systemEnvironment() + environment_); child.start(cmdline); if (!child.waitForStarted(-1)) { -- cgit v1.2.3 From d19d25a68bd92dc6a1b55de0a5c7e0fcce55299b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 24 Feb 2012 13:07:24 +0000 Subject: Use QSystemError for QDnsLookup windows backend The OS provides the error string in this case. This gives more information to the developer seeing a generic error. Change-Id: Ia03642982f3513ee5a8a9fa98d918e948f8d97a5 Reviewed-by: Miikka Heikkinen Reviewed-by: Thiago Macieira Reviewed-by: Richard J. Moore --- tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index 3baca3c50b..249ccd3d75 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -139,7 +139,7 @@ void tst_QDnsLookup::lookup() lookup.lookup(); QVERIFY(waitForDone(&lookup)); QVERIFY(lookup.isFinished()); - QCOMPARE(int(lookup.error()), error); + QVERIFY2(int(lookup.error()) == error, qPrintable(lookup.errorString())); if (error == QDnsLookup::NoError) QVERIFY(lookup.errorString().isEmpty()); QCOMPARE(int(lookup.type()), type); -- cgit v1.2.3 From 30974151c159d42d194b5516efc8ca8d7e611f10 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Thu, 23 Feb 2012 08:50:28 +0100 Subject: Cocoa: Implement QPlatformTheme:palette() Causes a new test failure in QGraphicsProxyWidget::updateAndDelete, expand the EXPECT_FAIL to cover that one as well. Change-Id: If9da757206445d17510c4fac82a559de7b8c0563 Reviewed-by: Friedemann Kleint --- .../graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index ca5b992012..843b584ce5 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3379,10 +3379,11 @@ void tst_QGraphicsProxyWidget::updateAndDelete() // Update and hide. proxy->update(); proxy->hide(); - QTRY_COMPARE(view.npaints, 1); #ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23700", Continue); + QEXPECT_FAIL("", "QTBUG-23700", Abort); #endif + + QTRY_COMPARE(view.npaints, 1); QCOMPARE(view.paintEventRegion, expectedRegion); proxy->show(); -- cgit v1.2.3 From 15c141511fab24233d42b3c8593f0781a4931c8a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 19:54:46 +0100 Subject: QPair: specialise QTypeInfo based on the typeinfos of its arguments Specialise QTypeInfo> based on the properties of T1 and T2: - If either T1 or T2 is Q_COMPLEX_TYPE, so is QPair. - Otherwise, if either T1 or T2 is Q_MOVABLE_TYPE, so is QPair. - Otherwise, QPair is Q_PRIMITIVE_TYPE. Change-Id: I8aecbd37e3b7924f77f38967498deabf1a19ca24 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly --- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 39 ++++++++ tests/auto/corelib/tools/qpair/qpair.pro | 4 + tests/auto/corelib/tools/qpair/tst_qpair.cpp | 105 +++++++++++++++++++++ tests/auto/corelib/tools/tools.pro | 1 + 4 files changed, 149 insertions(+) create mode 100644 tests/auto/corelib/tools/qpair/qpair.pro create mode 100644 tests/auto/corelib/tools/qpair/tst_qpair.cpp (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 72913d10f2..06919c6f58 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -682,6 +682,36 @@ public: }; Q_DECLARE_METATYPE(CustomMultiInheritanceObject*); +class C { char _[4]; }; +class M { char _[4]; }; +class P { char _[4]; }; + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(M, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(P, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE + +// avoid the comma: +typedef QPair QPairCC; +typedef QPair QPairCM; +typedef QPair QPairCP; +typedef QPair QPairMC; +typedef QPair QPairMM; +typedef QPair QPairMP; +typedef QPair QPairPC; +typedef QPair QPairPM; +typedef QPair QPairPP; + +Q_DECLARE_METATYPE(QPairCC) +Q_DECLARE_METATYPE(QPairCM) +Q_DECLARE_METATYPE(QPairCP) +Q_DECLARE_METATYPE(QPairMC) +Q_DECLARE_METATYPE(QPairMM) +Q_DECLARE_METATYPE(QPairMP) +Q_DECLARE_METATYPE(QPairPC) +Q_DECLARE_METATYPE(QPairPM) +Q_DECLARE_METATYPE(QPairPP) + void tst_QMetaType::flags_data() { QTest::addColumn("type"); @@ -700,6 +730,15 @@ QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) QTest::newRow("CustomMovable") << ::qMetaTypeId() << true << true << false; QTest::newRow("CustomObject*") << ::qMetaTypeId() << true << false << true; QTest::newRow("CustomMultiInheritanceObject*") << ::qMetaTypeId() << true << false << true; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << false << false; } void tst_QMetaType::flags() diff --git a/tests/auto/corelib/tools/qpair/qpair.pro b/tests/auto/corelib/tools/qpair/qpair.pro new file mode 100644 index 0000000000..9c7752327e --- /dev/null +++ b/tests/auto/corelib/tools/qpair/qpair.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qpair +QT = core testlib +SOURCES = tst_qpair.cpp diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp new file mode 100644 index 0000000000..5de1e8f8bb --- /dev/null +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz +** 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 + +#include + +class tst_QPair : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void dummy() {} +}; + +class C { char _[4]; }; +class M { char _[4]; }; +class P { char _[4]; }; + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(M, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(P, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE + +// avoid the comma: +typedef QPair QPairCC; +typedef QPair QPairCM; +typedef QPair QPairCP; +typedef QPair QPairMC; +typedef QPair QPairMM; +typedef QPair QPairMP; +typedef QPair QPairPC; +typedef QPair QPairPM; +typedef QPair QPairPP; + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT(!QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT(!QTypeInfo::isDummy ); +Q_STATIC_ASSERT(!QTypeInfo::isPointer); + + +QTEST_APPLESS_MAIN(tst_QPair) +#include "tst_qpair.moc" diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 930799e3b3..89bb3bc416 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -20,6 +20,7 @@ SUBDIRS=\ qlocale \ qmap \ qmargins \ + qpair \ qpoint \ qqueue \ qrect \ -- cgit v1.2.3 From d9649812521e9c67cebb2f9a932e853d5333b2b1 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 24 Feb 2012 01:52:11 -0800 Subject: Remove ARMFPA support and Q_DOUBLE_FORMAT detection Remove the -armfpa option the config.tests/unix/doubleformat* detection. The places where we used QT_ARMFPA and Q_DOUBLE_FORMAT has been removed as well. Rationale: ARM FPA with GCC does not work with EABI. Qt currently does not support compiling without EABI, making ARM FPA an impossibility. It is unknown whether other compilers provide ARM FPA support with EABI. Support for ARM FPA can be re-added in the future should the need arise, but since ARM VFP is available for ARMv5 and up, we should encourage implementors to instead use soft-floats or VFP. Change-Id: I3671aba575118ae3e3e6d769759301c8f2f496f5 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 4 ---- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 11 +---------- tests/auto/other/compiler/tst_compiler.cpp | 10 ---------- 3 files changed, 1 insertion(+), 24 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 02acb00548..b3b573c64b 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -809,11 +809,7 @@ void tst_QLocale::negativeZero() { double negativeZero( 0.0 ); // Initialise to zero. uchar *ptr = (uchar *)&negativeZero; -#ifdef QT_ARMFPA - ptr[3] = 0x80; -#else ptr[QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 7] = 0x80; -#endif QString s = QString::number(negativeZero); QCOMPARE(s, QString("0")); } diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 7e4f591f47..f007d44262 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -4147,16 +4147,7 @@ void tst_QString::tortureSprintfDouble() # error "Q_BYTE_ORDER not defined" # endif -# ifdef QT_ARMFPA - buff[0] = data->bytes[4]; - buff[1] = data->bytes[5]; - buff[2] = data->bytes[6]; - buff[3] = data->bytes[7]; - buff[4] = data->bytes[0]; - buff[5] = data->bytes[1]; - buff[6] = data->bytes[2]; - buff[7] = data->bytes[3]; -# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN +# if Q_BYTE_ORDER == Q_LITTLE_ENDIAN for (uint i = 0; i < 8; ++i) buff[i] = data->bytes[i]; # else diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index d72a04c8aa..1f461ba10b 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -525,33 +525,23 @@ void tst_Compiler::privateStaticTemplateMember() const // the second member of the union static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; -static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } }; static inline double qt_inf() { -#ifdef QT_ARMFPA - return qt_armfpa_inf_bytes.d; -#else return (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_inf_bytes.d : qt_le_inf_bytes.d); -#endif } #else static const unsigned char qt_be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }; static const unsigned char qt_le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; -static const unsigned char qt_armfpa_inf_bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }; static inline double qt_inf() { const uchar *bytes; -#ifdef QT_ARMFPA - bytes = qt_armfpa_inf_bytes; -#else bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_inf_bytes : qt_le_inf_bytes); -#endif union { uchar c[8]; double d; } returnValue; memcpy(returnValue.c, bytes, sizeof(returnValue.c)); -- cgit v1.2.3 From 2658a5201797dd413f26f97bc22e6366dcba5720 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Feb 2012 10:01:24 +0100 Subject: Fix tst_qregexp with QStringBuilder Change-Id: I1ac2a5c9ea5657ad2916465b77271e3d53c67cde Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- tests/auto/corelib/tools/qregexp/tst_qregexp.cpp | 266 +++++++++++------------ 1 file changed, 133 insertions(+), 133 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 2995c18dc9..5470de76ee 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -119,43 +119,43 @@ void tst_QRegExp::indexIn_data() stri.setNum(i); // anchors - QTest::newRow( stri + "anc00" ) << QString("a(?=)z") << QString("az") << 0 << 2 << QStringList(); - QTest::newRow( stri + "anc01" ) << QString("a(?!)z") << QString("az") << -1 << -1 << QStringList(); - QTest::newRow( stri + "anc02" ) << QString("a(?:(?=)|(?=))z") << QString("az") << 0 << 2 + QTest::newRow(qPrintable(stri + "anc00")) << QString("a(?=)z") << QString("az") << 0 << 2 << QStringList(); + QTest::newRow(qPrintable(stri + "anc01")) << QString("a(?!)z") << QString("az") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "anc02")) << QString("a(?:(?=)|(?=))z") << QString("az") << 0 << 2 << QStringList(); - QTest::newRow( stri + "anc03" ) << QString("a(?:(?=)|(?!))z") << QString("az") << 0 << 2 + QTest::newRow(qPrintable(stri + "anc03")) << QString("a(?:(?=)|(?!))z") << QString("az") << 0 << 2 << QStringList(); - QTest::newRow( stri + "anc04" ) << QString("a(?:(?!)|(?=))z") << QString("az") << 0 << 2 + QTest::newRow(qPrintable(stri + "anc04")) << QString("a(?:(?!)|(?=))z") << QString("az") << 0 << 2 << QStringList(); - QTest::newRow( stri + "anc05" ) << QString("a(?:(?!)|(?!))z") << QString("az") << -1 << -1 + QTest::newRow(qPrintable(stri + "anc05")) << QString("a(?:(?!)|(?!))z") << QString("az") << -1 << -1 << QStringList(); - QTest::newRow( stri + "anc06" ) << QString("a(?:(?=)|b)z") << QString("az") << 0 << 2 + QTest::newRow(qPrintable(stri + "anc06")) << QString("a(?:(?=)|b)z") << QString("az") << 0 << 2 << QStringList(); - QTest::newRow( stri + "anc07" ) << QString("a(?:(?=)|b)z") << QString("abz") << 0 << 3 + QTest::newRow(qPrintable(stri + "anc07")) << QString("a(?:(?=)|b)z") << QString("abz") << 0 << 3 << QStringList(); - QTest::newRow( stri + "anc08" ) << QString("a(?:(?!)|b)z") << QString("az") << -1 << -1 + QTest::newRow(qPrintable(stri + "anc08")) << QString("a(?:(?!)|b)z") << QString("az") << -1 << -1 << QStringList(); - QTest::newRow( stri + "anc09" ) << QString("a(?:(?!)|b)z") << QString("abz") << 0 << 3 + QTest::newRow(qPrintable(stri + "anc09")) << QString("a(?:(?!)|b)z") << QString("abz") << 0 << 3 << QStringList(); #if 0 - QTest::newRow( stri + "anc10" ) << QString("a?(?=^b$)") << QString("ab") << 0 << 1 + QTest::newRow(qPrintable(stri + "anc10")) << QString("a?(?=^b$)") << QString("ab") << 0 << 1 << QStringList(); - QTest::newRow( stri + "anc11" ) << QString("a?(?=^b$)") << QString("b") << 0 << 0 + QTest::newRow(qPrintable(stri + "anc11")) << QString("a?(?=^b$)") << QString("b") << 0 << 0 << QStringList(); #endif // back-references - QTest::newRow( stri + "bref00" ) << QString("(a*)(\\1)") << QString("aaaaa") << 0 << 4 + QTest::newRow(qPrintable(stri + "bref00")) << QString("(a*)(\\1)") << QString("aaaaa") << 0 << 4 << QStringList( QStringList() << "aa" << "aa" ); - QTest::newRow( stri + "bref01" ) << QString("<(\\w*)>.+") << QString("blablabla") + QTest::newRow(qPrintable(stri + "bref01")) << QString("<(\\w*)>.+") << QString("blablabla") << 0 << 13 << QStringList( QStringList() << "b" ); - QTest::newRow( stri + "bref02" ) << QString("<(\\w*)>.+") << QString("<>blablabla") + QTest::newRow(qPrintable(stri + "bref02")) << QString("<(\\w*)>.+") << QString("<>blablabla") << 0 << 18 << QStringList( QStringList() << "" ); - QTest::newRow( stri + "bref03" ) << QString("((a*\\2)\\2)") << QString("aaaa") << 0 << 4 + QTest::newRow(qPrintable(stri + "bref03")) << QString("((a*\\2)\\2)") << QString("aaaa") << 0 << 4 << QStringList( QStringList() << QString("aaaa") << "aa" ); - QTest::newRow( stri + "bref04" ) << QString("^(aa+)\\1+$") << QString("aaaaaa") << 0 << 6 + QTest::newRow(qPrintable(stri + "bref04")) << QString("^(aa+)\\1+$") << QString("aaaaaa") << 0 << 6 << QStringList( QStringList() << QString("aa") ); - QTest::newRow( stri + "bref05" ) << QString("^(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13)(14)" + QTest::newRow(qPrintable(stri + "bref05")) << QString("^(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13)(14)" "\\14\\13\\12\\11\\10\\9\\8\\7\\6\\5\\4\\3\\2\\1") << QString("12345678910111213141413121110987654321") << 0 << 38 << QStringList( QStringList() << "1" << "2" << "3" << "4" << "5" << "6" @@ -163,49 +163,49 @@ void tst_QRegExp::indexIn_data() << "12" << "13" << "14"); // captures - QTest::newRow( stri + "cap00" ) << QString("(a*)") << QString("") << 0 << 0 + QTest::newRow(qPrintable(stri + "cap00")) << QString("(a*)") << QString("") << 0 << 0 << QStringList( QStringList() << QString("") ); - QTest::newRow( stri + "cap01" ) << QString("(a*)") << QString("aaa") << 0 << 3 + QTest::newRow(qPrintable(stri + "cap01")) << QString("(a*)") << QString("aaa") << 0 << 3 << QStringList( QStringList() << "aaa" ); - QTest::newRow( stri + "cap02" ) << QString("(a*)") << QString("baaa") << 0 << 0 + QTest::newRow(qPrintable(stri + "cap02")) << QString("(a*)") << QString("baaa") << 0 << 0 << QStringList( QStringList() << QString("") ); - QTest::newRow( stri + "cap03" ) << QString("(a*)(a*)") << QString("aaa") << 0 << 3 + QTest::newRow(qPrintable(stri + "cap03")) << QString("(a*)(a*)") << QString("aaa") << 0 << 3 << QStringList( QStringList() << QString("aaa") << QString("") ); - QTest::newRow( stri + "cap04" ) << QString("(a*)(b*)") << QString("aaabbb") << 0 << 6 + QTest::newRow(qPrintable(stri + "cap04")) << QString("(a*)(b*)") << QString("aaabbb") << 0 << 6 << QStringList( QStringList() << QString("aaa") << QString("bbb") ); - QTest::newRow( stri + "cap06" ) << QString("(a*)a*") << QString("aaa") << 0 << 3 + QTest::newRow(qPrintable(stri + "cap06")) << QString("(a*)a*") << QString("aaa") << 0 << 3 << QStringList( QStringList() << QString("aaa") ); - QTest::newRow( stri + "cap07" ) << QString("((a*a*)*)") << QString("aaa") << 0 << 3 + QTest::newRow(qPrintable(stri + "cap07")) << QString("((a*a*)*)") << QString("aaa") << 0 << 3 << QStringList( QStringList() << "aaa" << QString("aaa") ); - QTest::newRow( stri + "cap08" ) << QString("(((a)*(b)*)*)") << QString("ababa") << 0 << 5 + QTest::newRow(qPrintable(stri + "cap08")) << QString("(((a)*(b)*)*)") << QString("ababa") << 0 << 5 << QStringList( QStringList() << QString("ababa") << QString("a") << QString("a") << "" ); - QTest::newRow( stri + "cap09" ) << QString("(((a)*(b)*)c)*") << QString("") << 0 << 0 + QTest::newRow(qPrintable(stri + "cap09")) << QString("(((a)*(b)*)c)*") << QString("") << 0 << 0 << QStringList( QStringList() << QString("") << QString("") << QString("") << QString("") ); - QTest::newRow( stri + "cap10" ) << QString("(((a)*(b)*)c)*") << QString("abc") << 0 << 3 + QTest::newRow(qPrintable(stri + "cap10")) << QString("(((a)*(b)*)c)*") << QString("abc") << 0 << 3 << QStringList( QStringList() << "abc" << "ab" << "a" << "b" ); - QTest::newRow( stri + "cap11" ) << QString("(((a)*(b)*)c)*") << QString("abcc") << 0 << 4 + QTest::newRow(qPrintable(stri + "cap11")) << QString("(((a)*(b)*)c)*") << QString("abcc") << 0 << 4 << QStringList( QStringList() << "c" << "" << "" << "" ); - QTest::newRow( stri + "cap12" ) << QString("(((a)*(b)*)c)*") << QString("abcac") << 0 << 5 + QTest::newRow(qPrintable(stri + "cap12")) << QString("(((a)*(b)*)c)*") << QString("abcac") << 0 << 5 << QStringList( QStringList() << "ac" << "a" << "a" << "" ); - QTest::newRow( stri + "cap13" ) << QString("(to|top)?(o|polo)?(gical|o?logical)") + QTest::newRow(qPrintable(stri + "cap13")) << QString("(to|top)?(o|polo)?(gical|o?logical)") << QString("topological") << 0 << 11 << QStringList( QStringList() << "top" << "o" << "logical" ); - QTest::newRow( stri + "cap14" ) << QString("(a)+") << QString("aaaa") << 0 << 4 + QTest::newRow(qPrintable(stri + "cap14")) << QString("(a)+") << QString("aaaa") << 0 << 4 << QStringList( QStringList() << "a" ); // concatenation - QTest::newRow( stri + "cat00" ) << QString("") << QString("") << 0 << 0 << QStringList(); - QTest::newRow( stri + "cat01" ) << QString("") << QString("a") << 0 << 0 << QStringList(); - QTest::newRow( stri + "cat02" ) << QString("a") << QString("") << -1 << -1 << QStringList(); - QTest::newRow( stri + "cat03" ) << QString("a") << QString("a") << 0 << 1 << QStringList(); - QTest::newRow( stri + "cat04" ) << QString("a") << QString("b") << -1 << -1 << QStringList(); - QTest::newRow( stri + "cat05" ) << QString("b") << QString("a") << -1 << -1 << QStringList(); - QTest::newRow( stri + "cat06" ) << QString("ab") << QString("ab") << 0 << 2 << QStringList(); - QTest::newRow( stri + "cat07" ) << QString("ab") << QString("ba") << -1 << -1 << QStringList(); - QTest::newRow( stri + "cat08" ) << QString("abab") << QString("abbaababab") << 4 << 4 << QStringList(); + QTest::newRow(qPrintable(stri + "cat00")) << QString("") << QString("") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "cat01")) << QString("") << QString("a") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "cat02")) << QString("a") << QString("") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "cat03")) << QString("a") << QString("a") << 0 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "cat04")) << QString("a") << QString("b") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "cat05")) << QString("b") << QString("a") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "cat06")) << QString("ab") << QString("ab") << 0 << 2 << QStringList(); + QTest::newRow(qPrintable(stri + "cat07")) << QString("ab") << QString("ba") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "cat08")) << QString("abab") << QString("abbaababab") << 4 << 4 << QStringList(); indexIn_addMoreRows(stri); } @@ -214,96 +214,96 @@ void tst_QRegExp::indexIn_data() void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri) { // from Perl Cookbook - QTest::newRow( stri + "cook00" ) << QString("^(m*)(d?c{0,3}|c[dm])(1?x{0,3}|x[lc])(v?i{0,3}|i[vx])$") + QTest::newRow(qPrintable(stri + "cook00")) << QString("^(m*)(d?c{0,3}|c[dm])(1?x{0,3}|x[lc])(v?i{0,3}|i[vx])$") << QString("mmxl") << 0 << 4 << QStringList( QStringList() << "mm" << "" << "xl" << "" ); - QTest::newRow( stri + "cook01" ) << QString("(\\S+)(\\s+)(\\S+)") << QString(" a b") << 1 << 5 + QTest::newRow(qPrintable(stri + "cook01")) << QString("(\\S+)(\\s+)(\\S+)") << QString(" a b") << 1 << 5 << QStringList( QStringList() << "a" << " " << "b" ); - QTest::newRow( stri + "cook02" ) << QString("(\\w+)\\s*=\\s*(.*)\\s*$") << QString(" PATH=. ") << 1 + QTest::newRow(qPrintable(stri + "cook02")) << QString("(\\w+)\\s*=\\s*(.*)\\s*$") << QString(" PATH=. ") << 1 << 7 << QStringList( QStringList() << "PATH" << ". " ); - QTest::newRow( stri + "cook03" ) << QString(".{80,}") + QTest::newRow(qPrintable(stri + "cook03")) << QString(".{80,}") << QString("0000000011111111222222223333333344444444555" "5555566666666777777778888888899999999000000" "00aaaaaaaa") << 0 << 96 << QStringList(); - QTest::newRow( stri + "cook04" ) << QString("(\\d+)/(\\d+)/(\\d+) (\\d+):(\\d+):(\\d+)") + QTest::newRow(qPrintable(stri + "cook04")) << QString("(\\d+)/(\\d+)/(\\d+) (\\d+):(\\d+):(\\d+)") << QString("1978/05/24 07:30:00") << 0 << 19 << QStringList( QStringList() << "1978" << "05" << "24" << "07" << "30" << "00" ); - QTest::newRow( stri + "cook05" ) << QString("/usr/bin") << QString("/usr/local/bin:/usr/bin") + QTest::newRow(qPrintable(stri + "cook05")) << QString("/usr/bin") << QString("/usr/local/bin:/usr/bin") << 15 << 8 << QStringList(); - QTest::newRow( stri + "cook06" ) << QString("%([0-9A-Fa-f]{2})") << QString("http://%7f") << 7 << 3 + QTest::newRow(qPrintable(stri + "cook06")) << QString("%([0-9A-Fa-f]{2})") << QString("http://%7f") << 7 << 3 << QStringList( QStringList() << "7f" ); - QTest::newRow( stri + "cook07" ) << QString("/\\*.*\\*/") << QString("i++; /* increment i */") << 5 + QTest::newRow(qPrintable(stri + "cook07")) << QString("/\\*.*\\*/") << QString("i++; /* increment i */") << 5 << 17 << QStringList(); - QTest::newRow( stri + "cook08" ) << QString("^\\s+") << QString(" aaa ") << 0 << 3 + QTest::newRow(qPrintable(stri + "cook08")) << QString("^\\s+") << QString(" aaa ") << 0 << 3 << QStringList(); - QTest::newRow( stri + "cook09" ) << QString("\\s+$") << QString(" aaa ") << 6 << 3 + QTest::newRow(qPrintable(stri + "cook09")) << QString("\\s+$") << QString(" aaa ") << 6 << 3 << QStringList(); - QTest::newRow( stri + "cook10" ) << QString("^.*::") << QString("Box::cat") << 0 << 5 + QTest::newRow(qPrintable(stri + "cook10")) << QString("^.*::") << QString("Box::cat") << 0 << 5 << QStringList(); - QTest::newRow( stri + "cook11" ) << QString("^([01]?\\d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\" + QTest::newRow(qPrintable(stri + "cook11")) << QString("^([01]?\\d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\" "d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d|2[0-" "4]\\d|25[0-5])\\.([01]?\\d\\d|2[0-4]\\d|25[" "0-5])$") << QString("255.00.40.30") << 0 << 12 << QStringList( QStringList() << "255" << "00" << "40" << "30" ); - QTest::newRow( stri + "cook12" ) << QString("^.*/") << QString(" /usr/local/bin/moc") << 0 << 16 + QTest::newRow(qPrintable(stri + "cook12")) << QString("^.*/") << QString(" /usr/local/bin/moc") << 0 << 16 << QStringList(); - QTest::newRow( stri + "cook13" ) << QString(":co#(\\d+):") << QString("bla:co#55:") << 3 << 7 + QTest::newRow(qPrintable(stri + "cook13")) << QString(":co#(\\d+):") << QString("bla:co#55:") << 3 << 7 << QStringList( QStringList() << "55" ); - QTest::newRow( stri + "cook14" ) << QString("linux") << QString("alphalinuxinunix") << 5 << 5 + QTest::newRow(qPrintable(stri + "cook14")) << QString("linux") << QString("alphalinuxinunix") << 5 << 5 << QStringList(); - QTest::newRow( stri + "cook15" ) << QString("(\\d+\\.?\\d*|\\.\\d+)") << QString("0.0.5") << 0 << 3 + QTest::newRow(qPrintable(stri + "cook15")) << QString("(\\d+\\.?\\d*|\\.\\d+)") << QString("0.0.5") << 0 << 3 << QStringList( QStringList() << "0.0" ); // mathematical trivia - QTest::newRow( stri + "math00" ) << QString("^(a\\1*)$") << QString("a") << 0 << 1 + QTest::newRow(qPrintable(stri + "math00")) << QString("^(a\\1*)$") << QString("a") << 0 << 1 << QStringList( QStringList() << "a" ); - QTest::newRow( stri + "math01" ) << QString("^(a\\1*)$") << QString("aa") << 0 << 2 + QTest::newRow(qPrintable(stri + "math01")) << QString("^(a\\1*)$") << QString("aa") << 0 << 2 << QStringList( QStringList() << "aa" ); - QTest::newRow( stri + "math02" ) << QString("^(a\\1*)$") << QString("aaa") << -1 << -1 + QTest::newRow(qPrintable(stri + "math02")) << QString("^(a\\1*)$") << QString("aaa") << -1 << -1 << QStringList( QStringList() << QString() ); - QTest::newRow( stri + "math03" ) << QString("^(a\\1*)$") << QString("aaaa") << 0 << 4 + QTest::newRow(qPrintable(stri + "math03")) << QString("^(a\\1*)$") << QString("aaaa") << 0 << 4 << QStringList( QStringList() << "aaaa" ); - QTest::newRow( stri + "math04" ) << QString("^(a\\1*)$") << QString("aaaaa") << -1 << -1 + QTest::newRow(qPrintable(stri + "math04")) << QString("^(a\\1*)$") << QString("aaaaa") << -1 << -1 << QStringList( QStringList() << QString() ); - QTest::newRow( stri + "math05" ) << QString("^(a\\1*)$") << QString("aaaaaa") << -1 << -1 + QTest::newRow(qPrintable(stri + "math05")) << QString("^(a\\1*)$") << QString("aaaaaa") << -1 << -1 << QStringList( QStringList() << QString() ); - QTest::newRow( stri + "math06" ) << QString("^(a\\1*)$") << QString("aaaaaaa") << -1 << -1 + QTest::newRow(qPrintable(stri + "math06")) << QString("^(a\\1*)$") << QString("aaaaaaa") << -1 << -1 << QStringList( QStringList() << QString() ); - QTest::newRow( stri + "math07" ) << QString("^(a\\1*)$") << QString("aaaaaaaa") << 0 << 8 + QTest::newRow(qPrintable(stri + "math07")) << QString("^(a\\1*)$") << QString("aaaaaaaa") << 0 << 8 << QStringList( QStringList() << "aaaaaaaa" ); - QTest::newRow( stri + "math08" ) << QString("^(a\\1*)$") << QString("aaaaaaaaa") << -1 << -1 + QTest::newRow(qPrintable(stri + "math08")) << QString("^(a\\1*)$") << QString("aaaaaaaaa") << -1 << -1 << QStringList( QStringList() << QString() ); - QTest::newRow( stri + "math09" ) << QString("^a(?:a(\\1a))*$") << QString("a") << 0 << 1 + QTest::newRow(qPrintable(stri + "math09")) << QString("^a(?:a(\\1a))*$") << QString("a") << 0 << 1 << QStringList( QStringList() << "" ); - QTest::newRow( stri + "math10" ) << QString("^a(?:a(\\1a))*$") << QString("aaa") << 0 << 3 + QTest::newRow(qPrintable(stri + "math10")) << QString("^a(?:a(\\1a))*$") << QString("aaa") << 0 << 3 << QStringList( QStringList() << "a" ); - QTest::newRow( stri + "math13" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|(" + QTest::newRow(qPrintable(stri + "math13")) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|(" "?=a$)))*a$") << QString("aaa") << 0 << 3 << QStringList( QStringList() << "a" << "a" << "" ); - QTest::newRow( stri + "math14" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|(" + QTest::newRow(qPrintable(stri + "math14")) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|(" "?=a$)))*a$") << QString("aaaaa") << 0 << 5 << QStringList( QStringList() << "a" << "a" << "aa" ); - QTest::newRow( stri + "math17" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" + QTest::newRow(qPrintable(stri + "math17")) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") << QString("aaa") << 0 << 3 << QStringList( QStringList() << "" << "" << "" << "aaa" << "a" << "aa" ); - QTest::newRow( stri + "math18" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" + QTest::newRow(qPrintable(stri + "math18")) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") << QString("aaaaa") << 0 << 5 << QStringList( QStringList() << "aaaaa" << "a" << "aaa" << "" << "" << "" ); - QTest::newRow( stri + "math19" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" + QTest::newRow(qPrintable(stri + "math19")) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") << QString("aaaaaaaa") << 0 << 8 << QStringList( QStringList() << "" << "" << "" << "aaaaaaaa" << "a" << "aa" ); - QTest::newRow( stri + "math20" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" + QTest::newRow(qPrintable(stri + "math20")) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") << QString("aaaaaaaaa") << -1 << -1 << QStringList( QStringList() << QString() @@ -312,7 +312,7 @@ void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri) << QString() << QString() << QString() ); - QTest::newRow( stri + "math21" ) << QString("^(aa+)\\1+$") << QString("aaaaaaaaaaaa") << 0 << 12 + QTest::newRow(qPrintable(stri + "math21")) << QString("^(aa+)\\1+$") << QString("aaaaaaaaaaaa") << 0 << 12 << QStringList( QStringList() << "aa" ); static const char * const squareRegExp[] = { @@ -350,129 +350,129 @@ void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri) } // miscellaneous - QTest::newRow( stri + "misc00" ) << QString(email) + QTest::newRow(qPrintable(stri + "misc00")) << QString(email) << QString("email123@example.com") << 0 << 20 << QStringList(); - QTest::newRow( stri + "misc01" ) << QString("[0-9]*\\.[0-9]+") << QString("pi = 3.14") << 5 << 4 + QTest::newRow(qPrintable(stri + "misc01")) << QString("[0-9]*\\.[0-9]+") << QString("pi = 3.14") << 5 << 4 << QStringList(); // or operator - QTest::newRow( stri + "or00" ) << QString("(?:|b)") << QString("xxx") << 0 << 0 << QStringList(); - QTest::newRow( stri + "or01" ) << QString("(?:|b)") << QString("b") << 0 << 1 << QStringList(); - QTest::newRow( stri + "or02" ) << QString("(?:b|)") << QString("") << 0 << 0 << QStringList(); - QTest::newRow( stri + "or03" ) << QString("(?:b|)") << QString("b") << 0 << 1 << QStringList(); - QTest::newRow( stri + "or04" ) << QString("(?:||b||)") << QString("") << 0 << 0 << QStringList(); - QTest::newRow( stri + "or05" ) << QString("(?:||b||)") << QString("b") << 0 << 1 << QStringList(); - QTest::newRow( stri + "or06" ) << QString("(?:a|b)") << QString("") << -1 << -1 << QStringList(); - QTest::newRow( stri + "or07" ) << QString("(?:a|b)") << QString("cc") << -1 << -1 << QStringList(); - QTest::newRow( stri + "or08" ) << QString("(?:a|b)") << QString("abc") << 0 << 1 << QStringList(); - QTest::newRow( stri + "or09" ) << QString("(?:a|b)") << QString("cba") << 1 << 1 << QStringList(); - QTest::newRow( stri + "or10" ) << QString("(?:ab|ba)") << QString("aba") << 0 << 2 + QTest::newRow(qPrintable(stri + "or00")) << QString("(?:|b)") << QString("xxx") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "or01")) << QString("(?:|b)") << QString("b") << 0 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "or02")) << QString("(?:b|)") << QString("") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "or03")) << QString("(?:b|)") << QString("b") << 0 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "or04")) << QString("(?:||b||)") << QString("") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "or05")) << QString("(?:||b||)") << QString("b") << 0 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "or06")) << QString("(?:a|b)") << QString("") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "or07")) << QString("(?:a|b)") << QString("cc") << -1 << -1 << QStringList(); + QTest::newRow(qPrintable(stri + "or08")) << QString("(?:a|b)") << QString("abc") << 0 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "or09")) << QString("(?:a|b)") << QString("cba") << 1 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "or10")) << QString("(?:ab|ba)") << QString("aba") << 0 << 2 << QStringList(); - QTest::newRow( stri + "or11" ) << QString("(?:ab|ba)") << QString("bab") << 0 << 2 + QTest::newRow(qPrintable(stri + "or11")) << QString("(?:ab|ba)") << QString("bab") << 0 << 2 << QStringList(); - QTest::newRow( stri + "or12" ) << QString("(?:ab|ba)") << QString("caba") << 1 << 2 + QTest::newRow(qPrintable(stri + "or12")) << QString("(?:ab|ba)") << QString("caba") << 1 << 2 << QStringList(); - QTest::newRow( stri + "or13" ) << QString("(?:ab|ba)") << QString("cbab") << 1 << 2 + QTest::newRow(qPrintable(stri + "or13")) << QString("(?:ab|ba)") << QString("cbab") << 1 << 2 << QStringList(); // quantifiers - QTest::newRow( stri + "qua00" ) << QString("((([a-j])){0,0})") << QString("") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua00")) << QString("((([a-j])){0,0})") << QString("") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua01" ) << QString("((([a-j])){0,0})") << QString("a") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua01")) << QString("((([a-j])){0,0})") << QString("a") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua02" ) << QString("((([a-j])){0,0})") << QString("xyz") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua02")) << QString("((([a-j])){0,0})") << QString("xyz") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua03" ) << QString("((([a-j]))?)") << QString("") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua03")) << QString("((([a-j]))?)") << QString("") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua04" ) << QString("((([a-j]))?)") << QString("a") << 0 << 1 + QTest::newRow(qPrintable(stri + "qua04")) << QString("((([a-j]))?)") << QString("a") << 0 << 1 << QStringList( QStringList() << "a" << "a" << "a" ); - QTest::newRow( stri + "qua05" ) << QString("((([a-j]))?)") << QString("x") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua05")) << QString("((([a-j]))?)") << QString("x") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua06" ) << QString("((([a-j]))?)") << QString("ab") << 0 << 1 + QTest::newRow(qPrintable(stri + "qua06")) << QString("((([a-j]))?)") << QString("ab") << 0 << 1 << QStringList( QStringList() << "a" << "a" << "a" ); - QTest::newRow( stri + "qua07" ) << QString("((([a-j]))?)") << QString("xa") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua07")) << QString("((([a-j]))?)") << QString("xa") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua08" ) << QString("((([a-j])){0,3})") << QString("") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua08")) << QString("((([a-j])){0,3})") << QString("") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua09" ) << QString("((([a-j])){0,3})") << QString("a") << 0 << 1 + QTest::newRow(qPrintable(stri + "qua09")) << QString("((([a-j])){0,3})") << QString("a") << 0 << 1 << QStringList( QStringList() << "a" << "a" << "a" ); - QTest::newRow( stri + "qua10" ) << QString("((([a-j])){0,3})") << QString("abcd") << 0 << 3 + QTest::newRow(qPrintable(stri + "qua10")) << QString("((([a-j])){0,3})") << QString("abcd") << 0 << 3 << QStringList( QStringList() << "abc" << "c" << "c" ); - QTest::newRow( stri + "qua11" ) << QString("((([a-j])){0,3})") << QString("abcde") << 0 << 3 + QTest::newRow(qPrintable(stri + "qua11")) << QString("((([a-j])){0,3})") << QString("abcde") << 0 << 3 << QStringList( QStringList() << "abc" << "c" << "c" ); - QTest::newRow( stri + "qua12" ) << QString("((([a-j])){2,4})") << QString("a") << -1 << -1 + QTest::newRow(qPrintable(stri + "qua12")) << QString("((([a-j])){2,4})") << QString("a") << -1 << -1 << QStringList( QStringList() << QString() << QString() << QString() ); - QTest::newRow( stri + "qua13" ) << QString("((([a-j])){2,4})") << QString("ab") << 0 << 2 + QTest::newRow(qPrintable(stri + "qua13")) << QString("((([a-j])){2,4})") << QString("ab") << 0 << 2 << QStringList( QStringList() << "ab" << "b" << "b" ); - QTest::newRow( stri + "qua14" ) << QString("((([a-j])){2,4})") << QString("abcd") << 0 << 4 + QTest::newRow(qPrintable(stri + "qua14")) << QString("((([a-j])){2,4})") << QString("abcd") << 0 << 4 << QStringList( QStringList() << "abcd" << "d" << "d" ); - QTest::newRow( stri + "qua15" ) << QString("((([a-j])){2,4})") << QString("abcdef") << 0 << 4 + QTest::newRow(qPrintable(stri + "qua15")) << QString("((([a-j])){2,4})") << QString("abcdef") << 0 << 4 << QStringList( QStringList() << "abcd" << "d" << "d" ); - QTest::newRow( stri + "qua16" ) << QString("((([a-j])){2,4})") << QString("xaybcd") << 3 << 3 + QTest::newRow(qPrintable(stri + "qua16")) << QString("((([a-j])){2,4})") << QString("xaybcd") << 3 << 3 << QStringList( QStringList() << "bcd" << "d" << "d" ); - QTest::newRow( stri + "qua17" ) << QString("((([a-j])){0,})") << QString("abcdefgh") << 0 << 8 + QTest::newRow(qPrintable(stri + "qua17")) << QString("((([a-j])){0,})") << QString("abcdefgh") << 0 << 8 << QStringList( QStringList() << "abcdefgh" << "h" << "h" ); - QTest::newRow( stri + "qua18" ) << QString("((([a-j])){,0})") << QString("abcdefgh") << 0 << 0 + QTest::newRow(qPrintable(stri + "qua18")) << QString("((([a-j])){,0})") << QString("abcdefgh") << 0 << 0 << QStringList( QStringList() << "" << "" << "" ); - QTest::newRow( stri + "qua19" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("123332333") << 0 + QTest::newRow(qPrintable(stri + "qua19")) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("123332333") << 0 << 9 << QStringList( QStringList() << "123332333" << "2333" << "3" ); - QTest::newRow( stri + "qua20" ) << QString("(1(2(3){3,4}){2,3}){1,2}") + QTest::newRow(qPrintable(stri + "qua20")) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333323333233331233332333323333") << 0 << 32 << QStringList( QStringList() << "1233332333323333" << "23333" << "3" ); - QTest::newRow( stri + "qua21" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("") << -1 << -1 + QTest::newRow(qPrintable(stri + "qua21")) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("") << -1 << -1 << QStringList( QStringList() << QString() << QString() << QString() ); - QTest::newRow( stri + "qua22" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333") << -1 + QTest::newRow(qPrintable(stri + "qua22")) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333") << -1 << -1 << QStringList( QStringList() << QString() << QString() << QString() ); - QTest::newRow( stri + "qua23" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333233") << -1 + QTest::newRow(qPrintable(stri + "qua23")) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333233") << -1 << -1 << QStringList( QStringList() << QString() << QString() << QString() ); - QTest::newRow( stri + "qua24" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("122333") << -1 + QTest::newRow(qPrintable(stri + "qua24")) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("122333") << -1 << -1 << QStringList( QStringList() << QString() << QString() << QString() ); // star operator - QTest::newRow( stri + "star00" ) << QString("(?:)*") << QString("") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star01" ) << QString("(?:)*") << QString("abc") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star02" ) << QString("(?:a)*") << QString("") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star03" ) << QString("(?:a)*") << QString("a") << 0 << 1 << QStringList(); - QTest::newRow( stri + "star04" ) << QString("(?:a)*") << QString("aaa") << 0 << 3 << QStringList(); - QTest::newRow( stri + "star05" ) << QString("(?:a)*") << QString("bbbbaaa") << 0 << 0 + QTest::newRow(qPrintable(stri + "star00")) << QString("(?:)*") << QString("") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "star01")) << QString("(?:)*") << QString("abc") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "star02")) << QString("(?:a)*") << QString("") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "star03")) << QString("(?:a)*") << QString("a") << 0 << 1 << QStringList(); + QTest::newRow(qPrintable(stri + "star04")) << QString("(?:a)*") << QString("aaa") << 0 << 3 << QStringList(); + QTest::newRow(qPrintable(stri + "star05")) << QString("(?:a)*") << QString("bbbbaaa") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star06" ) << QString("(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 0 + QTest::newRow(qPrintable(stri + "star06")) << QString("(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star07" ) << QString("(?:b)*(?:a)*") << QString("") << 0 << 0 + QTest::newRow(qPrintable(stri + "star07")) << QString("(?:b)*(?:a)*") << QString("") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star08" ) << QString("(?:b)*(?:a)*") << QString("a") << 0 << 1 + QTest::newRow(qPrintable(stri + "star08")) << QString("(?:b)*(?:a)*") << QString("a") << 0 << 1 << QStringList(); - QTest::newRow( stri + "star09" ) << QString("(?:b)*(?:a)*") << QString("aaa") << 0 << 3 + QTest::newRow(qPrintable(stri + "star09")) << QString("(?:b)*(?:a)*") << QString("aaa") << 0 << 3 << QStringList(); - QTest::newRow( stri + "star10" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaa") << 0 << 7 + QTest::newRow(qPrintable(stri + "star10")) << QString("(?:b)*(?:a)*") << QString("bbbbaaa") << 0 << 7 << QStringList(); - QTest::newRow( stri + "star11" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 7 + QTest::newRow(qPrintable(stri + "star11")) << QString("(?:b)*(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 7 << QStringList(); - QTest::newRow( stri + "star12" ) << QString("(?:a|b)*") << QString("c") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star13" ) << QString("(?:a|b)*") << QString("abac") << 0 << 3 + QTest::newRow(qPrintable(stri + "star12")) << QString("(?:a|b)*") << QString("c") << 0 << 0 << QStringList(); + QTest::newRow(qPrintable(stri + "star13")) << QString("(?:a|b)*") << QString("abac") << 0 << 3 << QStringList(); - QTest::newRow( stri + "star14" ) << QString("(?:a|b|)*") << QString("c") << 0 << 0 + QTest::newRow(qPrintable(stri + "star14")) << QString("(?:a|b|)*") << QString("c") << 0 << 0 << QStringList(); - QTest::newRow( stri + "star15" ) << QString("(?:a|b|)*") << QString("abac") << 0 << 3 + QTest::newRow(qPrintable(stri + "star15")) << QString("(?:a|b|)*") << QString("abac") << 0 << 3 << QStringList(); - QTest::newRow( stri + "star16" ) << QString("(?:ab|ba|b)*") << QString("abbbababbbaaab") << 0 << 11 + QTest::newRow(qPrintable(stri + "star16")) << QString("(?:ab|ba|b)*") << QString("abbbababbbaaab") << 0 << 11 << QStringList(); } -- cgit v1.2.3 From 022ff04a6bb76f18b8b4d0a8bbcb2b21bd771546 Mon Sep 17 00:00:00 2001 From: Jan Arne Petersen Date: Fri, 24 Feb 2012 18:05:06 +0100 Subject: Unset _NET_WM_USER_TIME_WINDOW before destroying the window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise metacity was crashing when a QWindow was destroyed immediately after being activated, because metacity was trying to select events (XSelectInput) for the already destroyed m_netWmUserTimeWindow. Task-number: QTBUG-24492 Change-Id: Iedbe7bdd6b26110ca8bec6f33525209ae551ffd5 Reviewed-by: Samuel Rødal --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 90c96b4030..f4556f7e32 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -64,6 +64,8 @@ private slots: void touchCancelWithTouchToMouse(); void orientation(); void close(); + void activateAndClose(); + void initTestCase() { touchDevice = new QTouchDevice; @@ -632,5 +634,16 @@ void tst_QWindow::close() QVERIFY(b.close()); } +void tst_QWindow::activateAndClose() +{ + for (int i = 0; i < 10; ++i) { + QWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qGuiApp->focusWindow(), &window); + } +} + #include QTEST_MAIN(tst_QWindow); -- cgit v1.2.3 From 123eb803ef1a7af36eefdf9a668f1f29d6597f1d Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 1 Mar 2012 11:01:49 +1000 Subject: testlib: Add selftests for -v1 and -v2 command-line switches. These tests don't have their own source code but rather reuse the counting selftest with additional command-line options. Note that currently the -v1 switch only changes the plain text output, and the expected xml output is identical to that of the counting test. This may change in the future however. This commit also restores a couple of lists to alphabetical order, where the findtestdata selftest was not sorted into the list correctly. Change-Id: Ie38e255f8029157b34162b3864b5fa66e137d74a Reviewed-by: Rohan McGovern --- .../testlib/selftests/expected_verbose1.lightxml | 150 +++++++++++++++ tests/auto/testlib/selftests/expected_verbose1.txt | 69 +++++++ tests/auto/testlib/selftests/expected_verbose1.xml | 153 ++++++++++++++++ .../testlib/selftests/expected_verbose1.xunitxml | 64 +++++++ .../testlib/selftests/expected_verbose2.lightxml | 198 ++++++++++++++++++++ tests/auto/testlib/selftests/expected_verbose2.txt | 93 ++++++++++ tests/auto/testlib/selftests/expected_verbose2.xml | 201 +++++++++++++++++++++ .../testlib/selftests/expected_verbose2.xunitxml | 89 +++++++++ tests/auto/testlib/selftests/selftests.pri | 2 + tests/auto/testlib/selftests/selftests.qrc | 16 +- tests/auto/testlib/selftests/tst_selftests.cpp | 10 +- tests/auto/testlib/selftests/verbose1/verbose1.pro | 10 + tests/auto/testlib/selftests/verbose2/verbose2.pro | 10 + 13 files changed, 1060 insertions(+), 5 deletions(-) create mode 100644 tests/auto/testlib/selftests/expected_verbose1.lightxml create mode 100644 tests/auto/testlib/selftests/expected_verbose1.txt create mode 100644 tests/auto/testlib/selftests/expected_verbose1.xml create mode 100644 tests/auto/testlib/selftests/expected_verbose1.xunitxml create mode 100644 tests/auto/testlib/selftests/expected_verbose2.lightxml create mode 100644 tests/auto/testlib/selftests/expected_verbose2.txt create mode 100644 tests/auto/testlib/selftests/expected_verbose2.xml create mode 100644 tests/auto/testlib/selftests/expected_verbose2.xunitxml create mode 100644 tests/auto/testlib/selftests/verbose1/verbose1.pro create mode 100644 tests/auto/testlib/selftests/verbose2/verbose2.pro (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/expected_verbose1.lightxml b/tests/auto/testlib/selftests/expected_verbose1.lightxml new file mode 100644 index 0000000000..e7b1136417 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose1.lightxml @@ -0,0 +1,150 @@ + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_verbose1.txt b/tests/auto/testlib/selftests/expected_verbose1.txt new file mode 100644 index 0000000000..4a0fec51ae --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose1.txt @@ -0,0 +1,69 @@ +********* Start testing of tst_Counting ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +INFO : tst_Counting::initTestCase() entering +PASS : tst_Counting::initTestCase() +INFO : tst_Counting::testPassPass() entering +PASS : tst_Counting::testPassPass(row 1) +PASS : tst_Counting::testPassPass(row 2) +INFO : tst_Counting::testPassSkip() entering +PASS : tst_Counting::testPassSkip(row 1) +SKIP : tst_Counting::testPassSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testPassFail() entering +PASS : tst_Counting::testPassFail(row 1) +FAIL! : tst_Counting::testPassFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testSkipPass() entering +SKIP : tst_Counting::testSkipPass(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +PASS : tst_Counting::testSkipPass(row 2) +INFO : tst_Counting::testSkipSkip() entering +SKIP : tst_Counting::testSkipSkip(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +SKIP : tst_Counting::testSkipSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testSkipFail() entering +SKIP : tst_Counting::testSkipFail(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +FAIL! : tst_Counting::testSkipFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testFailPass() entering +FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +PASS : tst_Counting::testFailPass(row 2) +INFO : tst_Counting::testFailSkip() entering +FAIL! : tst_Counting::testFailSkip(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +SKIP : tst_Counting::testFailSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testFailFail() entering +FAIL! : tst_Counting::testFailFail(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testFailFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testFailInInit() entering +PASS : tst_Counting::testFailInInit(before) +FAIL! : tst_Counting::testFailInInit(fail) Fail in init() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(233)] +PASS : tst_Counting::testFailInInit(after) +INFO : tst_Counting::testFailInCleanup() entering +PASS : tst_Counting::testFailInCleanup(before) +QDEBUG : tst_Counting::testFailInCleanup(fail) This test function should execute and then QFAIL in cleanup() +FAIL! : tst_Counting::testFailInCleanup(fail) Fail in cleanup() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(241)] +PASS : tst_Counting::testFailInCleanup(after) +INFO : tst_Counting::testSkipInInit() entering +PASS : tst_Counting::testSkipInInit(before) +SKIP : tst_Counting::testSkipInInit(skip) Skip in init() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(235)] +PASS : tst_Counting::testSkipInInit(after) +INFO : tst_Counting::testSkipInCleanup() entering +PASS : tst_Counting::testSkipInCleanup(before) +QDEBUG : tst_Counting::testSkipInCleanup(skip) This test function should execute and then QSKIP in cleanup() +SKIP : tst_Counting::testSkipInCleanup(skip) Skip in cleanup() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(243)] +PASS : tst_Counting::testSkipInCleanup(after) +INFO : tst_Counting::cleanupTestCase() entering +PASS : tst_Counting::cleanupTestCase() +Totals: 16 passed, 8 failed, 8 skipped +********* Finished testing of tst_Counting ********* diff --git a/tests/auto/testlib/selftests/expected_verbose1.xml b/tests/auto/testlib/selftests/expected_verbose1.xml new file mode 100644 index 0000000000..a97296807d --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose1.xml @@ -0,0 +1,153 @@ + + + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_verbose1.xunitxml b/tests/auto/testlib/selftests/expected_verbose1.xunitxml new file mode 100644 index 0000000000..f317ed5923 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose1.xunitxml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_verbose2.lightxml b/tests/auto/testlib/selftests/expected_verbose2.lightxml new file mode 100644 index 0000000000..b2d9607ade --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose2.lightxml @@ -0,0 +1,198 @@ + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_verbose2.txt b/tests/auto/testlib/selftests/expected_verbose2.txt new file mode 100644 index 0000000000..9d36a5e98e --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose2.txt @@ -0,0 +1,93 @@ +********* Start testing of tst_Counting ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +INFO : tst_Counting::initTestCase() entering +PASS : tst_Counting::initTestCase() +INFO : tst_Counting::testPassPass() entering +INFO : tst_Counting::testPassPass(row 1) QVERIFY(true) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +PASS : tst_Counting::testPassPass(row 1) +INFO : tst_Counting::testPassPass(row 2) QVERIFY(true) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +PASS : tst_Counting::testPassPass(row 2) +INFO : tst_Counting::testPassSkip() entering +INFO : tst_Counting::testPassSkip(row 1) QVERIFY(true) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +PASS : tst_Counting::testPassSkip(row 1) +SKIP : tst_Counting::testPassSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testPassFail() entering +INFO : tst_Counting::testPassFail(row 1) QVERIFY(true) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +PASS : tst_Counting::testPassFail(row 1) +INFO : tst_Counting::testPassFail(row 2) QVERIFY(false) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testPassFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testSkipPass() entering +SKIP : tst_Counting::testSkipPass(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testSkipPass(row 2) QVERIFY(true) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +PASS : tst_Counting::testSkipPass(row 2) +INFO : tst_Counting::testSkipSkip() entering +SKIP : tst_Counting::testSkipSkip(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +SKIP : tst_Counting::testSkipSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testSkipFail() entering +SKIP : tst_Counting::testSkipFail(row 1) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testSkipFail(row 2) QVERIFY(false) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testSkipFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testFailPass() entering +INFO : tst_Counting::testFailPass(row 1) QVERIFY(false) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testFailPass(row 2) QVERIFY(true) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +PASS : tst_Counting::testFailPass(row 2) +INFO : tst_Counting::testFailSkip() entering +INFO : tst_Counting::testFailSkip(row 1) QVERIFY(false) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testFailSkip(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +SKIP : tst_Counting::testFailSkip(row 2) Skipping + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] +INFO : tst_Counting::testFailFail() entering +INFO : tst_Counting::testFailFail(row 1) QVERIFY(false) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testFailFail(row 1) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testFailFail(row 2) QVERIFY(false) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +FAIL! : tst_Counting::testFailFail(row 2) 'false' returned FALSE. () + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] +INFO : tst_Counting::testFailInInit() entering +PASS : tst_Counting::testFailInInit(before) +FAIL! : tst_Counting::testFailInInit(fail) Fail in init() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(233)] +PASS : tst_Counting::testFailInInit(after) +INFO : tst_Counting::testFailInCleanup() entering +PASS : tst_Counting::testFailInCleanup(before) +QDEBUG : tst_Counting::testFailInCleanup(fail) This test function should execute and then QFAIL in cleanup() +FAIL! : tst_Counting::testFailInCleanup(fail) Fail in cleanup() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(241)] +PASS : tst_Counting::testFailInCleanup(after) +INFO : tst_Counting::testSkipInInit() entering +PASS : tst_Counting::testSkipInInit(before) +SKIP : tst_Counting::testSkipInInit(skip) Skip in init() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(235)] +PASS : tst_Counting::testSkipInInit(after) +INFO : tst_Counting::testSkipInCleanup() entering +PASS : tst_Counting::testSkipInCleanup(before) +QDEBUG : tst_Counting::testSkipInCleanup(skip) This test function should execute and then QSKIP in cleanup() +SKIP : tst_Counting::testSkipInCleanup(skip) Skip in cleanup() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(243)] +PASS : tst_Counting::testSkipInCleanup(after) +INFO : tst_Counting::cleanupTestCase() entering +PASS : tst_Counting::cleanupTestCase() +Totals: 16 passed, 8 failed, 8 skipped +********* Finished testing of tst_Counting ********* diff --git a/tests/auto/testlib/selftests/expected_verbose2.xml b/tests/auto/testlib/selftests/expected_verbose2.xml new file mode 100644 index 0000000000..90582e6116 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose2.xml @@ -0,0 +1,201 @@ + + + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_verbose2.xunitxml b/tests/auto/testlib/selftests/expected_verbose2.xunitxml new file mode 100644 index 0000000000..558550f17b --- /dev/null +++ b/tests/auto/testlib/selftests/expected_verbose2.xunitxml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 1fc66e6364..c9474419eb 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -39,5 +39,7 @@ SUBPROGRAMS = \ sleep \ strcmp \ subtest \ + verbose1 \ + verbose2 \ warnings \ xunit diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index e39515e5be..03de05fb89 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -75,6 +75,10 @@ expected_fetchbogus.txt expected_fetchbogus.xml expected_fetchbogus.xunitxml + expected_findtestdata.lightxml + expected_findtestdata.txt + expected_findtestdata.xml + expected_findtestdata.xunitxml expected_float.txt expected_globaldata.lightxml expected_globaldata.txt @@ -122,10 +126,14 @@ expected_subtest.txt expected_subtest.xml expected_subtest.xunitxml - expected_findtestdata.lightxml - expected_findtestdata.txt - expected_findtestdata.xml - expected_findtestdata.xunitxml + expected_verbose1.lightxml + expected_verbose1.txt + expected_verbose1.xml + expected_verbose1.xunitxml + expected_verbose2.lightxml + expected_verbose2.txt + expected_verbose2.xml + expected_verbose2.xunitxml expected_warnings.lightxml expected_warnings.txt expected_warnings.xml diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 2b90bdb389..5d216992d7 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -346,6 +346,7 @@ void tst_Selftests::runSubTest_data() // Disable this test on Windows, as the run-time will popup dialogs with warnings << "fetchbogus" #endif + << "findtestdata" << "float" << "globaldata" << "longstring" @@ -363,7 +364,8 @@ void tst_Selftests::runSubTest_data() << "sleep" << "strcmp" << "subtest" - << "findtestdata" + << "verbose1" + << "verbose2" << "warnings" << "xunit" ; @@ -413,6 +415,12 @@ void tst_Selftests::runSubTest_data() else if (subtest == "silent") { arguments << "-silent"; } + else if (subtest == "verbose1") { + arguments << "-v1"; + } + else if (subtest == "verbose2") { + arguments << "-v2"; + } // These tests don't work right unless logging plain text to diff --git a/tests/auto/testlib/selftests/verbose1/verbose1.pro b/tests/auto/testlib/selftests/verbose1/verbose1.pro new file mode 100644 index 0000000000..f00ae69d17 --- /dev/null +++ b/tests/auto/testlib/selftests/verbose1/verbose1.pro @@ -0,0 +1,10 @@ +# This test just reuses the counting selftest to show how the output +# differs when the -v1 command-line switch is used. + +SOURCES += ../counting/tst_counting.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = verbose1 diff --git a/tests/auto/testlib/selftests/verbose2/verbose2.pro b/tests/auto/testlib/selftests/verbose2/verbose2.pro new file mode 100644 index 0000000000..796cdeb975 --- /dev/null +++ b/tests/auto/testlib/selftests/verbose2/verbose2.pro @@ -0,0 +1,10 @@ +# This test just reuses the counting selftest to show how the output +# differs when the -v2 command-line switch is used. + +SOURCES += ../counting/tst_counting.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = verbose2 -- cgit v1.2.3 From fb8c95bac09910c4dfa476ab97c6206b2e94ee53 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 15:07:12 +0100 Subject: Automatic metatype registration of two-template-argument types. This commit is complimentary to the commit which introduced a similar partial specialization for single template argument types: 6b4f8a68c8da1af7c5be7dc6075b688c9d6ca55f If T and U are available as metatypes, then QHash is too. Change-Id: I09097b954666418b424c8c23577032beb814343a Reviewed-by: Olivier Goffart --- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 06919c6f58..f8403f11a1 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1053,6 +1053,61 @@ void tst_QMetaType::registerStreamBuiltin() Q_DECLARE_METATYPE(QSharedPointer) +typedef QHash IntUIntHash; +Q_DECLARE_METATYPE(IntUIntHash) +typedef QMap IntUIntMap; +Q_DECLARE_METATYPE(IntUIntMap) +typedef QPair IntUIntPair; +Q_DECLARE_METATYPE(IntUIntPair) + +struct CustomComparable +{ + CustomComparable(int i_ = 0) :i(i_) { } + bool operator==(const CustomComparable &other) const + { + return i == other.i; + } + int i; +}; + +struct UnregisteredType {}; + +typedef QHash IntComparableHash; +Q_DECLARE_METATYPE(IntComparableHash) +typedef QMap IntComparableMap; +Q_DECLARE_METATYPE(IntComparableMap) +typedef QPair IntComparablePair; +Q_DECLARE_METATYPE(IntComparablePair) + +typedef QHash IntIntHash; +typedef int NaturalNumber; +class AutoMetaTypeObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(IntIntHash someHash READ someHash CONSTANT) + Q_PROPERTY(NaturalNumber someInt READ someInt CONSTANT) +public: + AutoMetaTypeObject(QObject *parent = 0) + : QObject(parent), m_int(42) + { + m_hash.insert(4, 2); + } + + QHash someHash() const + { + return m_hash; + } + + int someInt() const + { + return m_int; + } + +private: + QHash m_hash; + int m_int; +}; + void tst_QMetaType::automaticTemplateRegistration() { { @@ -1094,6 +1149,84 @@ void tst_QMetaType::automaticTemplateRegistration() vectorList << sharedPointerList; QVERIFY(QVariant::fromValue(vectorList).value > > >().first().first() == testObject); } + { + IntIntHash intIntHash; + intIntHash.insert(4, 2); + QCOMPARE(QVariant::fromValue(intIntHash).value().value(4), 2); + + AutoMetaTypeObject amto; + + qRegisterMetaType >("IntIntHash"); + QVariant hashVariant = amto.property("someHash"); + QCOMPARE(hashVariant.value().value(4), 2); + + qRegisterMetaType("NaturalNumber"); + QVariant intVariant = amto.property("someInt"); + QCOMPARE(intVariant.value(), 42); + } + { + IntUIntHash intUIntHash; + intUIntHash.insert(4, 2); + QCOMPARE(QVariant::fromValue(intUIntHash).value().value(4), (uint)2); + } + { + IntComparableHash intComparableHash; + CustomComparable m; + intComparableHash.insert(4, m); + QCOMPARE(QVariant::fromValue(intComparableHash).value().value(4), m); + } + { + QVariantHash variantHash; + variantHash.insert(QStringLiteral("4"), 2); + QCOMPARE(QVariant::fromValue(variantHash).value().value(QStringLiteral("4")), QVariant(2)); + } + { + typedef QMap IntIntMap; + IntIntMap intIntMap; + intIntMap.insert(4, 2); + QCOMPARE(QVariant::fromValue(intIntMap).value().value(4), 2); + } + { + IntUIntMap intUIntMap; + intUIntMap.insert(4, 2); + QCOMPARE(QVariant::fromValue(intUIntMap).value().value(4), (uint)2); + } + { + IntComparableMap intComparableMap; + CustomComparable m; + intComparableMap.insert(4, m); + QCOMPARE(QVariant::fromValue(intComparableMap).value().value(4), m); + } + { + QVariantMap variantMap; + variantMap.insert(QStringLiteral("4"), 2); + QCOMPARE(QVariant::fromValue(variantMap).value().value(QStringLiteral("4")), QVariant(2)); + } + { + typedef QPair IntIntPair; + IntIntPair intIntPair = qMakePair(4, 2); + QCOMPARE(QVariant::fromValue(intIntPair).value().first, 4); + QCOMPARE(QVariant::fromValue(intIntPair).value().second, 2); + } + { + IntUIntPair intUIntPair = qMakePair(4, 2); + QCOMPARE(QVariant::fromValue(intUIntPair).value().first, 4); + QCOMPARE(QVariant::fromValue(intUIntPair).value().second, (uint)2); + } + { + CustomComparable m; + IntComparablePair intComparablePair = qMakePair(4, m); + QCOMPARE(QVariant::fromValue(intComparablePair).value().first, 4); + QCOMPARE(QVariant::fromValue(intComparablePair).value().second, m); + } + { + typedef QHash IntUnregisteredTypeHash; + QVERIFY(qRegisterMetaType("IntUnregisteredTypeHash") > 0); + } + { + typedef QList UnregisteredTypeList; + QVERIFY(qRegisterMetaType("UnregisteredTypeList") > 0); + } } // Compile-time test, it should be possible to register function pointer types -- cgit v1.2.3 From 099029a3425bf44704672b8105b91968a3a46148 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Mar 2012 17:31:37 +0100 Subject: Fix QPixmap::grabWidget() on Windows. Do not draw on the backingstore DC when drawing to a pixmap. Access the paintdevice for checking via the QPaintEngine since QPainter returns the clipdevice, which is a widget. Fix warning about accessing handle of 0-window in the test. Task-number: QTBUG-24183 Change-Id: Ie91ea6ab9d09528c7ec1d35633f9a0ee667719b1 Reviewed-by: Miikka Heikkinen Reviewed-by: Friedemann Kleint --- tests/auto/gui/image/qpixmap/qpixmap.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/image/qpixmap/qpixmap.pro b/tests/auto/gui/image/qpixmap/qpixmap.pro index 91d93a781d..15098770c6 100644 --- a/tests/auto/gui/image/qpixmap/qpixmap.pro +++ b/tests/auto/gui/image/qpixmap/qpixmap.pro @@ -10,5 +10,3 @@ SOURCES += tst_qpixmap.cpp RESOURCES += qpixmap.qrc TESTDATA += convertFromImage/* convertFromToHICON/* loadFromData/* images/* - -win32:CONFIG += insignificant_test # QTBUG-24183 -- cgit v1.2.3 From 53229ec8f79c4895e0476d1f3fb950f0427ba427 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 1 Mar 2012 16:41:39 +0100 Subject: Add note about failing test when using shared-mime-info < 1.0 Change-Id: I3ba9d14d915a579b9e102114866f6c9e0344ba16 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 200944d198..63adcadb86 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -721,6 +721,9 @@ void tst_QMimeDatabase::findByFile_data() findByFileName_data(); } +// Note: this test fails on "testcompress.z" when using a shared-mime-info older than 1.0. +// This because of commit 0f9a506069c in shared-mime-info, which fixed the writing of +// case-insensitive patterns into mime.cache. void tst_QMimeDatabase::findByFile() { QFETCH(QString, filePath); -- cgit v1.2.3 From 62a654cc902197cc99326879076ba53b6509dc67 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 1 Mar 2012 13:19:24 +0200 Subject: Fix QApplication autotest crash when running on multiple screens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Screens need to be destroyed in reverse order to ensure the primary screen stays valid when other screens are destroyed. Task-number: QTBUG-24300 Change-Id: I9d9d710aa67ec045baa8bf292833ffe7d9eea935 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 98872cb2f6..9bbb6aa7f6 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -605,9 +605,6 @@ public slots: void tst_QApplication::quitOnLastWindowClosed() { -#ifdef Q_OS_WIN32 - QSKIP("This test crashes on Windows. Remove skip once the issue causing the crash is fixed (QTBUG-24300)."); -#endif #ifndef Q_OS_MAC // Test hangs on Mac OS X, see QTBUG-24319 { -- cgit v1.2.3 From 81dcb377e5c53e3e0ec91dffa749da73472b6030 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Wed, 29 Feb 2012 08:18:43 +1100 Subject: Add additional QGraphicsView tests for regression Add additional tests for graphics view tooltip regression introduced by 7c0d15a22266a425c9e9ac0120d6774e120fe01e. Task-number: QTBUG-17517 Task-number: QTBUG-22663 Change-Id: I5e0d0e19504730a3e14ac84712a366dbebe688e6 Reviewed-by: Robin Burchell (cherry picked from commit aaa46755dcc15b8baaa0d1b928828eb60e0babbc) --- .../qgraphicsview/tst_qgraphicsview.cpp | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 84dea04c45..fc49403748 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -69,6 +69,7 @@ #include #include #include +#include #include #include "../../../platformquirks.h" #include "../../../shared/platforminputcontext.h" @@ -136,6 +137,14 @@ protected: QEvent::Type spied; }; +#if defined QT_BUILD_INTERNAL +class FriendlyGraphicsScene : public QGraphicsScene +{ + friend class tst_QGraphicsView; + Q_DECLARE_PRIVATE(QGraphicsScene); +}; +#endif + class tst_QGraphicsView : public QObject { Q_OBJECT @@ -167,6 +176,10 @@ private slots: void ensureVisibleRect(); void fitInView(); void itemsAtPoint(); +#if defined QT_BUILD_INTERNAL + void itemsAtPosition_data(); + void itemsAtPosition(); +#endif void itemsInRect(); void itemsInRect_cosmeticAdjust_data(); void itemsInRect_cosmeticAdjust(); @@ -1354,6 +1367,54 @@ void tst_QGraphicsView::itemsAtPoint() QCOMPARE(items.takeFirst()->zValue(), qreal(-1)); } +#if defined QT_BUILD_INTERNAL +void tst_QGraphicsView::itemsAtPosition_data() +{ + QTest::addColumn("rotation"); + QTest::addColumn("scale"); + QTest::addColumn("viewPos"); + QTest::addColumn("ignoreTransform"); + QTest::addColumn("hit"); + QTest::newRow("scaled + ignore transform, no hit") << 0.0f << 1000.0f << QPoint(0, 0) << true << false; + QTest::newRow("scaled + ignore transform, hit") << 0.0f << 1000.0f << QPoint(100, 100) << true << true; + QTest::newRow("rotated + scaled, no hit") << 45.0f << 2.0f << QPoint(90, 90) << false << false; + QTest::newRow("rotated + scaled, hit") << 45.0f << 2.0f << QPoint(100, 100) << false << true; +} + +void tst_QGraphicsView::itemsAtPosition() +{ + QFETCH(float, rotation); + QFETCH(float, scale); + QFETCH(QPoint, viewPos); + QFETCH(bool, ignoreTransform); + QFETCH(bool, hit); + + FriendlyGraphicsScene scene; + scene.setSceneRect(QRect(-100, -100, 200, 200)); + QGraphicsItem *item = scene.addRect(-5, -5, 10, 10); + + if (ignoreTransform) + item->setFlag(QGraphicsItem::ItemIgnoresTransformations); + + QGraphicsView view; + view.resize(200, 200); + view.scale(scale, scale); + view.rotate(rotation); + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setScene(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QPoint screenPos = view.viewport()->mapToGlobal(viewPos); + QPointF scenePos = view.mapToScene(viewPos); + QGraphicsScenePrivate *viewPrivate = scene.d_func(); + QList items; + items = viewPrivate->itemsAtPosition(screenPos, scenePos, view.viewport()); + QCOMPARE(!items.empty(), hit); +} +#endif + void tst_QGraphicsView::itemsInRect() { QGraphicsScene scene; -- cgit v1.2.3 From b2fb578a115f554ec7a00558978e5532a2ac855a Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Thu, 1 Mar 2012 08:09:26 +1100 Subject: Fix sizing in QGraphicsView itemsAtPosition auto test The auto test may fail incorrectly depending on the width of the QGraphicsView frame. To ensure more consistent test results, the frame is disabled. Change-Id: I8d70fb07e45803230954f776947d525e4cf9050f Reviewed-by: Robin Burchell --- tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index fc49403748..af76b1c3c1 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -1397,6 +1397,7 @@ void tst_QGraphicsView::itemsAtPosition() item->setFlag(QGraphicsItem::ItemIgnoresTransformations); QGraphicsView view; + view.setFrameStyle(QFrame::NoFrame); view.resize(200, 200); view.scale(scale, scale); view.rotate(rotation); -- cgit v1.2.3 From db1abf9f760ebc40b1f7f0f3e88698cea8aebbd7 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 2 Mar 2012 11:04:01 +0100 Subject: Change bugreports.qt.nokia.com -> bugreports.qt-project.org Change-Id: Ia795098f24cf358b15067f54cd08dff0bd792bc5 Reviewed-by: Thiago Macieira --- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 2 +- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index dd839ec0ae..6f6662a80f 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -772,7 +772,7 @@ void tst_QImageReader::animatedGif() } } -// http://bugreports.qt.nokia.com/browse/QTBUG-6696 +// http://bugreports.qt-project.org/browse/QTBUG-6696 // Check the count of images in various call orders... void tst_QImageReader::gifImageCount() { diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 5b34fa7c29..d8f9bf32ad 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -6474,7 +6474,7 @@ void tst_QNetworkReply::synchronousRequest() // workaround for HTTPS requests: add self-signed server cert to list of CA certs, // since we cannot react to the sslErrors() signal // to fix this properly we would need to have an ignoreSslErrors() method in the - // QNetworkRequest, see http://bugreports.qt.nokia.com/browse/QTBUG-14774 + // QNetworkRequest, see http://bugreports.qt-project.org/browse/QTBUG-14774 if (url.scheme() == "https") { QSslConfiguration sslConf; QList certs = QSslCertificate::fromPath(testDataDir + "/certs/qt-test-server-cacert.pem"); -- cgit v1.2.3 From 87975f88ce72b803fe3fa982540b940c2e205009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Thu, 23 Feb 2012 15:53:51 +0100 Subject: QAbstractSlider - adding setRange as a slot In many situations it would be very nice to have setRange as a slot. It fits good with the rangeChanged signal - and in some situations it does make sense to synchronize scrollbars ranges. Change-Id: I6bcb41ed6e009e5822b56b621e4e187fe52502a6 Reviewed-by: Robin Burchell --- .../widgets/widgets/qabstractslider/tst_qabstractslider.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 6021f90ed4..cff847474c 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -93,6 +93,7 @@ private slots: void setValue_data(); void setValue(); void setRepeatAction(); + void connectedSliders(); private: void waitUntilTimeElapsed(const QTime& t, int ms); @@ -1259,5 +1260,17 @@ void tst_QAbstractSlider::setRepeatAction() QCOMPARE(slider->value(), 115); } +void tst_QAbstractSlider::connectedSliders() +{ + Slider *slider2 = new Slider(topLevel); + connect(slider, SIGNAL(rangeChanged(int, int)), slider2, SLOT(setRange(int, int))); + const int sliderlow = 13; + const int sliderhigh = 1017; + slider->setRange(sliderlow, sliderhigh); + QCOMPARE(slider2->minimum(), sliderlow); + QCOMPARE(slider2->maximum(), sliderhigh); + delete slider2; +} + QTEST_MAIN(tst_QAbstractSlider) #include "tst_qabstractslider.moc" -- cgit v1.2.3 From d423fd0975569928faeafad28702750407e889ee Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 5 Mar 2012 12:10:32 +1000 Subject: Avoid using internal testlib API in QDbusConnection autotest. QCOMPARE should only be used in a test function because it makes the test function return if the compare fails. The test wants to compare without returning on failure because the compare is inside a helper function called by many test functions, so the test was calling testlib's internal QTest::compare_helper() functions instead of QCOMPARE. This commit makes this code slightly less objectionable by calling the public QTest::qCompare() instead. Change-Id: Ida17a641e89f8a297d6a036449f44b33aa266368 Reviewed-by: Thiago Macieira --- .../dbus/qdbusconnection/tst_qdbusconnection.cpp | 24 ++++------------------ 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index e1d128dac7..65b68b7f34 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -829,16 +829,8 @@ bool tst_QDBusConnection::callMethod(const QDBusConnection &conn, const QString QDBusMessage reply = conn.call(msg, QDBus::Block/*WithGui*/); if (reply.type() != QDBusMessage::ReplyMessage) return false; - if (MyObject::path == path) { - QTest::compare_helper(true, "COMPARE()", __FILE__, __LINE__); - } else { - QTest::compare_helper(false, "Compared values are not the same", - QTest::toString(MyObject::path), QTest::toString(path), - "MyObject::path", "path", __FILE__, __LINE__); - return false; - } - - return true; + QTest::qCompare(MyObject::path, path, "MyObject::path", "path", __FILE__, __LINE__); + return (MyObject::path == path); } bool tst_QDBusConnection::callMethodPeer(const QDBusConnection &conn, const QString &path) @@ -848,16 +840,8 @@ bool tst_QDBusConnection::callMethodPeer(const QDBusConnection &conn, const QStr if (reply.type() != QDBusMessage::ReplyMessage) return false; - if (MyObject::path == path) { - QTest::compare_helper(true, "COMPARE()", __FILE__, __LINE__); - } else { - QTest::compare_helper(false, "Compared values are not the same", - QTest::toString(MyObject::path), QTest::toString(path), - "MyObject::path", "path", __FILE__, __LINE__); - return false; - } - - return true; + QTest::qCompare(MyObject::path, path, "MyObject::path", "path", __FILE__, __LINE__); + return (MyObject::path == path); } class TestObject : public QObject -- cgit v1.2.3 From 0862d7f78af978cf513097b3bdc33cd8096dee75 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 1 Mar 2012 15:14:18 +1000 Subject: testlib: Make verbose2 selftest use QCOMPARE as well as QVERIFY. The verbose output for QCOMPARE is not very helpful. Make the verbose2 selftest (which reuses the counting selftest) demonstrate this, so that a future commit can demonstrate improvement. Change-Id: I6b3bc8f5199e984aa11d0a67b76a8c916be86380 Reviewed-by: Rohan McGovern --- .../testlib/selftests/counting/tst_counting.cpp | 1 + .../testlib/selftests/expected_counting.lightxml | 32 +++++----- tests/auto/testlib/selftests/expected_counting.txt | 32 +++++----- tests/auto/testlib/selftests/expected_counting.xml | 32 +++++----- .../testlib/selftests/expected_verbose1.lightxml | 32 +++++----- tests/auto/testlib/selftests/expected_verbose1.txt | 32 +++++----- tests/auto/testlib/selftests/expected_verbose1.xml | 32 +++++----- .../testlib/selftests/expected_verbose2.lightxml | 68 +++++++++++++++------- tests/auto/testlib/selftests/expected_verbose2.txt | 56 +++++++++++------- tests/auto/testlib/selftests/expected_verbose2.xml | 68 +++++++++++++++------- .../testlib/selftests/expected_verbose2.xunitxml | 14 ++++- 11 files changed, 236 insertions(+), 163 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/counting/tst_counting.cpp b/tests/auto/testlib/selftests/counting/tst_counting.cpp index fa61fce173..9c3dd48015 100644 --- a/tests/auto/testlib/selftests/counting/tst_counting.cpp +++ b/tests/auto/testlib/selftests/counting/tst_counting.cpp @@ -109,6 +109,7 @@ void tst_Counting::helper() switch (result) { case Pass: QVERIFY(true); + QCOMPARE(2 + 1, 3); break; case Fail: QVERIFY(false); diff --git a/tests/auto/testlib/selftests/expected_counting.lightxml b/tests/auto/testlib/selftests/expected_counting.lightxml index e7b1136417..c49792fec4 100644 --- a/tests/auto/testlib/selftests/expected_counting.lightxml +++ b/tests/auto/testlib/selftests/expected_counting.lightxml @@ -17,7 +17,7 @@ - + @@ -26,13 +26,13 @@ - + - + @@ -41,27 +41,27 @@ - + - + - + - + - + @@ -70,21 +70,21 @@ - + - + - + - + @@ -93,7 +93,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -137,7 +137,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_counting.txt b/tests/auto/testlib/selftests/expected_counting.txt index 5c17e3c257..3245d9d7be 100644 --- a/tests/auto/testlib/selftests/expected_counting.txt +++ b/tests/auto/testlib/selftests/expected_counting.txt @@ -5,49 +5,49 @@ PASS : tst_Counting::testPassPass(row 1) PASS : tst_Counting::testPassPass(row 2) PASS : tst_Counting::testPassSkip(row 1) SKIP : tst_Counting::testPassSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] PASS : tst_Counting::testPassFail(row 1) FAIL! : tst_Counting::testPassFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] SKIP : tst_Counting::testSkipPass(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] PASS : tst_Counting::testSkipPass(row 2) SKIP : tst_Counting::testSkipSkip(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] SKIP : tst_Counting::testSkipSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] SKIP : tst_Counting::testSkipFail(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] FAIL! : tst_Counting::testSkipFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] PASS : tst_Counting::testFailPass(row 2) FAIL! : tst_Counting::testFailSkip(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] SKIP : tst_Counting::testFailSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] FAIL! : tst_Counting::testFailFail(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] PASS : tst_Counting::testFailInInit(before) FAIL! : tst_Counting::testFailInInit(fail) Fail in init() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(233)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(234)] PASS : tst_Counting::testFailInInit(after) PASS : tst_Counting::testFailInCleanup(before) QDEBUG : tst_Counting::testFailInCleanup(fail) This test function should execute and then QFAIL in cleanup() FAIL! : tst_Counting::testFailInCleanup(fail) Fail in cleanup() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(241)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(242)] PASS : tst_Counting::testFailInCleanup(after) PASS : tst_Counting::testSkipInInit(before) SKIP : tst_Counting::testSkipInInit(skip) Skip in init() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(235)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(236)] PASS : tst_Counting::testSkipInInit(after) PASS : tst_Counting::testSkipInCleanup(before) QDEBUG : tst_Counting::testSkipInCleanup(skip) This test function should execute and then QSKIP in cleanup() SKIP : tst_Counting::testSkipInCleanup(skip) Skip in cleanup() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(243)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(244)] PASS : tst_Counting::testSkipInCleanup(after) PASS : tst_Counting::cleanupTestCase() Totals: 16 passed, 8 failed, 8 skipped diff --git a/tests/auto/testlib/selftests/expected_counting.xml b/tests/auto/testlib/selftests/expected_counting.xml index a97296807d..7ed93b9c73 100644 --- a/tests/auto/testlib/selftests/expected_counting.xml +++ b/tests/auto/testlib/selftests/expected_counting.xml @@ -19,7 +19,7 @@ - + @@ -28,13 +28,13 @@ - + - + @@ -43,27 +43,27 @@ - + - + - + - + - + @@ -72,21 +72,21 @@ - + - + - + - + @@ -95,7 +95,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose1.lightxml b/tests/auto/testlib/selftests/expected_verbose1.lightxml index e7b1136417..c49792fec4 100644 --- a/tests/auto/testlib/selftests/expected_verbose1.lightxml +++ b/tests/auto/testlib/selftests/expected_verbose1.lightxml @@ -17,7 +17,7 @@ - + @@ -26,13 +26,13 @@ - + - + @@ -41,27 +41,27 @@ - + - + - + - + - + @@ -70,21 +70,21 @@ - + - + - + - + @@ -93,7 +93,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -137,7 +137,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose1.txt b/tests/auto/testlib/selftests/expected_verbose1.txt index 4a0fec51ae..0286f719aa 100644 --- a/tests/auto/testlib/selftests/expected_verbose1.txt +++ b/tests/auto/testlib/selftests/expected_verbose1.txt @@ -8,60 +8,60 @@ PASS : tst_Counting::testPassPass(row 2) INFO : tst_Counting::testPassSkip() entering PASS : tst_Counting::testPassSkip(row 1) SKIP : tst_Counting::testPassSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testPassFail() entering PASS : tst_Counting::testPassFail(row 1) FAIL! : tst_Counting::testPassFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testSkipPass() entering SKIP : tst_Counting::testSkipPass(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] PASS : tst_Counting::testSkipPass(row 2) INFO : tst_Counting::testSkipSkip() entering SKIP : tst_Counting::testSkipSkip(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] SKIP : tst_Counting::testSkipSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testSkipFail() entering SKIP : tst_Counting::testSkipFail(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] FAIL! : tst_Counting::testSkipFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailPass() entering FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] PASS : tst_Counting::testFailPass(row 2) INFO : tst_Counting::testFailSkip() entering FAIL! : tst_Counting::testFailSkip(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] SKIP : tst_Counting::testFailSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testFailFail() entering FAIL! : tst_Counting::testFailFail(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailInInit() entering PASS : tst_Counting::testFailInInit(before) FAIL! : tst_Counting::testFailInInit(fail) Fail in init() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(233)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(234)] PASS : tst_Counting::testFailInInit(after) INFO : tst_Counting::testFailInCleanup() entering PASS : tst_Counting::testFailInCleanup(before) QDEBUG : tst_Counting::testFailInCleanup(fail) This test function should execute and then QFAIL in cleanup() FAIL! : tst_Counting::testFailInCleanup(fail) Fail in cleanup() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(241)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(242)] PASS : tst_Counting::testFailInCleanup(after) INFO : tst_Counting::testSkipInInit() entering PASS : tst_Counting::testSkipInInit(before) SKIP : tst_Counting::testSkipInInit(skip) Skip in init() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(235)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(236)] PASS : tst_Counting::testSkipInInit(after) INFO : tst_Counting::testSkipInCleanup() entering PASS : tst_Counting::testSkipInCleanup(before) QDEBUG : tst_Counting::testSkipInCleanup(skip) This test function should execute and then QSKIP in cleanup() SKIP : tst_Counting::testSkipInCleanup(skip) Skip in cleanup() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(243)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(244)] PASS : tst_Counting::testSkipInCleanup(after) INFO : tst_Counting::cleanupTestCase() entering PASS : tst_Counting::cleanupTestCase() diff --git a/tests/auto/testlib/selftests/expected_verbose1.xml b/tests/auto/testlib/selftests/expected_verbose1.xml index a97296807d..7ed93b9c73 100644 --- a/tests/auto/testlib/selftests/expected_verbose1.xml +++ b/tests/auto/testlib/selftests/expected_verbose1.xml @@ -19,7 +19,7 @@ - + @@ -28,13 +28,13 @@ - + - + @@ -43,27 +43,27 @@ - + - + - + - + - + @@ -72,21 +72,21 @@ - + - + - + - + @@ -95,7 +95,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose2.lightxml b/tests/auto/testlib/selftests/expected_verbose2.lightxml index b2d9607ade..1310f2bb09 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.lightxml +++ b/tests/auto/testlib/selftests/expected_verbose2.lightxml @@ -10,6 +10,10 @@ + + + + @@ -17,6 +21,10 @@ + + + + @@ -26,10 +34,14 @@ + + + + - + @@ -39,20 +51,24 @@ + + + + - + - + - + @@ -60,40 +76,44 @@ + + + + - + - + - + - + - + - + - + @@ -101,38 +121,42 @@ + + + + - + - + - + - + - + - + - + @@ -141,7 +165,7 @@ - + @@ -157,7 +181,7 @@ - + @@ -169,7 +193,7 @@ - + @@ -185,7 +209,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose2.txt b/tests/auto/testlib/selftests/expected_verbose2.txt index 9d36a5e98e..9012a7c569 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.txt +++ b/tests/auto/testlib/selftests/expected_verbose2.txt @@ -5,87 +5,99 @@ PASS : tst_Counting::initTestCase() INFO : tst_Counting::testPassPass() entering INFO : tst_Counting::testPassPass(row 1) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +INFO : tst_Counting::testPassPass(row 1) COMPARE() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassPass(row 1) INFO : tst_Counting::testPassPass(row 2) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +INFO : tst_Counting::testPassPass(row 2) COMPARE() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassPass(row 2) INFO : tst_Counting::testPassSkip() entering INFO : tst_Counting::testPassSkip(row 1) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +INFO : tst_Counting::testPassSkip(row 1) COMPARE() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassSkip(row 1) SKIP : tst_Counting::testPassSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testPassFail() entering INFO : tst_Counting::testPassFail(row 1) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +INFO : tst_Counting::testPassFail(row 1) COMPARE() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassFail(row 1) INFO : tst_Counting::testPassFail(row 2) QVERIFY(false) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testPassFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testSkipPass() entering SKIP : tst_Counting::testSkipPass(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testSkipPass(row 2) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +INFO : tst_Counting::testSkipPass(row 2) COMPARE() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testSkipPass(row 2) INFO : tst_Counting::testSkipSkip() entering SKIP : tst_Counting::testSkipSkip(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] SKIP : tst_Counting::testSkipSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testSkipFail() entering SKIP : tst_Counting::testSkipFail(row 1) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testSkipFail(row 2) QVERIFY(false) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testSkipFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailPass() entering INFO : tst_Counting::testFailPass(row 1) QVERIFY(false) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailPass(row 2) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] +INFO : tst_Counting::testFailPass(row 2) COMPARE() + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testFailPass(row 2) INFO : tst_Counting::testFailSkip() entering INFO : tst_Counting::testFailSkip(row 1) QVERIFY(false) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailSkip(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] SKIP : tst_Counting::testFailSkip(row 2) Skipping - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(117)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testFailFail() entering INFO : tst_Counting::testFailFail(row 1) QVERIFY(false) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailFail(row 1) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailFail(row 2) QVERIFY(false) - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] FAIL! : tst_Counting::testFailFail(row 2) 'false' returned FALSE. () - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(114)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailInInit() entering PASS : tst_Counting::testFailInInit(before) FAIL! : tst_Counting::testFailInInit(fail) Fail in init() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(233)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(234)] PASS : tst_Counting::testFailInInit(after) INFO : tst_Counting::testFailInCleanup() entering PASS : tst_Counting::testFailInCleanup(before) QDEBUG : tst_Counting::testFailInCleanup(fail) This test function should execute and then QFAIL in cleanup() FAIL! : tst_Counting::testFailInCleanup(fail) Fail in cleanup() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(241)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(242)] PASS : tst_Counting::testFailInCleanup(after) INFO : tst_Counting::testSkipInInit() entering PASS : tst_Counting::testSkipInInit(before) SKIP : tst_Counting::testSkipInInit(skip) Skip in init() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(235)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(236)] PASS : tst_Counting::testSkipInInit(after) INFO : tst_Counting::testSkipInCleanup() entering PASS : tst_Counting::testSkipInCleanup(before) QDEBUG : tst_Counting::testSkipInCleanup(skip) This test function should execute and then QSKIP in cleanup() SKIP : tst_Counting::testSkipInCleanup(skip) Skip in cleanup() - Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(243)] + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(244)] PASS : tst_Counting::testSkipInCleanup(after) INFO : tst_Counting::cleanupTestCase() entering PASS : tst_Counting::cleanupTestCase() diff --git a/tests/auto/testlib/selftests/expected_verbose2.xml b/tests/auto/testlib/selftests/expected_verbose2.xml index 90582e6116..693ef2b187 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.xml +++ b/tests/auto/testlib/selftests/expected_verbose2.xml @@ -12,6 +12,10 @@ + + + + @@ -19,6 +23,10 @@ + + + + @@ -28,10 +36,14 @@ + + + + - + @@ -41,20 +53,24 @@ + + + + - + - + - + @@ -62,40 +78,44 @@ + + + + - + - + - + - + - + - + - + @@ -103,38 +123,42 @@ + + + + - + - + - + - + - + - + - + @@ -143,7 +167,7 @@ - + @@ -159,7 +183,7 @@ - + @@ -171,7 +195,7 @@ - + @@ -187,7 +211,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose2.xunitxml b/tests/auto/testlib/selftests/expected_verbose2.xunitxml index 558550f17b..8b9ed5257d 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.xunitxml +++ b/tests/auto/testlib/selftests/expected_verbose2.xunitxml @@ -1,5 +1,5 @@ - + @@ -7,20 +7,25 @@ + + + + + @@ -35,6 +40,7 @@ + @@ -64,19 +70,25 @@ + + + + + + -- cgit v1.2.3 From d94165ab326f24a725720a705405067975b82af8 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 5 Mar 2012 12:31:03 +0100 Subject: Fix tst_QStyleSheetStyle::qproperty to not implicitly rely on QHash ordering. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing qHash() for string data affected the order of properties to be set, causing 'checkable' to be set after 'checked'. As 'checkable' state affects 'checked' as well (setting it to false), this means that the test was unreliable, a bug, which was exposed by the qHash change. Change-Id: I03a8dd7d07609683d99f0b2a40012a147d409c6e Reviewed-by: Mark Brand Reviewed-by: João Abecasis --- tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 1201b0f1da..8f187190aa 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -555,11 +555,11 @@ void tst_QStyleSheetStyle::layoutSpacing() void tst_QStyleSheetStyle::qproperty() { QPushButton pb; - pb.setStyleSheet("QPushButton { qproperty-text: hello; qproperty-checkable: true; qproperty-checked: 1}"); + pb.setStyleSheet("QPushButton { qproperty-text: hello; qproperty-checkable: 1; qproperty-checked: false}"); pb.ensurePolished(); QCOMPARE(pb.text(), QString("hello")); QCOMPARE(pb.isCheckable(), true); - QCOMPARE(pb.isChecked(), true); + QCOMPARE(pb.isChecked(), false); } namespace ns { -- cgit v1.2.3 From deb3c134b5b718e429a71ed0cff8f1f711b30e62 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 3 Feb 2012 18:03:24 +0100 Subject: remove injection of default_pre in infile()/$$fromfile() this is a hack from the times when these functions were (ab)used to inspect proper project files, but the inclusion was done with a clean project, so that the included files did not have any functions to work with. Change-Id: I19925e8ead597ca38df040000c183e368b32c06d Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testdata/export_across_file_boundaries/oink.pri | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/testdata/export_across_file_boundaries/oink.pri b/tests/auto/tools/qmake/testdata/export_across_file_boundaries/oink.pri index cbd2d0f7d0..ea58ef076e 100644 --- a/tests/auto/tools/qmake/testdata/export_across_file_boundaries/oink.pri +++ b/tests/auto/tools/qmake/testdata/export_across_file_boundaries/oink.pri @@ -1 +1,2 @@ +load(default_pre) setVar(BAR) -- cgit v1.2.3 From 82fd18fe3640a4e4d57cf736691c201e78a4a771 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 1 Mar 2012 15:05:38 +0200 Subject: Windows: Make QSettings autotest significant again The latest windows run of CI has QSettings test passing, so remove the CONFIG += insignificant_test from it. Task-number: QTBUG-24145 Change-Id: I35c0d8d4f72ad49f9f21dcd486ab33a37ab95e15 Reviewed-by: Sergio Ahumada --- tests/auto/corelib/io/qsettings/qsettings.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qsettings/qsettings.pro b/tests/auto/corelib/io/qsettings/qsettings.pro index 9de476fe13..1772f4b65f 100644 --- a/tests/auto/corelib/io/qsettings/qsettings.pro +++ b/tests/auto/corelib/io/qsettings/qsettings.pro @@ -5,5 +5,3 @@ SOURCES = tst_qsettings.cpp RESOURCES += qsettings.qrc win32-msvc*:LIBS += advapi32.lib - -win32: CONFIG += insignificant_test # QTBUG-24145 -- cgit v1.2.3 From f449cefc27fc321f96aadbcb0f0a46e6f7a2b0b4 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 12 Feb 2012 12:35:12 +0100 Subject: Remove AccessibilityPrepare event. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This event was completely unused. In addition it leads to crashes on linux when sending the Destroy accessibility update. The Destroy event on linux would still query an accessible interface. That in turn would trigger the event to be sent. Change-Id: I8915527de067b8b70ba41b1361e3ef5d12866d7d Reviewed-by: Frederik Gladhorn Reviewed-by: Jan-Arve Sæther --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index caf0f1f80d..dab9dd7690 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -5693,7 +5693,6 @@ private: void tst_QWidget::childEvents() { EventRecorder::EventList expected; - bool accessibilityEnabled = false; // Move away the cursor; otherwise it might result in an enter event if it's // inside the widget when the widget is shown. @@ -5735,8 +5734,6 @@ void tst_QWidget::childEvents() << qMakePair(&widget, QEvent::Resize) << qMakePair(&widget, QEvent::Show); - if (accessibilityEnabled) - expected << qMakePair(&widget, QEvent::AccessibilityPrepare); expected << qMakePair(&widget, QEvent::ShowToParent); QCOMPARE(spy.eventList(), expected); spy.clear(); @@ -5820,8 +5817,6 @@ void tst_QWidget::childEvents() << qMakePair(&widget, QEvent::Resize) << qMakePair(&widget, QEvent::Show); - if (accessibilityEnabled) - expected << qMakePair(&widget, QEvent::AccessibilityPrepare); expected << qMakePair(&widget, QEvent::ShowToParent); QCOMPARE(spy.eventList(), expected); spy.clear(); @@ -5908,8 +5903,6 @@ void tst_QWidget::childEvents() << qMakePair(&widget, QEvent::Resize) << qMakePair(&widget, QEvent::Show); - if (accessibilityEnabled) - expected << qMakePair(&widget, QEvent::AccessibilityPrepare); expected << qMakePair(&widget, QEvent::ShowToParent); QCOMPARE(spy.eventList(), expected); spy.clear(); -- cgit v1.2.3 From 961c3f958f2cd4c993fc384c6e50e25e080c7585 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 6 Mar 2012 09:48:59 +1000 Subject: Stabilize tst_QAccessibility::actionTest show() on a window is asynchronous. Wait for it to complete before continuing with the test. Change-Id: Icd0daa0c0e8f287171c57708bb2fce0b6cf0906a Reviewed-by: Toby Tomkins Reviewed-by: Kalle Lehtonen --- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index b2a4b1cca2..4c370bebc7 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -777,6 +777,7 @@ void tst_QAccessibility::actionTest() { QPushButton *button = new QPushButton; button->show(); + QTest::qWaitForWindowShown(button); button->clearFocus(); QCOMPARE(button->hasFocus(), false); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(button); -- cgit v1.2.3 From 443fd332f941f8c30074390ddd9e00ee40cd584d Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 6 Mar 2012 09:54:55 +1000 Subject: Stabilize tst_QShortcut show() on a window is asynchronous. Wait for it to complete before continuing with the test. Note the test already contained code for this, but it was inside of a Q_WS_X11 block, making it dead code in Qt 5. Change-Id: I06f892eea86278c56b1773a7e968bbe065f86260 Reviewed-by: Kalle Lehtonen --- tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp index 97c749e5ba..7a87266b8b 100644 --- a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp @@ -221,9 +221,7 @@ void tst_QShortcut::initTestCase() mainW->setFixedSize( 100, 100 ); mainW->setCentralWidget( edit ); mainW->show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(mainW); -#endif + QTest::qWaitForWindowShown(mainW); mainW->activateWindow(); QTest::qWait(100); connect( mainW->statusBar(), SIGNAL(messageChanged(const QString&)), -- cgit v1.2.3 From 7206f9c539f7302b7349be111e9400c3abb7b048 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 6 Mar 2012 10:03:35 +1000 Subject: Stabilize tst_QCalendarWidget::buttonClickCheck The window should be shown and activated before sending user input. Task-number: QTBUG-23615 Change-Id: I2fc1738d9dc4ee7f03c81b040eed6389910a9d3c Reviewed-by: Toby Tomkins --- tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro | 3 --- tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro b/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro index 127d78596a..f16110cbd1 100644 --- a/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro +++ b/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro @@ -2,6 +2,3 @@ CONFIG += testcase TARGET = tst_qcalendarwidget QT += widgets testlib SOURCES += tst_qcalendarwidget.cpp - -# QTBUG-23615 - unstable test -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp index 4f95f80525..4857900dc8 100644 --- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp +++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp @@ -175,6 +175,8 @@ void tst_QCalendarWidget::buttonClickCheck() QSize size = object.sizeHint(); object.setGeometry(0,0,size.width(), size.height()); object.show(); + QTest::qWaitForWindowShown(&object); + object.activateWindow(); QDate selectedDate(2005, 1, 1); //click on the month buttons -- cgit v1.2.3 From c78957766a5adba45289a0f7afe22949a183b34b Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 2 Mar 2012 20:33:55 +0100 Subject: QMimeDatabase: Fix crash on empty filename This is due to the search in the suffix tree starting at position fileName.length() - 1. Change-Id: I98501c1724c7dde2626351ace8ba19faa0d2e1e1 Reviewed-by: Ivan Komissarov Reviewed-by: Wolf-Michael Bolle --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 63adcadb86..9076f37c7c 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -207,6 +207,7 @@ void tst_QMimeDatabase::mimeTypeForFileName_data() QTest::newRow("directory") << "/" << "inode/directory"; QTest::newRow("doesn't exist, no extension") << "IDontExist" << "application/octet-stream"; QTest::newRow("doesn't exist but has known extension") << "IDontExist.txt" << "text/plain"; + QTest::newRow("empty") << "" << "application/octet-stream"; } static inline QByteArray msgMimeTypeForFileNameFailed(const QList &actual, -- cgit v1.2.3 From 00821ec710ec8d9549b9f7e68837a7393a954754 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 29 Feb 2012 15:53:24 +0000 Subject: QSslCertificate - make lazy initialisation thread safe QSslCertificate can be copied around into multiple threads, without detaching. For example, the https worker threads inside QNetworkAccessManager. There are const methods, which lazily initialise members of the private class without detaching (i.e. caching results of expensive function calls) These functions now lock the d pointer using QMutexPool to avoid concurrency related crashes. autotest crashes 20% of the time in release builds without the fix, passes 100 times in a row with the fix. Task-number: QTBUG-20452 Change-Id: I64a01af8159216f2dd6215a08669890f6c029ca8 Reviewed-by: Thiago Macieira Reviewed-by: Richard J. Moore --- .../ssl/qsslcertificate/tst_qsslcertificate.cpp | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 5da9ff0476..93299c26c6 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -109,6 +109,7 @@ private slots: void subjectAndIssuerAttributes(); void verify(); void extensions(); + void threadSafeConstMethods(); // helper for verbose test failure messages QString toString(const QList&); @@ -1059,6 +1060,77 @@ void tst_QSslCertificate::extensions() } +class TestThread : public QThread +{ +public: + void run() + { + effectiveDate = cert.effectiveDate(); + expiryDate = cert.expiryDate(); + extensions = cert.extensions(); + isBlacklisted = cert.isBlacklisted(); + issuerInfo = cert.issuerInfo(QSslCertificate::CommonName); + issuerInfoAttributes = cert.issuerInfoAttributes(); + publicKey = cert.publicKey(); + serialNumber = cert.serialNumber(); + subjectInfo = cert.subjectInfo(QSslCertificate::CommonName); + subjectInfoAttributes = cert.subjectInfoAttributes(); + toDer = cert.toDer(); + toPem = cert.toPem(); + toText = cert.toText(); + version = cert.version(); + } + QSslCertificate cert; + QDateTime effectiveDate; + QDateTime expiryDate; + QList extensions; + bool isBlacklisted; + QStringList issuerInfo; + QList issuerInfoAttributes; + QSslKey publicKey; + QByteArray serialNumber; + QStringList subjectInfo; + QList subjectInfoAttributes; + QByteArray toDer; + QByteArray toPem; + QByteArray toText; + QByteArray version; +}; + +void tst_QSslCertificate::threadSafeConstMethods() +{ + if (!QSslSocket::supportsSsl()) + return; + + QByteArray encoded = readFile(testDataDir + "/certificates/cert.pem"); + QSslCertificate certificate(encoded); + QVERIFY(!certificate.isNull()); + + TestThread t1; + t1.cert = certificate; //shallow copy + TestThread t2; + t2.cert = certificate; //shallow copy + t1.start(); + t2.start(); + QVERIFY(t1.wait(5000)); + QVERIFY(t2.wait(5000)); + QVERIFY(t1.cert == t2.cert); + QVERIFY(t1.effectiveDate == t2.effectiveDate); + QVERIFY(t1.expiryDate == t2.expiryDate); + //QVERIFY(t1.extensions == t2.extensions); // no equality operator, so not tested + QVERIFY(t1.isBlacklisted == t2.isBlacklisted); + QVERIFY(t1.issuerInfo == t2.issuerInfo); + QVERIFY(t1.issuerInfoAttributes == t2.issuerInfoAttributes); + QVERIFY(t1.publicKey == t2.publicKey); + QVERIFY(t1.serialNumber == t2.serialNumber); + QVERIFY(t1.subjectInfo == t2.subjectInfo); + QVERIFY(t1.subjectInfoAttributes == t2.subjectInfoAttributes); + QVERIFY(t1.toDer == t2.toDer); + QVERIFY(t1.toPem == t2.toPem); + QVERIFY(t1.toText == t2.toText); + QVERIFY(t1.version == t2.version); + +} #endif // QT_NO_SSL -- cgit v1.2.3 From eb24dfcccb304c84a147f0eafd3b3fc3df3ef4f3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 2 Mar 2012 14:48:09 +0100 Subject: Add template specialization of QMetaType for QObject derived pointers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it possible to do things like QVariant::fromValue(new SomeObject); without first using Q_DECLARE_METATYPE(Something*) This functionality was originally part of http://codereview.qt-project.org/#change,11710 but was rejected because the functionality was based on specialization of QVariant::fromValue which could be dangerous. This new implementation doesn't have such danger. Change-Id: I83fe941b6984be54469bc6b9191f6eacaceaa036 Reviewed-by: Jędrzej Nowacki Reviewed-by: Olivier Goffart --- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 17 +++++++++++++++++ tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 15 +++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index f8403f11a1..572ecc9ba8 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -100,12 +100,29 @@ private slots: struct Foo { int i; }; + +class CustomQObject : public QObject +{ + Q_OBJECT +public: + CustomQObject(QObject *parent = 0) + : QObject(parent) + { + } +}; + +class CustomNonQObject {}; + void tst_QMetaType::defined() { QCOMPARE(int(QMetaTypeId2::Defined), 1); QCOMPARE(int(QMetaTypeId2::Defined), 0); QCOMPARE(int(QMetaTypeId2::Defined), 1); QCOMPARE(int(QMetaTypeId2::Defined), 0); + QVERIFY(QMetaTypeId2::Defined); + QVERIFY(!QMetaTypeId2::Defined); + QVERIFY(!QMetaTypeId2::Defined); + QVERIFY(!QMetaTypeId2::Defined); } struct Bar diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index ccdab17668..5aa1389b65 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -2541,8 +2541,23 @@ public: }; Q_DECLARE_METATYPE(CustomQObjectDerived*) +class CustomQObjectDerivedNoMetaType : public CustomQObject { + Q_OBJECT +public: + CustomQObjectDerivedNoMetaType(QObject *parent = 0) : CustomQObject(parent) {} +}; + void tst_QVariant::qvariant_cast_QObject_derived() { + { + CustomQObjectDerivedNoMetaType *object = new CustomQObjectDerivedNoMetaType(this); + QVariant data = QVariant::fromValue(object); + QVERIFY(data.userType() == qMetaTypeId()); + QCOMPARE(data.value(), object); + QCOMPARE(data.value(), object); + QCOMPARE(data.value(), object); + QVERIFY(data.value() == 0); + } { CustomQObjectDerived *object = new CustomQObjectDerived(this); QVariant data = QVariant::fromValue(object); -- cgit v1.2.3 From 299e7ffd6a8a91f1d4259b91d4a519c1933c5f33 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 5 Mar 2012 14:09:04 +0000 Subject: Fix QNetworkReply ioGetFromHttpWithCache test case Expiration date is calculated from max-age header when a response is inserted into the cache. Because the test case is prepopulating the cache outside of QNAM's control, the expiration date was uninitialised, causing the test to fail. This is due to a 2 year old change in QNAM, where max age calculation was removed from cache retrieval, and more recent changes to QDateTime where secsTo() returns 0 if one of the arguments is invalid. Change-Id: Ieecd46123dde4ca0fd0be3ae79e70e1528ec02bc Reviewed-by: Martin Petersson --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index d8f9bf32ad..00b3fd1973 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -3385,6 +3385,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache_data() << QNetworkCacheMetaData::RawHeader("Cache-control", "max-age=0"); // isn't used in cache loading content.first.setRawHeaders(rawHeaders); content.first.setLastModified(past); + content.first.setExpirationDate(past); QTest::newRow("expired,200,prefer-network") << reply200 << "Reloaded" << content << int(QNetworkRequest::PreferNetwork) << QStringList() << false << true; -- cgit v1.2.3 From c93f7b69486a0d12b475e31eeb699ae07aa928c2 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 5 Mar 2012 16:54:12 +0000 Subject: Fix tst_QNetworkReply::httpWithNoCredentialUsage autotest The test was testing the wrong thing, and passing even though QNetworkRequest::AuthenticationReuseAttribute was not being respected, until recently when I fixed username/password in URLs Now the cache is properly bypassed when this attribute is set to manual, and the autotest is updated to check this. Change-Id: I87943515562d0b16b03504f0758ba265758d1c22 Reviewed-by: Martin Petersson --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 55 +++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 00b3fd1973..8685546a5f 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -6335,29 +6335,52 @@ void tst_QNetworkReply::qtbug13431replyThrottling() void tst_QNetworkReply::httpWithNoCredentialUsage() { - QNetworkRequest request(QUrl("http://httptest:httptest@" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi")); - // Do not use credentials - request.setAttribute(QNetworkRequest::AuthenticationReuseAttribute, QNetworkRequest::Manual); QNetworkAccessManager manager; - QNetworkReplyPtr reply = manager.get(request); - qRegisterMetaType("QNetworkReply*"); - qRegisterMetaType("QAuthenticator*"); QSignalSpy authSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*))); - qRegisterMetaType("QNetworkReply::NetworkError"); - QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); + // Get with credentials, to preload authentication cache + { + QNetworkRequest request(QUrl("http://httptest:httptest@" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi")); + QNetworkReplyPtr reply = manager.get(request); + QVERIFY(waitForFinish(reply) == Success); + // credentials in URL, so don't expect authentication signal + QCOMPARE(authSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 1); + finishedSpy.clear(); + } - // We check if authenticationRequired was emitted, however we do not anything in it so it should be 401 - QCOMPARE(authSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(errorSpy.count(), 1); + // Get with cached credentials (normal usage) + { + QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi")); + QNetworkReplyPtr reply = manager.get(request); + QVERIFY(waitForFinish(reply) == Success); + // credentials in cache, so don't expect authentication signal + QCOMPARE(authSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 1); + finishedSpy.clear(); + } - QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); + // Do not use cached credentials (webkit cross origin usage) + { + QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi")); + request.setAttribute(QNetworkRequest::AuthenticationReuseAttribute, QNetworkRequest::Manual); + QNetworkReplyPtr reply = manager.get(request); + + QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + // We check if authenticationRequired was emitted, however we do not anything in it so it should be 401 + QCOMPARE(authSpy.count(), 1); + QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(errorSpy.count(), 1); + + QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); + } } void tst_QNetworkReply::qtbug15311doubleContentLength() -- cgit v1.2.3 From 676304e706266f09357ad8bfbe6c4c281f3f3873 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 2 Mar 2012 15:46:39 +0100 Subject: Add test for QUrl::isLocalFile (there weren't any). Change-Id: I839d2eee7b0651700516d6140635151a52a9fa40 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index a74d817b8a..f782b26b46 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1001,6 +1001,7 @@ void tst_QUrl::toLocalFile() QUrl url(theUrl); QCOMPARE(url.toLocalFile(), theFile); + QCOMPARE(url.isLocalFile(), !theFile.isEmpty()); } void tst_QUrl::fromLocalFile_data() -- cgit v1.2.3 From c7cb455a47c42e8e658e3433defee613f8643cd2 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 23 Jan 2012 22:47:59 +0000 Subject: QRegularExpression: add QRegularExpression* set of classes Added QRegularExpression, QRegularExpressionMatch and QRegularExpressionMatchIterator as PCRE-enabled, regexp classes. Documentation is included, as well as a first round of autotests. Task-number: QTBUG-23489 Change-Id: Id47031b80602c913ccd2fd740070e3024ea06abc Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- .../corelib/tools/qregularexpression/.gitignore | 1 + .../qregularexpression/qregularexpression.pro | 4 + .../qregularexpression/tst_qregularexpression.cpp | 1150 ++++++++++++++++++++ tests/auto/corelib/tools/tools.pro | 1 + 4 files changed, 1156 insertions(+) create mode 100644 tests/auto/corelib/tools/qregularexpression/.gitignore create mode 100644 tests/auto/corelib/tools/qregularexpression/qregularexpression.pro create mode 100644 tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregularexpression/.gitignore b/tests/auto/corelib/tools/qregularexpression/.gitignore new file mode 100644 index 0000000000..4a224d26fc --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/.gitignore @@ -0,0 +1 @@ +tst_qregularexpression diff --git a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro new file mode 100644 index 0000000000..bce6643be6 --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qregularexpression +QT = core testlib +SOURCES = tst_qregularexpression.cpp diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp new file mode 100644 index 0000000000..93cb6823cd --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -0,0 +1,1150 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Giuseppe D'Angelo . +** 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 +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QRegularExpression::PatternOptions) +Q_DECLARE_METATYPE(QRegularExpression::MatchType) +Q_DECLARE_METATYPE(QRegularExpression::MatchOptions) + +class tst_QRegularExpression : public QObject +{ + Q_OBJECT + +private slots: + void gettersSetters_data(); + void gettersSetters(); + void escape_data(); + void escape(); + void validity_data(); + void validity(); + void patternOptions_data(); + void patternOptions(); + void normalMatch_data(); + void normalMatch(); + void partialMatch_data(); + void partialMatch(); + void globalMatch_data(); + void globalMatch(); + void serialize_data(); + void serialize(); + +private: + void provideRegularExpressions(); +}; + +struct Match +{ + Match() + { + clear(); + } + + void clear() + { + isValid = false; + hasMatch = false; + hasPartialMatch = false; + captured.clear(); + namedCaptured.clear(); + } + + bool isValid; + bool hasMatch; + bool hasPartialMatch; + QStringList captured; + QHash namedCaptured; +}; + +Q_DECLARE_METATYPE(Match) +Q_DECLARE_METATYPE(QList) + +bool operator==(const QRegularExpressionMatch &rem, const Match &m) +{ + if (rem.isValid() != m.isValid) + return false; + if (!rem.isValid()) + return true; + if ((rem.hasMatch() != m.hasMatch) || (rem.hasPartialMatch() != m.hasPartialMatch)) + return false; + if (rem.hasMatch() || rem.hasPartialMatch()) { + if (rem.lastCapturedIndex() != (m.captured.size() - 1)) + return false; + for (int i = 0; i <= rem.lastCapturedIndex(); ++i) { + QString remCaptured = rem.captured(i); + QString mCaptured = m.captured.at(i); + if (remCaptured != mCaptured + || remCaptured.isNull() != mCaptured.isNull() + || remCaptured.isEmpty() != mCaptured.isEmpty()) { + return false; + } + } + + Q_FOREACH (const QString &name, m.namedCaptured.keys()) { + if (rem.captured(name) != m.namedCaptured.value(name)) + return false; + } + } + + return true; +} + +bool operator==(const Match &m, const QRegularExpressionMatch &rem) +{ + return operator==(rem, m); +} + +bool operator!=(const QRegularExpressionMatch &rem, const Match &m) +{ + return !operator==(rem, m); +} + +bool operator!=(const Match &m, const QRegularExpressionMatch &rem) +{ + return !operator==(m, rem); +} + + +bool operator==(const QRegularExpressionMatchIterator &iterator, const QList &expectedMatchList) +{ + QRegularExpressionMatchIterator i = iterator; + if (i.isValid() != (!expectedMatchList.isEmpty())) + return false; + + foreach (const Match &expectedMatch, expectedMatchList) + { + if (!i.hasNext()) + return false; + + QRegularExpressionMatch match = i.next(); + if (match != expectedMatch) + return false; + } + + if (i.hasNext()) + return false; + + return true; +} + +bool operator==(const QList &expectedMatchList, const QRegularExpressionMatchIterator &iterator) +{ + return operator==(iterator, expectedMatchList); +} + +bool operator!=(const QRegularExpressionMatchIterator &iterator, const QList &expectedMatchList) +{ + return !operator==(iterator, expectedMatchList); +} + +bool operator!=(const QList &expectedMatchList, const QRegularExpressionMatchIterator &iterator) +{ + return !operator==(expectedMatchList, iterator); +} + +void consistencyCheck(const QRegularExpressionMatch &match) +{ + QVERIFY(match.isValid() == match.regularExpression().isValid()); + + if (match.isValid()) { + QVERIFY(!(match.hasMatch() && match.hasPartialMatch())); + + if (match.hasMatch() || match.hasPartialMatch()) { + QVERIFY(match.lastCapturedIndex() >= 0); + if (match.hasPartialMatch()) + QVERIFY(match.lastCapturedIndex() == 0); + + for (int i = 0; i <= match.lastCapturedIndex(); ++i) { + int startPos = match.capturedStart(i); + int endPos = match.capturedEnd(i); + int length = match.capturedLength(i); + QString captured = match.captured(i); + QStringRef capturedRef = match.capturedRef(i); + + if (!captured.isNull()) { + QVERIFY(startPos >= 0); + QVERIFY(endPos >= 0); + QVERIFY(length >= 0); + QVERIFY(endPos >= startPos); + QVERIFY((endPos - startPos) == length); + QVERIFY(captured == capturedRef); + } else { + QVERIFY(startPos == -1); + QVERIFY(endPos == -1); + QVERIFY((endPos - startPos) == length); + QVERIFY(capturedRef.isNull()); + } + } + } + } else { + QVERIFY(!match.hasMatch()); + QVERIFY(!match.hasPartialMatch()); + QVERIFY(match.captured(0).isNull()); + QVERIFY(match.capturedStart(0) == -1); + QVERIFY(match.capturedEnd(0) == -1); + QVERIFY(match.capturedLength(0) == 0); + } +} + +void consistencyCheck(const QRegularExpressionMatchIterator &iterator) +{ + QRegularExpressionMatchIterator i(iterator); // make a copy, we modify it + if (i.isValid()) { + while (i.hasNext()) { + QRegularExpressionMatch peeked = i.peekNext(); + QRegularExpressionMatch match = i.next(); + consistencyCheck(peeked); + consistencyCheck(match); + QVERIFY(match.isValid()); + QVERIFY(match.hasMatch() || match.hasPartialMatch()); + QCOMPARE(i.regularExpression(), match.regularExpression()); + QCOMPARE(i.matchOptions(), match.matchOptions()); + QCOMPARE(i.matchType(), match.matchType()); + + QVERIFY(peeked.isValid() == match.isValid()); + QVERIFY(peeked.hasMatch() == match.hasMatch()); + QVERIFY(peeked.hasPartialMatch() == match.hasPartialMatch()); + QVERIFY(peeked.lastCapturedIndex() == match.lastCapturedIndex()); + for (int i = 0; i <= peeked.lastCapturedIndex(); ++i) { + QVERIFY(peeked.captured(i) == match.captured(i)); + QVERIFY(peeked.capturedStart(i) == match.capturedStart(i)); + QVERIFY(peeked.capturedEnd(i) == match.capturedEnd(i)); + } + } + } else { + QVERIFY(!i.hasNext()); + QRegularExpressionMatch peeked = i.peekNext(); + QRegularExpressionMatch match = i.next(); + consistencyCheck(peeked); + consistencyCheck(match); + QVERIFY(!match.isValid()); + QVERIFY(!peeked.isValid()); + } + +} + +void tst_QRegularExpression::provideRegularExpressions() +{ + QTest::addColumn("pattern"); + QTest::addColumn("patternOptions"); + + QTest::newRow("emptynull01") << QString() + << QRegularExpression::PatternOptions(0); + QTest::newRow("emptynull02") << QString() + << QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption + | QRegularExpression::DotMatchesEverythingOption + | QRegularExpression::MultilineOption); + QTest::newRow("emptynull03") << "" + << QRegularExpression::PatternOptions(0); + QTest::newRow("emptynull04") << "" + << QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption + | QRegularExpression::DotMatchesEverythingOption + | QRegularExpression::MultilineOption); + + QTest::newRow("regexp01") << "a pattern" + << QRegularExpression::PatternOptions(0); + QTest::newRow("regexp02") << "^a (.*) more complicated(?

pattern)$" + << QRegularExpression::PatternOptions(0); + QTest::newRow("regexp03") << "(?:a) pAttErN" + << QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption); + QTest::newRow("regexp04") << "a\nmultiline\npattern" + << QRegularExpression::PatternOptions(QRegularExpression::MultilineOption); + QTest::newRow("regexp05") << "an extended # IGNOREME\npattern" + << QRegularExpression::PatternOptions(QRegularExpression::ExtendedPatternSyntaxOption); + QTest::newRow("regexp06") << "a [sS]ingleline .* match" + << QRegularExpression::PatternOptions(QRegularExpression::DotMatchesEverythingOption); + QTest::newRow("regexp07") << "multiple.*options" + << QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption + | QRegularExpression::DotMatchesEverythingOption + | QRegularExpression::MultilineOption + | QRegularExpression::DontCaptureOption + | QRegularExpression::InvertedGreedinessOption); + + QTest::newRow("unicode01") << QString::fromUtf8("^s[ome] latin-1 \xc3\x80\xc3\x88\xc3\x8c\xc3\x92\xc3\x99 chars$") + << QRegularExpression::PatternOptions(0); + QTest::newRow("unicode02") << QString::fromUtf8("^s[ome] latin-1 \xc3\x80\xc3\x88\xc3\x8c\xc3\x92\xc3\x99 chars$") + << QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption + | QRegularExpression::DotMatchesEverythingOption + | QRegularExpression::InvertedGreedinessOption); + QTest::newRow("unicode03") << QString::fromUtf8("Unicode \xf0\x9d\x85\x9d \xf0\x9d\x85\x9e\xf0\x9d\x85\x9f") + << QRegularExpression::PatternOptions(0); + QTest::newRow("unicode04") << QString::fromUtf8("Unicode \xf0\x9d\x85\x9d \xf0\x9d\x85\x9e\xf0\x9d\x85\x9f") + << QRegularExpression::PatternOptions(QRegularExpression::CaseInsensitiveOption + | QRegularExpression::DotMatchesEverythingOption + | QRegularExpression::InvertedGreedinessOption); +} + +void tst_QRegularExpression::gettersSetters_data() +{ + provideRegularExpressions(); +} + +void tst_QRegularExpression::gettersSetters() +{ + QFETCH(QString, pattern); + QFETCH(QRegularExpression::PatternOptions, patternOptions); + { + QRegularExpression re; + re.setPattern(pattern); + QCOMPARE(re.pattern(), pattern); + QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption); + } + { + QRegularExpression re; + re.setPatternOptions(patternOptions); + QCOMPARE(re.pattern(), QString()); + QCOMPARE(re.patternOptions(), patternOptions); + } + { + QRegularExpression re(pattern); + QCOMPARE(re.pattern(), pattern); + QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption); + } + { + QRegularExpression re(pattern, patternOptions); + QCOMPARE(re.pattern(), pattern); + QCOMPARE(re.patternOptions(), patternOptions); + } + { + QRegularExpression re(pattern, patternOptions); + QRegularExpression re2(pattern, patternOptions); + QVERIFY(re == re2); + } +} + +void tst_QRegularExpression::escape_data() +{ + QTest::addColumn("string"); + QTest::addColumn("escaped"); + QTest::newRow("escape01") << "a normal pattern" + << "a\\ normal\\ pattern"; + + QTest::newRow("escape02") << "abcdefghijklmnopqrstuvzABCDEFGHIJKLMNOPQRSTUVZ1234567890_" + << "abcdefghijklmnopqrstuvzABCDEFGHIJKLMNOPQRSTUVZ1234567890_"; + + QTest::newRow("escape03") << "^\\ba\\b.*(?reg|exp)$" + << "\\^\\\\ba\\\\b\\.\\*\\(\\?\\reg\\|exp\\)\\$"; + + QString nulString("abcXabcXXabc"); + nulString[3] = nulString[7] = nulString[8] = QChar(0, 0); + QTest::newRow("NUL") << nulString + << "abc\\0abc\\0\\0abc"; + + QTest::newRow("unicode01") << QString::fromUtf8("^s[ome] latin-1 \xc3\x80\xc3\x88\xc3\x8c\xc3\x92\xc3\x99 chars$") + << QString::fromUtf8("\\^s\\[ome\\]\\ latin\\-1\\ \\\xc3\x80\\\xc3\x88\\\xc3\x8c\\\xc3\x92\\\xc3\x99\\ chars\\$"); + QTest::newRow("unicode02") << QString::fromUtf8("Unicode \xf0\x9d\x85\x9d \xf0\x9d\x85\x9e\xf0\x9d\x85\x9f") + << QString::fromUtf8("Unicode\\ \\\xf0\x9d\x85\x9d\\ \\\xf0\x9d\x85\x9e\\\xf0\x9d\x85\x9f"); + + QString unicodeAndNulString = QString::fromUtf8("^\xc3\x80\xc3\x88\xc3\x8cN\xc3\x92NN\xc3\x99 chars$"); + unicodeAndNulString[4] = unicodeAndNulString[6] = unicodeAndNulString[7] = QChar(0, 0); + QTest::newRow("unicode03") << unicodeAndNulString + << QString::fromUtf8("\\^\\\xc3\x80\\\xc3\x88\\\xc3\x8c\\0\\\xc3\x92\\0\\0\\\xc3\x99\\ chars\\$"); +} + +void tst_QRegularExpression::escape() +{ + QFETCH(QString, string); + QFETCH(QString, escaped); + QCOMPARE(QRegularExpression::escape(string), escaped); + QRegularExpression re(escaped); + QCOMPARE(re.isValid(), true); +} + +void tst_QRegularExpression::validity_data() +{ + QTest::addColumn("pattern"); + QTest::addColumn("validity"); + + QTest::newRow("valid01") << "a pattern" << true; + QTest::newRow("valid02") << "(a|pattern)" << true; + QTest::newRow("valid03") << "a [pP]attern" << true; + QTest::newRow("valid04") << "^(?

a).*(?pattern)$" << true; + QTest::newRow("valid05") << "a \\P{Ll}attern" << true; + + QTest::newRow("invalid01") << "a pattern\\" << false; + QTest::newRow("invalid02") << "(a|pattern" << false; + QTest::newRow("invalid03") << "a \\P{BLAH}attern" << false; + + QString pattern; + // 0xD800 (high surrogate) not followed by a low surrogate + pattern = "abcdef"; + pattern[3] = QChar(0x00, 0xD8); + QTest::newRow("invalidUnicode01") << pattern << false; +} + +void tst_QRegularExpression::validity() +{ + QFETCH(QString, pattern); + QFETCH(bool, validity); + QRegularExpression re(pattern); + QCOMPARE(re.isValid(), validity); + if (!validity) + QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object"); + QRegularExpressionMatch match = re.match("a pattern"); + QCOMPARE(match.isValid(), validity); + consistencyCheck(match); + + if (!validity) + QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object"); + QRegularExpressionMatchIterator iterator = re.globalMatch("a pattern"); + QCOMPARE(iterator.isValid(), validity); +} + +void tst_QRegularExpression::patternOptions_data() +{ + QTest::addColumn("regexp"); + QTest::addColumn("subject"); + QTest::addColumn("match"); + + // none of these would successfully match if the respective + // pattern option is not set + + Match m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << QString::fromUtf8("AbC\xc3\xa0"); + QTest::newRow("/i") << QRegularExpression(QString::fromUtf8("abc\xc3\x80"), QRegularExpression::CaseInsensitiveOption) + << QString::fromUtf8("AbC\xc3\xa0") + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "abc123\n678def"; + QTest::newRow("/s") << QRegularExpression("\\Aabc.*def\\z", QRegularExpression::DotMatchesEverythingOption) + << "abc123\n678def" + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "jumped over"; + QTest::newRow("/m") << QRegularExpression("^\\w+ \\w+$", QRegularExpression::MultilineOption) + << "the quick fox\njumped over\nthe lazy\ndog" + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "abc 123456"; + QTest::newRow("/x") << QRegularExpression("\\w+ # a word\n" + "\\ # a space\n" + "\\w+ # another word", + QRegularExpression::ExtendedPatternSyntaxOption) + << "abc 123456 def" + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "the quick fox" << "the" << "quick fox"; + QTest::newRow("/U") << QRegularExpression("(.+) (.+?)", QRegularExpression::InvertedGreedinessOption) + << "the quick fox" + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "the quick fox" << "quick"; + m.namedCaptured["named"] = "quick"; + QTest::newRow("no cap") << QRegularExpression("(\\w+) (?\\w+) (\\w+)", QRegularExpression::DontCaptureOption) + << "the quick fox" + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << QString::fromUtf8("abc\xc3\x80\xc3\xa0 12\xdb\xb1\xdb\xb2\xf0\x9d\x9f\x98") + << QString::fromUtf8("abc\xc3\x80\xc3\xa0") + << QString::fromUtf8("12\xdb\xb1\xdb\xb2\xf0\x9d\x9f\x98"); + QTest::newRow("unicode properties") << QRegularExpression("(\\w+) (\\d+)", QRegularExpression::UseUnicodePropertiesOption) + << QString::fromUtf8("abc\xc3\x80\xc3\xa0 12\xdb\xb1\xdb\xb2\xf0\x9d\x9f\x98") + << m; +} + +void tst_QRegularExpression::patternOptions() +{ + QFETCH(QRegularExpression, regexp); + QFETCH(QString, subject); + QFETCH(Match, match); + + QRegularExpressionMatch m = regexp.match(subject); + consistencyCheck(m); + QVERIFY(m == match); +} + +void tst_QRegularExpression::normalMatch_data() +{ + QTest::addColumn("regexp"); + QTest::addColumn("subject"); + QTest::addColumn("offset"); + QTest::addColumn("matchOptions"); + QTest::addColumn("match"); + + Match m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "string" << "string"; + QTest::newRow("match01") << QRegularExpression("(\\bstring\\b)") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "a string" << "a" << "string"; + QTest::newRow("match02") << QRegularExpression("(\\w+) (\\w+)") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "a string" << "a" << "string"; + m.namedCaptured["article"] = "a"; + m.namedCaptured["noun"] = "string"; + QTest::newRow("match03") << QRegularExpression("(?
\\w+) (?\\w+)") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << " string" << QString() << "string"; + QTest::newRow("match04") << QRegularExpression("(\\w+)? (\\w+)") + << " string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << " string" << QString("") << "string"; + QTest::newRow("match05") << QRegularExpression("(\\w*) (\\w+)") + << " string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "c123def" << "c12" << "3" << "def"; + QTest::newRow("match06") << QRegularExpression("(\\w*)(\\d+)(\\w*)") + << "abc123def" + << 2 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << QString(""); + QTest::newRow("match07") << QRegularExpression("\\w*") + << "abc123def" + << 9 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << QString("a string") << QString("a string") << QString(""); + QTest::newRow("match08") << QRegularExpression("(.*)(.*)") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << QString("a string") << QString("") << QString("a string"); + QTest::newRow("match09") << QRegularExpression("(.*?)(.*)") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + // *** + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch01") << QRegularExpression("\\d+") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch02") << QRegularExpression("(\\w+) (\\w+)") + << "a string" + << 1 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch03") << QRegularExpression("\\w+") + << "abc123def" + << 9 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + // *** + + m.clear(); + m.isValid = true; + QTest::newRow("anchoredmatch01") << QRegularExpression("\\d+") + << "abc123def" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::AnchoredMatchOption) + << m; +} + + +void tst_QRegularExpression::normalMatch() +{ + QFETCH(QRegularExpression, regexp); + QFETCH(QString, subject); + QFETCH(int, offset); + QFETCH(QRegularExpression::MatchOptions, matchOptions); + QFETCH(Match, match); + + QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NormalMatch, matchOptions); + consistencyCheck(m); + QVERIFY(m == match); +} + + +void tst_QRegularExpression::partialMatch_data() +{ + QTest::addColumn("regexp"); + QTest::addColumn("subject"); + QTest::addColumn("offset"); + QTest::addColumn("matchType"); + QTest::addColumn("matchOptions"); + QTest::addColumn("match"); + + Match m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "str"; + QTest::newRow("softmatch01") << QRegularExpression("string") + << "a str" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << " str"; + QTest::newRow("softmatch02") << QRegularExpression("\\bstring\\b") + << "a str" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << " str"; + QTest::newRow("softmatch03") << QRegularExpression("(\\bstring\\b)") + << "a str" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "8 Dec 19"; + QTest::newRow("softmatch04") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$") + << "8 Dec 19" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "8 Dec 1985" << "8" << "Dec" << "1985"; + QTest::newRow("softmatch05") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$") + << "8 Dec 1985" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "def"; + QTest::newRow("softmatch06") << QRegularExpression("abc\\w+X|def") + << "abcdef" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "abcdef"; + QTest::newRow("softmatch07") << QRegularExpression("abc\\w+X|defY") + << "abcdef" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "def"; + QTest::newRow("softmatch08") << QRegularExpression("abc\\w+X|defY") + << "abcdef" + << 1 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + // *** + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "str"; + QTest::newRow("hardmatch01") << QRegularExpression("string") + << "a str" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << " str"; + QTest::newRow("hardmatch02") << QRegularExpression("\\bstring\\b") + << "a str" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << " str"; + QTest::newRow("hardmatch03") << QRegularExpression("(\\bstring\\b)") + << "a str" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "8 Dec 19"; + QTest::newRow("hardmatch04") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$") + << "8 Dec 19" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "8 Dec 1985"; + QTest::newRow("hardmatch05") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$") + << "8 Dec 1985" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "abcdef"; + QTest::newRow("hardmatch06") << QRegularExpression("abc\\w+X|def") + << "abcdef" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "abcdef"; + QTest::newRow("hardmatch07") << QRegularExpression("abc\\w+X|defY") + << "abcdef" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "def"; + QTest::newRow("hardmatch08") << QRegularExpression("abc\\w+X|defY") + << "abcdef" + << 1 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "ab"; + QTest::newRow("hardmatch09") << QRegularExpression("abc|ab") + << "ab" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "abc"; + QTest::newRow("hardmatch10") << QRegularExpression("abc(def)?") + << "abc" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasPartialMatch = true; + m.captured << "abc"; + QTest::newRow("hardmatch11") << QRegularExpression("(abc)*") + << "abc" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + + // *** + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch01") << QRegularExpression("abc\\w+X|defY") + << "123456" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch02") << QRegularExpression("abc\\w+X|defY") + << "123456" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch03") << QRegularExpression("abc\\w+X|defY") + << "ab123" + << 0 + << QRegularExpression::PartialPreferCompleteMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; + QTest::newRow("nomatch04") << QRegularExpression("abc\\w+X|defY") + << "ab123" + << 0 + << QRegularExpression::PartialPreferFirstMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + +} + +void tst_QRegularExpression::partialMatch() +{ + QFETCH(QRegularExpression, regexp); + QFETCH(QString, subject); + QFETCH(int, offset); + QFETCH(QRegularExpression::MatchType, matchType); + QFETCH(QRegularExpression::MatchOptions, matchOptions); + QFETCH(Match, match); + + QRegularExpressionMatch m = regexp.match(subject, offset, matchType, matchOptions); + consistencyCheck(m); + QVERIFY(m == match); +} + +void tst_QRegularExpression::globalMatch_data() +{ + QTest::addColumn("regexp"); + QTest::addColumn("subject"); + QTest::addColumn("offset"); + QTest::addColumn("matchType"); + QTest::addColumn("matchOptions"); + QTest::addColumn >("matchList"); + + QList matchList; + Match m; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the"; + matchList << m; + m.captured = QStringList() << "quick"; + matchList << m; + m.captured = QStringList() << "fox"; + matchList << m; + QTest::newRow("globalmatch01") << QRegularExpression("\\w+") + << "the quick fox" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the" << "t" << "he"; + matchList << m; + m.captured = QStringList() << "quick" << "q" << "uick"; + matchList << m; + m.captured = QStringList() << "fox" << "f" << "ox"; + matchList << m; + QTest::newRow("globalmatch02") << QRegularExpression("(\\w+?)(\\w+)") + << "the quick fox" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "c"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "c"; + matchList << m; + m.captured = QStringList() << "aabb"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + + QTest::newRow("globalmatch_emptycaptures01") << QRegularExpression("a*b*|c") + << "ccaabbd" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "quick"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "fox"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + + QTest::newRow("globalmatch_emptycaptures02") << QRegularExpression(".*") + << "the\nquick\nfox" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "quick"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "fox"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + + QTest::newRow("globalmatch_emptycaptures03") << QRegularExpression(".*") + << "the\nquick\nfox\n" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "quick"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "fox"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + + QTest::newRow("globalmatch_emptycaptures04") << QRegularExpression("(*CRLF).*") + << "the\r\nquick\r\nfox" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "quick"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "fox"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + + QTest::newRow("globalmatch_emptycaptures05") << QRegularExpression("(*CRLF).*") + << "the\r\nquick\r\nfox\r\n" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; + + matchList.clear(); + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured = QStringList() << "the"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "quick"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "fox"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + m.captured = QStringList() << "jumped"; + matchList << m; + m.captured = QStringList() << ""; + matchList << m; + + QTest::newRow("globalmatch_emptycaptures06") << QRegularExpression("(*ANYCRLF).*") + << "the\r\nquick\nfox\rjumped" + << 0 + << QRegularExpression::NormalMatch + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << matchList; +} + +void tst_QRegularExpression::globalMatch() +{ + QFETCH(QRegularExpression, regexp); + QFETCH(QString, subject); + QFETCH(int, offset); + QFETCH(QRegularExpression::MatchType, matchType); + QFETCH(QRegularExpression::MatchOptions, matchOptions); + QFETCH(QList, matchList); + + QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, matchType, matchOptions); + consistencyCheck(iterator); + QVERIFY(iterator == matchList); +} + +void tst_QRegularExpression::serialize_data() +{ + provideRegularExpressions(); +} + +void tst_QRegularExpression::serialize() +{ + QFETCH(QString, pattern); + QFETCH(QRegularExpression::PatternOptions, patternOptions); + QRegularExpression outRe(pattern, patternOptions); + QByteArray buffer; + { + QDataStream out(&buffer, QIODevice::WriteOnly); + out << outRe; + } + QRegularExpression inRe; + { + QDataStream in(&buffer, QIODevice::ReadOnly); + in >> inRe; + } + QCOMPARE(inRe, outRe); +} + +QTEST_APPLESS_MAIN(tst_QRegularExpression) + +#include "tst_qregularexpression.moc" + diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 89bb3bc416..d8961559e5 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -25,6 +25,7 @@ SUBDIRS=\ qqueue \ qrect \ qregexp \ + qregularexpression \ qringbuffer \ qscopedpointer \ qscopedvaluerollback \ -- cgit v1.2.3 From bd30234b59c1a0cef81b8ce43f2fefac1f28b318 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 8 Feb 2012 18:53:22 +0000 Subject: QRegularExpression: improve operator==, add dedicated autotest Trivial change: compare dpointers first, then the data. Added test function for operator==. Change-Id: I33ac64a59db4ccad56c30be17622187e42415f38 Reviewed-by: Lars Knoll --- .../qregularexpression/tst_qregularexpression.cpp | 64 ++++++++++++++++++++-- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 93cb6823cd..8365a09689 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -71,6 +71,8 @@ private slots: void globalMatch(); void serialize_data(); void serialize(); + void operatoreq_data(); + void operatoreq(); private: void provideRegularExpressions(); @@ -348,11 +350,6 @@ void tst_QRegularExpression::gettersSetters() QCOMPARE(re.pattern(), pattern); QCOMPARE(re.patternOptions(), patternOptions); } - { - QRegularExpression re(pattern, patternOptions); - QRegularExpression re2(pattern, patternOptions); - QVERIFY(re == re2); - } } void tst_QRegularExpression::escape_data() @@ -1144,6 +1141,63 @@ void tst_QRegularExpression::serialize() QCOMPARE(inRe, outRe); } +static void verifyEquality(const QRegularExpression &re1, const QRegularExpression &re2) +{ + QVERIFY(re1 == re2); + QVERIFY(re2 == re1); + QVERIFY(!(re1 != re2)); + QVERIFY(!(re2 != re1)); + + QRegularExpression re3(re1); + + QVERIFY(re1 == re3); + QVERIFY(re3 == re1); + QVERIFY(!(re1 != re3)); + QVERIFY(!(re3 != re1)); + + QVERIFY(re2 == re3); + QVERIFY(re3 == re2); + QVERIFY(!(re2 != re3)); + QVERIFY(!(re3 != re2)); + + re3 = re2; + QVERIFY(re1 == re3); + QVERIFY(re3 == re1); + QVERIFY(!(re1 != re3)); + QVERIFY(!(re3 != re1)); + + QVERIFY(re2 == re3); + QVERIFY(re3 == re2); + QVERIFY(!(re2 != re3)); + QVERIFY(!(re3 != re2)); +} + +void tst_QRegularExpression::operatoreq_data() +{ + provideRegularExpressions(); +} + +void tst_QRegularExpression::operatoreq() +{ + QFETCH(QString, pattern); + QFETCH(QRegularExpression::PatternOptions, patternOptions); + { + QRegularExpression re1(pattern); + QRegularExpression re2(pattern); + verifyEquality(re1, re2); + } + { + QRegularExpression re1(QString(), patternOptions); + QRegularExpression re2(QString(), patternOptions); + verifyEquality(re1, re2); + } + { + QRegularExpression re1(pattern, patternOptions); + QRegularExpression re2(pattern, patternOptions); + verifyEquality(re1, re2); + } +} + QTEST_APPLESS_MAIN(tst_QRegularExpression) #include "tst_qregularexpression.moc" -- cgit v1.2.3 From efcd4d9470781e3a0331afeab49cd00cee24399f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 19 Feb 2012 23:56:50 +0100 Subject: QRegularExpression: add captureCount() QRegularExpression::captureCount() returns the number of capturing groups inside the regular expression pattern. Change-Id: Ib90ce67c67d06ab2966f0c98bd91da21defc156d Reviewed-by: Thiago Macieira --- .../qregularexpression/tst_qregularexpression.cpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 8365a09689..9430425532 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -73,6 +73,8 @@ private slots: void serialize(); void operatoreq_data(); void operatoreq(); + void captureCount_data(); + void captureCount(); private: void provideRegularExpressions(); @@ -1198,6 +1200,35 @@ void tst_QRegularExpression::operatoreq() } } +void tst_QRegularExpression::captureCount_data() +{ + QTest::addColumn("pattern"); + QTest::addColumn("captureCount"); + QTest::newRow("captureCount01") << "a pattern" << 0; + QTest::newRow("captureCount02") << "a.*pattern" << 0; + QTest::newRow("captureCount03") << "(a) pattern" << 1; + QTest::newRow("captureCount04") << "(a).*(pattern)" << 2; + QTest::newRow("captureCount05") << "^(?
\\w+) (?\\w+)$" << 2; + QTest::newRow("captureCount06") << "^(\\w+) (?\\w+) (.)$" << 3; + QTest::newRow("captureCount07") << "(?:non capturing) (capturing) (?named) (?:non (capturing))" << 3; + QTest::newRow("captureCount08") << "(?|(a)(b)|(c)(d))" << 2; + QTest::newRow("captureCount09") << "(?|(a)(b)|(c)(d)(?:e))" << 2; + QTest::newRow("captureCount10") << "(?|(a)(b)|(c)(d)(e)) (f)(g)" << 5; + QTest::newRow("captureCount11") << "(?|(a)(b)|(c)(d)(e)) (f)(?:g)" << 4; + QTest::newRow("captureCount_invalid01") << "(.*" << -1; + QTest::newRow("captureCount_invalid02") << "\\" << -1; + QTest::newRow("captureCount_invalid03") << "(? Date: Wed, 15 Feb 2012 09:56:23 +0100 Subject: QSqlTableModel: handle changes between submit and select Once an insert has been submitted, the cached record behaves like an update. For row bookkeeping, we still have to remember that it was originally inserted and is not in the query rows. Between submitting a delete and selecting, we remove the values from the deleted record. This causes a blank row to be displayed. Read-only flag is set for cells in deleted row. Reverting between submit and select means going back to the last submitted values. When removing rows, it's better to process from highest row numbers to lowest. This avoids complications with higher rows shifting down when lower rows are removed. Change-Id: I8752fa11f7a1b88f2a71b9e03a020ac37e62487f Reviewed-by: Honglei Zhang --- tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index 270de8292b..43829987d4 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -730,10 +730,10 @@ void tst_QSqlTableModel::removeRows() QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int))); QVERIFY(model.removeRows(0, 2, QModelIndex())); QCOMPARE(headerDataChangedSpy.count(), 2); - QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 0); - QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 0); - QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 1); - QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 1); + QCOMPARE(headerDataChangedSpy.at(0).at(1).toInt(), 1); + QCOMPARE(headerDataChangedSpy.at(0).at(2).toInt(), 1); + QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 0); + QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 0); QCOMPARE(model.rowCount(), 3); QVERIFY(beforeDeleteSpy.count() == 0); QVERIFY(model.submitAll()); -- cgit v1.2.3 From 888fed8065f708baeb6efa5f280c2f1aec3dee78 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Tue, 21 Feb 2012 09:22:26 +0100 Subject: QSqlTableModel: use selectRow() for field and row edit strategies Calling select refreshes the query data but disrupts view navigation. For OnFieldChange and OnRecordChange it makes sense to only select the row in question. This does not disturb view navigation. Assume disruption of view navigation is not a problem for OnManualSubmit because the user or application decides when submitAll is called. Task-number: QTBUG-2875 Change-Id: I1e5f68668fb9102f6296d67d543e80daa403f1c4 Reviewed-by: Yunqiao Yin --- .../tst_qsqlrelationaltablemodel.cpp | 11 +++ .../models/qsqltablemodel/tst_qsqltablemodel.cpp | 79 ++++++++++++++++++---- 2 files changed, 76 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index ddafeea427..ce0d8db1fd 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -542,6 +542,13 @@ void tst_QSqlRelationalTableModel::setRecord() model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, submit()); + if (model.editStrategy() != QSqlTableModel::OnManualSubmit) { + QCOMPARE(model.data(model.index(1, 0)).toInt(), 7); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("tester")); + QCOMPARE(model.data(model.index(1, 2)).toString(), QString("herr")); + QVERIFY_SQL(model, select()); + } + QCOMPARE(model.data(model.index(3, 0)).toInt(), 7); QCOMPARE(model.data(model.index(3, 1)).toString(), QString("tester")); QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr")); @@ -599,6 +606,8 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QVERIFY_SQL(model, submitAll()); model.setEditStrategy(QSqlTableModel::OnManualSubmit); + // The changes were submitted, but there was no automatic select to resort + QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0,0)).toInt(), 1); QCOMPARE(model.data(model.index(0,1)).toString(), QString("harry")); @@ -1401,6 +1410,8 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() QVERIFY_SQL(model, insertRecord(-1, rec)); model.submitAll(); + if (model.editStrategy() != QSqlTableModel::OnManualSubmit) + QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 0)).toInt(), 3); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("Washington")); diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index 43829987d4..448111cd9f 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -411,8 +411,11 @@ void tst_QSqlTableModel::setRecord() } else if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnRowChange && i == model.rowCount() -1) model.submit(); else { - // dataChanged() is not emitted when submitAll() is called - QCOMPARE(spy.count(), 1); + // dataChanged() emitted by selectRow() as well as setRecord() + if ((QSqlTableModel::EditStrategy)submitpolicy == QSqlTableModel::OnFieldChange) + QCOMPARE(spy.count(), 2); + else + QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).count(), 2); QCOMPARE(qvariant_cast(spy.at(0).at(0)), model.index(i, 0)); QCOMPARE(qvariant_cast(spy.at(0).at(1)), model.index(i, rec.count() - 1)); @@ -471,8 +474,7 @@ void tst_QSqlTableModel::insertRow() rec.setValue(0, 42); rec.setValue(1, QString("francis")); - // FieldChange updates immediately and resorts - // Row/Manual submit does not resort + // Setting record does not cause resort QVERIFY(model.setRecord(2, rec)); QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); @@ -482,8 +484,23 @@ void tst_QSqlTableModel::insertRow() QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); QCOMPARE(model.data(model.index(1, 2)).toInt(), 2); - // See comment above setRecord - if (submitpolicy == QSqlTableModel::OnFieldChange) { + QCOMPARE(model.data(model.index(2, 0)).toInt(), 42); + QCOMPARE(model.data(model.index(2, 1)).toString(), QString("francis")); + QCOMPARE(model.data(model.index(2, 2)).toInt(), 2); + QCOMPARE(model.data(model.index(3, 0)).toInt(), 3); + QCOMPARE(model.data(model.index(3, 1)).toString(), QString("vohi")); + QCOMPARE(model.data(model.index(3, 2)).toInt(), 3); + + QVERIFY(model.submitAll()); + + if (submitpolicy == QSqlTableModel::OnManualSubmit) { + // After the submit we should have the resorted view + QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); + QCOMPARE(model.data(model.index(0, 2)).toInt(), 1); + QCOMPARE(model.data(model.index(1, 0)).toInt(), 2); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); + QCOMPARE(model.data(model.index(1, 2)).toInt(), 2); QCOMPARE(model.data(model.index(2, 0)).toInt(), 3); QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi")); QCOMPARE(model.data(model.index(2, 2)).toInt(), 3); @@ -491,6 +508,13 @@ void tst_QSqlTableModel::insertRow() QCOMPARE(model.data(model.index(3, 1)).toString(), QString("francis")); QCOMPARE(model.data(model.index(3, 2)).toInt(), 2); } else { + // Submit does not select, therefore not resorted + QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); + QCOMPARE(model.data(model.index(0, 2)).toInt(), 1); + QCOMPARE(model.data(model.index(1, 0)).toInt(), 2); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); + QCOMPARE(model.data(model.index(1, 2)).toInt(), 2); QCOMPARE(model.data(model.index(2, 0)).toInt(), 42); QCOMPARE(model.data(model.index(2, 1)).toString(), QString("francis")); QCOMPARE(model.data(model.index(2, 2)).toInt(), 2); @@ -499,9 +523,8 @@ void tst_QSqlTableModel::insertRow() QCOMPARE(model.data(model.index(3, 2)).toInt(), 3); } - QVERIFY(model.submitAll()); - - // After the submit we should have the resorted view + QVERIFY(model.select()); + // After the select we should have the resorted view in all strategies QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(0, 2)).toInt(), 1); @@ -514,7 +537,6 @@ void tst_QSqlTableModel::insertRow() QCOMPARE(model.data(model.index(3, 0)).toInt(), 42); QCOMPARE(model.data(model.index(3, 1)).toString(), QString("francis")); QCOMPARE(model.data(model.index(3, 2)).toInt(), 2); - } void tst_QSqlTableModel::insertRecord() @@ -647,8 +669,7 @@ void tst_QSqlTableModel::removeRow() QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); - // headerDataChanged must be emitted by the model when the edit strategy is OnManualSubmit, - // when OnFieldChange or OnRowChange it's not needed because the model will re-select. + // headerDataChanged must be emitted by the model since the row won't vanish until select qRegisterMetaType("Qt::Orientation"); QSignalSpy headerDataChangedSpy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int))); @@ -673,7 +694,10 @@ void tst_QSqlTableModel::removeRow() headerDataChangedSpy.clear(); QVERIFY(model.removeRow(1)); - QCOMPARE(headerDataChangedSpy.count(), 0); + QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(model.rowCount(), 3); + + QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 2); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); @@ -706,6 +730,11 @@ void tst_QSqlTableModel::removeRows() QCOMPARE(beforeDeleteSpy.count(), 2); QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 0); QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 1); + // deleted rows shown as empty until select + QCOMPARE(model.rowCount(), 3); + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("")); + QVERIFY(model.select()); + // deleted rows are gone QCOMPARE(model.rowCount(), 1); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("vohi")); model.clear(); @@ -778,6 +807,14 @@ void tst_QSqlTableModel::removeInsertedRow() model.submitAll(); + if (model.editStrategy() != QSqlTableModel::OnManualSubmit) { + QCOMPARE(model.rowCount(), 4); + QCOMPARE(model.data(model.index(1, 0)).toInt(), 55); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("null columns")); + QCOMPARE(model.data(model.index(1, 2)).isNull(), true); + QVERIFY(model.select()); + } + QCOMPARE(model.rowCount(), 4); QCOMPARE(model.data(model.index(3, 0)).toInt(), 55); QCOMPARE(model.data(model.index(3, 1)).toString(), QString("null columns")); @@ -785,8 +822,17 @@ void tst_QSqlTableModel::removeInsertedRow() QVERIFY(model.removeRow(3)); model.submitAll(); - QCOMPARE(model.rowCount(), 3); + if (model.editStrategy() != QSqlTableModel::OnManualSubmit) { + QCOMPARE(model.rowCount(), 4); + QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); + QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); + QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi")); + QCOMPARE(model.data(model.index(3, 1)).toString(), QString("")); + QVERIFY(model.select()); + } + + QCOMPARE(model.rowCount(), 3); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry")); QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond")); QCOMPARE(model.data(model.index(2, 1)).toString(), QString("vohi")); @@ -1129,6 +1175,11 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() buffer.setValue("title", 0); QVERIFY_SQL(model, insertRecord(1, buffer)); + if (model.editStrategy() != QSqlTableModel::OnManualSubmit) { + QCOMPARE(model.rowCount(), 2); + QVERIFY_SQL(model, select()); + } + int rowCount = model.rowCount(); model.clear(); QCOMPARE(model.rowCount(), 0); -- cgit v1.2.3 From 6b7898059386fe48d9de55d68f1f3f330ce8fb0a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 23 Feb 2012 02:49:52 +0000 Subject: QRegularExpression: fix autotest Some minor fixes: obviously, a valid match always come from a valid regular expression, but a valid regular expression can create an invalid match (internal error during matching). Also, testing an invalid iterator should silence the emitted warnings. Change-Id: I585bb99a81e22f108601fd66bf30b56e0229d68b Reviewed-by: Thiago Macieira --- .../auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 9430425532..238d8626c3 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -191,9 +191,8 @@ bool operator!=(const QList &expectedMatchList, const QRegularExpressionM void consistencyCheck(const QRegularExpressionMatch &match) { - QVERIFY(match.isValid() == match.regularExpression().isValid()); - if (match.isValid()) { + QVERIFY(match.regularExpression().isValid()); QVERIFY(!(match.hasMatch() && match.hasPartialMatch())); if (match.hasMatch() || match.hasPartialMatch()) { @@ -260,7 +259,9 @@ void consistencyCheck(const QRegularExpressionMatchIterator &iterator) } } else { QVERIFY(!i.hasNext()); + QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionMatchIterator::peekNext() called on an iterator already at end"); QRegularExpressionMatch peeked = i.peekNext(); + QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionMatchIterator::next() called on an iterator already at end"); QRegularExpressionMatch match = i.next(); consistencyCheck(peeked); consistencyCheck(match); -- cgit v1.2.3 From 53bbea232830af3f056cd8253c4ff4dd33f525c7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 6 Mar 2012 13:05:09 +0100 Subject: Fix parsing of unicode escape sequences Change-Id: I63a7cd3a571fb47c97157bcb2ca29c4239c600ba Reviewed-by: Thiago Macieira --- tests/auto/corelib/json/test.bjson | Bin 60992 -> 60992 bytes tests/auto/corelib/json/tst_qtjson.cpp | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/json/test.bjson b/tests/auto/corelib/json/test.bjson index aa412eec67..9a0515f3ef 100644 Binary files a/tests/auto/corelib/json/test.bjson and b/tests/auto/corelib/json/test.bjson differ diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index f5b4f17732..f35831c900 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -115,6 +115,8 @@ private Q_SLOTS: void testCompaction(); void testDebugStream(); void testCompactionError(); + + void parseUnicodeEscapes(); private: QString testDataDir; }; @@ -1758,5 +1760,19 @@ void TestQtJson::testCompactionError() } } +void TestQtJson::parseUnicodeEscapes() +{ + const QByteArray json = "[ \"A\\u00e4\\u00C4\" ]"; + + QJsonDocument doc = QJsonDocument::fromJson(json); + QJsonArray array = doc.array(); + + QString result = QLatin1String("A"); + result += QChar(0xe4); + result += QChar(0xc4); + + QCOMPARE(array.first().toString(), result); +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" -- cgit v1.2.3 From dd7a06d0c9eda4bdda2db3160930d8267d1bb821 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 1 Mar 2012 14:37:50 +1000 Subject: Refactor headersclean for usage from modules other than qtbase headersclean enforces various rules which all Qt headers are supposed to abide by. It fails compilation if these rules are broken. These rules should be followed also by modules hosted outside of qtbase. Split the test up so that it can be easily reused by other modules. Change-Id: Icf09cbfde411c926ed87914dc821e6dfc569b0de Reviewed-by: Jason McDonald --- tests/auto/other/headersclean/headersclean.pri | 38 ++++++++++++ tests/auto/other/headersclean/headersclean.pro | 28 +-------- .../other/headersclean/qt_headersclean_headers.h | 70 ++++++++++++++++++++++ tests/auto/other/headersclean/tst_headersclean.cpp | 36 ++--------- tests/auto/other/headersclean/tst_headersclean.h | 61 +++++++++++++++++++ tests/auto/other/other.pro | 3 +- 6 files changed, 176 insertions(+), 60 deletions(-) create mode 100644 tests/auto/other/headersclean/headersclean.pri create mode 100644 tests/auto/other/headersclean/qt_headersclean_headers.h create mode 100644 tests/auto/other/headersclean/tst_headersclean.h (limited to 'tests/auto') diff --git a/tests/auto/other/headersclean/headersclean.pri b/tests/auto/other/headersclean/headersclean.pri new file mode 100644 index 0000000000..163ef6d409 --- /dev/null +++ b/tests/auto/other/headersclean/headersclean.pri @@ -0,0 +1,38 @@ +# The headersclean test attempts to ensure all public Qt headers +# abide by various rules. +# +# To reuse this test outside of the qtbase module, +# include this .pri and create a qt_headersclean_headers.h which includes +# the headers you'd like to test. + +*-g++*: QMAKE_CXXFLAGS += -W -Wall -Wextra -Werror + +# The flags here come from http://wiki.qt-project.org/Coding_Conventions#Conventions_for_public_header_files +# -Wold-style-cast cannot be used, /usr/include/bits/byteswap.h defines the macro bswap_16 using C style casts :( +# -Wfloat-equal cannot be used, qrect.h and qvector2d.h do exact comparisons in isNull and operator==. Would need #pragmas. +*-g++*: QMAKE_CXXFLAGS += -Woverloaded-virtual -Wshadow -Wundef + +# Other nice flags +*-g++*: QMAKE_CXXFLAGS += -Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wpointer-arith -Wformat-security + +# Enable pedantic mode, but accept variadic macros and 'long long' usage. +*-g++*: QMAKE_CXXFLAGS += -Wno-long-long -Wno-variadic-macros -pedantic-errors + +# There are outstanding alignment issues on ARM in some container classes. +contains(QT_ARCH,arm):*-g++*:QMAKE_CXXFLAGS -= -Wcast-align + +QMAKE_CXXFLAGS += -DQT_NO_CAST_TO_ASCII \ + -DQT_NO_CAST_FROM_ASCII \ + -DQT_STRICT_ITERATORS \ + -DQT_NO_URL_CAST_FROM_STRING \ + -DQT_NO_CAST_FROM_BYTEARRAY \ + -DQT_NO_KEYWORDS \ + -DQT_USE_FAST_CONCATENATION \ + -DQT_USE_FAST_OPERATOR_PLUS + +TARGET = tst_headersclean +SOURCES += $$PWD/tst_headersclean.cpp +HEADERS += $$PWD/tst_headersclean.h + +# qt_headersclean_headers.h should be alongside the .pro file +INCLUDEPATH += $$_PRO_FILE_PWD_ diff --git a/tests/auto/other/headersclean/headersclean.pro b/tests/auto/other/headersclean/headersclean.pro index 5444bebfb9..9bfadca08c 100644 --- a/tests/auto/other/headersclean/headersclean.pro +++ b/tests/auto/other/headersclean/headersclean.pro @@ -1,28 +1,2 @@ -CONFIG += testcase -TARGET = tst_headersclean -SOURCES += tst_headersclean.cpp - -# No need to link to all modules, only those actually used QT = core testlib gui widgets - -*-g++*: QMAKE_CXXFLAGS += -W -Wall -Wextra -Werror - -# The flags here come from http://wiki.qt-project.org/Coding_Conventions#Conventions_for_public_header_files -# -Wold-style-cast cannot be used, /usr/include/bits/byteswap.h defines the macro bswap_16 using C style casts :( -# -Wfloat-equal cannot be used, qrect.h and qvector2d.h do exact comparisons in isNull and operator==. Would need #pragmas. -*-g++*: QMAKE_CXXFLAGS += -Woverloaded-virtual -Wshadow -Wundef - -# Other nice flags -*-g++*: QMAKE_CXXFLAGS += -Wnon-virtual-dtor -ansi -Wcast-align -Wchar-subscripts -Wpointer-arith -Wformat-security - -# Enable pedantic mode, but accept variadic macros and 'long long' usage. -*-g++*: QMAKE_CXXFLAGS += -Wno-long-long -Wno-variadic-macros -pedantic-errors - -QMAKE_CXXFLAGS += -DQT_NO_CAST_TO_ASCII \ - -DQT_NO_CAST_FROM_ASCII \ - -DQT_STRICT_ITERATORS \ - -DQT_NO_URL_CAST_FROM_STRING \ - -DQT_NO_CAST_FROM_BYTEARRAY \ - -DQT_NO_KEYWORDS \ - -DQT_USE_FAST_CONCATENATION \ - -DQT_USE_FAST_OPERATOR_PLUS +include(headersclean.pri) diff --git a/tests/auto/other/headersclean/qt_headersclean_headers.h b/tests/auto/other/headersclean/qt_headersclean_headers.h new file mode 100644 index 0000000000..c9b4e3f399 --- /dev/null +++ b/tests/auto/other/headersclean/qt_headersclean_headers.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QT_HEADERSCLEAN_HEADERS +#define QT_HEADERSCLEAN_HEADERS + +/* + This file should include all the headers to be tested by the headersclean + test. It may be copied and customized for each module. +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifndef QT_NO_OPENGL +#include +#endif + +#if !defined(QT_NO_DBUS) && defined(Q_OS_UNIX) +#include +#endif + +#endif diff --git a/tests/auto/other/headersclean/tst_headersclean.cpp b/tests/auto/other/headersclean/tst_headersclean.cpp index 81d0aa3a4a..d442ad39d3 100644 --- a/tests/auto/other/headersclean/tst_headersclean.cpp +++ b/tests/auto/other/headersclean/tst_headersclean.cpp @@ -39,38 +39,12 @@ ** ****************************************************************************/ -#define signals int -#define slots int -#define emit public:; -#define foreach public:; -#define forever public:; +#include "tst_headersclean.h" +#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifndef QT_NO_OPENGL -#include -#endif - -#if !defined(QT_NO_DBUS) && defined(Q_OS_UNIX) -#include -#endif - -class tst_HeadersClean: public QObject +void tst_HeadersClean::initTestCase() { - Q_OBJECT -public: - tst_HeadersClean() {} -}; + QWARN("This is a compile test only"); +} QTEST_MAIN(tst_HeadersClean) -#include "tst_headersclean.moc" diff --git a/tests/auto/other/headersclean/tst_headersclean.h b/tests/auto/other/headersclean/tst_headersclean.h new file mode 100644 index 0000000000..7479e061dc --- /dev/null +++ b/tests/auto/other/headersclean/tst_headersclean.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef TST_HEADERSCLEAN_H +#define TST_HEADERSCLEAN_H + +#define signals int +#define slots int +#define emit public:; +#define foreach public:; +#define forever public:; + +#include +#include + +class tst_HeadersClean: public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase(); +}; + +#endif diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 9ec5ea8e34..6c708baa6b 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -30,8 +30,7 @@ testcocoon: SUBDIRS -= headersclean cross_compile: SUBDIRS -= \ atwrapper \ - compiler \ - headersclean \ + compiler wince*|!contains(QT_CONFIG, accessibility):SUBDIRS -= qaccessibility -- cgit v1.2.3 From 678ab52ccba0b6a6903e9aee404dbe84fb74c91d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 2 Mar 2012 10:46:57 +0100 Subject: Improve type detection for query results When an aggregate function is used for a column in a SQL resultset then it should ensure that the right data type is reported for that column. This also concerns expressions when the returned column does not map directly to a table column. Test included for this. Task-number: QTBUG-22038 Change-Id: I07487694c0ed393d46af06e232914fe923356a99 Reviewed-by: Mark Brand Reviewed-by: Honglei Zhang --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 118 ++++++++++++++++++++++ 1 file changed, 118 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index b22e876c3c..584fcb045a 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -222,6 +222,8 @@ private slots: void sqlite_real_data() { generic_data("QSQLITE"); } void sqlite_real(); + void aggregateFunctionTypes_data() { generic_data(); } + void aggregateFunctionTypes(); private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -3339,5 +3341,121 @@ void tst_QSqlQuery::sqlite_real() QCOMPARE(q.value(0).toDouble(), 5.6); } +void tst_QSqlQuery::aggregateFunctionTypes() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + { + const QString tableName(qTableName("numericFunctionsWithIntValues", __FILE__)); + tst_Databases::safeDropTable( db, tableName ); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INTEGER)")); + + // First test without any entries + QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (1)")); + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (2)")); + + QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), 3); + QCOMPARE(q.record().field(0).type(), QVariant::Int); + + QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 1.5); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + + QVERIFY_SQL(q, exec("SELECT COUNT(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), 2); + QCOMPARE(q.record().field(0).type(), QVariant::Int); + + QVERIFY_SQL(q, exec("SELECT MIN(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), 1); + QCOMPARE(q.record().field(0).type(), QVariant::Int); + + QVERIFY_SQL(q, exec("SELECT MAX(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), 2); + QCOMPARE(q.record().field(0).type(), QVariant::Int); + } + { + const QString tableName(qTableName("numericFunctionsWithDoubleValues", __FILE__)); + tst_Databases::safeDropTable( db, tableName ); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id DOUBLE)")); + + // First test without any entries + QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (1.5)")); + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (2.5)")); + + QVERIFY_SQL(q, exec("SELECT SUM(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 4.0); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + + QVERIFY_SQL(q, exec("SELECT AVG(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 2.0); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + + QVERIFY_SQL(q, exec("SELECT COUNT(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toInt(), 2); + QCOMPARE(q.record().field(0).type(), QVariant::Int); + + QVERIFY_SQL(q, exec("SELECT MIN(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 1.5); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + + QVERIFY_SQL(q, exec("SELECT MAX(id) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 2.5); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + + QVERIFY_SQL(q, exec("SELECT ROUND(id, 1) FROM " + tableName + " WHERE id=1.5")); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 1.5); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + + QVERIFY_SQL(q, exec("SELECT ROUND(id, 0) FROM " + tableName + " WHERE id=2.5")); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toDouble(), 3.0); + QCOMPARE(q.record().field(0).type(), QVariant::Double); + } + { + const QString tableName(qTableName("stringFunctions", __FILE__)); + tst_Databases::safeDropTable( db, tableName ); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id INTEGER, txt VARCHAR(50))")); + + QVERIFY_SQL(q, exec("SELECT MAX(txt) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.record().field(0).type(), QVariant::Invalid); + + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, txt) VALUES (1, 'lower')")); + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id, txt) VALUES (2, 'upper')")); + + QVERIFY_SQL(q, exec("SELECT MAX(txt) FROM " + tableName)); + QVERIFY(q.next()); + QCOMPARE(q.value(0).toString(), QLatin1String("upper")); + QCOMPARE(q.record().field(0).type(), QVariant::String); + } +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" -- cgit v1.2.3 From 7df2422fa4ec32daf421af1f3cb4f36e13234b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 6 Mar 2012 15:06:33 +0100 Subject: Remove abuse of QMetaTypeId from tst_qshortcut test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Q_DECLARE_METATYPE macro is much better for a custom type registration then a handwritten template specialization. Change-Id: Ia15688d89f708fbff0c1da93e08052d31f3b3fc0 Reviewed-by: Stephen Kelly Reviewed-by: Samuel Rødal --- tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp | 73 +++++++++++------------ 1 file changed, 34 insertions(+), 39 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp index 7a87266b8b..61efb6e3f3 100644 --- a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp @@ -151,14 +151,9 @@ protected: Result ambigResult; }; -QT_BEGIN_NAMESPACE -template<> struct QMetaTypeId : public QMetaTypeId -{ static inline int qt_metatype_id() { return QMetaType::Int; } }; -template<> struct QMetaTypeId : public QMetaTypeId -{ static inline int qt_metatype_id() { return QMetaType::Int; } }; -template<> struct QMetaTypeId : public QMetaTypeId -{ static inline int qt_metatype_id() { return QMetaType::Int; } }; -QT_END_NAMESPACE +Q_DECLARE_METATYPE(tst_QShortcut::Widget); +Q_DECLARE_METATYPE(tst_QShortcut::Result); +Q_DECLARE_METATYPE(tst_QShortcut::Action); class TestEdit : public QTextEdit { @@ -249,8 +244,8 @@ Qt::KeyboardModifiers tst_QShortcut::toButtons( int key ) void tst_QShortcut::defElements() { - QTest::addColumn("action"); - QTest::addColumn("testWidget"); + QTest::addColumn("action"); + QTest::addColumn("testWidget"); QTest::addColumn("txt"); QTest::addColumn("k1"); QTest::addColumn("c1"); @@ -260,7 +255,7 @@ void tst_QShortcut::defElements() QTest::addColumn("c3"); QTest::addColumn("k4"); QTest::addColumn("c4"); - QTest::addColumn("result"); + QTest::addColumn("result"); } void tst_QShortcut::number() @@ -285,7 +280,7 @@ void tst_QShortcut::number_data() defElements(); // Clear all - QTest::newRow("N00 - clear") << ClearAll <<0< Date: Wed, 7 Mar 2012 08:56:41 +0100 Subject: Add fonts to QPlatformTheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove QPlatformFontDatabase::defaultFonts() returning a hash containing widget name ->font and the Windows implementation. - Add enumeration and font accessor to QPlatformTheme. The value returned for the enumeration value overwrites the default font of the font database. - Implement for Windows, Mac and KDE. - Add more Windows palettes. Task-number: QTBUG-23686 Change-Id: I8a2abdfd216df23daa7c9630c54264cdf61295db Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp | 3 ++- .../auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 7 +------ 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index f139eac275..9bb08edcce 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -1830,10 +1830,11 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems() QStringListModel model(&view); QStringList list; for (int i = 0; i < rowCount; ++i) - list << QString::fromAscii("Item %1").arg(i); + list << QString::number(i); model.setStringList(list); view.setModel(&model); + view.setUniformItemSizes(true); view.setViewMode(QListView::ListMode); for (int i = 0; i < rowCount / 2; ++i) view.setRowHidden(2 * i, true); diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 8f187190aa..544923a1c3 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -781,10 +781,6 @@ void tst_QStyleSheetStyle::focusColors() + " did not contain background color #e8ff66, using style " + QString::fromLatin1(qApp->style()->metaObject()->className())) .toLocal8Bit().constData()); -#ifdef Q_OS_MAC - if (widget == widgets.first()) - QEXPECT_FAIL("", "Failure only for first widget, the QPushButton, see QTBUG-23686", Continue); -#endif QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), (QString::fromLatin1(widget->metaObject()->className()) + " did not contain text color #ff0084, using style " @@ -882,8 +878,7 @@ void tst_QStyleSheetStyle::hoverColors() (QString::fromLatin1(widget->metaObject()->className()) + " did not contain background color #e8ff66").toLocal8Bit().constData()); #ifdef Q_OS_MAC - if (qobject_cast(widget) - || qobject_cast(widget)) + if (qobject_cast(widget)) QEXPECT_FAIL("", "Failure only for QPushButton and QComboBox, see QTBUG-23686", Continue); #endif QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), -- cgit v1.2.3 From 5713dde8a1e6a35483134ffe9d986db66b208cf5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 7 Mar 2012 12:24:30 +0100 Subject: Fix deadlock in QPropertyAnimation Commit 1e6514a714c1f55b9cb57d2b8b65bc2305c2e2c6 changed the mutex from recursive to non-recursive, which could introduce dead lock if the animation starts other animation (This is the case in QMainWindow layouts) Change-Id: I1b149b78a802748eb24b5700fffeca0b8555f005 Reviewed-by: Friedemann Kleint --- .../qpropertyanimation/tst_qpropertyanimation.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 534dec8160..05d1569988 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -123,6 +123,7 @@ private slots: void deletedInUpdateCurrentTime(); void totalDuration(); void zeroLoopCount(); + void recursiveAnimations(); }; void tst_QPropertyAnimation::initTestCase() @@ -1237,5 +1238,49 @@ void tst_QPropertyAnimation::zeroLoopCount() QCOMPARE(finishedSpy.count(), 0); } + +class RecursiveObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal x READ x WRITE setX) + Q_PROPERTY(qreal y READ y WRITE setY) +public: + RecursiveObject() : m_x(0), m_y(0) { + animation.setTargetObject(this); + animation.setPropertyName("y"); + animation.setDuration(30); + } + qreal x() const { return m_x; } + void setX(qreal x) { + m_x = x; + animation.setEndValue(x); + animation.start(); + } + qreal y() const { return m_y; } + void setY(qreal y) { m_y = y; } + + qreal m_x; + qreal m_y; + QPropertyAnimation animation; +}; + + +void tst_QPropertyAnimation::recursiveAnimations() +{ + RecursiveObject o; + QPropertyAnimation anim; + anim.setTargetObject(&o); + anim.setPropertyName("x"); + anim.setDuration(30); + + anim.setEndValue(4000); + anim.start(); + QTest::qWait(anim.duration() + o.animation.duration()); + QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(o.animation.state(), QAbstractAnimation::Stopped); + QCOMPARE(o.y(), qreal(4000)); +} + + QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" -- cgit v1.2.3 From a6a7cabcd3b38dbd65570a23a800d7e3800a78d0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 2 Mar 2012 15:41:51 +0100 Subject: Add QUrl formatting option "PreferLocalFile". For the readonly case (e.g. progress dialogs), where local file paths look much nicer to end users than file:/// URLs. Change-Id: I899fed27cfb73ebf565389cfd489d2d2fcbeac7c Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index f782b26b46..3bff330db2 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -262,9 +262,16 @@ void tst_QUrl::hashInPath() QCOMPARE(withHashInPath.path(), QString::fromLatin1("hi#mum.txt")); QCOMPARE(withHashInPath.toEncoded(), QByteArray("hi%23mum.txt")); QCOMPARE(withHashInPath.toString(), QString("hi%23mum.txt")); + QCOMPARE(withHashInPath.toDisplayString(QUrl::PreferLocalFile), QString("hi%23mum.txt")); QUrl fromHashInPath = QUrl::fromEncoded(withHashInPath.toEncoded()); QVERIFY(withHashInPath == fromHashInPath); + + const QUrl localWithHash = QUrl::fromLocalFile("/hi#mum.txt"); + QCOMPARE(localWithHash.path(), QString::fromLatin1("/hi#mum.txt")); + QCOMPARE(localWithHash.toEncoded(), QByteArray("file:///hi%23mum.txt")); + QCOMPARE(localWithHash.toString(), QString("file:///hi%23mum.txt")); + QCOMPARE(localWithHash.toDisplayString(QUrl::PreferLocalFile), QString("/hi#mum.txt")); } void tst_QUrl::unc() @@ -352,6 +359,7 @@ void tst_QUrl::setUrl() QCOMPARE(url.port(), -1); QCOMPARE(url.toString(), QString::fromLatin1("file:///")); QCOMPARE(url.toDisplayString(), QString::fromLatin1("file:///")); + QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), QString::fromLatin1("/")); } { @@ -367,6 +375,7 @@ void tst_QUrl::setUrl() QCOMPARE(url.port(), 80); QCOMPARE(url.toString(), QString::fromLatin1("http://www.foo.bar:80")); QCOMPARE(url.toDisplayString(), QString::fromLatin1("http://www.foo.bar:80")); + QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), QString::fromLatin1("http://www.foo.bar:80")); QUrl url2("//www1.foo.bar"); QCOMPARE(url.resolved(url2).toString(), QString::fromLatin1("http://www1.foo.bar")); @@ -451,15 +460,7 @@ void tst_QUrl::setUrl() QUrl url = u1; QVERIFY(url.isValid()); QCOMPARE(url.toString(), QString::fromLatin1("file:///home/dfaure/my#myref")); - QCOMPARE(url.fragment(), QString::fromLatin1("myref")); - } - - { - QString u1 = "file:/home/dfaure/my#myref"; - QUrl url = u1; - QVERIFY(url.isValid()); - - QCOMPARE(url.toString(), QString::fromLatin1("file:///home/dfaure/my#myref")); + QCOMPARE(url.toString(QUrl::PreferLocalFile), QString::fromLatin1("file:///home/dfaure/my#myref")); QCOMPARE(url.fragment(), QString::fromLatin1("myref")); } -- cgit v1.2.3 From eb709333989a7e3d8eb662a0e167ac81ca19d882 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 22 Feb 2012 03:33:00 +0000 Subject: QRegularExpression: add optimizations autotest Exporting the counter that controls the optimization of a compiled pattern lets us to forcibly optimize all patterns. Therefore, two tests are now run: one with default optimization values and another one which always optimizes the pattern. The counter itself was renamed with a qt_ prefix and put inside the Qt compilation namespace (thanks to rohanpm for pointing it out). Change-Id: I56602433d37adc127772b2d0d2cdaf2e49d43c71 Reviewed-by: Rohan McGovern Reviewed-by: Thiago Macieira --- .../corelib/tools/qregularexpression/.gitignore | 3 +- .../alwaysoptimize/alwaysoptimize.pro | 7 ++ .../tst_qregularexpression_alwaysoptimize.cpp | 64 ++++++++++++++++++ .../defaultoptimize/defaultoptimize.pro | 7 ++ .../tst_qregularexpression_defaultoptimize.cpp | 52 +++++++++++++++ .../qregularexpression/qregularexpression.pro | 7 +- .../qregularexpression/tst_qregularexpression.cpp | 40 +---------- .../qregularexpression/tst_qregularexpression.h | 77 ++++++++++++++++++++++ 8 files changed, 213 insertions(+), 44 deletions(-) create mode 100644 tests/auto/corelib/tools/qregularexpression/alwaysoptimize/alwaysoptimize.pro create mode 100644 tests/auto/corelib/tools/qregularexpression/alwaysoptimize/tst_qregularexpression_alwaysoptimize.cpp create mode 100644 tests/auto/corelib/tools/qregularexpression/defaultoptimize/defaultoptimize.pro create mode 100644 tests/auto/corelib/tools/qregularexpression/defaultoptimize/tst_qregularexpression_defaultoptimize.cpp create mode 100644 tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregularexpression/.gitignore b/tests/auto/corelib/tools/qregularexpression/.gitignore index 4a224d26fc..c9249e090e 100644 --- a/tests/auto/corelib/tools/qregularexpression/.gitignore +++ b/tests/auto/corelib/tools/qregularexpression/.gitignore @@ -1 +1,2 @@ -tst_qregularexpression +tst_qregularexpression_alwaysoptimize +tst_qregularexpression_defaultoptimize diff --git a/tests/auto/corelib/tools/qregularexpression/alwaysoptimize/alwaysoptimize.pro b/tests/auto/corelib/tools/qregularexpression/alwaysoptimize/alwaysoptimize.pro new file mode 100644 index 0000000000..f48b1ee96a --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/alwaysoptimize/alwaysoptimize.pro @@ -0,0 +1,7 @@ +CONFIG += testcase parallel_test +TARGET = tst_qregularexpression_alwaysoptimize +QT = core testlib +HEADERS = ../tst_qregularexpression.h +SOURCES = \ + tst_qregularexpression_alwaysoptimize.cpp \ + ../tst_qregularexpression.cpp diff --git a/tests/auto/corelib/tools/qregularexpression/alwaysoptimize/tst_qregularexpression_alwaysoptimize.cpp b/tests/auto/corelib/tools/qregularexpression/alwaysoptimize/tst_qregularexpression_alwaysoptimize.cpp new file mode 100644 index 0000000000..9190f183a1 --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/alwaysoptimize/tst_qregularexpression_alwaysoptimize.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Giuseppe D'Angelo . +** 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 +#include "../tst_qregularexpression.h" + +class tst_QRegularExpression_AlwaysOptimize : public tst_QRegularExpression +{ + Q_OBJECT + +private slots: + void initTestCase(); +}; + +QT_BEGIN_NAMESPACE +extern Q_CORE_EXPORT unsigned int qt_qregularexpression_optimize_after_use_count; // from qregularexpression.cpp +QT_END_NAMESPACE + +void tst_QRegularExpression_AlwaysOptimize::initTestCase() +{ + qt_qregularexpression_optimize_after_use_count = 1; +} + +QTEST_APPLESS_MAIN(tst_QRegularExpression_AlwaysOptimize) + +#include "tst_qregularexpression_alwaysoptimize.moc" diff --git a/tests/auto/corelib/tools/qregularexpression/defaultoptimize/defaultoptimize.pro b/tests/auto/corelib/tools/qregularexpression/defaultoptimize/defaultoptimize.pro new file mode 100644 index 0000000000..dd1a90cfbc --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/defaultoptimize/defaultoptimize.pro @@ -0,0 +1,7 @@ +CONFIG += testcase parallel_test +TARGET = tst_qregularexpression_defaultoptimize +QT = core testlib +HEADERS = ../tst_qregularexpression.h +SOURCES = \ + tst_qregularexpression_defaultoptimize.cpp \ + ../tst_qregularexpression.cpp diff --git a/tests/auto/corelib/tools/qregularexpression/defaultoptimize/tst_qregularexpression_defaultoptimize.cpp b/tests/auto/corelib/tools/qregularexpression/defaultoptimize/tst_qregularexpression_defaultoptimize.cpp new file mode 100644 index 0000000000..d0b5bee4b7 --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/defaultoptimize/tst_qregularexpression_defaultoptimize.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Giuseppe D'Angelo . +** 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 +#include "../tst_qregularexpression.h" + +class tst_QRegularExpression_DefaultOptimize : public tst_QRegularExpression +{ + Q_OBJECT +}; + +QTEST_APPLESS_MAIN(tst_QRegularExpression_DefaultOptimize) + +#include "tst_qregularexpression_defaultoptimize.moc" diff --git a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro index bce6643be6..0cae10112f 100644 --- a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro +++ b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro @@ -1,4 +1,3 @@ -CONFIG += testcase parallel_test -TARGET = tst_qregularexpression -QT = core testlib -SOURCES = tst_qregularexpression.cpp +TEMPLATE = subdirs +SUBDIRS = defaultoptimize +contains(QT_CONFIG,private_tests):SUBDIRS += alwaysoptimize diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 238d8626c3..72157c0536 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -40,45 +40,12 @@ ****************************************************************************/ #include -#include #include #include #include #include -Q_DECLARE_METATYPE(QRegularExpression::PatternOptions) -Q_DECLARE_METATYPE(QRegularExpression::MatchType) -Q_DECLARE_METATYPE(QRegularExpression::MatchOptions) - -class tst_QRegularExpression : public QObject -{ - Q_OBJECT - -private slots: - void gettersSetters_data(); - void gettersSetters(); - void escape_data(); - void escape(); - void validity_data(); - void validity(); - void patternOptions_data(); - void patternOptions(); - void normalMatch_data(); - void normalMatch(); - void partialMatch_data(); - void partialMatch(); - void globalMatch_data(); - void globalMatch(); - void serialize_data(); - void serialize(); - void operatoreq_data(); - void operatoreq(); - void captureCount_data(); - void captureCount(); - -private: - void provideRegularExpressions(); -}; +#include "tst_qregularexpression.h" struct Match { @@ -1229,8 +1196,3 @@ void tst_QRegularExpression::captureCount() if (!re.isValid()) QCOMPARE(re.captureCount(), -1); } - -QTEST_APPLESS_MAIN(tst_QRegularExpression) - -#include "tst_qregularexpression.moc" - diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h new file mode 100644 index 0000000000..1a703a8f92 --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Giuseppe D'Angelo . +** 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 +#include + +Q_DECLARE_METATYPE(QRegularExpression::PatternOptions) +Q_DECLARE_METATYPE(QRegularExpression::MatchType) +Q_DECLARE_METATYPE(QRegularExpression::MatchOptions) + +class tst_QRegularExpression : public QObject +{ + Q_OBJECT + +private slots: + void gettersSetters_data(); + void gettersSetters(); + void escape_data(); + void escape(); + void validity_data(); + void validity(); + void patternOptions_data(); + void patternOptions(); + void normalMatch_data(); + void normalMatch(); + void partialMatch_data(); + void partialMatch(); + void globalMatch_data(); + void globalMatch(); + void serialize_data(); + void serialize(); + void operatoreq_data(); + void operatoreq(); + void captureCount_data(); + void captureCount(); + +private: + void provideRegularExpressions(); +}; -- cgit v1.2.3 From b7915a4d0d97a60fc30e55eb4cc1b10e7fe9ce2f Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 23 Dec 2011 00:27:32 +0800 Subject: Fix dockwidgets behavior when window resized or central widgets is set. When adding and showing a central widget in a QMainWindow then the layout does not respect the size policy of the central widget. This is a side effect of 059be19781a22d2e41f22072152589857d0fabf9 After the layout of QMainWindow is restored or the separator between central widget and dock widgets is moved by user, dock widgets should keep their size when the window if resized. Task-number: QTBUG-15689 Change-Id: Idfccb7b4ae057a99f431c2ed54e3b9fcfb6ef54c Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 0f07546559..c6a039cb37 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -1435,6 +1435,11 @@ void MoveSeparator::apply(QMainWindow *mw) const } QVERIFY(!path.isEmpty()); + // For QTBUG-15689: + // Following commands is used to simulate user move action. A better way should + // use QMainWindowLayout::startSeparatorMove/separatorMove/endSeparatorMove, + // but then we will need real start/end position coordinates. + l->layoutState.dockAreaLayout.fallbackToSizeHints = false; l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta)); } #endif -- cgit v1.2.3 From b319d44798fe4c5aa8b859966d64f28b08be28dd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 5 Mar 2012 14:42:42 +0100 Subject: QCursor: Associate cursor with screen. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Introduce cursor() accessor to QPlatformScreen. - Remove screen member of QPlatformCursor (a cursor can be shared by multiple screens of a virtual desktop). - Add QCursor::pos()/ QCursor::setPos() taking a QScreen-parameter, use primaryScreen() for old overloads. QCursor::pos() can then query the platform cursor for the position and return the position even if the mouse position is outside the windows owned by the Qt application. - Fix tests Reviewed-by: Samuel Rødal Task-number: QTBUG-22457 Task-number: QTBUG-22565 Task-number: QTBUG-20753 Change-Id: Ia69f37343f95772e934eab1cd806bd54cbdbbe51 Reviewed-by: Friedemann Kleint --- .../graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 13 ++++++++++--- .../graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp | 3 --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 6 ------ 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index af76b1c3c1..ee7ec7ba57 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4338,9 +4338,16 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() QPointF newMouseScenePos = view.mapToScene(mouseViewPos); qreal slack = 1; - QEXPECT_FAIL("", "QTBUG-22455", Abort); - QVERIFY(qAbs(newMouseScenePos.x() - mouseScenePos.x()) < slack); - QVERIFY(qAbs(newMouseScenePos.y() - mouseScenePos.y()) < slack); + + const qreal dx = qAbs(newMouseScenePos.x() - mouseScenePos.x()); + const qreal dy = qAbs(newMouseScenePos.y() - mouseScenePos.y()); + const QByteArray message = QString::fromLatin1("QTBUG-22455, distance: dx=%1, dy=%2 slack=%3 (%4)."). + arg(dx).arg(dy).arg(slack).arg(qApp->style()->metaObject()->className()).toLocal8Bit(); + // This is highly unstable (observed to pass on Windows and some Linux configurations). +#ifdef Q_OS_MAC + QEXPECT_FAIL("", message.constData(), Abort); +#endif + QVERIFY2(dx < slack && dy < slack, message.constData()); #endif } diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 0a2d0cd2f8..c6b2b49d98 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1158,9 +1158,6 @@ void tst_QGraphicsWidget::initStyleOption() QCOMPARE(hasFocus, focus); bool isUnderMouse = option.state & QStyle::State_MouseOver; #ifndef Q_OS_WINCE -# if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) - QEXPECT_FAIL("all", "QTBUG-22457", Abort); -# endif QCOMPARE(isUnderMouse, underMouse); #endif // if (layoutDirection != Qt::LeftToRight) diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 4fffd74491..473c5e05ec 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -562,9 +562,6 @@ void tst_QMenu::tearOff() QTest::mouseClick(menu, Qt::LeftButton, 0, QPoint(3, 3), 10); QTest::qWait(100); -#ifndef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-22565", Abort); -#endif QVERIFY(menu->isTearOffMenuVisible()); QPointer torn = 0; foreach (QWidget *w, QApplication::allWidgets()) { @@ -783,9 +780,6 @@ void tst_QMenu::task258920_mouseBorder() #ifdef Q_OS_WINCE_WM QSKIP("Mouse move related signals for Windows Mobile unavailable"); #endif - // ### fixme: Check platforms - QSKIP("QTBUG-20753 QCursor::setPos() / QTest::mouseMove() doesn't work on qpa"); - Menu258920 menu; // For styles which inherit from QWindowsStyle, styleHint(QStyle::SH_Menu_MouseTracking) is true. menu.setMouseTracking(true); -- cgit v1.2.3