diff options
Diffstat (limited to 'tests/auto')
371 files changed, 6603 insertions, 3395 deletions
diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp index b5e3dee9a6..cadd4e82cd 100644 --- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp @@ -1443,45 +1443,45 @@ void tst_QtConcurrentFilter::noDetach() QVERIFY(l.isDetached()); QList<int> ll = l; - QVERIFY(l.isDetached() == false); + QVERIFY(!l.isDetached()); QtConcurrent::filtered(l, waitFilterfn).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::blockingFiltered(l, waitFilterfn); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::filteredReduced(l, waitFilterfn, intSumReduce).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::filter(l, waitFilterfn).waitForFinished(); if (!l.isDetached()) QEXPECT_FAIL("", "QTBUG-20688: Known unstable failure", Abort); - QVERIFY(l.isDetached() == true); - QVERIFY(ll.isDetached() == true); + QVERIFY(l.isDetached()); + QVERIFY(ll.isDetached()); } { const QList<int> l = QList<int>() << 1; QVERIFY(l.isDetached()); const QList<int> ll = l; - QVERIFY(l.isDetached() == false); + QVERIFY(!l.isDetached()); QtConcurrent::filtered(l, waitFilterfn).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::filteredReduced(l, waitFilterfn, intSumReduce).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); } } diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index 4e19124ca8..33941d8e90 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -2250,38 +2250,38 @@ void tst_QtConcurrentMap::noDetach() QVERIFY(l.isDetached()); QList<int> ll = l; - QVERIFY(l.isDetached() == false); + QVERIFY(!l.isDetached()); QtConcurrent::mapped(l, mapper).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::mappedReduced(l, mapper, intSumReduce).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::map(l, multiplyBy2Immutable).waitForFinished(); - QVERIFY(l.isDetached() == true); - QVERIFY(ll.isDetached() == true); + QVERIFY(l.isDetached()); + QVERIFY(ll.isDetached()); } { const QList<int> l = QList<int>() << 1; QVERIFY(l.isDetached()); const QList<int> ll = l; - QVERIFY(l.isDetached() == false); + QVERIFY(!l.isDetached()); QtConcurrent::mapped(l, mapper).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); QtConcurrent::mappedReduced(l, mapper, intSumReduce).waitForFinished(); - QVERIFY(l.isDetached() == false); - QVERIFY(ll.isDetached() == false); + QVERIFY(!l.isDetached()); + QVERIFY(!ll.isDetached()); } } diff --git a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST new file mode 100644 index 0000000000..3b2cd84749 --- /dev/null +++ b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST @@ -0,0 +1,4 @@ +[multiplePauseAnimations] +osx-10.9 +[pauseAndPropertyAnimations] +* diff --git a/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST b/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST new file mode 100644 index 0000000000..a7e95b1e97 --- /dev/null +++ b/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST @@ -0,0 +1,4 @@ +[statesAndSignals:normal animation] +windows +[startBackwardWithoutEndValue] +windows diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST new file mode 100644 index 0000000000..e11e4ae6fb --- /dev/null +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST @@ -0,0 +1,4 @@ +[startGroupWithRunningChild] +windows +[finishWithUncontrolledAnimation] +windows diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 69bf7598fc..00f70f5380 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -457,7 +457,7 @@ void tst_QGlobal::isEnum() // fallback type traits implementation. Any compiler // supported by Qt that supports C++0x class enums // should also support the __is_enum intrinsic. - QVERIFY(Q_IS_ENUM(isEnum_G) == true); + QVERIFY(Q_IS_ENUM(isEnum_G)); #endif #undef IS_ENUM_TRUE diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index a1cfff7e85..e9fd999e9f 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -41,10 +41,17 @@ #include <QtCore/QThread> #include <QtTest/QtTest> +#if defined(Q_OS_UNIX) +#include <sys/resource.h> +#endif + class tst_QGlobalStatic : public QObject { Q_OBJECT +public Q_SLOTS: + void initTestCase(); + private Q_SLOTS: void beforeInitialization(); void api(); @@ -55,6 +62,20 @@ private Q_SLOTS: void afterDestruction(); }; +void tst_QGlobalStatic::initTestCase() +{ +#if defined(Q_OS_UNIX) + // The tests create a lot of threads, which require file descriptors. On systems like + // OS X low defaults such as 256 as the limit for the number of simultaneously + // open files is not sufficient. + struct rlimit numFiles; + if (getrlimit(RLIMIT_NOFILE, &numFiles) == 0 && numFiles.rlim_cur < 1024) { + numFiles.rlim_cur = qMin(rlim_t(1024), numFiles.rlim_max); + setrlimit(RLIMIT_NOFILE, &numFiles); + } +#endif +} + Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42)) Q_GLOBAL_STATIC_WITH_ARGS(volatile int, volatileInt, (-47)) diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 3e19e816c9..db2805ebf0 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -49,6 +49,7 @@ private slots: void debugWithBool() const; void debugSpaceHandling() const; void debugNoQuotes() const; + void verbosity() const; void stateSaver() const; void veryLongWarningMessage() const; void qDebugQChar() const; @@ -192,7 +193,11 @@ public: QDebug operator<< (QDebug s, const MyLine& line) { const QDebugStateSaver saver(s); - s.nospace() << "MyLine(" << line.p1 << ", " << line.p2 << ")"; + s.nospace(); + s << "MyLine(" << line.p1 << ", "<< line.p2; + if (s.verbosity() > 2) + s << ", Manhattan length=" << (qAbs(line.p2.v1 - line.p1.v1) + qAbs(line.p2.v2 - line.p1.v2)); + s << ')'; return s; } @@ -255,6 +260,33 @@ void tst_QDebug::debugNoQuotes() const QCOMPARE(s_msg, QString::fromLatin1("'H' \"Hello\" \"Hello\" H Hello Hello")); } +void tst_QDebug::verbosity() const +{ + MyLine line(MyPoint(10, 11), MyPoint (12, 13)); + QString output; + QDebug d(&output); + d.nospace(); + d << line << '\n'; + const int oldVerbosity = d.verbosity(); + d.setVerbosity(0); + QCOMPARE(d.verbosity(), 0); + d.setVerbosity(7); + QCOMPARE(d.verbosity(), 7); + const int newVerbosity = oldVerbosity + 2; + d.setVerbosity(newVerbosity); + QCOMPARE(d.verbosity(), newVerbosity); + d << line << '\n'; + d.setVerbosity(oldVerbosity ); + QCOMPARE(d.verbosity(), oldVerbosity ); + d << line; + const QStringList lines = output.split(QLatin1Char('\n')); + QCOMPARE(lines.size(), 3); + // Verbose should be longer + QVERIFY2(lines.at(1).size() > lines.at(0).size(), qPrintable(lines.join(QLatin1Char(',')))); + // Switching back to brief produces same output + QCOMPARE(lines.at(0).size(), lines.at(2).size()); +} + void tst_QDebug::stateSaver() const { MessageHandlerSetter mhs(myMessageHandler); diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index d3e954bd32..0adc7e0450 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -10,3 +10,5 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 android:!android-no-sdk { RESOURCES += android_testdata.qrc } + +win32: CONFIG += insignificant_test # Crashes on Windows in release builds diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro index 3b5d2bd931..a2429bf2f0 100644 --- a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro @@ -8,3 +8,5 @@ TESTDATA += entrylist wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +win32: CONFIG += insignificant_test # Crashes on Windows in release builds diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro index de99447404..571637be37 100644 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/auto/corelib/io/qfileinfo/qfileinfo.pro @@ -7,3 +7,5 @@ RESOURCES += qfileinfo.qrc \ win32:!wince:!winrt:LIBS += -ladvapi32 -lnetapi32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +win32: CONFIG += insignificant_test # Crashes on Windows in release builds diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 96ad78a666..8d276b3616 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -287,7 +287,8 @@ void tst_QFileInfo::initTestCase() m_resourcesDir = dataPath + QLatin1String("/resources"); m_proFile = dataPath + QLatin1String("/tst_qfileinfo.pro"); - QVERIFY(m_dir.isValid()); + QVERIFY2(m_dir.isValid(), + ("Failed to create temporary dir: " + m_dir.errorString()).toUtf8()); QVERIFY(QDir::setCurrent(m_dir.path())); } diff --git a/tests/auto/corelib/io/qfileselector/platforms/+haiku/test b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test diff --git a/tests/auto/corelib/io/qfileselector/platforms/+haiku/test2 b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test2 new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+haiku/test2 diff --git a/tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test b/tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/corelib/io/qfileselector/platforms/+unix/+haiku/test diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc index 661647f933..6e2699774d 100644 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ b/tests/auto/corelib/io/qfileselector/qfileselector.qrc @@ -19,6 +19,7 @@ <file>platforms/+unix/+darwin/+mac/+osx/test</file> <file>platforms/+unix/+darwin/+mac/test</file> <file>platforms/+unix/+darwin/test</file> + <file>platforms/+unix/+haiku/test</file> <file>platforms/+unix/+linux/test</file> <file>platforms/+unix/test</file> <file>platforms/+windows/+wince/test</file> @@ -30,6 +31,7 @@ <file>platforms/+osx/test</file> <file>platforms/+darwin/test</file> <file>platforms/+mac/test</file> + <file>platforms/+haiku/test</file> <file>platforms/+linux/test</file> <file>platforms/+wince/test</file> @@ -39,6 +41,7 @@ <file>platforms/+blackberry/test2</file> <file>platforms/+ios/test2</file> <file>platforms/+osx/test2</file> + <file>platforms/+haiku/test2</file> <file>platforms/+linux/test2</file> <file>platforms/+wince/test2</file> <file>platforms/+winnt/test2</file> diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index b3767b4887..87381f4c4e 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -89,7 +89,7 @@ void tst_QFileSelector::basicTest_data() QString expectedPlatform2File(""); //Only the last selector QString expectedPlatform3File; // Only the first selector (the family) #if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && \ - !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) + !defined(Q_OS_DARWIN) && !defined(Q_OS_LINUX) && !defined(Q_OS_HAIKU) /* We are only aware of specific unixes, and do not have test files for any of the others. However those unixes can get a selector added from the result of a uname call, so this will lead to a case where we don't have that file so we can't expect the concatenation of platform diff --git a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST index 3ac0b9dff4..10a4ba069e 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST +++ b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST @@ -6,3 +6,4 @@ windows 64bit msvc osx [watchFileAndItsDirectory:native backend-specialchars] osx +windows diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 7e56ecaab3..a0434aa8ee 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -553,7 +553,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); int fileChangedSpyCount = fileChangedSpy.count(); -#ifdef Q_OS_WIN64 +#ifdef Q_OS_WIN if (fileChangedSpyCount != 0) QEXPECT_FAIL("", "See QTBUG-30943", Continue); #endif diff --git a/tests/auto/corelib/io/qiodevice/BLACKLIST b/tests/auto/corelib/io/qiodevice/BLACKLIST new file mode 100644 index 0000000000..b8a61d3ca9 --- /dev/null +++ b/tests/auto/corelib/io/qiodevice/BLACKLIST @@ -0,0 +1,2 @@ +[unget] +redhatenterpriselinuxworkstation-6.6 diff --git a/tests/auto/corelib/io/qprocess/BLACKLIST b/tests/auto/corelib/io/qprocess/BLACKLIST new file mode 100644 index 0000000000..dcd913ca49 --- /dev/null +++ b/tests/auto/corelib/io/qprocess/BLACKLIST @@ -0,0 +1,2 @@ +[lockupsInStartDetached] +redhatenterpriselinuxworkstation-6.6 diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 0995f764b7..caefc3fc21 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -124,9 +124,9 @@ private slots: void removeFileWhileProcessIsRunning(); void fileWriterProcess(); void switchReadChannels(); -#ifdef Q_OS_WIN + void discardUnwantedOutput(); void setWorkingDirectory(); -#endif // Q_OS_WIN + void setNonExistentWorkingDirectory(); #endif // not Q_OS_WINCE void exitStatus_data(); @@ -220,7 +220,6 @@ void tst_QProcess::getSetCheck() QCOMPARE(QProcess::ProcessChannel(QProcess::StandardError), obj1.readChannel()); } -//----------------------------------------------------------------------------- void tst_QProcess::constructing() { QProcess process; @@ -282,7 +281,6 @@ void tst_QProcess::simpleStart() QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning); } -//----------------------------------------------------------------------------- void tst_QProcess::startWithOpen() { QProcess p; @@ -300,7 +298,6 @@ void tst_QProcess::startWithOpen() QVERIFY(p.waitForFinished(5000)); } -//----------------------------------------------------------------------------- void tst_QProcess::startWithOldOpen() { // similar to the above, but we start with start() actually @@ -319,7 +316,6 @@ void tst_QProcess::startWithOldOpen() QVERIFY(p.waitForFinished(5000)); } -//----------------------------------------------------------------------------- void tst_QProcess::execute() { QCOMPARE(QProcess::execute("testProcessNormal/testProcessNormal", @@ -327,7 +323,6 @@ void tst_QProcess::execute() QCOMPARE(QProcess::execute("nonexistingexe"), -2); } -//----------------------------------------------------------------------------- void tst_QProcess::startDetached() { QProcess proc; @@ -339,7 +334,6 @@ void tst_QProcess::startDetached() QCOMPARE(QProcess::startDetached("nonexistingexe"), false); } -//----------------------------------------------------------------------------- void tst_QProcess::readFromProcess() { int lines = 0; @@ -349,7 +343,6 @@ void tst_QProcess::readFromProcess() } } -//----------------------------------------------------------------------------- void tst_QProcess::crashTest() { qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); @@ -362,11 +355,13 @@ void tst_QProcess::crashTest() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); - QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); - QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); + QSignalSpy spy(process, &QProcess::errorOccurred); + QSignalSpy spy2(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy spy3(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); + QVERIFY(spy3.isValid()); QVERIFY(process->waitForFinished(30000)); @@ -374,7 +369,10 @@ void tst_QProcess::crashTest() QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); QCOMPARE(spy2.count(), 1); - QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy2.at(0).at(1).constData()), QProcess::CrashExit); + QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed); + + QCOMPARE(spy3.count(), 1); + QCOMPARE(*static_cast<const QProcess::ExitStatus *>(spy3.at(0).at(1).constData()), QProcess::CrashExit); QCOMPARE(process->exitStatus(), QProcess::CrashExit); @@ -387,7 +385,6 @@ void tst_QProcess::crashTest() QCOMPARE(qvariant_cast<QProcess::ProcessState>(stateSpy.at(2).at(0)), QProcess::NotRunning); } -//----------------------------------------------------------------------------- void tst_QProcess::crashTest2() { process = new QProcess; @@ -397,7 +394,7 @@ void tst_QProcess::crashTest2() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); - QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::errorOccurred)); QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(spy.isValid()); @@ -423,7 +420,6 @@ void tst_QProcess::crashTest2() #ifndef Q_OS_WINCE //Reading and writing to a process is not supported on Qt/CE -//----------------------------------------------------------------------------- void tst_QProcess::echoTest_data() { QTest::addColumn<QByteArray>("input"); @@ -438,8 +434,6 @@ void tst_QProcess::echoTest_data() QTest::newRow("10000 bytes") << QByteArray(10000, '@'); } -//----------------------------------------------------------------------------- - void tst_QProcess::echoTest() { QFETCH(QByteArray, input); @@ -484,14 +478,11 @@ void tst_QProcess::echoTest() } #endif -//----------------------------------------------------------------------------- void tst_QProcess::exitLoopSlot() { QTestEventLoop::instance().exitLoop(); } -//----------------------------------------------------------------------------- - #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::echoTest2() @@ -543,7 +534,6 @@ void tst_QProcess::echoTest2() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Reading and writing to a process is not supported on Qt/CE -//----------------------------------------------------------------------------- void tst_QProcess::echoTestGui() { QProcess process; @@ -572,7 +562,6 @@ void tst_QProcess::testSetNamedPipeHandleState() } #endif // !Q_OS_WINCE && Q_OS_WIN -//----------------------------------------------------------------------------- #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Batch files are not supported on Windows CE void tst_QProcess::batFiles_data() @@ -601,7 +590,6 @@ void tst_QProcess::batFiles() } #endif // !Q_OS_WINCE && Q_OS_WIN -//----------------------------------------------------------------------------- void tst_QProcess::exitStatus_data() { QTest::addColumn<QStringList>("processList"); @@ -644,7 +632,7 @@ void tst_QProcess::exitStatus() process->deleteLater(); process = 0; } -//----------------------------------------------------------------------------- + #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::loopBackTest() @@ -670,7 +658,6 @@ void tst_QProcess::loopBackTest() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::readTimeoutAndThenCrash() @@ -688,8 +675,10 @@ void tst_QProcess::readTimeoutAndThenCrash() QCOMPARE(process->error(), QProcess::Timedout); qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); - QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy spy(process, &QProcess::errorOccurred); + QSignalSpy spy2(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QVERIFY(spy.isValid()); + QVERIFY(spy2.isValid()); process->kill(); @@ -698,6 +687,8 @@ void tst_QProcess::readTimeoutAndThenCrash() QCOMPARE(spy.count(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); + QCOMPARE(spy2.count(), 1); + QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed); delete process; process = 0; @@ -750,7 +741,6 @@ void tst_QProcess::deadWhileReading() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::restartProcessDeadlock() @@ -780,7 +770,6 @@ void tst_QProcess::restartProcess() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::closeWriteChannel() @@ -808,7 +797,6 @@ void tst_QProcess::closeWriteChannel() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE" void tst_QProcess::closeReadChannel() @@ -840,7 +828,6 @@ void tst_QProcess::closeReadChannel() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::openModes() @@ -885,7 +872,6 @@ void tst_QProcess::openModes() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() @@ -921,7 +907,6 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() } #endif -//----------------------------------------------------------------------------- void tst_QProcess::hardExit() { QProcess proc; @@ -945,7 +930,6 @@ void tst_QProcess::hardExit() QCOMPARE(int(proc.error()), int(QProcess::Crashed)); } -//----------------------------------------------------------------------------- void tst_QProcess::softExit() { QProcess proc; @@ -1055,7 +1039,6 @@ private: QByteArray dataToWrite; }; -//----------------------------------------------------------------------------- void tst_QProcess::softExitInSlots_data() { QTest::addColumn<QString>("appName"); @@ -1065,7 +1048,6 @@ void tst_QProcess::softExitInSlots_data() #endif QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2"; } -//----------------------------------------------------------------------------- void tst_QProcess::softExitInSlots() { @@ -1081,7 +1063,6 @@ void tst_QProcess::softExitInSlots() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::mergedChannels() @@ -1106,7 +1087,6 @@ void tst_QProcess::mergedChannels() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE @@ -1161,7 +1141,6 @@ void tst_QProcess::forwardedChannels() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::atEnd() @@ -1222,7 +1201,6 @@ private: int exitCode; }; -//----------------------------------------------------------------------------- void tst_QProcess::processInAThread() { for (int i = 0; i < 10; ++i) { @@ -1233,7 +1211,6 @@ void tst_QProcess::processInAThread() } } -//----------------------------------------------------------------------------- void tst_QProcess::processesInMultipleThreads() { for (int i = 0; i < 10; ++i) { @@ -1258,7 +1235,6 @@ void tst_QProcess::processesInMultipleThreads() } } -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::waitForFinishedWithTimeout() @@ -1279,7 +1255,6 @@ void tst_QProcess::waitForFinishedWithTimeout() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::waitForReadyReadInAReadyReadSlot() @@ -1308,7 +1283,6 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot() @@ -1320,7 +1294,6 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() @@ -1347,7 +1320,6 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot() @@ -1357,7 +1329,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot() QTestEventLoop::instance().exitLoop(); } #endif -//----------------------------------------------------------------------------- + void tst_QProcess::spaceArgsTest_data() { QTest::addColumn<QStringList>("args"); @@ -1410,7 +1382,6 @@ static QByteArray startFailMessage(const QString &program, const QProcess &proce return result; } -//----------------------------------------------------------------------------- void tst_QProcess::spaceArgsTest() { QFETCH(QStringList, args); @@ -1483,7 +1454,6 @@ void tst_QProcess::spaceArgsTest() #if defined(Q_OS_WIN) -//----------------------------------------------------------------------------- void tst_QProcess::nativeArguments() { QProcess proc; @@ -1527,7 +1497,6 @@ void tst_QProcess::nativeArguments() #endif -//----------------------------------------------------------------------------- void tst_QProcess::exitCodeTest() { for (int i = 0; i < 255; ++i) { @@ -1544,7 +1513,6 @@ void tst_QProcess::exitCodeTest() } } -//----------------------------------------------------------------------------- void tst_QProcess::failToStart() { #if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) @@ -1556,12 +1524,14 @@ void tst_QProcess::failToStart() QProcess process; QSignalSpy stateSpy(&process, &QProcess::stateChanged); - QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy errorSpy(&process, &QProcess::errorOccurred); + QSignalSpy errorSpy2(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(stateSpy.isValid()); QVERIFY(errorSpy.isValid()); + QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); QVERIFY(finishedSpy2.isValid()); @@ -1578,6 +1548,7 @@ void tst_QProcess::failToStart() for (int j = 0; j < 8; ++j) { for (int i = 0; i < attempts; ++i) { QCOMPARE(errorSpy.count(), j * attempts + i); + QCOMPARE(errorSpy2.count(), j * attempts + i); process.start("/blurp"); switch (j) { @@ -1602,6 +1573,7 @@ void tst_QProcess::failToStart() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), j * attempts + i + 1); + QCOMPARE(errorSpy2.count(), j * attempts + i + 1); QCOMPARE(finishedSpy.count(), 0); QCOMPARE(finishedSpy2.count(), 0); @@ -1614,7 +1586,6 @@ void tst_QProcess::failToStart() } } -//----------------------------------------------------------------------------- void tst_QProcess::failToStartWithWait() { #if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) @@ -1625,11 +1596,13 @@ void tst_QProcess::failToStartWithWait() QProcess process; QEventLoop loop; - QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy errorSpy(&process, &QProcess::errorOccurred); + QSignalSpy errorSpy2(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); + QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); QVERIFY(finishedSpy2.isValid()); @@ -1639,12 +1612,12 @@ void tst_QProcess::failToStartWithWait() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), i + 1); + QCOMPARE(errorSpy2.count(), i + 1); QCOMPARE(finishedSpy.count(), 0); QCOMPARE(finishedSpy2.count(), 0); } } -//----------------------------------------------------------------------------- void tst_QProcess::failToStartWithEventLoop() { #if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) @@ -1655,16 +1628,18 @@ void tst_QProcess::failToStartWithEventLoop() QProcess process; QEventLoop loop; - QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy errorSpy(&process, &QProcess::errorOccurred); + QSignalSpy errorSpy2(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); + QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy.isValid()); QVERIFY(finishedSpy2.isValid()); // The error signal may be emitted before start() returns - connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()), Qt::QueuedConnection); + connect(&process, &QProcess::errorOccurred, &loop, &QEventLoop::quit, Qt::QueuedConnection); for (int i = 0; i < 50; ++i) { @@ -1674,6 +1649,7 @@ void tst_QProcess::failToStartWithEventLoop() QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(errorSpy.count(), i + 1); + QCOMPARE(errorSpy2.count(), i + 1); QCOMPARE(finishedSpy.count(), 0); QCOMPARE(finishedSpy2.count(), 0); } @@ -1715,7 +1691,6 @@ void tst_QProcess::failToStartEmptyArgs() QCOMPARE(process.error(), QProcess::FailedToStart); } -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::removeFileWhileProcessIsRunning() @@ -1734,7 +1709,6 @@ void tst_QProcess::removeFileWhileProcessIsRunning() QVERIFY(process.waitForFinished(5000)); } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // OS doesn't support environment variables void tst_QProcess::setEnvironment_data() @@ -1812,7 +1786,6 @@ void tst_QProcess::setEnvironment() } } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // OS doesn't support environment variables void tst_QProcess::setProcessEnvironment_data() @@ -1853,7 +1826,7 @@ void tst_QProcess::setProcessEnvironment() } } #endif -//----------------------------------------------------------------------------- + void tst_QProcess::systemEnvironment() { #if defined (Q_OS_WINCE) @@ -1869,7 +1842,6 @@ void tst_QProcess::systemEnvironment() #endif } -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::spaceInName() @@ -1882,7 +1854,6 @@ void tst_QProcess::spaceInName() } #endif -//----------------------------------------------------------------------------- void tst_QProcess::lockupsInStartDetached() { // Check that QProcess doesn't cause a lock up at this program's @@ -1896,7 +1867,6 @@ void tst_QProcess::lockupsInStartDetached() QProcess::startDetached("yjhbrty"); } -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::atEnd2() @@ -1915,7 +1885,6 @@ void tst_QProcess::atEnd2() } #endif -//----------------------------------------------------------------------------- void tst_QProcess::waitForReadyReadForNonexistantProcess() { // Start a program that doesn't exist, process events and then try to waitForReadyRead @@ -1923,11 +1892,13 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); QProcess process; - QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy errorSpy(&process, &QProcess::errorOccurred); + QSignalSpy errorSpy2(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QSignalSpy finishedSpy1(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); + QVERIFY(errorSpy2.isValid()); QVERIFY(finishedSpy1.isValid()); QVERIFY(finishedSpy2.isValid()); @@ -1939,11 +1910,12 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() #endif QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); + QCOMPARE(errorSpy2.count(), 1); + QCOMPARE(errorSpy2.at(0).at(0).toInt(), 0); QCOMPARE(finishedSpy1.count(), 0); QCOMPARE(finishedSpy2.count(), 0); } -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::setStandardInputFile() @@ -1973,7 +1945,6 @@ void tst_QProcess::setStandardInputFile() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::setStandardOutputFile_data() @@ -2004,7 +1975,6 @@ void tst_QProcess::setStandardOutputFile_data() << true; } -//----------------------------------------------------------------------------- void tst_QProcess::setStandardOutputFile() { static const char data[] = "Original data. "; @@ -2089,7 +2059,6 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::setStandardOutputProcess_data() @@ -2130,7 +2099,6 @@ void tst_QProcess::setStandardOutputProcess() } #endif -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::fileWriterProcess() @@ -2158,7 +2126,6 @@ void tst_QProcess::fileWriterProcess() } #endif -//----------------------------------------------------------------------------- void tst_QProcess::detachedWorkingDirectoryAndPid() { qint64 pid; @@ -2202,7 +2169,6 @@ void tst_QProcess::detachedWorkingDirectoryAndPid() QCOMPARE(actualPid, pid); } -//----------------------------------------------------------------------------- #ifndef Q_OS_WINCE // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::switchReadChannels() @@ -2233,16 +2199,38 @@ void tst_QProcess::switchReadChannels() } #endif -//----------------------------------------------------------------------------- -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#ifndef Q_OS_WINCE +// Reading and writing to a process is not supported on Qt/CE +void tst_QProcess::discardUnwantedOutput() +{ + QProcess process; + + process.setProgram("testProcessEcho2/testProcessEcho2"); + process.start(QIODevice::WriteOnly); + process.write("Hello, World"); + process.closeWriteChannel(); + QVERIFY(process.waitForFinished(5000)); + + process.setReadChannel(QProcess::StandardOutput); + QCOMPARE(process.bytesAvailable(), Q_INT64_C(0)); + process.setReadChannel(QProcess::StandardError); + QCOMPARE(process.bytesAvailable(), Q_INT64_C(0)); +} +#endif + +#ifndef Q_OS_WINCE // Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices // Windows CE does not support working directory logic void tst_QProcess::setWorkingDirectory() { process = new QProcess; process->setWorkingDirectory("test"); - process->start("testSetWorkingDirectory/testSetWorkingDirectory"); - QVERIFY(process->waitForFinished()); + + // use absolute path because on Windows, the executable is relative to the parent's CWD + // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either). + process->start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath()); + + QVERIFY2(process->waitForFinished(), process->errorString().toLocal8Bit()); QByteArray workingDir = process->readAllStandardOutput(); QCOMPARE(QDir("test").canonicalPath(), QDir(workingDir.constData()).canonicalPath()); @@ -2250,9 +2238,26 @@ void tst_QProcess::setWorkingDirectory() delete process; process = 0; } + +void tst_QProcess::setNonExistentWorkingDirectory() +{ + process = new QProcess; + process->setWorkingDirectory("this/directory/should/not/exist/for/sure"); + + // use absolute path because on Windows, the executable is relative to the parent's CWD + // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either). + process->start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath()); + QVERIFY(!process->waitForFinished()); +#ifdef QPROCESS_USE_SPAWN + QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); +#endif + QCOMPARE(int(process->error()), int(QProcess::FailedToStart)); + + delete process; + process = 0; +} #endif -//----------------------------------------------------------------------------- void tst_QProcess::startFinishStartFinish() { QProcess process; @@ -2271,7 +2276,6 @@ void tst_QProcess::startFinishStartFinish() } } -//----------------------------------------------------------------------------- void tst_QProcess::invalidProgramString_data() { QTest::addColumn<QString>("programString"); @@ -2286,17 +2290,19 @@ void tst_QProcess::invalidProgramString() QProcess process; qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); - QSignalSpy spy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy spy(&process, &QProcess::errorOccurred); + QSignalSpy spy2(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QVERIFY(spy.isValid()); + QVERIFY(spy2.isValid()); process.start(programString); QCOMPARE(process.error(), QProcess::FailedToStart); QCOMPARE(spy.count(), 1); + QCOMPARE(spy2.count(), 1); QVERIFY(!QProcess::startDetached(programString)); } -//----------------------------------------------------------------------------- void tst_QProcess::onlyOneStartedSignal() { qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -2323,8 +2329,6 @@ void tst_QProcess::onlyOneStartedSignal() QCOMPARE(spyFinished.count(), 1); } -//----------------------------------------------------------------------------- - class BlockOnReadStdOut : public QObject { Q_OBJECT diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index be9a38c499..2099101a91 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp @@ -66,11 +66,19 @@ void tst_QProcessEnvironment::operator_eq() QVERIFY(e1 == e2); e1.clear(); - QVERIFY(e1 != e2); + QVERIFY(e1 == e2); e2.clear(); + QVERIFY(e1 == e2); + + e1.insert("FOO", "bar"); + QVERIFY(e1 != e2); + e2.insert("FOO", "bar"); QVERIFY(e1 == e2); + + e2.insert("FOO", "baz"); + QVERIFY(e1 != e2); } void tst_QProcessEnvironment::clearAndIsEmpty() @@ -196,6 +204,15 @@ void tst_QProcessEnvironment::insertEnv() QCOMPARE(e.value("Hello"), QString("Another World")); QCOMPARE(e.value("FOO2"), QString("bar2")); QCOMPARE(e.value("A2"), QString("bc2")); + + QProcessEnvironment e3; + e3.insert("FOO2", "bar2"); + e3.insert("A2", "bc2"); + e3.insert("Hello", "Another World"); + + e3.insert(e3); // mustn't deadlock + + QVERIFY(e3 == e2); } void tst_QProcessEnvironment::caseSensitivity() diff --git a/tests/auto/corelib/io/qsettings/BLACKLIST b/tests/auto/corelib/io/qsettings/BLACKLIST new file mode 100644 index 0000000000..1cba99b66c --- /dev/null +++ b/tests/auto/corelib/io/qsettings/BLACKLIST @@ -0,0 +1,2 @@ +[isWritable:native] +osx-10.10 diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 3e98a369ce..58a3db9615 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -93,6 +93,7 @@ void tst_QTemporaryDir::construction() QCOMPARE(dir.path().left(tmp.size()), tmp); QVERIFY(dir.path().contains("tst_qtemporarydir")); QVERIFY(QFileInfo(dir.path()).isDir()); + QCOMPARE(dir.errorString(), QString()); } // Testing get/set functions @@ -251,6 +252,7 @@ void tst_QTemporaryDir::nonWritableCurrentDir() QTemporaryDir dir("tempXXXXXX"); dir.setAutoRemove(true); QVERIFY(!dir.isValid()); + QVERIFY(!dir.errorString().isEmpty()); QVERIFY(dir.path().isEmpty()); #endif } @@ -287,7 +289,11 @@ void tst_QTemporaryDir::stressTest() for (int i = 0; i < iterations; ++i) { QTemporaryDir dir(pattern); dir.setAutoRemove(false); - QVERIFY2(dir.isValid(), qPrintable(QString::fromLatin1("Failed to create #%1 under %2.").arg(i).arg(QDir::toNativeSeparators(pattern)))); + QVERIFY2(dir.isValid(), + qPrintable(QString::fromLatin1("Failed to create #%1 under %2: %3.") + .arg(i) + .arg(QDir::toNativeSeparators(pattern)) + .arg(dir.errorString()))); QVERIFY(!names.contains(dir.path())); names.insert(dir.path()); } diff --git a/tests/auto/corelib/io/qtextstream/BLACKLIST b/tests/auto/corelib/io/qtextstream/BLACKLIST new file mode 100644 index 0000000000..bc3f118b33 --- /dev/null +++ b/tests/auto/corelib/io/qtextstream/BLACKLIST @@ -0,0 +1,2 @@ +[stillOpenWhenAtEnd] +windows diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp index db0136dd20..769a96ac64 100644 --- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp +++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp @@ -177,6 +177,7 @@ void tst_QUrlQuery::constructing() QVERIFY(copy.isEmpty()); QVERIFY(!copy.isDetached()); QVERIFY(copy == empty); + QCOMPARE(qHash(copy), qHash(empty)); QVERIFY(!(copy != empty)); copy = empty; @@ -184,6 +185,7 @@ void tst_QUrlQuery::constructing() copy = QUrlQuery(); QVERIFY(copy == empty); + QCOMPARE(qHash(copy), qHash(empty)); } { QUrlQuery copy(emptyQuery()); @@ -298,6 +300,7 @@ void tst_QUrlQuery::addRemove() QVERIFY(query == original); QVERIFY(!(query != original)); + QCOMPARE(qHash(query), qHash(original)); } { diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 64170b15dd..c4d2df7c3e 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -379,7 +379,7 @@ void tst_QAbstractItemModel::hasChildren() { QtTestModel model(1, 1); QModelIndex idx = model.index(0, 0, QModelIndex()); - QVERIFY(model.hasChildren(idx) == false); + QVERIFY(!model.hasChildren(idx)); } void tst_QAbstractItemModel::data() diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 8d331389f5..23cd254477 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1530,7 +1530,7 @@ void tst_QItemSelectionModel::resetModel() model.reset(); QVERIFY(selectionModel->selection().isEmpty()); - QVERIFY(selectionModel->hasSelection() == false); + QVERIFY(!selectionModel->hasSelection()); selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 1c30adc8de..0302ae5cbf 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -87,6 +87,7 @@ private slots: void filter_qtbug30662(); void changeSourceLayout(); + void changeSourceLayoutFilteredOut(); void removeSourceRows_data(); void removeSourceRows(); void insertSourceRows_data(); @@ -1533,6 +1534,32 @@ void tst_QSortFilterProxyModel::changeSourceLayout() } } +void tst_QSortFilterProxyModel::changeSourceLayoutFilteredOut() +{ + QStandardItemModel model(2, 1); + model.setData(model.index(0, 0), QString("b")); + model.setData(model.index(1, 0), QString("a")); + QSortFilterProxyModel proxy; + proxy.setSourceModel(&model); + + int beforeSortFilter = proxy.rowCount(); + + QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + // Filter everything out + proxy.setFilterRegExp(QRegExp("c")); + QCOMPARE(removeSpy.count(), 1); + QCOMPARE(0, proxy.rowCount()); + + // change layout of source model + model.sort(0, Qt::AscendingOrder); + + QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); + // Remove filter; we expect an insert + proxy.setFilterRegExp(QRegExp("")); + QCOMPARE(insertSpy.count(), 1); + QCOMPARE(beforeSortFilter, proxy.rowCount()); +} + void tst_QSortFilterProxyModel::removeSourceRows_data() { QTest::addColumn<QStringList>("sourceItems"); diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index 0602b9fc38..1039f2c08d 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -3,3 +3,4 @@ TARGET = tst_qcoreapplication QT = core testlib core-private SOURCES = tst_qcoreapplication.cpp HEADERS = tst_qcoreapplication.h +requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index efecf31d66..060ef99d65 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -78,6 +78,21 @@ public: } }; +class Thread : public QDaemonThread +{ + void run() Q_DECL_OVERRIDE + { + QThreadData *data = QThreadData::current(); + QVERIFY(!data->requiresCoreApplication); // daemon thread + data->requiresCoreApplication = requiresCoreApplication; + QThread::run(); + } + +public: + Thread() : requiresCoreApplication(true) {} + bool requiresCoreApplication; +}; + void tst_QCoreApplication::sendEventsOnProcessEvents() { int argc = 1; @@ -853,6 +868,68 @@ void tst_QCoreApplication::applicationEventFilters_auxThread() QVERIFY(!spy.recordedEvents.contains(QEvent::User + 1)); } +void tst_QCoreApplication::threadedEventDelivery_data() +{ + QTest::addColumn<bool>("requiresCoreApplication"); + QTest::addColumn<bool>("createCoreApplication"); + QTest::addColumn<bool>("eventsReceived"); + + // invalid combination: + //QTest::newRow("default-without-coreapp") << true << false << false; + QTest::newRow("default") << true << true << true; + QTest::newRow("independent-without-coreapp") << false << false << true; + QTest::newRow("independent-with-coreapp") << false << true << true; +} + +// posts the event before the QCoreApplication is destroyed, starts thread after +void tst_QCoreApplication::threadedEventDelivery() +{ + QFETCH(bool, requiresCoreApplication); + QFETCH(bool, createCoreApplication); + QFETCH(bool, eventsReceived); + + int argc = 1; + char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; + QScopedPointer<TestApplication> app(createCoreApplication ? new TestApplication(argc, argv) : 0); + + Thread thread; + thread.requiresCoreApplication = requiresCoreApplication; + ThreadedEventReceiver receiver; + receiver.moveToThread(&thread); + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User + 1))); + + thread.start(); + QVERIFY(thread.wait(1000)); + QCOMPARE(receiver.recordedEvents.contains(QEvent::User + 1), eventsReceived); +} + +void tst_QCoreApplication::addRemoveLibPaths() +{ + QStringList paths = QCoreApplication::libraryPaths(); + if (paths.isEmpty()) + QSKIP("Cannot add/remove library paths if there are none."); + + QString currentDir = QDir().absolutePath(); + QCoreApplication::addLibraryPath(currentDir); + QVERIFY(QCoreApplication::libraryPaths().contains(currentDir)); + + QCoreApplication::removeLibraryPath(paths[0]); + QVERIFY(!QCoreApplication::libraryPaths().contains(paths[0])); + + int argc = 1; + char *argv[] = { const_cast<char*>(QTest::currentAppName()) }; + TestApplication app(argc, argv); + + // Check that modifications stay alive across the creation of an application. + QVERIFY(QCoreApplication::libraryPaths().contains(currentDir)); + QVERIFY(!QCoreApplication::libraryPaths().contains(paths[0])); + + QStringList replace; + replace << currentDir << paths[0]; + QCoreApplication::setLibraryPaths(replace); + QVERIFY(QCoreApplication::libraryPaths() == replace); +} + static void createQObjectOnDestruction() { // Make sure that we can create a QObject after the last QObject has been diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h index 09e15723ac..d9296b3846 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -61,6 +61,9 @@ private slots: void QTBUG31606_QEventDestructorDeadLock(); void applicationEventFilters_mainThread(); void applicationEventFilters_auxThread(); + void threadedEventDelivery_data(); + void threadedEventDelivery(); + void addRemoveLibPaths(); }; #endif // TST_QCOREAPPLICATION_H diff --git a/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST new file mode 100644 index 0000000000..00be65751b --- /dev/null +++ b/tests/auto/corelib/kernel/qeventdispatcher/BLACKLIST @@ -0,0 +1,4 @@ +[sendPostedEvents] +windows +[registerTimer] +windows diff --git a/tests/auto/corelib/kernel/qeventloop/BLACKLIST b/tests/auto/corelib/kernel/qeventloop/BLACKLIST new file mode 100644 index 0000000000..6ea6314b0a --- /dev/null +++ b/tests/auto/corelib/kernel/qeventloop/BLACKLIST @@ -0,0 +1,2 @@ +[testQuitLock] +windows diff --git a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp index a18c9eb370..4d54aa4dc8 100644 --- a/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp +++ b/tests/auto/corelib/kernel/qmetaproperty/tst_qmetaproperty.cpp @@ -46,6 +46,7 @@ class tst_QMetaProperty : public QObject Q_PROPERTY(int value8 READ value8) Q_PROPERTY(int value9 READ value9 CONSTANT) Q_PROPERTY(int value10 READ value10 FINAL) + Q_PROPERTY(QMap<int, int> map MEMBER map) private slots: void hasStdCppSet(); @@ -53,6 +54,7 @@ private slots: void isFinal(); void gadget(); void readAndWriteWithLazyRegistration(); + void mapProperty(); public: enum EnumType { EnumType1 }; @@ -65,6 +67,8 @@ public: int value8() const { return 1; } int value9() const { return 1; } int value10() const { return 1; } + + QMap<int, int> map; }; void tst_QMetaProperty::hasStdCppSet() @@ -182,6 +186,14 @@ void tst_QMetaProperty::readAndWriteWithLazyRegistration() QCOMPARE(o.property("write").value<CustomWriteObjectChild*>(), &data); } +void tst_QMetaProperty::mapProperty() +{ + map.insert(5, 9); + QVariant v1 = QVariant::fromValue(map); + QVariant v = property("map"); + QVERIFY(v.isValid()); + QCOMPARE(map, (v.value<QMap<int,int> >())); +} QTEST_MAIN(tst_QMetaProperty) #include "tst_qmetaproperty.moc" diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp index 01bf16c295..d368d9961b 100644 --- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp +++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp @@ -70,7 +70,7 @@ void tst_QMimeData::clear() const mimeData.setData("text/plain", "pirates"); QVERIFY(mimeData.hasText()); mimeData.clear(); - QVERIFY(mimeData.hasText() == false); + QVERIFY(!mimeData.hasText()); // repopulate, verify not empty mimeData.setData("text/plain", "pirates"); @@ -136,7 +136,7 @@ void tst_QMimeData::hasColor() const QMimeData mimeData; // initial state - QVERIFY(mimeData.hasColor() == false); + QVERIFY(!mimeData.hasColor()); // set, verify mimeData.setColorData(QColor(Qt::red)); @@ -144,11 +144,11 @@ void tst_QMimeData::hasColor() const // clear, verify mimeData.clear(); - QVERIFY(mimeData.hasColor() == false); + QVERIFY(!mimeData.hasColor()); // set something else, verify mimeData.setData("text/plain", "pirates"); - QVERIFY(mimeData.hasColor() == false); + QVERIFY(!mimeData.hasColor()); } void tst_QMimeData::hasFormat() const @@ -156,17 +156,17 @@ void tst_QMimeData::hasFormat() const QMimeData mimeData; // initial state - QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(!mimeData.hasFormat("text/plain")); // add, verify mimeData.setData("text/plain", "pirates"); QVERIFY(mimeData.hasFormat("text/plain")); - QVERIFY(mimeData.hasFormat("text/html") == false); + QVERIFY(!mimeData.hasFormat("text/html")); // clear, verify mimeData.clear(); - QVERIFY(mimeData.hasFormat("text/plain") == false); - QVERIFY(mimeData.hasFormat("text/html") == false); + QVERIFY(!mimeData.hasFormat("text/plain")); + QVERIFY(!mimeData.hasFormat("text/html")); } void tst_QMimeData::hasHtml() const @@ -174,11 +174,11 @@ void tst_QMimeData::hasHtml() const QMimeData mimeData; // initial state - QVERIFY(mimeData.hasHtml() == false); + QVERIFY(!mimeData.hasHtml()); // add plain, verify false mimeData.setData("text/plain", "pirates"); - QVERIFY(mimeData.hasHtml() == false); + QVERIFY(!mimeData.hasHtml()); // add html, verify mimeData.setData("text/html", "ninjas"); @@ -186,7 +186,7 @@ void tst_QMimeData::hasHtml() const // clear, verify mimeData.clear(); - QVERIFY(mimeData.hasHtml() == false); + QVERIFY(!mimeData.hasHtml()); // readd, verify mimeData.setData("text/html", "ninjas"); @@ -198,11 +198,11 @@ void tst_QMimeData::hasImage() const QMimeData mimeData; // initial state - QVERIFY(mimeData.hasImage() == false); + QVERIFY(!mimeData.hasImage()); // add text, verify false mimeData.setData("text/plain", "pirates"); - QVERIFY(mimeData.hasImage() == false); + QVERIFY(!mimeData.hasImage()); // add image mimeData.setImageData(QImage()); @@ -210,7 +210,7 @@ void tst_QMimeData::hasImage() const // clear, verify mimeData.clear(); - QVERIFY(mimeData.hasImage() == false); + QVERIFY(!mimeData.hasImage()); } void tst_QMimeData::imageData() const @@ -244,13 +244,13 @@ void tst_QMimeData::removeFormat() const // remove, verify mimeData.removeFormat("text/plain"); - QVERIFY(mimeData.hasFormat("text/plain") == false); + QVERIFY(!mimeData.hasFormat("text/plain")); QVERIFY(mimeData.hasFormat("text/html")); // remove, verify mimeData.removeFormat("text/html"); - QVERIFY(mimeData.hasFormat("text/plain") == false); - QVERIFY(mimeData.hasFormat("text/html") == false); + QVERIFY(!mimeData.hasFormat("text/plain")); + QVERIFY(!mimeData.hasFormat("text/html")); } void tst_QMimeData::setHtml() const @@ -258,7 +258,7 @@ void tst_QMimeData::setHtml() const QMimeData mimeData; // initial state - QVERIFY(mimeData.hasHtml() == false); + QVERIFY(!mimeData.hasHtml()); // add html, verify mimeData.setHtml("ninjas"); @@ -277,7 +277,7 @@ void tst_QMimeData::setText() const // verify initial state QCOMPARE(mimeData.text(), QLatin1String("")); - QVERIFY(mimeData.hasText() == false); + QVERIFY(!mimeData.hasText()); // set, verify mimeData.setText("pirates"); @@ -294,7 +294,7 @@ void tst_QMimeData::setText() const // clear, verify mimeData.clear(); QCOMPARE(mimeData.text(), QLatin1String("")); - QVERIFY(mimeData.hasText() == false); + QVERIFY(!mimeData.hasText()); } // Publish retrieveData for verifying content validity diff --git a/tests/auto/corelib/kernel/qobject/BLACKLIST b/tests/auto/corelib/kernel/qobject/BLACKLIST new file mode 100644 index 0000000000..0887a73b4c --- /dev/null +++ b/tests/auto/corelib/kernel/qobject/BLACKLIST @@ -0,0 +1,2 @@ +[moveToThread] +windows diff --git a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp index 814c4bb691..d7cce4ada4 100644 --- a/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp +++ b/tests/auto/corelib/kernel/qpointer/tst_qpointer.cpp @@ -50,6 +50,7 @@ private slots: void destructor(); void assignment_operators(); void equality_operators(); + void swap(); void isNull(); void dereference_operators(); void disconnect(); @@ -169,6 +170,22 @@ void tst_QPointer::equality_operators() #endif } +void tst_QPointer::swap() +{ + QPointer<QObject> c1, c2; + { + QObject o; + c1 = &o; + QVERIFY(c2.isNull()); + QCOMPARE(c1.data(), &o); + c1.swap(c2); + QVERIFY(c1.isNull()); + QCOMPARE(c2.data(), &o); + } + QVERIFY(c1.isNull()); + QVERIFY(c2.isNull()); +} + void tst_QPointer::isNull() { QPointer<QObject> p1; diff --git a/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST new file mode 100644 index 0000000000..e68bf84268 --- /dev/null +++ b/tests/auto/corelib/kernel/qsocketnotifier/BLACKLIST @@ -0,0 +1,3 @@ +[unexpectedDisconnection] +windows +osx diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 1d1432f600..1dc358bd97 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -440,6 +440,9 @@ void tst_QTimer::deleteLaterOnQTimer() void tst_QTimer::moveToThread() { +#if defined(Q_OS_WIN32) + QSKIP("Does not work reliably on Windows :("); +#endif QTimer ti1; QTimer ti2; ti1.start(MOVETOTHREAD_TIMEOUT); diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index a192ccde59..6da8f55e61 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -3357,9 +3357,6 @@ void tst_QVariant::numericalConvert_data() void tst_QVariant::numericalConvert() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__) - QSKIP("Known to fail due to a GCC bug on at least Ubuntu 10.04 32-bit - check QTBUG-8959"); -#endif QFETCH(QVariant, v); QFETCH(bool, isInteger); double num = isInteger ? 5 : 5.3; diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 8bc90d917e..dd04849f87 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -35,6 +35,7 @@ #include "qstandardpaths.h" +#include <QtCore/QElapsedTimer> #include <QtCore/QFile> #include <QtCore/QFileInfo> #include <QtCore/QStandardPaths> @@ -129,7 +130,8 @@ void tst_QMimeDatabase::initTestCase() #ifdef USE_XDG_DATA_DIRS // Create a temporary "global" XDG data dir for later use // It will initially contain a copy of freedesktop.org.xml - QVERIFY(m_temporaryDir.isValid()); + QVERIFY2(m_temporaryDir.isValid(), + ("Could not create temporary subdir: " + m_temporaryDir.errorString()).toUtf8()); const QDir here = QDir(m_temporaryDir.path()); m_globalXdgDir = m_temporaryDir.path() + QStringLiteral("/global"); const QString globalPackageDir = m_globalXdgDir + QStringLiteral("/mime/packages"); @@ -818,16 +820,20 @@ static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDa return false; } + QElapsedTimer timer; QProcess proc; proc.setProcessChannelMode(QProcess::MergedChannels); // silence output + qDebug().noquote() << "runUpdateMimeDatabase: running" << umd << path << "..."; + timer.start(); 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; + const bool success = proc.waitForFinished(); + qDebug().noquote() << "runUpdateMimeDatabase: done," + << success << timer.elapsed() << "ms"; return true; } diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index bdbb291d7f..72bd38d116 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -120,6 +120,7 @@ private slots: void loadGarbage(); #endif void relativePath(); + void absolutePath(); void reloadPlugin(); void preloadedPlugin_data(); void preloadedPlugin(); @@ -311,7 +312,7 @@ void tst_QPluginLoader::loadCorruptElf() void tst_QPluginLoader::loadMachO_data() { -#ifdef Q_OF_MACH_O +#if defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O) QTest::addColumn<int>("parseResult"); QTest::newRow("/dev/null") << int(QMachOParser::NotSuitable); @@ -347,7 +348,7 @@ void tst_QPluginLoader::loadMachO_data() void tst_QPluginLoader::loadMachO() { -#ifdef Q_OF_MACH_O +#if defined(QT_BUILD_INTERNAL) && defined(Q_OF_MACH_O) QFile f(QFINDTESTDATA(QTest::currentDataTag())); QVERIFY(f.open(QIODevice::ReadOnly)); QByteArray data = f.readAll(); @@ -406,6 +407,20 @@ void tst_QPluginLoader::relativePath() QVERIFY(loader.unload()); } +void tst_QPluginLoader::absolutePath() +{ + // Windows binaries run from release and debug subdirs, so we can't rely on the current dir. + const QString binDir = QFINDTESTDATA("bin"); + QVERIFY(!binDir.isEmpty()); + QVERIFY(QDir::isAbsolutePath(binDir)); + QPluginLoader loader(binDir + "/theplugin"); + loader.load(); // not recommended, instance() should do the job. + PluginInterface *instance = qobject_cast<PluginInterface*>(loader.instance()); + QVERIFY(instance); + QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok")); + QVERIFY(loader.unload()); +} + void tst_QPluginLoader::reloadPlugin() { QPluginLoader loader; diff --git a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp index ac3374b6a3..c64d55671a 100644 --- a/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp +++ b/tests/auto/corelib/statemachine/qstate/tst_qstate.cpp @@ -47,6 +47,7 @@ private slots: void historyInitialState(); void transitions(); void privateSignals(); + void parallelStateAndInitialState(); }; class TestClass: public QObject @@ -344,5 +345,35 @@ void tst_QState::privateSignals() } +void tst_QState::parallelStateAndInitialState() +{ + QStateMachine machine; + + { // setting an initial state on a parallel state: + QState a(QState::ParallelStates, &machine); + QState b(&a); + QVERIFY(!a.initialState()); + const QString warning + = QString::asprintf("QState::setInitialState: ignoring attempt to set initial state of parallel state group %p", &a); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + a.setInitialState(&b); // should produce a warning and do nothing. + QVERIFY(!a.initialState()); + } + + { // setting the child-mode from ExclusiveStates to ParallelStates should remove the initial state: + QState a(QState::ExclusiveStates, &machine); + QState b(&a); + a.setInitialState(&b); + QCOMPARE(a.initialState(), &b); + const QString warning + = QString::asprintf("QState::setChildMode: setting the child-mode of state %p to " + "parallel removes the initial state", &a); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + a.setChildMode(QState::ParallelStates); // should produce a warning and remove the initial state + QVERIFY(!a.initialState()); + QCOMPARE(a.childMode(), QState::ParallelStates); + } +} + QTEST_MAIN(tst_QState) #include "tst_qstate.moc" diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 1292c3b98f..28df7cce7b 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -250,6 +250,7 @@ private slots: void internalTransition(); void conflictingTransition(); void qtbug_46059(); + void qtbug_46703(); }; class TestState : public QState @@ -265,7 +266,7 @@ public: TestState(ChildMode mode, const QString &objectName = QString()) : QState(mode) { setObjectName(objectName); } - QList<QPair<int, Event> > events; + QVector<QPair<int, Event> > events; protected: virtual void onEntry(QEvent *) { events.append(qMakePair(globalTick++, Entry)); @@ -281,7 +282,7 @@ public: TestTransition(QAbstractState *target, const QString &objectName = QString()) : QAbstractTransition() { setTargetState(target); setObjectName(objectName); } - QList<int> triggers; + QVector<int> triggers; protected: virtual bool eventTest(QEvent *) { return true; @@ -4860,7 +4861,7 @@ public: signalList.append(signal); } - QList<QMetaMethod> signalList; + QVector<QMetaMethod> signalList; }; void tst_QStateMachine::testIncrementReceivers() @@ -6485,5 +6486,59 @@ void tst_QStateMachine::qtbug_46059() QVERIFY(machine.isRunning()); } +void tst_QStateMachine::qtbug_46703() +{ + QStateMachine machine; + QState root(&machine); + QHistoryState h(&root); + QState p(QState::ParallelStates, &root); + QState a(&p); + QState a1(&a); + QState a2(&a); + QState a3(&a); + QState b(&p); + QState b1(&b); + QState b2(&b); + + machine.setObjectName("machine"); + root.setObjectName("root"); + h.setObjectName("h"); + p.setObjectName("p"); + a.setObjectName("a"); + a1.setObjectName("a1"); + a2.setObjectName("a2"); + a3.setObjectName("a3"); + b.setObjectName("b"); + b1.setObjectName("b1"); + b2.setObjectName("b2"); + + machine.setInitialState(&root); + root.setInitialState(&h); + a.setInitialState(&a3); + b.setInitialState(&b1); + struct : public QAbstractTransition { + virtual bool eventTest(QEvent *) { return false; } + virtual void onTransition(QEvent *) {} + } defaultTransition; + defaultTransition.setTargetStates(QList<QAbstractState*>() << &a2 << &b2); + h.setDefaultTransition(&defaultTransition); + + machine.start(); + QCoreApplication::processEvents(); + + QTRY_COMPARE(machine.configuration().contains(&root), true); + QTRY_COMPARE(machine.configuration().contains(&h), false); + QTRY_COMPARE(machine.configuration().contains(&p), true); + QTRY_COMPARE(machine.configuration().contains(&a), true); + QTRY_COMPARE(machine.configuration().contains(&a1), false); + QTRY_COMPARE(machine.configuration().contains(&a2), true); + QTRY_COMPARE(machine.configuration().contains(&a3), false); + QTRY_COMPARE(machine.configuration().contains(&b), true); + QTRY_COMPARE(machine.configuration().contains(&b1), false); + QTRY_COMPARE(machine.configuration().contains(&b2), true); + + QVERIFY(machine.isRunning()); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index e8c58a9fa5..72ae68f81a 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -479,34 +479,34 @@ void tst_QAtomicInt::testAndSet_data() QTest::addColumn<int>("value"); QTest::addColumn<int>("expected"); QTest::addColumn<int>("newval"); - QTest::addColumn<int>("result"); + QTest::addColumn<bool>("result"); // these should succeed - QTest::newRow("success0") << 0 << 0 << 0 << 1; - QTest::newRow("success1") << 0 << 0 << 1 << 1; - QTest::newRow("success2") << 0 << 0 << -1 << 1; - QTest::newRow("success3") << 1 << 1 << 0 << 1; - QTest::newRow("success4") << 1 << 1 << 1 << 1; - QTest::newRow("success5") << 1 << 1 << -1 << 1; - QTest::newRow("success6") << -1 << -1 << 0 << 1; - QTest::newRow("success7") << -1 << -1 << 1 << 1; - QTest::newRow("success8") << -1 << -1 << -1 << 1; - QTest::newRow("success9") << INT_MIN+1 << INT_MIN+1 << INT_MIN+1 << 1; - QTest::newRow("successA") << INT_MIN+1 << INT_MIN+1 << 1 << 1; - QTest::newRow("successB") << INT_MIN+1 << INT_MIN+1 << -1 << 1; - QTest::newRow("successC") << INT_MAX << INT_MAX << INT_MAX << 1; - QTest::newRow("successD") << INT_MAX << INT_MAX << 1 << 1; - QTest::newRow("successE") << INT_MAX << INT_MAX << -1 << 1; + QTest::newRow("success0") << 0 << 0 << 0 << true; + QTest::newRow("success1") << 0 << 0 << 1 << true; + QTest::newRow("success2") << 0 << 0 << -1 << true; + QTest::newRow("success3") << 1 << 1 << 0 << true; + QTest::newRow("success4") << 1 << 1 << 1 << true; + QTest::newRow("success5") << 1 << 1 << -1 << true; + QTest::newRow("success6") << -1 << -1 << 0 << true; + QTest::newRow("success7") << -1 << -1 << 1 << true; + QTest::newRow("success8") << -1 << -1 << -1 << true; + QTest::newRow("success9") << INT_MIN+1 << INT_MIN+1 << INT_MIN+1 << true; + QTest::newRow("successA") << INT_MIN+1 << INT_MIN+1 << 1 << true; + QTest::newRow("successB") << INT_MIN+1 << INT_MIN+1 << -1 << true; + QTest::newRow("successC") << INT_MAX << INT_MAX << INT_MAX << true; + QTest::newRow("successD") << INT_MAX << INT_MAX << 1 << true; + QTest::newRow("successE") << INT_MAX << INT_MAX << -1 << true; // these should fail - QTest::newRow("failure0") << 0 << 1 << ~0 << 0; - QTest::newRow("failure1") << 0 << -1 << ~0 << 0; - QTest::newRow("failure2") << 1 << 0 << ~0 << 0; - QTest::newRow("failure3") << -1 << 0 << ~0 << 0; - QTest::newRow("failure4") << 1 << -1 << ~0 << 0; - QTest::newRow("failure5") << -1 << 1 << ~0 << 0; - QTest::newRow("failure6") << INT_MIN+1 << INT_MAX << ~0 << 0; - QTest::newRow("failure7") << INT_MAX << INT_MIN+1 << ~0 << 0; + QTest::newRow("failure0") << 0 << 1 << ~0 << false; + QTest::newRow("failure1") << 0 << -1 << ~0 << false; + QTest::newRow("failure2") << 1 << 0 << ~0 << false; + QTest::newRow("failure3") << -1 << 0 << ~0 << false; + QTest::newRow("failure4") << 1 << -1 << ~0 << false; + QTest::newRow("failure5") << -1 << 1 << ~0 << false; + QTest::newRow("failure6") << INT_MIN+1 << INT_MAX << ~0 << false; + QTest::newRow("failure7") << INT_MAX << INT_MIN+1 << ~0 << false; } void tst_QAtomicInt::testAndSet() @@ -517,26 +517,26 @@ void tst_QAtomicInt::testAndSet() { QAtomicInt atomic = value; - QTEST(atomic.testAndSetRelaxed(expected, newval) ? 1 : 0, "result"); + QTEST(atomic.testAndSetRelaxed(expected, newval), "result"); } { QAtomicInt atomic = value; - QTEST(atomic.testAndSetAcquire(expected, newval) ? 1 : 0, "result"); + QTEST(atomic.testAndSetAcquire(expected, newval), "result"); } { QAtomicInt atomic = value; - QTEST(atomic.testAndSetRelease(expected, newval) ? 1 : 0, "result"); + QTEST(atomic.testAndSetRelease(expected, newval), "result"); } { QAtomicInt atomic = value; - QTEST(atomic.testAndSetOrdered(expected, newval) ? 1 : 0, "result"); + QTEST(atomic.testAndSetOrdered(expected, newval), "result"); } #ifdef Q_ATOMIC_INT32_IS_SUPPORTED - QFETCH(int, result); + QFETCH(bool, result); // the new implementation has the version that loads the current value { diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index 99978a9923..ad690a094b 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -648,7 +648,7 @@ void tst_QFuture::cancel() result.reportStarted(); f = result.future(); - QVERIFY(f.isCanceled() == false); + QVERIFY(!f.isCanceled()); result.reportCanceled(); QVERIFY(f.isCanceled()); result.reportFinished(); @@ -663,14 +663,14 @@ void tst_QFuture::cancel() QFutureInterface<void> result; QFuture<void> f; - QVERIFY(f.isStarted() == true); + QVERIFY(f.isStarted()); result.reportStarted(); f = result.future(); - QVERIFY(f.isStarted() == true); + QVERIFY(f.isStarted()); - QVERIFY(result.isCanceled() == false); + QVERIFY(!result.isCanceled()); f.cancel(); QVERIFY(result.isCanceled()); @@ -683,12 +683,12 @@ void tst_QFuture::cancel() QFutureInterface<void> result; QFuture<void> f; - QVERIFY(f.isStarted() == true); + QVERIFY(f.isStarted()); result.reportStarted(); f = result.future(); - QVERIFY(f.isStarted() == true); + QVERIFY(f.isStarted()); result.reportFinished(); @@ -805,12 +805,12 @@ void tst_QFuture::indexedResults() { QFutureInterface<QChar> Interface; QFuture<QChar> f; - QVERIFY(f.isStarted() == true); + QVERIFY(f.isStarted()); Interface.reportStarted(); f = Interface.future(); - QVERIFY(f.isStarted() == true); + QVERIFY(f.isStarted()); QChar result; @@ -1126,14 +1126,14 @@ void tst_QFuture::iterators() QVERIFY(it.hasNext()); QCOMPARE(it.peekNext(), resultCount - 1); QCOMPARE(it.next(), resultCount - 1); - QVERIFY(it.hasNext() == false); + QVERIFY(!it.hasNext()); } { QFutureIterator<int> it(f); QVERIFY(it.hasNext()); it.toBack(); - QVERIFY(it.hasNext() == false); + QVERIFY(!it.hasNext()); it.toFront(); QVERIFY(it.hasNext()); } @@ -1192,15 +1192,15 @@ void tst_QFuture::pause() Interface.reportStarted(); QFuture<void> f = Interface.future(); - QVERIFY(Interface.isPaused() == false); + QVERIFY(!Interface.isPaused()); f.pause(); - QVERIFY(Interface.isPaused() == true); + QVERIFY(Interface.isPaused()); f.resume(); - QVERIFY(Interface.isPaused() == false); + QVERIFY(!Interface.isPaused()); f.togglePaused(); - QVERIFY(Interface.isPaused() == true); + QVERIFY(Interface.isPaused()); f.togglePaused(); - QVERIFY(Interface.isPaused() == false); + QVERIFY(!Interface.isPaused()); Interface.reportFinished(); } @@ -1228,13 +1228,13 @@ void tst_QFuture::throttling() i.reportStarted(); QFuture<void> f = i.future(); - QVERIFY(i.isThrottled() == false); + QVERIFY(!i.isThrottled()); i.setThrottled(true); QVERIFY(i.isThrottled()); i.setThrottled(false); - QVERIFY(i.isThrottled() == false); + QVERIFY(!i.isThrottled()); i.setThrottled(true); QVERIFY(i.isThrottled()); diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index 8831345ad7..60a4d749c9 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -743,7 +743,7 @@ void tst_QFutureWatcher::finishedState() iface.reportFinished(); QVERIFY(future.isFinished()); - QVERIFY(watcher.isFinished() == false); + QVERIFY(!watcher.isFinished()); QTest::qWait(10); QVERIFY(watcher.isFinished()); @@ -761,18 +761,18 @@ void tst_QFutureWatcher::throttling() QFutureWatcher<int> watcher; watcher.setFuture(future); - QVERIFY(iface.isThrottled() == false); + QVERIFY(!iface.isThrottled()); for (int i = 0; i < 1000; ++i) { int result = 0; iface.reportResult(result); } - QVERIFY(iface.isThrottled() == true); + QVERIFY(iface.isThrottled()); QTest::qWait(100); // process events. - QVERIFY(iface.isThrottled() == false); + QVERIFY(!iface.isThrottled()); iface.reportFinished(); } diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST new file mode 100644 index 0000000000..9f6f6e3ba6 --- /dev/null +++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST @@ -0,0 +1,3 @@ +# Times out randomly on linux, windows, osx +[tryAcquireWithTimeout] +* diff --git a/tests/auto/corelib/thread/qthread/BLACKLIST b/tests/auto/corelib/thread/qthread/BLACKLIST new file mode 100644 index 0000000000..d75249454f --- /dev/null +++ b/tests/auto/corelib/thread/qthread/BLACKLIST @@ -0,0 +1,2 @@ +[wait3_slowDestructor] +windows diff --git a/tests/auto/corelib/thread/qthreadpool/BLACKLIST b/tests/auto/corelib/thread/qthreadpool/BLACKLIST new file mode 100644 index 0000000000..684f650a72 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadpool/BLACKLIST @@ -0,0 +1,5 @@ +[expiryTimeoutRace] +osx +[tryStartCount] +windows msvc-2012 +linux diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 7eedd5bcf7..ae8ffe48be 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -2235,7 +2235,7 @@ void tst_Collections::qstring() void tst_Collections::bitArray() { QBitArray ba(20); - QVERIFY(ba.testBit(17) == false); + QVERIFY(!ba.testBit(17)); ba.setBit(17); QVERIFY(ba.size() == 20); QVERIFY(ba.testBit(17)==true); diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 9bce948140..99e5c4c85d 100644..100755 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -31,6 +31,7 @@ ** ****************************************************************************/ +#include "../../../../../src/corelib/tools/qalgorithms.h" #include <QtTest/QtTest> #include <iostream> @@ -80,6 +81,24 @@ private slots: void popCount32() { popCount_impl<quint32>(); } void popCount64() { popCount_impl<quint64>(); } + void countTrailing08_data() { countTrailing_data_impl(sizeof(quint8 )); } + void countTrailing16_data() { countTrailing_data_impl(sizeof(quint16)); } + void countTrailing32_data() { countTrailing_data_impl(sizeof(quint32)); } + void countTrailing64_data() { countTrailing_data_impl(sizeof(quint64)); } + void countTrailing08() { countTrailing_impl<quint8 >(); } + void countTrailing16() { countTrailing_impl<quint16>(); } + void countTrailing32() { countTrailing_impl<quint32>(); } + void countTrailing64() { countTrailing_impl<quint64>(); } + + void countLeading08_data() { countLeading_data_impl(sizeof(quint8 )); } + void countLeading16_data() { countLeading_data_impl(sizeof(quint16)); } + void countLeading32_data() { countLeading_data_impl(sizeof(quint32)); } + void countLeading64_data() { countLeading_data_impl(sizeof(quint64)); } + void countLeading08() { countLeading_impl<quint8 >(); } + void countLeading16() { countLeading_impl<quint16>(); } + void countLeading32() { countLeading_impl<quint32>(); } + void countLeading64() { countLeading_impl<quint64>(); } + private: #if Q_TEST_PERFORMANCE void performance(); @@ -87,6 +106,14 @@ private: void popCount_data_impl(size_t sizeof_T_Int); template <typename T_Int> void popCount_impl(); + + void countTrailing_data_impl(size_t sizeof_T_Int); + template <typename T_Int> + void countTrailing_impl(); + + void countLeading_data_impl(size_t sizeof_T_Int); + template <typename T_Int> + void countLeading_impl(); }; class TestInt @@ -1084,6 +1111,86 @@ void tst_QAlgorithms::popCount_impl() QCOMPARE(qPopulationCount(value), expected); } +void tst_QAlgorithms::countTrailing_data_impl(size_t sizeof_T_Int) +{ + using namespace QTest; + addColumn<quint64>("input"); + addColumn<uint>("expected"); + + int nibs = sizeof_T_Int*2; + + newRow(("0x"+QByteArray::number(0,16).rightJustified(nibs,'0')).constData()) << Q_UINT64_C(0) << uint(sizeof_T_Int*8); + for (uint i = 0; i < sizeof_T_Int*8; ++i) { + const quint64 input = Q_UINT64_C(1) << i; + newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << i; + } + + quint64 type_mask; + if (sizeof_T_Int>=8) + type_mask = ~Q_UINT64_C(0); + else + type_mask = (Q_UINT64_C(1) << (sizeof_T_Int*8))-1; + + // and some random ones: + for (uint i = 0; i < sizeof_T_Int*8; ++i) { + for (uint j = 0; j < sizeof_T_Int*3; ++j) { // 3 is arbitrary + const quint64 r = quint64(qrand()) << 32 | quint32(qrand()); + const quint64 b = Q_UINT64_C(1) << i; + const quint64 mask = ((~(b-1)) ^ b) & type_mask; + const quint64 input = (r&mask) | b; + newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << i; + } + } +} + +template <typename T_Int> +void tst_QAlgorithms::countTrailing_impl() +{ + QFETCH(quint64, input); + QFETCH(uint, expected); + + const T_Int value = static_cast<T_Int>(input); + + QCOMPARE(qCountTrailingZeroBits(value), expected); +} + +void tst_QAlgorithms::countLeading_data_impl(size_t sizeof_T_Int) +{ + using namespace QTest; + addColumn<quint64>("input"); + addColumn<uint>("expected"); + + int nibs = sizeof_T_Int*2; + + newRow(("0x"+QByteArray::number(0,16).rightJustified(nibs,'0')).constData()) << Q_UINT64_C(0) << uint(sizeof_T_Int*8); + for (uint i = 0; i < sizeof_T_Int*8; ++i) { + const quint64 input = Q_UINT64_C(1) << i; + newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << uint(sizeof_T_Int*8-i-1); + } + + // and some random ones: + for (uint i = 0; i < sizeof_T_Int*8; ++i) { + for (uint j = 0; j < sizeof_T_Int*3; ++j) { // 3 is arbitrary + const quint64 r = quint64(qrand()) << 32 | quint32(qrand()); + const quint64 b = Q_UINT64_C(1) << i; + const quint64 mask = b-1; + const quint64 input = (r&mask) | b; + newRow(("0x"+QByteArray::number(input,16).rightJustified(nibs,'0')).constData()) << input << uint(sizeof_T_Int*8-i-1); + } + } +} + +template <typename T_Int> +void tst_QAlgorithms::countLeading_impl() +{ + QFETCH(quint64, input); + QFETCH(uint, expected); + + const T_Int value = static_cast<T_Int>(input); + + QCOMPARE(qCountLeadingZeroBits(value), expected); +} + QTEST_APPLESS_MAIN(tst_QAlgorithms) #include "tst_qalgorithms.moc" diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 410b34e894..f942eab800 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -67,6 +67,7 @@ private slots: void endsWith_data(); void endsWith(); void endsWith_char(); + void reverseIterators(); void split_data(); void split(); void base64_data(); @@ -540,6 +541,20 @@ void tst_QByteArray::endsWith_char() QVERIFY(!QByteArray().endsWith('\0')); } +void tst_QByteArray::reverseIterators() +{ + QByteArray s = "1234"; + QByteArray sr = s; + std::reverse(sr.begin(), sr.end()); + const QByteArray &csr = sr; + QVERIFY(std::equal(s.begin(), s.end(), sr.rbegin())); + QVERIFY(std::equal(s.begin(), s.end(), sr.crbegin())); + QVERIFY(std::equal(s.begin(), s.end(), csr.rbegin())); + QVERIFY(std::equal(sr.rbegin(), sr.rend(), s.begin())); + QVERIFY(std::equal(sr.crbegin(), sr.crend(), s.begin())); + QVERIFY(std::equal(csr.rbegin(), csr.rend(), s.begin())); +} + void tst_QByteArray::split_data() { QTest::addColumn<QByteArray>("sample"); diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm b/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm index c2b76cc41a..95d05904a2 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray_mac.mm @@ -72,35 +72,31 @@ void tst_QByteArray_macTypes() } // QByteArray <-> NSData { - NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QByteArray qtByteArray("test bytearray"); const NSData *nsData = qtByteArray.toNSData(); QCOMPARE(QByteArray::fromNSData(nsData), qtByteArray); - [autoreleasepool release]; } { - NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QByteArray qtByteArray("test bytearray"); const NSData *nsData = qtByteArray.toNSData(); QByteArray qtByteArrayCopy(qtByteArray); qtByteArray = qtByteArray.toUpper(); // modify QCOMPARE(QByteArray::fromNSData(nsData), qtByteArrayCopy); - [autoreleasepool release]; } // QByteArray <-> NSData Raw { - NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QByteArray qtByteArray("test bytearray"); const NSData *nsData = qtByteArray.toRawNSData(); QCOMPARE([nsData bytes], qtByteArray.constData()); - [autoreleasepool release]; } { - NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; const char data[] = "nsdata test"; const NSData *nsData = [NSData dataWithBytes:data length:sizeof(data)]; QByteArray qtByteArray = QByteArray::fromRawNSData(nsData); QCOMPARE(qtByteArray.constData(), [nsData bytes]); - [autoreleasepool release]; } } diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index 7b1b7ce963..6e09ebb09b 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -73,6 +73,12 @@ int main(int argc, char *argv[]) "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); parser.addOption(newlineOption); + // A hidden option + QCommandLineOption hiddenOption(QStringList() << QStringLiteral("hidden")); + hiddenOption.setDescription(QStringLiteral("THIS SHOULD NEVER APPEAR")); + hiddenOption.setHidden(true); + parser.addOption(hiddenOption); + // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. parser.parse(QCoreApplication::arguments()); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 6ff46ed20b..fb0b971602 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -35,6 +35,7 @@ #include <QtCore/QCommandLineParser> Q_DECLARE_METATYPE(char**) +Q_DECLARE_METATYPE(QCommandLineParser::OptionsAfterPositionalArgumentsMode) class tst_QCommandLineParser : public QObject { @@ -51,6 +52,8 @@ private slots: void testPositionalArguments(); void testBooleanOption_data(); void testBooleanOption(); + void testOptionsAndPositional_data(); + void testOptionsAndPositional(); void testMultipleNames_data(); void testMultipleNames(); void testSingleValueOption_data(); @@ -130,7 +133,7 @@ void tst_QCommandLineParser::testBooleanOption() QFETCH(bool, expectedIsSet); QCoreApplication app(empty_argc, empty_argv); QCommandLineParser parser; - QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b"), QStringLiteral("a boolean option")))); + QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b")))); QVERIFY(parser.parse(args)); QCOMPARE(parser.optionNames(), expectedOptionNames); QCOMPARE(parser.isSet("b"), expectedIsSet); @@ -141,6 +144,40 @@ void tst_QCommandLineParser::testBooleanOption() QVERIFY(!parser.isSet("c")); } +void tst_QCommandLineParser::testOptionsAndPositional_data() +{ + QTest::addColumn<QStringList>("args"); + QTest::addColumn<QStringList>("expectedOptionNames"); + QTest::addColumn<bool>("expectedIsSet"); + QTest::addColumn<QStringList>("expectedPositionalArguments"); + QTest::addColumn<QCommandLineParser::OptionsAfterPositionalArgumentsMode>("parsingMode"); + + const QStringList arg = QStringList() << "arg"; + QTest::newRow("before_positional_default") << (QStringList() << "tst_qcommandlineparser" << "-b" << "arg") << (QStringList() << "b") << true << arg << QCommandLineParser::ParseAsOptions; + QTest::newRow("after_positional_default") << (QStringList() << "tst_qcommandlineparser" << "arg" << "-b") << (QStringList() << "b") << true << arg << QCommandLineParser::ParseAsOptions; + QTest::newRow("before_positional_parseAsArg") << (QStringList() << "tst_qcommandlineparser" << "-b" << "arg") << (QStringList() << "b") << true << arg << QCommandLineParser::ParseAsPositionalArguments; + QTest::newRow("after_positional_parseAsArg") << (QStringList() << "tst_qcommandlineparser" << "arg" << "-b") << (QStringList()) << false << (QStringList() << "arg" << "-b") << QCommandLineParser::ParseAsPositionalArguments; +} + +void tst_QCommandLineParser::testOptionsAndPositional() +{ + QFETCH(QStringList, args); + QFETCH(QStringList, expectedOptionNames); + QFETCH(bool, expectedIsSet); + QFETCH(QStringList, expectedPositionalArguments); + QFETCH(QCommandLineParser::OptionsAfterPositionalArgumentsMode, parsingMode); + + QCoreApplication app(empty_argc, empty_argv); + QCommandLineParser parser; + parser.setOptionsAfterPositionalArgumentsMode(parsingMode); + QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("b"), QStringLiteral("a boolean option")))); + QVERIFY(parser.parse(args)); + QCOMPARE(parser.optionNames(), expectedOptionNames); + QCOMPARE(parser.isSet("b"), expectedIsSet); + QCOMPARE(parser.values("b"), QStringList()); + QCOMPARE(parser.positionalArguments(), expectedPositionalArguments); +} + void tst_QCommandLineParser::testMultipleNames_data() { QTest::addColumn<QStringList>("args"); diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm b/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm index 6bdaa94e49..0ad9a8253b 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime_mac.mm @@ -56,19 +56,17 @@ void tst_QDateTime_macTypes() } // QDateTime <-> NSDate { - NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0); const NSDate *nsDate = qtDateTime.toNSDate(); QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTime); - [autoreleasepool release]; } { - NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0); const NSDate *nsDate = qtDateTime.toNSDate(); QDateTime qtDateTimeCopy(qtDateTime); qtDateTime.setTime_t(10000); // modify QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTimeCopy); - [autoreleasepool release]; } } diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 6ea33fb37f..6a5c6b5670 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -62,6 +62,7 @@ private slots: void compare(); void compare2(); void iterators(); // sligthly modified from tst_QMap + void keyIterator(); void keys_values_uniqueKeys(); // slightly modified from tst_QMap void noNeedlessRehashes(); @@ -965,6 +966,34 @@ void tst_QHash::iterators() } } +void tst_QHash::keyIterator() +{ + QHash<int, int> hash; + + for (int i = 0; i < 100; ++i) + hash.insert(i, i*100); + + QHash<int, int>::key_iterator key_it = hash.keyBegin(); + QHash<int, int>::const_iterator it = hash.cbegin(); + for (int i = 0; i < 100; ++i) { + QCOMPARE(*key_it, it.key()); + key_it++; + it++; + } + + key_it = std::find(hash.keyBegin(), hash.keyEnd(), 50); + it = std::find(hash.cbegin(), hash.cend(), 50 * 100); + + QVERIFY(key_it != hash.keyEnd()); + QCOMPARE(*key_it, it.key()); + QCOMPARE(*(key_it++), (it++).key()); + QCOMPARE(*(key_it--), (it--).key()); + QCOMPARE(*(++key_it), (++it).key()); + QCOMPARE(*(--key_it), (--it).key()); + + QCOMPARE(std::count(hash.keyBegin(), hash.keyEnd(), 99), 1); +} + void tst_QHash::rehash_isnt_quadratic() { // this test should be incredibly slow if rehash() is quadratic diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index 82303b4f72..2e829bb05e 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -527,12 +527,12 @@ void tst_QLinkedList::contains() const QLinkedList<T> list; list << T_FOO << T_BAR << T_BAZ; - QVERIFY(list.contains(T_FOO) == true); + QVERIFY(list.contains(T_FOO)); QVERIFY(list.contains(T_BLAH) != true); // add it and make sure it matches list.append(T_BLAH); - QVERIFY(list.contains(T_BLAH) == true); + QVERIFY(list.contains(T_BLAH)); } void tst_QLinkedList::containsInt() const diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 1207986dde..1bb31afa9c 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -76,6 +76,13 @@ struct Movable { return i == other.i; } + bool operator<(const Movable &other) const + { + check(state, Constructed); + check(other.state, Constructed); + return i < other.i; + } + Movable &operator=(const Movable &other) { check(state, Constructed); @@ -144,6 +151,13 @@ struct Optimal return i == other.i; } + bool operator<(const Optimal &other) const + { + check(state, Constructed); + check(other.state, Constructed); + return i < other.i; + } + Optimal &operator=(const Optimal &other) { check(state, Constructed); @@ -220,6 +234,12 @@ struct Complex return value == other.value; } + bool operator<(Complex const &other) const + { + check(); other.check(); + return value < other.value; + } + void check() const { QVERIFY(this == checkSum); @@ -293,6 +313,8 @@ private slots: void lastOptimal() const; void lastMovable() const; void lastComplex() const; + void constFirst() const; + void constLast() const; void beginOptimal() const; void beginMovable() const; void beginComplex() const; @@ -329,6 +351,9 @@ private slots: void replaceOptimal() const; void replaceMovable() const; void replaceComplex() const; + void reverseIteratorsOptimal() const; + void reverseIteratorsMovable() const; + void reverseIteratorsComplex() const; void startsWithOptimal() const; void startsWithMovable() const; void startsWithComplex() const; @@ -376,6 +401,9 @@ private slots: void eraseValidIteratorsOnSharedList() const; void insertWithValidIteratorsOnSharedList() const; + void qhashOptimal() const { qhash<Optimal>(); } + void qhashMovable() const { qhash<Movable>(); } + void qhashComplex() const { qhash<Complex>(); } void reserve() const; private: template<typename T> void length() const; @@ -392,10 +420,12 @@ private: template<typename T> void endsWith() const; template<typename T> void lastIndexOf() const; template<typename T> void move() const; + template<typename T> void qhash() const; template<typename T> void removeAll() const; template<typename T> void removeAt() const; template<typename T> void removeOne() const; template<typename T> void replace() const; + template<typename T> void reverseIterators() const; template<typename T> void startsWith() const; template<typename T> void swap() const; template<typename T> void takeAt() const; @@ -701,6 +731,140 @@ void tst_QList::firstComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +void tst_QList::constFirst() const +{ + // Based on tst_QVector::constFirst() + QList<int> list; + list << 69 << 42 << 3; + + // test it starts ok + QCOMPARE(list.constFirst(), 69); + QVERIFY(list.isDetached()); + + QList<int> listCopy = list; + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + QCOMPARE(list.constFirst(), 69); + QCOMPARE(listCopy.constFirst(), 69); + + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + // test removal changes + list.removeAt(0); + QVERIFY(list.isDetached()); + QVERIFY(!list.isSharedWith(listCopy)); + QCOMPARE(list.constFirst(), 42); + QCOMPARE(listCopy.constFirst(), 69); + + listCopy = list; + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + QCOMPARE(list.constFirst(), 42); + QCOMPARE(listCopy.constFirst(), 42); + + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + // test prepend changes + list.prepend(23); + QVERIFY(list.isDetached()); + QVERIFY(!list.isSharedWith(listCopy)); + QCOMPARE(list.constFirst(), 23); + QCOMPARE(listCopy.constFirst(), 42); + + listCopy = list; + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + QCOMPARE(list.constFirst(), 23); + QCOMPARE(listCopy.constFirst(), 23); + + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); +} + +void tst_QList::constLast() const +{ + // Based on tst_QVector::constLast() + QList<int> list; + list << 69 << 42 << 3; + + // test it starts ok + QCOMPARE(list.constLast(), 3); + QVERIFY(list.isDetached()); + + QList<int> listCopy = list; + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + QCOMPARE(list.constLast(), 3); + QCOMPARE(listCopy.constLast(), 3); + + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + // test removal changes + list.removeLast(); + QVERIFY(list.isDetached()); + QVERIFY(!list.isSharedWith(listCopy)); + QCOMPARE(list.constLast(), 42); + QCOMPARE(listCopy.constLast(), 3); + + listCopy = list; + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + QCOMPARE(list.constLast(), 42); + QCOMPARE(listCopy.constLast(), 42); + + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + // test prepend changes + list.append(23); + QVERIFY(list.isDetached()); + QVERIFY(!list.isSharedWith(listCopy)); + QCOMPARE(list.constLast(), 23); + QCOMPARE(listCopy.constLast(), 42); + + listCopy = list; + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); + + QCOMPARE(list.constLast(), 23); + QCOMPARE(listCopy.constLast(), 23); + + QVERIFY(!list.isDetached()); + QVERIFY(!listCopy.isDetached()); + QVERIFY(list.isSharedWith(listCopy)); + QVERIFY(listCopy.isSharedWith(list)); +} + template<typename T> void tst_QList::last() const { @@ -812,12 +976,12 @@ void tst_QList::contains() const QList<T> list; list << T_FOO << T_BAR << T_BAZ; - QVERIFY(list.contains(T_FOO) == true); + QVERIFY(list.contains(T_FOO)); QVERIFY(list.contains(T_BLAH) != true); // add it and make sure it matches list.append(T_BLAH); - QVERIFY(list.contains(T_BLAH) == true); + QVERIFY(list.contains(T_BLAH)); } void tst_QList::containsOptimal() const @@ -1220,6 +1384,43 @@ void tst_QList::replaceComplex() const } template<typename T> +void tst_QList::reverseIterators() const +{ + QList<T> v; + v << T_CAT << T_DOG << T_BLAH << T_BAZ; + QList<T> vr = v; + std::reverse(vr.begin(), vr.end()); + const QList<T> &cvr = vr; + QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin())); + QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin())); + QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin())); + QVERIFY(std::equal(vr.rbegin(), vr.rend(), v.begin())); + QVERIFY(std::equal(vr.crbegin(), vr.crend(), v.begin())); + QVERIFY(std::equal(cvr.rbegin(), cvr.rend(), v.begin())); +} + +void tst_QList::reverseIteratorsOptimal() const +{ + const int liveCount = Optimal::getLiveCount(); + reverseIterators<Optimal>(); + QCOMPARE(liveCount, Optimal::getLiveCount()); +} + +void tst_QList::reverseIteratorsMovable() const +{ + const int liveCount = Movable::getLiveCount(); + reverseIterators<Movable>(); + QCOMPARE(liveCount, Movable::getLiveCount()); +} + +void tst_QList::reverseIteratorsComplex() const +{ + const int liveCount = Complex::getLiveCount(); + reverseIterators<Complex>(); + QCOMPARE(liveCount, Complex::getLiveCount()); +} + +template<typename T> void tst_QList::startsWith() const { QList<T> list; @@ -1576,6 +1777,19 @@ void tst_QList::testOperators() const // [] QCOMPARE(list[0], T_FOO); QCOMPARE(list[list.size() - 1], T_CAT); + + // <, >, <=, >= + QVERIFY(!(list < listtwo)); + QVERIFY(!(list > listtwo)); + QVERIFY( list <= listtwo); + QVERIFY( list >= listtwo); + listtwo.push_back(T_CAT); + QVERIFY( list < listtwo); + QVERIFY(!(list > listtwo)); + QVERIFY( list <= listtwo); + QVERIFY(!(list >= listtwo)); + QVERIFY(listtwo > list); + QVERIFY(listtwo >= list); } void tst_QList::testOperatorsOptimal() const @@ -1834,6 +2048,16 @@ void tst_QList::insertWithValidIteratorsOnSharedList() const QCOMPARE(a.at(1), 15); } +template <typename T> +void tst_QList::qhash() const +{ + QList<T> l1, l2; + QCOMPARE(qHash(l1), qHash(l2)); + l1 << T_BAR; + l2 << T_BAR; + QCOMPARE(qHash(l1), qHash(l2)); +} + void tst_QList::reserve() const { // Note: diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index b1e13a0384..11b6922278 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -371,6 +371,8 @@ void tst_QLocale::ctor() QString("requested: \"" + QString(req_lc) + "\", got: " \ + QLocale::languageToString(l.language()) \ + "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \ + QCOMPARE(l, QLocale(QLocale::exp_lang, QLocale::exp_country)); \ + QCOMPARE(qHash(l), qHash(QLocale(QLocale::exp_lang, QLocale::exp_country))); \ } QLocale::setDefault(QLocale(QLocale::C)); diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 8560a2f18c..bb6535b635 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -65,6 +65,7 @@ private slots: void take(); void iterators(); + void keyIterator(); void keys_values_uniqueKeys(); void qmultimap_specific(); @@ -835,6 +836,34 @@ void tst_QMap::iterators() } } +void tst_QMap::keyIterator() +{ + QMap<int, int> map; + + for (int i = 0; i < 100; ++i) + map.insert(i, i*100); + + QMap<int, int>::key_iterator key_it = map.keyBegin(); + QMap<int, int>::const_iterator it = map.cbegin(); + for (int i = 0; i < 100; ++i) { + QCOMPARE(*key_it, it.key()); + ++key_it; + ++it; + } + + key_it = std::find(map.keyBegin(), map.keyEnd(), 50); + it = std::find(map.cbegin(), map.cend(), 50 * 100); + + QVERIFY(key_it != map.keyEnd()); + QCOMPARE(*key_it, it.key()); + QCOMPARE(*(key_it++), (it++).key()); + QCOMPARE(*(key_it--), (it--).key()); + QCOMPARE(*(++key_it), (++it).key()); + QCOMPARE(*(--key_it), (--it).key()); + + QCOMPARE(std::count(map.keyBegin(), map.keyEnd(), 99), 1); +} + void tst_QMap::keys_values_uniqueKeys() { QMap<QString, int> map; @@ -996,11 +1025,16 @@ void tst_QMap::const_shared_null() void tst_QMap::equal_range() { QMap<int, QString> map; + const QMap<int, QString> &cmap = map; QPair<QMap<int, QString>::iterator, QMap<int, QString>::iterator> result = map.equal_range(0); QCOMPARE(result.first, map.end()); QCOMPARE(result.second, map.end()); + QPair<QMap<int, QString>::const_iterator, QMap<int, QString>::const_iterator> cresult = cmap.equal_range(0); + QCOMPARE(cresult.first, cmap.cend()); + QCOMPARE(cresult.second, cmap.cend()); + map.insert(1, "one"); result = map.equal_range(0); @@ -1015,6 +1049,18 @@ void tst_QMap::equal_range() QCOMPARE(result.first, map.end()); QCOMPARE(result.second, map.end()); + cresult = cmap.equal_range(0); + QCOMPARE(cresult.first, cmap.find(1)); + QCOMPARE(cresult.second, cmap.find(1)); + + cresult = cmap.equal_range(1); + QCOMPARE(cresult.first, cmap.find(1)); + QCOMPARE(cresult.second, cmap.cend()); + + cresult = cmap.equal_range(2); + QCOMPARE(cresult.first, cmap.cend()); + QCOMPARE(cresult.second, cmap.cend()); + for (int i = -10; i < 10; i += 2) map.insert(i, QString("%1").arg(i)); @@ -1030,11 +1076,28 @@ void tst_QMap::equal_range() QCOMPARE(result.first, map.find(2)); QCOMPARE(result.second, map.find(4)); + cresult = cmap.equal_range(0); + QCOMPARE(cresult.first, cmap.find(0)); + QCOMPARE(cresult.second, cmap.find(1)); + + cresult = cmap.equal_range(1); + QCOMPARE(cresult.first, cmap.find(1)); + QCOMPARE(cresult.second, cmap.find(2)); + + cresult = cmap.equal_range(2); + QCOMPARE(cresult.first, cmap.find(2)); + QCOMPARE(cresult.second, cmap.find(4)); + map.insertMulti(1, "another one"); + result = map.equal_range(1); QCOMPARE(result.first, map.find(1)); QCOMPARE(result.second, map.find(2)); + cresult = cmap.equal_range(1); + QCOMPARE(cresult.first, cmap.find(1)); + QCOMPARE(cresult.second, cmap.find(2)); + QCOMPARE(map.count(1), 2); } diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index fefdec7496..b9a3fc13c5 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -1224,6 +1224,9 @@ void tst_QRegExp::operator_eq() for (int j = 0; j < I * J * K * ELL; ++j) { QCOMPARE(rxtable[i] == rxtable[j], i / ELL == j / ELL); QCOMPARE(rxtable[i] != rxtable[j], i / ELL != j / ELL); + // this just happens to have no hash collisions. If at some point + // we get collisions, restrict the test to only equal elements: + QCOMPARE(qHash(rxtable[i]) == qHash(rxtable[j]), i / ELL == j / ELL); } } } diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index d185e64251..8ddd4979b6 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -1423,6 +1423,7 @@ static void verifyEquality(const QRegularExpression &re1, const QRegularExpressi { QVERIFY(re1 == re2); QVERIFY(re2 == re1); + QCOMPARE(qHash(re1), qHash(re2)); QVERIFY(!(re1 != re2)); QVERIFY(!(re2 != re1)); @@ -1430,22 +1431,26 @@ static void verifyEquality(const QRegularExpression &re1, const QRegularExpressi QVERIFY(re1 == re3); QVERIFY(re3 == re1); + QCOMPARE(qHash(re1), qHash(re3)); QVERIFY(!(re1 != re3)); QVERIFY(!(re3 != re1)); QVERIFY(re2 == re3); QVERIFY(re3 == re2); + QCOMPARE(qHash(re2), qHash(re3)); QVERIFY(!(re2 != re3)); QVERIFY(!(re3 != re2)); re3 = re2; QVERIFY(re1 == re3); QVERIFY(re3 == re1); + QCOMPARE(qHash(re1), qHash(re3)); QVERIFY(!(re1 != re3)); QVERIFY(!(re3 != re1)); QVERIFY(re2 == re3); QVERIFY(re3 == re2); + QCOMPARE(qHash(re2), qHash(re3)); QVERIFY(!(re2 != re3)); QVERIFY(!(re3 != re2)); } diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp index 8c29064457..77fc6ad6ae 100644 --- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp +++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp @@ -48,10 +48,12 @@ private slots: void sizeWhenReserved(); void free(); void reserveAndRead(); + void reserveFrontAndRead(); void chop(); void ungetChar(); void indexOf(); void appendAndRead(); + void peek(); void readLine(); }; @@ -60,7 +62,7 @@ void tst_QRingBuffer::sizeWhenReserved() QRingBuffer ringBuffer; ringBuffer.reserve(5); - QCOMPARE(ringBuffer.size(), 5); + QCOMPARE(ringBuffer.size(), Q_INT64_C(5)); } void tst_QRingBuffer::sizeWhenReservedAndChopped() @@ -69,14 +71,14 @@ void tst_QRingBuffer::sizeWhenReservedAndChopped() ringBuffer.reserve(31337); ringBuffer.chop(31337); - QCOMPARE(ringBuffer.size(), 0); + QCOMPARE(ringBuffer.size(), Q_INT64_C(0)); } void tst_QRingBuffer::sizeWhenEmpty() { QRingBuffer ringBuffer; - QCOMPARE(ringBuffer.size(), 0); + QCOMPARE(ringBuffer.size(), Q_INT64_C(0)); } void tst_QRingBuffer::readPointerAtPositionReadTooMuch() @@ -86,7 +88,7 @@ void tst_QRingBuffer::readPointerAtPositionReadTooMuch() qint64 length; const char *buf = ringBuffer.readPointerAtPosition(42, length); QVERIFY(buf == 0); - QVERIFY(length == 0); + QCOMPARE(length, Q_INT64_C(0)); } void tst_QRingBuffer::readPointerAtPositionWithHead() @@ -101,22 +103,22 @@ void tst_QRingBuffer::readPointerAtPositionWithHead() qint64 length; const char* buf2 = ringBuffer.readPointerAtPosition(0, length); - QCOMPARE(length, qint64(2)); - QVERIFY(*buf2 == '2'); - QVERIFY(*(buf2+1) == '3'); + QCOMPARE(length, Q_INT64_C(2)); + QCOMPARE(*buf2, '2'); + QCOMPARE(*(buf2 + 1), '3'); // advance 2 more, ringBuffer should be empty then ringBuffer.free(2); buf2 = ringBuffer.readPointerAtPosition(0, length); - QCOMPARE(length, qint64(0)); + QCOMPARE(length, Q_INT64_C(0)); QVERIFY(buf2 == 0); // check buffer with 2 blocks memcpy(ringBuffer.reserve(4), "0123", 4); ringBuffer.append(QByteArray("45678", 5)); ringBuffer.free(3); - buf2 = ringBuffer.readPointerAtPosition(1, length); - QCOMPARE(length, qint64(5)); + buf2 = ringBuffer.readPointerAtPosition(Q_INT64_C(1), length); + QCOMPARE(length, Q_INT64_C(5)); } void tst_QRingBuffer::readPointerAtPositionEmptyRead() @@ -126,7 +128,7 @@ void tst_QRingBuffer::readPointerAtPositionEmptyRead() qint64 length; const char *buf = ringBuffer.readPointerAtPosition(0, length); QVERIFY(buf == 0); - QVERIFY(length == 0); + QCOMPARE(length, Q_INT64_C(0)); } void tst_QRingBuffer::readPointerAtPositionWriteRead() @@ -149,14 +151,14 @@ void tst_QRingBuffer::readPointerAtPositionWriteRead() // write in chunks of 50 bytes // this ensures there will be multiple QByteArrays inside the QRingBuffer // since QRingBuffer is then only using individual arrays of around 4000 bytes - qint64 thisWrite = qMin(remaining, qint64(50)); + qint64 thisWrite = qMin(remaining, Q_INT64_C(50)); char *pos = ringBuffer.reserve(thisWrite); inData.read(pos, thisWrite); remaining -= thisWrite; } // was data put into it? QVERIFY(ringBuffer.size() > 0); - QCOMPARE(qint64(ringBuffer.size()), inData.size()); + QCOMPARE(ringBuffer.size(), inData.size()); //read from the QRingBuffer in loop, put back into another QBuffer QBuffer outData; @@ -187,12 +189,12 @@ void tst_QRingBuffer::free() ringBuffer.append(QByteArray("01234", 5)); ringBuffer.free(1); - QCOMPARE(ringBuffer.size(), 4095 + 2048 + 5); + QCOMPARE(ringBuffer.size(), Q_INT64_C(4095 + 2048 + 5)); ringBuffer.free(4096); - QCOMPARE(ringBuffer.size(), 2047 + 5); + QCOMPARE(ringBuffer.size(), Q_INT64_C(2047 + 5)); ringBuffer.free(48); ringBuffer.free(2000); - QCOMPARE(ringBuffer.size(), 4); + QCOMPARE(ringBuffer.size(), Q_INT64_C(4)); QVERIFY(memcmp(ringBuffer.readPointer(), "1234", 4) == 0); } @@ -211,11 +213,33 @@ void tst_QRingBuffer::reserveAndRead() for (int i = 1; i < 256; ++i) { QByteArray ba; ba.resize(i); - int thisRead = ringBuffer.read(ba.data(), i); - QCOMPARE(thisRead, i); - QVERIFY(ba.count(char(i)) == i); + qint64 thisRead = ringBuffer.read(ba.data(), i); + QCOMPARE(thisRead, qint64(i)); + QCOMPARE(ba.count(char(i)), i); } - QVERIFY(ringBuffer.size() == 0); + QCOMPARE(ringBuffer.size(), Q_INT64_C(0)); +} + +void tst_QRingBuffer::reserveFrontAndRead() +{ + QRingBuffer ringBuffer; + // fill buffer with an arithmetic progression + for (int i = 1; i < 256; ++i) { + QByteArray ba(i, char(i)); + char *ringPos = ringBuffer.reserveFront(i); + QVERIFY(ringPos); + memcpy(ringPos, ba.constData(), i); + } + + // readback and check stored data + for (int i = 255; i > 0; --i) { + QByteArray ba; + ba.resize(i); + qint64 thisRead = ringBuffer.read(ba.data(), i); + QCOMPARE(thisRead, qint64(i)); + QCOMPARE(ba.count(char(i)), i); + } + QCOMPARE(ringBuffer.size(), Q_INT64_C(0)); } void tst_QRingBuffer::chop() @@ -227,12 +251,12 @@ void tst_QRingBuffer::chop() ringBuffer.reserve(4096); ringBuffer.chop(1); - QCOMPARE(ringBuffer.size(), 5 + 2048 + 4095); + QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2048 + 4095)); ringBuffer.chop(4096); - QCOMPARE(ringBuffer.size(), 5 + 2047); + QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2047)); ringBuffer.chop(48); ringBuffer.chop(2000); - QCOMPARE(ringBuffer.size(), 4); + QCOMPARE(ringBuffer.size(), Q_INT64_C(4)); QVERIFY(memcmp(ringBuffer.readPointer(), "0123", 4) == 0); } @@ -244,11 +268,11 @@ void tst_QRingBuffer::ungetChar() for (int i = 1; i < 31; ++i) { int c = ringBuffer.getChar(); - QVERIFY(c == 1); + QCOMPARE(c, 1); ringBuffer.getChar(); ringBuffer.ungetChar(char(c)); // unget first char } - QCOMPARE(ringBuffer.size(), 1); + QCOMPARE(ringBuffer.size(), Q_INT64_C(1)); } void tst_QRingBuffer::indexOf() @@ -258,10 +282,10 @@ void tst_QRingBuffer::indexOf() ringBuffer.putChar(char(i)); for (int i = 1; i < 256; ++i) { - int index = ringBuffer.indexOf(char(i)); - QCOMPARE(i - 1, index); - QCOMPARE(index, ringBuffer.indexOf(char(i), i)); - QVERIFY(ringBuffer.indexOf(char(i), i - 1) == -1); // test for absent char + qint64 index = ringBuffer.indexOf(char(i)); + QCOMPARE(index, qint64(i - 1)); + QCOMPARE(ringBuffer.indexOf(char(i), i), index); + QCOMPARE(ringBuffer.indexOf(char(i), i - 1), -1); // test for absent char } } @@ -275,9 +299,34 @@ void tst_QRingBuffer::appendAndRead() ringBuffer.append(ba2); ringBuffer.append(ba3); - QVERIFY(ringBuffer.read() == ba1); - QVERIFY(ringBuffer.read() == ba2); - QVERIFY(ringBuffer.read() == ba3); + QCOMPARE(ringBuffer.read(), ba1); + QCOMPARE(ringBuffer.read(), ba2); + QCOMPARE(ringBuffer.read(), ba3); +} + +void tst_QRingBuffer::peek() +{ + QRingBuffer ringBuffer; + QByteArray testBuffer; + // fill buffer with an arithmetic progression + for (int i = 1; i < 256; ++i) { + char *ringPos = ringBuffer.reserve(i); + QVERIFY(ringPos); + memset(ringPos, i, i); + testBuffer.append(ringPos, i); + } + + // check stored data + QByteArray resultBuffer; + int peekPosition = testBuffer.size(); + for (int i = 1; i < 256; ++i) { + QByteArray ba(i, 0); + peekPosition -= i; + qint64 thisPeek = ringBuffer.peek(ba.data(), i, peekPosition); + QCOMPARE(thisPeek, qint64(i)); + resultBuffer.prepend(ba); + } + QCOMPARE(resultBuffer, testBuffer); } void tst_QRingBuffer::readLine() @@ -293,18 +342,18 @@ void tst_QRingBuffer::readLine() char stringBuf[102]; stringBuf[101] = 0; // non-crash terminator - QVERIFY(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2) == ba1.size()); - QVERIFY(QByteArray(stringBuf, int(strlen(stringBuf))) == ba1); + QCOMPARE(ringBuffer.readLine(stringBuf, sizeof(stringBuf) - 2), qint64(ba1.size())); + QCOMPARE(QByteArray(stringBuf, int(strlen(stringBuf))), ba1); // check first empty string reading stringBuf[0] = char(0xFF); - QCOMPARE(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2), ba2.size()); - QVERIFY(stringBuf[0] == ba2[0]); + QCOMPARE(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2), qint64(ba2.size())); + QCOMPARE(stringBuf[0], ba2.at(0)); - QVERIFY(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2) == (ba3.size() + ba4.size() - + ba2.size())); - QVERIFY(QByteArray(stringBuf, int(strlen(stringBuf))) == (ba3 + ba4 + ba2)); - QVERIFY(ringBuffer.size() == 0); + QCOMPARE(ringBuffer.readLine(stringBuf, int(sizeof(stringBuf)) - 2), + qint64(ba3.size() + ba4.size() + ba2.size())); + QCOMPARE(QByteArray(stringBuf, int(strlen(stringBuf))), ba3 + ba4 + ba2); + QCOMPARE(ringBuffer.size(), Q_INT64_C(0)); } QTEST_APPLESS_MAIN(tst_QRingBuffer) diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index f13d69514a..ef0ebabd66 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -73,6 +73,7 @@ private slots: void makeSureTheComfortFunctionsCompile(); void initializerList(); void qhash(); + void intersects(); }; struct IdentityTracker { @@ -1030,6 +1031,32 @@ void tst_QSet::qhash() } } +void tst_QSet::intersects() +{ + QSet<int> s1; + QSet<int> s2; + + QVERIFY(!s1.intersects(s1)); + QVERIFY(!s1.intersects(s2)); + + s1 << 100; + QVERIFY(s1.intersects(s1)); + QVERIFY(!s1.intersects(s2)); + + s2 << 200; + QVERIFY(!s1.intersects(s2)); + + s1 << 200; + QVERIFY(s1.intersects(s2)); + + const QtQHashSeedSaver seedSaver(0x10101010); + QSet<int> s3; + s3 << 500; + QVERIFY(!s1.intersects(s3)); + s3 << 200; + QVERIFY(s1.intersects(s3)); +} + QTEST_APPLESS_MAIN(tst_QSet) #include "tst_qset.moc" diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 6d4dbab1fd..745cbbfad3 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -60,11 +60,241 @@ #include <qhash.h> #include <string> +#include <algorithm> #define CREATE_REF(string) \ const QString padded = QString::fromLatin1(" %1 ").arg(string); \ QStringRef ref = padded.midRef(1, padded.size() - 2); +namespace { + +// this wraps an argument to a QString function, as well as how to apply +// the argument to a given QString member function. +template <typename T> +class Arg; + +template <typename T> +class Reversed {}; // marker for Arg<QChar> to apply the operation in reverse order (for prepend()) + +class ArgBase +{ +protected: + QString pinned; + explicit ArgBase(const char *str) + : pinned(QString::fromLatin1(str)) {} +}; + +template <> +class Arg<QChar> : protected ArgBase +{ +public: + explicit Arg(const char *str) : ArgBase(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(ch); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { Q_FOREACH (QChar ch, this->pinned) (s.*mf)(a1, ch); } +}; + +template <> +class Arg<Reversed<QChar> > : private Arg<QChar> +{ +public: + explicit Arg(const char *str) : Arg<QChar>(str) + { + std::reverse(this->pinned.begin(), this->pinned.end()); + } + + using Arg<QChar>::apply0; + using Arg<QChar>::apply1; +}; + +template <> +class Arg<QString> : ArgBase +{ +public: + explicit Arg(const char *str) : ArgBase(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { (s.*mf)(this->pinned); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { (s.*mf)(a1, this->pinned); } +}; + +template <> +class Arg<QStringRef> : ArgBase +{ + QStringRef ref() const + { return this->pinned.isNull() ? QStringRef() : this->pinned.midRef(0) ; } +public: + explicit Arg(const char *str) : ArgBase(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { (s.*mf)(ref()); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { (s.*mf)(a1, ref()); } +}; + +template <> +class Arg<QPair<const QChar *, int> > : ArgBase +{ +public: + explicit Arg(const char *str) : ArgBase(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { (s.*mf)(this->pinned.constData(), this->pinned.length()); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { (s.*mf)(a1, this->pinned.constData(), this->pinned.length()); } +}; + +template <> +class Arg<QLatin1String> +{ + QLatin1String l1; +public: + explicit Arg(const char *str) : l1(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { (s.*mf)(l1); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { (s.*mf)(a1, l1); } +}; + +template <> +class Arg<char> +{ +protected: + const char *str; +public: + explicit Arg(const char *str) : str(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { + if (str) { + for (const char *it = str; *it; ++it) + (s.*mf)(*it); + } + } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { + if (str) { + for (const char *it = str; *it; ++it) + (s.*mf)(a1, *it); + } + } +}; + +template <> +class Arg<Reversed<char> > : private Arg<char> +{ + static const char *dupAndReverse(const char *s) + { + char *s2 = qstrdup(s); + std::reverse(s2, s2 + qstrlen(s2)); + return s2; + } +public: + explicit Arg(const char *str) : Arg<char>(dupAndReverse(str)) {} + ~Arg() { delete[] str; } + + using Arg<char>::apply0; + using Arg<char>::apply1; +}; + +template <> +class Arg<const char*> +{ + const char *str; +public: + explicit Arg(const char *str) : str(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { (s.*mf)(str); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { (s.*mf)(a1, str); } +}; + +template <> +class Arg<QByteArray> +{ + QByteArray ba; +public: + explicit Arg(const char *str) : ba(str) {} + + template <typename MemFun> + void apply0(QString &s, MemFun mf) const + { (s.*mf)(ba); } + + template <typename MemFun, typename A1> + void apply1(QString &s, MemFun mf, A1 a1) const + { (s.*mf)(a1, ba); } +}; + +// const char* is not allowed as columns in data-driven tests (causes static_assert failure), +// so wrap it in a container (default ctor is a QMetaType/QVariant requirement): +class CharStarContainer +{ + const char *str; +public: + explicit Q_DECL_CONSTEXPR CharStarContainer(const char *s = Q_NULLPTR) : str(s) {} + Q_DECL_CONSTEXPR operator const char *() const { return str; } +}; + +} // unnamed namespace + +Q_DECLARE_METATYPE(CharStarContainer) + +// implementation helpers for append_impl/prepend_impl etc +template <typename ArgType, typename MemFun> +static void do_apply0(MemFun mf) +{ + QFETCH(QString, s); + QFETCH(CharStarContainer, arg); + QFETCH(QString, expected); + + Arg<ArgType>(arg).apply0(s, mf); + + QCOMPARE(s, expected); + QCOMPARE(s.isEmpty(), expected.isEmpty()); + QCOMPARE(s.isNull(), expected.isNull()); +} + +template <typename ArgType, typename A1, typename MemFun> +static void do_apply1(MemFun mf) +{ + QFETCH(QString, s); + QFETCH(CharStarContainer, arg); + QFETCH(A1, a1); + QFETCH(QString, expected); + + Arg<ArgType>(arg).apply1(s, mf, a1); + + QCOMPARE(s, expected); + QCOMPARE(s.isEmpty(), expected.isEmpty()); + QCOMPARE(s.isNull(), expected.isNull()); +} + class tst_QString : public QObject { Q_OBJECT @@ -73,6 +303,27 @@ class tst_QString : public QObject void split_regexp(const QString &string, const QString &pattern, QStringList result); template<typename List> void split(const QString &string, const QString &separator, QStringList result); + + template <typename ArgType, typename MemFun> + void append_impl() const { do_apply0<ArgType>(MemFun(&QString::append)); } + template <typename ArgType> + void append_impl() const { append_impl<ArgType, QString &(QString::*)(const ArgType&)>(); } + void append_data(bool emptyIsNoop = false); + template <typename ArgType, typename MemFun> + void operator_pluseq_impl() const { do_apply0<ArgType>(MemFun(&QString::operator+=)); } + template <typename ArgType> + void operator_pluseq_impl() const { operator_pluseq_impl<ArgType, QString &(QString::*)(const ArgType&)>(); } + void operator_pluseq_data(bool emptyIsNoop = false); + template <typename ArgType, typename MemFun> + void prepend_impl() const { do_apply0<ArgType>(MemFun(&QString::prepend)); } + template <typename ArgType> + void prepend_impl() const { prepend_impl<ArgType, QString &(QString::*)(const ArgType&)>(); } + void prepend_data(bool emptyIsNoop = false); + template <typename ArgType, typename MemFun> + void insert_impl() const { do_apply1<ArgType, int>(MemFun(&QString::insert)); } + template <typename ArgType> + void insert_impl() const { insert_impl<ArgType, QString &(QString::*)(int, const ArgType&)>(); } + void insert_data(bool emptyIsNoop = false); public: tst_QString(); public slots: @@ -121,19 +372,86 @@ private slots: void remove_regexp_data(); void remove_regexp(); void swap(); - void prepend(); - void prepend_bytearray_data(); - void prepend_bytearray(); - void append(); - void append_bytearray_data(); - void append_bytearray(); - void operator_pluseq_bytearray_data(); - void operator_pluseq_bytearray(); + + void prepend_qstring() { prepend_impl<QString>(); } + void prepend_qstring_data() { prepend_data(true); } + void prepend_qstringref() { prepend_impl<QStringRef>(); } + void prepend_qstringref_data() { prepend_data(true); } + void prepend_qlatin1string() { prepend_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); } + void prepend_qlatin1string_data() { prepend_data(true); } + void prepend_qcharstar_int() { prepend_impl<QPair<const QChar *, int>, QString &(QString::*)(const QChar *, int)>(); } + void prepend_qcharstar_int_data() { prepend_data(true); } + void prepend_qchar() { prepend_impl<Reversed<QChar>, QString &(QString::*)(QChar)>(); } + void prepend_qchar_data() { prepend_data(true); } + void prepend_qbytearray() { prepend_impl<QByteArray>(); } + void prepend_qbytearray_data() { prepend_data(true); } + void prepend_char() { prepend_impl<Reversed<char>, QString &(QString::*)(QChar)>(); } + void prepend_char_data() { prepend_data(true); } + void prepend_charstar() { prepend_impl<const char *, QString &(QString::*)(const char *)>(); } + void prepend_charstar_data() { prepend_data(true); } + void prepend_bytearray_special_cases_data(); + void prepend_bytearray_special_cases(); + + void append_qstring() { append_impl<QString>(); } + void append_qstring_data() { append_data(); } + void append_qstringref() { append_impl<QStringRef>(); } + void append_qstringref_data() { append_data(); } + void append_qlatin1string() { append_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); } + void append_qlatin1string_data() { append_data(); } + void append_qcharstar_int() { append_impl<QPair<const QChar *, int>, QString&(QString::*)(const QChar *, int)>(); } + void append_qcharstar_int_data() { append_data(true); } + void append_qchar() { append_impl<QChar, QString &(QString::*)(QChar)>(); } + void append_qchar_data() { append_data(true); } + void append_qbytearray() { append_impl<QByteArray>(); } + void append_qbytearray_data() { append_data(); } + void append_char() { append_impl<char, QString &(QString::*)(QChar)>(); } + void append_char_data() { append_data(true); } + void append_charstar() { append_impl<const char *, QString &(QString::*)(const char *)>(); } + void append_charstar_data() { append_data(); } + void append_special_cases(); + void append_bytearray_special_cases_data(); + void append_bytearray_special_cases(); + + void operator_pluseq_qstring() { operator_pluseq_impl<QString>(); } + void operator_pluseq_qstring_data() { operator_pluseq_data(); } + void operator_pluseq_qstringref() { operator_pluseq_impl<QStringRef>(); } + void operator_pluseq_qstringref_data() { operator_pluseq_data(); } + void operator_pluseq_qlatin1string() { operator_pluseq_impl<QLatin1String, QString &(QString::*)(QLatin1String)>(); } + void operator_pluseq_qlatin1string_data() { operator_pluseq_data(); } + void operator_pluseq_qchar() { operator_pluseq_impl<QChar, QString &(QString::*)(QChar)>(); } + void operator_pluseq_qchar_data() { operator_pluseq_data(true); } + void operator_pluseq_qbytearray() { operator_pluseq_impl<QByteArray>(); } + void operator_pluseq_qbytearray_data() { operator_pluseq_data(); } + void operator_pluseq_char() { operator_pluseq_impl<char, QString &(QString::*)(char)>(); } + void operator_pluseq_char_data() { operator_pluseq_data(true); } + void operator_pluseq_charstar() { operator_pluseq_impl<const char *, QString &(QString::*)(const char *)>(); } + void operator_pluseq_charstar_data() { operator_pluseq_data(); } + void operator_pluseq_bytearray_special_cases_data(); + void operator_pluseq_bytearray_special_cases(); + void operator_eqeq_bytearray_data(); void operator_eqeq_bytearray(); void operator_eqeq_nullstring(); void operator_smaller(); - void insert(); + + void insert_qstring() { insert_impl<QString>(); } + void insert_qstring_data() { insert_data(true); } + void insert_qstringref() { insert_impl<QStringRef>(); } + void insert_qstringref_data() { insert_data(true); } + void insert_qlatin1string() { insert_impl<QLatin1String, QString &(QString::*)(int, QLatin1String)>(); } + void insert_qlatin1string_data() { insert_data(true); } + void insert_qcharstar_int() { insert_impl<QPair<const QChar *, int>, QString &(QString::*)(int, const QChar*, int) >(); } + void insert_qcharstar_int_data() { insert_data(true); } + void insert_qchar() { insert_impl<Reversed<QChar>, QString &(QString::*)(int, QChar)>(); } + void insert_qchar_data() { insert_data(true); } + void insert_qbytearray() { insert_impl<QByteArray>(); } + void insert_qbytearray_data() { insert_data(true); } + void insert_char() { insert_impl<Reversed<char>, QString &(QString::*)(int, QChar)>(); } + void insert_char_data() { insert_data(true); } + void insert_charstar() { insert_impl<const char *, QString &(QString::*)(int, const char*) >(); } + void insert_charstar_data() { insert_data(true); } + void insert_special_cases(); + void simplified_data(); void simplified(); void trimmed(); @@ -183,6 +501,7 @@ private slots: void fromLocal8Bit(); void local8Bit_data(); void local8Bit(); + void nullFromLocal8Bit(); void fromLatin1Roundtrip_data(); void fromLatin1Roundtrip(); void toLatin1Roundtrip_data(); @@ -215,6 +534,7 @@ private slots: void localeAwareCompare_data(); void localeAwareCompare(); #endif + void reverseIterators(); void split_data(); void split(); void split_regexp_data(); @@ -827,7 +1147,7 @@ void tst_QString::constructorQByteArray_data() ba1[5] = 'e'; ba1[6] = 'f'; - QTest::newRow( "2" ) << ba1 << QString("abc"); + QTest::newRow( "2" ) << ba1 << QStringLiteral("abc\0def"); QTest::newRow( "3" ) << QByteArray::fromRawData("abcd", 3) << QString("abc"); QTest::newRow( "4" ) << QByteArray("\xc3\xa9") << QString("\xc3\xa9"); @@ -848,12 +1168,6 @@ void tst_QString::constructorQByteArray() QCOMPARE( strBA, expected ); // test operator= too - if (src.constData()[src.length()] == '\0') { - str1.clear(); - str1 = src.constData(); - QCOMPARE( str1, expected ); - } - strBA.clear(); strBA = src; QCOMPARE( strBA, expected ); @@ -2066,7 +2380,46 @@ void tst_QString::simplified() QCOMPARE(qMove(full).simplified(), simple); } -void tst_QString::insert() +void tst_QString::insert_data(bool emptyIsNoop) +{ + QTest::addColumn<QString>("s"); + QTest::addColumn<CharStarContainer>("arg"); + QTest::addColumn<int>("a1"); + QTest::addColumn<QString>("expected"); + + const CharStarContainer nullC; + const CharStarContainer emptyC(""); + const CharStarContainer aC("a"); + const CharStarContainer bC("b"); + //const CharStarContainer abC("ab"); + const CharStarContainer baC("ba"); + + const QString null; + const QString empty(""); + const QString a("a"); + const QString b("b"); + const QString ab("ab"); + const QString ba("ba"); + + QTest::newRow("null.insert(0, null)") << null << nullC << 0 << null; + QTest::newRow("null.insert(0, empty)") << null << emptyC << 0 << (emptyIsNoop ? null : empty); + QTest::newRow("null.insert(0, a)") << null << aC << 0 << a; + QTest::newRow("empty.insert(0, null)") << empty << nullC << 0 << empty; + QTest::newRow("empty.insert(0, empty)") << empty << emptyC << 0 << empty; + QTest::newRow("empty.insert(0, a)") << empty << aC << 0 << a; + QTest::newRow("a.insert(0, null)") << a << nullC << 0 << a; + QTest::newRow("a.insert(0, empty)") << a << emptyC << 0 << a; + QTest::newRow("a.insert(0, b)") << a << bC << 0 << ba; + QTest::newRow("a.insert(0, ba)") << a << baC << 0 << (ba + a); + QTest::newRow("a.insert(1, null)") << a << nullC << 1 << a; + QTest::newRow("a.insert(1, empty)") << a << emptyC << 1 << a; + QTest::newRow("a.insert(1, b)") << a << bC << 1 << ab; + QTest::newRow("a.insert(1, ba)") << a << baC << 1 << (a + ba); + QTest::newRow("ba.insert(1, a)") << ba << aC << 1 << (ba + a); + QTest::newRow("ba.insert(2, b)") << ba << bC << 2 << (ba + b); +} + +void tst_QString::insert_special_cases() { QString a; @@ -2097,14 +2450,37 @@ void tst_QString::insert() QCOMPARE(a.insert(0, QLatin1String("a")), QString("aMontreal")); } -void tst_QString::append() +void tst_QString::append_data(bool emptyIsNoop) { - { - QString a; - a = "<>ABCABCABCABC"; - QCOMPARE(a.append(">"),QString("<>ABCABCABCABC>")); - } + QTest::addColumn<QString>("s"); + QTest::addColumn<CharStarContainer>("arg"); + QTest::addColumn<QString>("expected"); + + const CharStarContainer nullC; + const CharStarContainer emptyC(""); + const CharStarContainer aC("a"); + const CharStarContainer bC("b"); + //const CharStarContainer abC("ab"); + const QString null; + const QString empty(""); + const QString a("a"); + //const QString b("b"); + const QString ab("ab"); + + QTest::newRow("null + null") << null << nullC << null; + QTest::newRow("null + empty") << null << emptyC << (emptyIsNoop ? null : empty); + QTest::newRow("null + a") << null << aC << a; + QTest::newRow("empty + null") << empty << nullC << empty; + QTest::newRow("empty + empty") << empty << emptyC << empty; + QTest::newRow("empty + a") << empty << aC << a; + QTest::newRow("a + null") << a << nullC << a; + QTest::newRow("a + empty") << a << emptyC << a; + QTest::newRow("a + b") << a << bC << ab; +} + +void tst_QString::append_special_cases() +{ { QString a; static const QChar unicode[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!' }; @@ -2124,7 +2500,7 @@ void tst_QString::append() } } -void tst_QString::append_bytearray_data() +void tst_QString::append_bytearray_special_cases_data() { QTest::addColumn<QString>("str" ); QTest::addColumn<QByteArray>("ba" ); @@ -2158,7 +2534,7 @@ void tst_QString::append_bytearray_data() QTest::newRow( "nonAsciiByteArray2") << QString() << QByteArray("\xc3\xa9") << QString::fromUtf8("\xc3\xa9"); } -void tst_QString::append_bytearray() +void tst_QString::append_bytearray_special_cases() { { QFETCH( QString, str ); @@ -2176,22 +2552,19 @@ void tst_QString::append_bytearray() QTEST( str, "res" ); } +} - QFETCH( QByteArray, ba ); - if (ba.constData()[ba.length()] == '\0') { - QFETCH( QString, str ); - - str.append(ba.constData()); - QTEST( str, "res" ); - } +void tst_QString::operator_pluseq_data(bool emptyIsNoop) +{ + append_data(emptyIsNoop); } -void tst_QString::operator_pluseq_bytearray_data() +void tst_QString::operator_pluseq_bytearray_special_cases_data() { - append_bytearray_data(); + append_bytearray_special_cases_data(); } -void tst_QString::operator_pluseq_bytearray() +void tst_QString::operator_pluseq_bytearray_special_cases() { { QFETCH( QString, str ); @@ -2209,14 +2582,6 @@ void tst_QString::operator_pluseq_bytearray() QTEST( str, "res" ); } - - QFETCH( QByteArray, ba ); - if (ba.constData()[ba.length()] == '\0') { - QFETCH( QString, str ); - - str += ba.constData(); - QTEST( str, "res" ); - } } void tst_QString::operator_eqeq_bytearray_data() @@ -2231,11 +2596,6 @@ void tst_QString::operator_eqeq_bytearray() QVERIFY(expected == src); QVERIFY(!(expected != src)); - - if (src.constData()[src.length()] == '\0') { - QVERIFY(expected == src.constData()); - QVERIFY(!(expected != src.constData())); - } } void tst_QString::swap() @@ -2248,14 +2608,37 @@ void tst_QString::swap() QCOMPARE(s2,QLatin1String("s1")); } -void tst_QString::prepend() +void tst_QString::prepend_data(bool emptyIsNoop) { - QString a; - a = "<>ABCABCABCABC>"; - QCOMPARE(a.prepend("-"),(QString)"-<>ABCABCABCABC>"); + QTest::addColumn<QString>("s"); + QTest::addColumn<CharStarContainer>("arg"); + QTest::addColumn<QString>("expected"); + + const CharStarContainer nullC; + const CharStarContainer emptyC(""); + const CharStarContainer aC("a"); + const CharStarContainer bC("b"); + const CharStarContainer baC("ba"); + + const QString null; + const QString empty(""); + const QString a("a"); + //const QString b("b"); + const QString ba("ba"); + + QTest::newRow("null.prepend(null)") << null << nullC << null; + QTest::newRow("null.prepend(empty)") << null << emptyC << (emptyIsNoop ? null : empty); + QTest::newRow("null.prepend(a)") << null << aC << a; + QTest::newRow("empty.prepend(null)") << empty << nullC << empty; + QTest::newRow("empty.prepend(empty)") << empty << emptyC << empty; + QTest::newRow("empty.prepend(a)") << empty << aC << a; + QTest::newRow("a.prepend(null)") << a << nullC << a; + QTest::newRow("a.prepend(empty)") << a << emptyC << a; + QTest::newRow("a.prepend(b)") << a << bC << ba; + QTest::newRow("a.prepend(ba)") << a << baC << (ba + a); } -void tst_QString::prepend_bytearray_data() +void tst_QString::prepend_bytearray_special_cases_data() { QTest::addColumn<QString>("str" ); QTest::addColumn<QByteArray>("ba" ); @@ -2270,7 +2653,7 @@ void tst_QString::prepend_bytearray_data() // byte array with only a 0 ba.resize( 1 ); ba[0] = 0; - QTest::newRow( "emptyString" ) << QString("foobar ") << ba << QString("foobar "); + QTest::newRow( "emptyString" ) << QString("foobar ") << ba << QStringLiteral("\0foobar "); // empty byte array ba.resize( 0 ); @@ -2281,7 +2664,7 @@ void tst_QString::prepend_bytearray_data() QTest::newRow( "nonAsciiByteArray2") << QString() << QByteArray("\xc3\xa9") << QString::fromUtf8("\xc3\xa9"); } -void tst_QString::prepend_bytearray() +void tst_QString::prepend_bytearray_special_cases() { { QFETCH( QString, str ); @@ -2300,14 +2683,6 @@ void tst_QString::prepend_bytearray() QTEST( str, "res" ); } - - QFETCH( QByteArray, ba ); - if (ba.constData()[ba.length()] == '\0') { - QFETCH( QString, str ); - - str.prepend(ba.constData()); - QTEST( str, "res" ); - } } void tst_QString::replace_uint_uint() @@ -3697,6 +4072,12 @@ void tst_QString::nullFromUtf8() a = QString::fromUtf8(""); QVERIFY(!a.isNull()); QVERIFY(a.isEmpty()); + a = QString::fromUtf8(QByteArray()); + QVERIFY(a.isNull()); + QVERIFY(a.isEmpty()); + a = QString::fromUtf8(QByteArray("")); + QVERIFY(!a.isNull()); + QVERIFY(a.isEmpty()); } void tst_QString::fromLocal8Bit_data() @@ -3779,6 +4160,23 @@ void tst_QString::local8Bit() QCOMPARE(local8Bit.toLocal8Bit(), QByteArray(result)); } +void tst_QString::nullFromLocal8Bit() +{ + QString a; + a = QString::fromLocal8Bit(0); + QVERIFY(a.isNull()); + QVERIFY(a.isEmpty()); + a = QString::fromLocal8Bit(""); + QVERIFY(!a.isNull()); + QVERIFY(a.isEmpty()); + a = QString::fromLocal8Bit(QByteArray()); + QVERIFY(a.isNull()); + QVERIFY(a.isEmpty()); + a = QString::fromLocal8Bit(QByteArray("")); + QVERIFY(!a.isNull()); + QVERIFY(a.isEmpty()); +} + void tst_QString::stringRef_local8Bit_data() { local8Bit_data(); @@ -3945,6 +4343,12 @@ void tst_QString::fromLatin1() a = QString::fromLatin1( "" ); QVERIFY( !a.isNull() ); QVERIFY( a.isEmpty() ); + a = QString::fromLatin1(QByteArray()); + QVERIFY(a.isNull()); + QVERIFY(a.isEmpty()); + a = QString::fromLatin1(QByteArray("")); + QVERIFY(!a.isNull()); + QVERIFY(a.isEmpty()); a = QString::fromLatin1(0, 0); QVERIFY(a.isNull()); @@ -4996,6 +5400,20 @@ void tst_QString::localeAwareCompare() } #endif //!defined(Q_OS_WIN) || defined(Q_OS_WIN_AND_WINCE) +void tst_QString::reverseIterators() +{ + QString s = "1234"; + QString sr = s; + std::reverse(sr.begin(), sr.end()); + const QString &csr = sr; + QVERIFY(std::equal(s.begin(), s.end(), sr.rbegin())); + QVERIFY(std::equal(s.begin(), s.end(), sr.crbegin())); + QVERIFY(std::equal(s.begin(), s.end(), csr.rbegin())); + QVERIFY(std::equal(sr.rbegin(), sr.rend(), s.begin())); + QVERIFY(std::equal(sr.crbegin(), sr.crend(), s.begin())); + QVERIFY(std::equal(csr.rbegin(), csr.rend(), s.begin())); +} + void tst_QString::split_data() { QTest::addColumn<QString>("str"); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm index f4b748e62a..550f835bea 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm +++ b/tests/auto/corelib/tools/qstring/tst_qstring_mac.mm @@ -55,23 +55,19 @@ void tst_QString_macTypes() } // QString <-> NSString { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QString qtString("test string"); const NSString *nsString = qtString.toNSString(); QCOMPARE(QString::fromNSString(nsString), qtString); - - [pool release]; } { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool pool; QString qtString("test string"); const NSString *nsString = qtString.toNSString(); QString qtStringCopy(qtString); qtString = qtString.toUpper(); // modify QCOMPARE(QString::fromNSString(nsString), qtStringCopy); - - [pool release]; } } diff --git a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp index 7fc855a359..82d103c460 100644 --- a/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp +++ b/tests/auto/corelib/tools/qstringref/tst_qstringref.cpp @@ -82,6 +82,7 @@ private slots: void integer_conversion_data(); void integer_conversion(); void trimmed(); + void truncate(); void left(); void right(); void mid(); @@ -1839,6 +1840,30 @@ void tst_QStringRef::trimmed() QCOMPARE(b.trimmed().compare(QStringLiteral("a")), 0); } +void tst_QStringRef::truncate() +{ + const QString str = "OriginalString~"; + const QStringRef cref = str.midRef(0); + { + QStringRef ref = cref; + ref.truncate(1000); + QCOMPARE(ref, cref); + for (int i = str.size(); i >= 0; --i) { + ref.truncate(i); + QCOMPARE(ref.size(), i); + QCOMPARE(ref, cref.left(i)); + } + QVERIFY(ref.isEmpty()); + } + + { + QStringRef ref = cref; + QVERIFY(!ref.isEmpty()); + ref.truncate(-1); + QVERIFY(ref.isEmpty()); + } +} + void tst_QStringRef::left() { QString originalString = "OrginalString~"; diff --git a/tests/auto/corelib/tools/qtimeline/BLACKLIST b/tests/auto/corelib/tools/qtimeline/BLACKLIST new file mode 100644 index 0000000000..b5861756d8 --- /dev/null +++ b/tests/auto/corelib/tools/qtimeline/BLACKLIST @@ -0,0 +1,4 @@ +[interpolation] +windows +[duration] +windows diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index 975ed129fc..507f7e3992 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -208,7 +208,7 @@ void tst_QTimeLine::frameRate() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QVERIFY(slowCount < spy.count()); + QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count())); } void tst_QTimeLine::value() diff --git a/tests/auto/corelib/tools/qtimezone/BLACKLIST b/tests/auto/corelib/tools/qtimezone/BLACKLIST new file mode 100644 index 0000000000..665e78bc08 --- /dev/null +++ b/tests/auto/corelib/tools/qtimezone/BLACKLIST @@ -0,0 +1,2 @@ +[tzTest] +opensuse-13.1 diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 94d81e0a5a..82f78b2b0b 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -47,10 +47,12 @@ private slots: void appendCausingRealloc(); void resize(); void realloc(); + void reverseIterators(); void count(); void first(); void last(); void squeeze(); + void operators(); void indexOf(); void lastIndexOf(); void contains(); @@ -563,6 +565,21 @@ void tst_QVarLengthArray::realloc() QVERIFY(reallocTestProceed); } +void tst_QVarLengthArray::reverseIterators() +{ + QVarLengthArray<int> v; + v << 1 << 2 << 3 << 4; + QVarLengthArray<int> vr = v; + std::reverse(vr.begin(), vr.end()); + const QVarLengthArray<int> &cvr = vr; + QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin())); + QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin())); + QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin())); + QVERIFY(std::equal(vr.rbegin(), vr.rend(), v.begin())); + QVERIFY(std::equal(vr.crbegin(), vr.crend(), v.begin())); + QVERIFY(std::equal(cvr.rbegin(), cvr.rend(), v.begin())); +} + void tst_QVarLengthArray::count() { // tests size(), count() and length(), since they're the same thing @@ -691,6 +708,49 @@ void tst_QVarLengthArray::squeeze() QCOMPARE(list.capacity(), sizeOnHeap); } +void tst_QVarLengthArray::operators() +{ + QVarLengthArray<QString> myvla; + myvla << "A" << "B" << "C"; + QVarLengthArray<QString> myvlatwo; + myvlatwo << "D" << "E" << "F"; + QVarLengthArray<QString> combined; + combined << "A" << "B" << "C" << "D" << "E" << "F"; + + // != + QVERIFY(myvla != myvlatwo); + + // +=: not provided, emulate + //myvla += myvlatwo; + Q_FOREACH (const QString &s, myvlatwo) + myvla.push_back(s); + QCOMPARE(myvla, combined); + + // == + QVERIFY(myvla == combined); + + // <, >, <=, >= + QVERIFY(!(myvla < combined)); + QVERIFY(!(myvla > combined)); + QVERIFY( myvla <= combined); + QVERIFY( myvla >= combined); + combined.push_back("G"); + QVERIFY( myvla < combined); + QVERIFY(!(myvla > combined)); + QVERIFY( myvla <= combined); + QVERIFY(!(myvla >= combined)); + QVERIFY(combined > myvla); + QVERIFY(combined >= myvla); + + // [] + QCOMPARE(myvla[0], QLatin1String("A")); + QCOMPARE(myvla[1], QLatin1String("B")); + QCOMPARE(myvla[2], QLatin1String("C")); + QCOMPARE(myvla[3], QLatin1String("D")); + QCOMPARE(myvla[4], QLatin1String("E")); + QCOMPARE(myvla[5], QLatin1String("F")); +} + void tst_QVarLengthArray::indexOf() { QVarLengthArray<QString> myvec; diff --git a/tests/auto/corelib/tools/qvector/qvector.pro b/tests/auto/corelib/tools/qvector/qvector.pro index 22edde3412..c1e0564915 100644 --- a/tests/auto/corelib/tools/qvector/qvector.pro +++ b/tests/auto/corelib/tools/qvector/qvector.pro @@ -1,4 +1,5 @@ CONFIG += testcase parallel_test +contains(QT_CONFIG, c++11):CONFIG += c++11 TARGET = tst_qvector QT = core testlib SOURCES = $$PWD/tst_qvector.cpp diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 69da6e450e..87822bca6f 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -86,6 +86,8 @@ private: } }; +inline uint qHash(const Movable &key, uint seed = 0) { return qHash(key.i, seed); } + QAtomicInt Movable::counter = 0; QT_BEGIN_NAMESPACE Q_DECLARE_TYPEINFO(Movable, Q_MOVABLE_TYPE); @@ -123,6 +125,13 @@ struct Custom { return i == other.i; } + bool operator<(const Custom &other) const + { + check(&other); + check(this); + return i < other.i; + } + Custom &operator=(const Custom &other) { check(&other); @@ -148,6 +157,8 @@ private: }; QAtomicInt Custom::counter = 0; +inline uint qHash(const Custom &key, uint seed = 0) { return qHash(key.i, seed); } + Q_DECLARE_METATYPE(Custom); // tests depends on the fact that: @@ -179,6 +190,7 @@ private slots: void appendInt() const; void appendMovable() const; void appendCustom() const; + void appendRvalue() const; void at() const; void capacityInt() const; void capacityMovable() const; @@ -187,6 +199,8 @@ private slots: void clearMovable() const; void clearCustom() const; void constData() const; + void constFirst() const; + void constLast() const; void contains() const; void countInt() const; void countMovable() const; @@ -227,9 +241,15 @@ private slots: void last() const; void lastIndexOf() const; void mid() const; + void moveInt() const; + void moveMovable() const; + void moveCustom() const; void prependInt() const; void prependMovable() const; void prependCustom() const; + void qhashInt() const { qhash<int>(); } + void qhashMovable() const { qhash<Movable>(); } + void qhashCustom() const { qhash<Custom>(); } void removeInt() const; void removeMovable() const; void removeCustom() const; @@ -241,6 +261,7 @@ private slots: void resizeComplex_data() const; void resizeComplex() const; void resizeCtorAndDtor() const; + void reverseIterators() const; void sizeInt() const; void sizeMovable() const; void sizeCustom() const; @@ -294,6 +315,8 @@ private: template<typename T> void fill() const; template<typename T> void fromList() const; template<typename T> void insert() const; + template<typename T> void qhash() const; + template<typename T> void move() const; template<typename T> void prepend() const; template<typename T> void remove() const; template<typename T> void size() const; @@ -332,6 +355,14 @@ const Movable SimpleValue<Movable>::Values[] = { 110, 105, 101, 114, 111, 98 }; template<> const Custom SimpleValue<Custom>::Values[] = { 110, 105, 101, 114, 111, 98 }; +// Make some macros for the tests to use in order to be slightly more readable... +#define T_FOO SimpleValue<T>::at(0) +#define T_BAR SimpleValue<T>::at(1) +#define T_BAZ SimpleValue<T>::at(2) +#define T_CAT SimpleValue<T>::at(3) +#define T_DOG SimpleValue<T>::at(4) +#define T_BLAH SimpleValue<T>::at(5) + void tst_QVector::constructors_empty() const { QVector<int> emptyInt; @@ -608,6 +639,21 @@ void tst_QVector::appendCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +void tst_QVector::appendRvalue() const +{ +#ifdef Q_COMPILER_RVALUE_REFS + QVector<QString> v; + v.append("hello"); + QString world = "world"; + v.append(std::move(world)); + QVERIFY(world.isEmpty()); + QCOMPARE(v.front(), QString("hello")); + QCOMPARE(v.back(), QString("world")); +#else + QSKIP("This test requires that C++11 move semantics support is enabled in the compiler"); +#endif +} + void tst_QVector::at() const { QVector<QString> myvec; @@ -1206,16 +1252,86 @@ void tst_QVector::first() const // test it starts ok QCOMPARE(myvec.first(), 69); + QCOMPARE(myvec.constFirst(), 69); // test removal changes myvec.remove(0); QCOMPARE(myvec.first(), 42); + QCOMPARE(myvec.constFirst(), 42); // test prepend changes myvec.prepend(23); QCOMPARE(myvec.first(), 23); + QCOMPARE(myvec.constFirst(), 23); +} + +void tst_QVector::constFirst() const +{ + QVector<int> myvec; + myvec << 69 << 42 << 3; + + // test it starts ok + QCOMPARE(myvec.constFirst(), 69); + QVERIFY(myvec.isDetached()); + + QVector<int> myvecCopy = myvec; + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + QCOMPARE(myvec.constFirst(), 69); + QCOMPARE(myvecCopy.constFirst(), 69); + + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + // test removal changes + myvec.remove(0); + QVERIFY(myvec.isDetached()); + QVERIFY(!myvec.isSharedWith(myvecCopy)); + QCOMPARE(myvec.constFirst(), 42); + QCOMPARE(myvecCopy.constFirst(), 69); + + myvecCopy = myvec; + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + QCOMPARE(myvec.constFirst(), 42); + QCOMPARE(myvecCopy.constFirst(), 42); + + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + // test prepend changes + myvec.prepend(23); + QVERIFY(myvec.isDetached()); + QVERIFY(!myvec.isSharedWith(myvecCopy)); + QCOMPARE(myvec.constFirst(), 23); + QCOMPARE(myvecCopy.constFirst(), 42); + + myvecCopy = myvec; + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + QCOMPARE(myvec.constFirst(), 23); + QCOMPARE(myvecCopy.constFirst(), 23); + + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); } + template<typename T> void tst_QVector::fromList() const { @@ -1393,14 +1509,83 @@ void tst_QVector::last() const // test starts ok QCOMPARE(myvec.last(), QLatin1String("C")); + QCOMPARE(myvec.constLast(), QLatin1String("C")); // test it changes ok myvec.append(QLatin1String("X")); QCOMPARE(myvec.last(), QLatin1String("X")); + QCOMPARE(myvec.constLast(), QLatin1String("X")); // and remove again myvec.remove(3); QCOMPARE(myvec.last(), QLatin1String("C")); + QCOMPARE(myvec.constLast(), QLatin1String("C")); +} + +void tst_QVector::constLast() const +{ + QVector<int> myvec; + myvec << 69 << 42 << 3; + + // test it starts ok + QCOMPARE(myvec.constLast(), 3); + QVERIFY(myvec.isDetached()); + + QVector<int> myvecCopy = myvec; + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + QCOMPARE(myvec.constLast(), 3); + QCOMPARE(myvecCopy.constLast(), 3); + + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + // test removal changes + myvec.removeLast(); + QVERIFY(myvec.isDetached()); + QVERIFY(!myvec.isSharedWith(myvecCopy)); + QCOMPARE(myvec.constLast(), 42); + QCOMPARE(myvecCopy.constLast(), 3); + + myvecCopy = myvec; + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + QCOMPARE(myvec.constLast(), 42); + QCOMPARE(myvecCopy.constLast(), 42); + + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + // test prepend changes + myvec.append(23); + QVERIFY(myvec.isDetached()); + QVERIFY(!myvec.isSharedWith(myvecCopy)); + QCOMPARE(myvec.constLast(), 23); + QCOMPARE(myvecCopy.constLast(), 42); + + myvecCopy = myvec; + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); + + QCOMPARE(myvec.constLast(), 23); + QCOMPARE(myvecCopy.constLast(), 23); + + QVERIFY(!myvec.isDetached()); + QVERIFY(!myvecCopy.isDetached()); + QVERIFY(myvec.isSharedWith(myvecCopy)); + QVERIFY(myvecCopy.isSharedWith(myvec)); } void tst_QVector::lastIndexOf() const @@ -1437,6 +1622,54 @@ void tst_QVector::mid() const QCOMPARE(list.mid(4), QVector<QString>() << "buck" << "hello" << "kitty"); } +template <typename T> +void tst_QVector::qhash() const +{ + QVector<T> l1, l2; + QCOMPARE(qHash(l1), qHash(l2)); + l1 << SimpleValue<T>::at(0); + l2 << SimpleValue<T>::at(0); + QCOMPARE(qHash(l1), qHash(l2)); +} + +template <typename T> +void tst_QVector::move() const +{ + QVector<T> list; + list << T_FOO << T_BAR << T_BAZ; + + // move an item + list.move(0, list.count() - 1); + QCOMPARE(list, QVector<T>() << T_BAR << T_BAZ << T_FOO); + + // move it back + list.move(list.count() - 1, 0); + QCOMPARE(list, QVector<T>() << T_FOO << T_BAR << T_BAZ); + + // move an item in the middle + list.move(1, 0); + QCOMPARE(list, QVector<T>() << T_BAR << T_FOO << T_BAZ); +} + +void tst_QVector::moveInt() const +{ + move<int>(); +} + +void tst_QVector::moveMovable() const +{ + const int instancesCount = Movable::counter.loadAcquire(); + move<Movable>(); + QCOMPARE(instancesCount, Movable::counter.loadAcquire()); +} + +void tst_QVector::moveCustom() const +{ + const int instancesCount = Custom::counter.loadAcquire(); + move<Custom>(); + QCOMPARE(instancesCount, Custom::counter.loadAcquire()); +} + template<typename T> void tst_QVector::prepend() const { @@ -1907,6 +2140,21 @@ void tst_QVector::resizeCtorAndDtor() const QCOMPARE(Custom::counter.loadAcquire(), items); } +void tst_QVector::reverseIterators() const +{ + QVector<int> v; + v << 1 << 2 << 3 << 4; + QVector<int> vr = v; + std::reverse(vr.begin(), vr.end()); + const QVector<int> &cvr = vr; + QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin())); + QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin())); + QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin())); + QVERIFY(std::equal(vr.rbegin(), vr.rend(), v.begin())); + QVERIFY(std::equal(vr.crbegin(), vr.crend(), v.begin())); + QVERIFY(std::equal(cvr.rbegin(), cvr.rend(), v.begin())); +} + template<typename T> void tst_QVector::size() const { @@ -2076,6 +2324,19 @@ void tst_QVector::testOperators() const // == QVERIFY(myvec == combined); + // <, >, <=, >= + QVERIFY(!(myvec < combined)); + QVERIFY(!(myvec > combined)); + QVERIFY( myvec <= combined); + QVERIFY( myvec >= combined); + combined.push_back("G"); + QVERIFY( myvec < combined); + QVERIFY(!(myvec > combined)); + QVERIFY( myvec <= combined); + QVERIFY(!(myvec >= combined)); + QVERIFY(combined > myvec); + QVERIFY(combined >= myvec); + // [] QCOMPARE(myvec[0], QLatin1String("A")); QCOMPARE(myvec[1], QLatin1String("B")); diff --git a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp index 4202b87b2d..0b8b63a1e8 100644 --- a/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp +++ b/tests/auto/corelib/tools/qversionnumber/tst_qversionnumber.cpp @@ -33,7 +33,7 @@ ****************************************************************************/ #include <QtTest/QtTest> -#include <private/qversionnumber_p.h> +#include <QtCore/qversionnumber.h> class tst_QVersionNumber : public QObject { diff --git a/tests/auto/dbus/qdbusabstractadaptor/BLACKLIST b/tests/auto/dbus/qdbusabstractadaptor/BLACKLIST new file mode 100644 index 0000000000..d3d970f4f4 --- /dev/null +++ b/tests/auto/dbus/qdbusabstractadaptor/BLACKLIST @@ -0,0 +1,2 @@ +[overloadedSignalEmission] +linux diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index 32c228c186..d85e842a23 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -105,6 +105,8 @@ private slots: void sendWithGui(); void sendAsync(); void sendSignal(); + void sendSignalToName(); + void sendSignalToOtherName(); void registerObject_data(); void registerObject(); @@ -189,6 +191,49 @@ void tst_QDBusConnection::sendSignal() QTest::qWait(1000); } +void tst_QDBusConnection::sendSignalToName() +{ + QDBusSpy spy; + + QDBusConnection con = QDBusConnection::sessionBus(); + + con.connect(con.baseService(), "/org/kde/selftest", "org.kde.selftest", "ping", &spy, + SLOT(handlePing(QString))); + + QDBusMessage msg = + QDBusMessage::createTargetedSignal(con.baseService(), "/org/kde/selftest", + "org.kde.selftest", "ping"); + msg << QLatin1String("ping"); + + QVERIFY(con.send(msg)); + + QTest::qWait(1000); + + QCOMPARE(spy.args.count(), 1); + QCOMPARE(spy.args.at(0).toString(), QString("ping")); +} + +void tst_QDBusConnection::sendSignalToOtherName() +{ + QDBusSpy spy; + + QDBusConnection con = QDBusConnection::sessionBus(); + + con.connect(con.baseService(), "/org/kde/selftest", "org.kde.selftest", "ping", &spy, + SLOT(handlePing(QString))); + + QDBusMessage msg = + QDBusMessage::createTargetedSignal("some.other.service", "/org/kde/selftest", + "org.kde.selftest", "ping"); + msg << QLatin1String("ping"); + + QVERIFY(con.send(msg)); + + QTest::qWait(1000); + + QCOMPARE(spy.args.count(), 0); +} + void tst_QDBusConnection::send() { QDBusConnection con = QDBusConnection::sessionBus(); diff --git a/tests/auto/dbus/qdbusmarshall/BLACKLIST b/tests/auto/dbus/qdbusmarshall/BLACKLIST new file mode 100644 index 0000000000..036378d204 --- /dev/null +++ b/tests/auto/dbus/qdbusmarshall/BLACKLIST @@ -0,0 +1,3 @@ +[receiveUnknownType] +ubuntu-14.04 +opensuse-13.1 diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 16314a5dc5..b681f9829a 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -869,7 +869,7 @@ void tst_QDBusMarshall::sendSignalErrors() "signalName"); msg << QVariant::fromValue(QDBusObjectPath()); - QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); msg.setArguments(QVariantList()); @@ -879,19 +879,19 @@ void tst_QDBusMarshall::sendSignalErrors() path.setPath("abc"); msg << QVariant::fromValue(path); - QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid object path passed in arguments"); QVERIFY(!con.send(msg)); QDBusSignature sig; msg.setArguments(QVariantList() << QVariant::fromValue(sig)); - QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); QTest::ignoreMessage(QtWarningMsg, "QDBusSignature: invalid signature \"a\""); sig.setSignature("a"); msg.setArguments(QVariantList()); msg << QVariant::fromValue(sig); - QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal to service \"\" path \"/foo\" interface \"local.interfaceName\" member \"signalName\": Marshalling failed: Invalid signature passed in arguments"); QVERIFY(!con.send(msg)); } @@ -1079,7 +1079,7 @@ static bool canSendUnixFd(DBusConnection *connection) # if DBUS_VERSION-0 >= 0x010400 can_send_type = dbus_connection_can_send_type; # endif -#else +#elif !defined(QT_NO_LIBRARY) // run-time check if the next functions are available can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif diff --git a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp index 63444b61ad..4408729e7c 100644 --- a/tests/auto/dbus/qdbustype/tst_qdbustype.cpp +++ b/tests/auto/dbus/qdbustype/tst_qdbustype.cpp @@ -94,7 +94,11 @@ static void addFixedTypes() // the library recognizes this as valid type first. // The following function was added for Unix FD support, so if it is // present, so is support for Unix FDs. +# ifndef QT_NO_LIBRARY bool supportsUnixFds = qdbus_resolve_conditionally("dbus_connection_can_send_type"); +# else + bool supportsUnixFds = false; +# endif # else bool supportsUnixFds = true; # endif diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 20a08e10a2..9ed3873682 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -75,14 +75,8 @@ private: const QString m_pngImageFileName; const QString m_pngRectFileName; const QString m_sourceFileName; - - const static QIcon staticIcon; }; -// Creating an icon statically should not cause a crash. -// But we do not officially support this. See QTBUG-8666 -const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find"); - bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) { return QImageReader::supportedImageFormats().contains(desiredFormat); @@ -354,10 +348,10 @@ void tst_QIcon::cacheKey() qint64 icon1_key = icon1.cacheKey(); QIcon icon2 = icon1; - QVERIFY(icon2.cacheKey() == icon1.cacheKey()); + QCOMPARE(icon2.cacheKey(), icon1.cacheKey()); icon2.detach(); QVERIFY(icon2.cacheKey() != icon1.cacheKey()); - QVERIFY(icon1.cacheKey() == icon1_key); + QCOMPARE(icon1.cacheKey(), icon1_key); } void tst_QIcon::detach() @@ -374,7 +368,7 @@ void tst_QIcon::detach() img1 = icon1.pixmap(32, 32).toImage(); img2 = icon2.pixmap(32, 32).toImage(); - QVERIFY(img1 == img2); + QCOMPARE(img1, img2); } void tst_QIcon::addFile() @@ -562,7 +556,7 @@ void tst_QIcon::fromTheme() QString firstSearchPath = QLatin1String(":/icons"); QString secondSearchPath = QLatin1String(":/second_icons"); QIcon::setThemeSearchPaths(QStringList() << firstSearchPath << secondSearchPath); - QVERIFY(QIcon::themeSearchPaths().size() == 2); + QCOMPARE(QIcon::themeSearchPaths().size(), 2); QCOMPARE(firstSearchPath, QIcon::themeSearchPaths()[0]); QCOMPARE(secondSearchPath, QIcon::themeSearchPaths()[1]); @@ -599,7 +593,7 @@ void tst_QIcon::fromTheme() // Test non existing icon with fallback noIcon = QIcon::fromTheme("broken-icon", abIcon); - QVERIFY(noIcon.cacheKey() == abIcon.cacheKey()); + QCOMPARE(noIcon.cacheKey(), abIcon.cacheKey()); // Test svg-only icon noIcon = QIcon::fromTheme("svg-icon", abIcon); diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 8286c800c2..08f48abd20 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -478,7 +478,7 @@ void tst_QImage::setAlphaChannel() image.setAlphaChannel(alphaChannel); image = image.convertToFormat(QImage::Format_ARGB32); - QVERIFY(image.format() == QImage::Format_ARGB32); + QCOMPARE(image.format(), QImage::Format_ARGB32); // alpha of 0 becomes black at a=0 due to premultiplication QRgb pixel = alpha == 0 ? 0 : qRgba(red, green, blue, alpha); @@ -1565,12 +1565,12 @@ void tst_QImage::createHeuristicMask() // line 2 QVERIFY(newMask.pixel(0,1) != newMask.pixel(1,1)); - QVERIFY(newMask.pixel(1,1) == newMask.pixel(2,1)); + QCOMPARE(newMask.pixel(1,1), newMask.pixel(2,1)); QVERIFY(newMask.pixel(2,1) != newMask.pixel(3,1)); // line 3 QVERIFY(newMask.pixel(0,2) != newMask.pixel(1,2)); - QVERIFY(newMask.pixel(1,2) == newMask.pixel(2,2)); + QCOMPARE(newMask.pixel(1,2), newMask.pixel(2,2)); QVERIFY(newMask.pixel(2,2) != newMask.pixel(3,2)); } #endif @@ -1581,10 +1581,10 @@ void tst_QImage::cacheKey() qint64 image1_key = image1.cacheKey(); QImage image2 = image1; - QVERIFY(image2.cacheKey() == image1.cacheKey()); + QCOMPARE(image2.cacheKey(), image1.cacheKey()); image2.detach(); QVERIFY(image2.cacheKey() != image1.cacheKey()); - QVERIFY(image1.cacheKey() == image1_key); + QCOMPARE(image1.cacheKey(), image1_key); } void tst_QImage::smoothScale() diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 4b3e2606fd..07b75adae4 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -733,7 +733,7 @@ void tst_QImageReader::gifHandlerBugs() QVERIFY(io.loopCount() != 1); int count=0; for (; io.canRead(); io.read(), ++count) ; - QVERIFY(count == 34); + QCOMPARE(count, 34); } // Task 95166 @@ -810,7 +810,7 @@ void tst_QImageReader::gifImageCount() QVERIFY(io.canRead()); QImage greenFrame = io.read(); - QVERIFY(io.imageCount() == 4); + QCOMPARE(io.imageCount(), 4); QVERIFY(io.canRead()); QImage blueFrame = io.read(); @@ -925,8 +925,8 @@ void tst_QImageReader::gifImageCount() } { QImageReader io(":images/trolltech.gif"); - QVERIFY(io.imageCount() == 34); - QVERIFY(io.size() == QSize(128,64)); + QCOMPARE(io.imageCount(), 34); + QCOMPARE(io.size(), QSize(128,64)); } } diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp index c61c88d1a6..b8c99ca324 100644 --- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp +++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp @@ -188,8 +188,8 @@ void tst_QMovie::jumpToFrame() QMovie movie(QFINDTESTDATA(fileName)); movie.start(); movie.stop(); - QVERIFY(movie.jumpToFrame(-1) == false); - QVERIFY(movie.currentFrameNumber() == 0); + QVERIFY(!movie.jumpToFrame(-1)); + QCOMPARE(movie.currentFrameNumber(), 0); } void tst_QMovie::changeMovieFile() @@ -198,7 +198,7 @@ void tst_QMovie::changeMovieFile() movie.start(); movie.stop(); movie.setFileName(QFINDTESTDATA("animations/trolltech.gif")); - QVERIFY(movie.currentFrameNumber() == -1); + QCOMPARE(movie.currentFrameNumber(), -1); } #ifndef QT_NO_WIDGETS diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 58cc5824bd..67d7e57fd4 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -447,7 +447,7 @@ void tst_QPixmap::scroll() QString fileName = QString(":/images/%1.png").arg(QTest::currentDataTag()); QPixmap output(fileName); - QVERIFY(input.isNull() == output.isNull()); + QCOMPARE(input.isNull(), output.isNull()); QVERIFY(lenientCompare(pixmap, output)); QCOMPARE(exp, exposed); } @@ -713,11 +713,11 @@ void tst_QPixmap::cacheKey() QVERIFY(pixmap1.cacheKey() != pixmap2.cacheKey()); pixmap2 = pixmap1; - QVERIFY(pixmap2.cacheKey() == pixmap1.cacheKey()); + QCOMPARE(pixmap2.cacheKey(), pixmap1.cacheKey()); pixmap2.detach(); QVERIFY(pixmap2.cacheKey() != pixmap1.cacheKey()); - QVERIFY(pixmap1.cacheKey() == pixmap1_key); + QCOMPARE(pixmap1.cacheKey(), pixmap1_key); } // Test drawing a bitmap on a pixmap. @@ -743,7 +743,7 @@ void tst_QPixmap::isNull() { { QPixmap pixmap(1,1); - QVERIFY(pixmap.isNull() == false); + QVERIFY(!pixmap.isNull()); } { QPixmap pixmap(0,0); @@ -783,11 +783,11 @@ void tst_QPixmap::convertFromImageNoDetach() QPixmap pix = QPixmap::fromImage(orig); QImage copy = pix.toImage(); - QVERIFY(copy.format() == screenFormat); + QCOMPARE(copy.format(), screenFormat); const QImage constOrig = orig; const QImage constCopy = copy; - QVERIFY(constOrig.bits() == constCopy.bits()); + QCOMPARE(constOrig.bits(), constCopy.bits()); } void tst_QPixmap::convertFromImageDetach() @@ -821,7 +821,7 @@ void tst_QPixmap::convertFromImageCacheKey() QPixmap pix = QPixmap::fromImage(orig); QImage copy = pix.toImage(); - QVERIFY(copy.format() == screenFormat); + QCOMPARE(copy.format(), screenFormat); QCOMPARE(orig.cacheKey(), pix.cacheKey()); QCOMPARE(copy.cacheKey(), pix.cacheKey()); @@ -1135,9 +1135,9 @@ void tst_QPixmap::copy() void tst_QPixmap::depthOfNullObjects() { QBitmap b1; - QVERIFY(b1.depth() == 0); + QCOMPARE(b1.depth(), 0); QPixmap p4; - QVERIFY(p4.depth() == 0); + QCOMPARE(p4.depth(), 0); } void tst_QPixmap::transformed() @@ -1437,7 +1437,7 @@ void tst_QPixmap::task_246446() { QPixmap pm2(pm); } - QVERIFY(pm.width() == 10); + QCOMPARE(pm.width(), 10); QVERIFY(pm.mask().isNull()); } @@ -1490,14 +1490,14 @@ void tst_QPixmap::loadAsBitmapOrPixmap() // The do the same check for bitmaps.. QBitmap bitmap("temp_image.png"); QVERIFY(!bitmap.isNull()); - QVERIFY(bitmap.depth() == 1); + QCOMPARE(bitmap.depth(), 1); QVERIFY(bitmap.isQBitmap()); bitmap = QBitmap(); ok = bitmap.load("temp_image.png"); QVERIFY(ok); QVERIFY(!bitmap.isNull()); - QVERIFY(bitmap.depth() == 1); + QCOMPARE(bitmap.depth(), 1); QVERIFY(bitmap.isQBitmap()); } diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp index f22aa63112..a3cf66da18 100644 --- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp @@ -111,7 +111,7 @@ void tst_QPixmapCache::setCacheLimit() delete p1; QPixmapCache::setCacheLimit(0); - QVERIFY(QPixmapCache::find("P1") == 0); + QVERIFY(!QPixmapCache::find("P1")); p1 = new QPixmap(2, 3); QPixmapCache::setCacheLimit(1000); @@ -346,12 +346,12 @@ void tst_QPixmapCache::remove() QVERIFY(p1.toImage() == p1.toImage()); // sanity check QPixmapCache::remove("red"); - QVERIFY(QPixmapCache::find("red") == 0); + QVERIFY(!QPixmapCache::find("red")); QPixmapCache::remove("red"); - QVERIFY(QPixmapCache::find("red") == 0); + QVERIFY(!QPixmapCache::find("red")); QPixmapCache::remove("green"); - QVERIFY(QPixmapCache::find("green") == 0); + QVERIFY(!QPixmapCache::find("green")); //The int part of the API QPixmapCache::clear(); @@ -424,7 +424,7 @@ void tst_QPixmapCache::clear() QPixmapCache::clear(); for (int k = 0; k < numberOfKeys; ++k) - QVERIFY(QPixmapCache::find(QString::number(k)) == 0); + QVERIFY(!QPixmapCache::find(QString::number(k))); //The int part of the API QPixmap p2(10, 10); diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index 2448b89296..ff263c166a 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -278,9 +278,12 @@ void tst_QStandardItem::getSetFlags() QVERIFY(item.isCheckable()); QCOMPARE(item.checkState(), Qt::Unchecked); QVERIFY(item.flags() & Qt::ItemIsUserCheckable); - item.setTristate(true); - QVERIFY(item.isTristate()); - QVERIFY(item.flags() & Qt::ItemIsTristate); + item.setUserTristate(true); + QVERIFY(item.isUserTristate()); + QVERIFY(item.flags() & Qt::ItemIsUserTristate); + item.setAutoTristate(true); + QVERIFY(item.isAutoTristate()); + QVERIFY(item.flags() & Qt::ItemIsAutoTristate); #ifndef QT_NO_DRAGANDDROP item.setDragEnabled(true); QVERIFY(item.isDragEnabled()); @@ -306,10 +309,12 @@ void tst_QStandardItem::getSetFlags() item.setCheckable(false); QVERIFY(!item.isCheckable()); QVERIFY(!(item.flags() & Qt::ItemIsUserCheckable)); - QVERIFY(item.isTristate()); - item.setTristate(false); - QVERIFY(!item.isTristate()); - QVERIFY(!(item.flags() & Qt::ItemIsTristate)); + item.setUserTristate(false); + QVERIFY(!item.isUserTristate()); + QVERIFY(!(item.flags() & Qt::ItemIsUserTristate)); + item.setAutoTristate(false); + QVERIFY(!item.isAutoTristate()); + QVERIFY(!(item.flags() & Qt::ItemIsAutoTristate)); #ifndef QT_NO_DRAGANDDROP QVERIFY(item.isDragEnabled()); item.setDragEnabled(false); @@ -325,6 +330,13 @@ void tst_QStandardItem::getSetFlags() item.setCheckState(Qt::Checked); item.setCheckable(true); QCOMPARE(item.checkState(), Qt::Checked); + + // deprecated API + item.setTristate(true); + QVERIFY(item.isTristate()); + QVERIFY(item.flags() & Qt::ItemIsTristate); + item.setTristate(false); + QVERIFY(!(item.flags() & Qt::ItemIsTristate)); } void tst_QStandardItem::getSetRowAndColumnCount() diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 19365bffdd..2ddfdad7e4 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -912,7 +912,7 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents() QGuiApplication app(argc, argv); QVERIFY(QGuiApplication::primaryScreen()); - QVERIFY(QGuiApplication::primaryScreen()->orientation() == testOrientationToSend); + QCOMPARE(QGuiApplication::primaryScreen()->orientation(), testOrientationToSend); QCOMPARE(testReceiver.customEvents, 0); QCoreApplication::sendPostedEvents(&testReceiver); diff --git a/tests/auto/gui/kernel/qguieventloop/BLACKLIST b/tests/auto/gui/kernel/qguieventloop/BLACKLIST new file mode 100644 index 0000000000..688df0192b --- /dev/null +++ b/tests/auto/gui/kernel/qguieventloop/BLACKLIST @@ -0,0 +1,2 @@ +[processEvents] +ubuntu-14.04 diff --git a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp index c37e633d75..1294751224 100644 --- a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp +++ b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp @@ -56,7 +56,7 @@ void tst_QGuiVariantNoApplication::variantWithoutApplication() { QVariant v = QString("red"); - QVERIFY(qvariant_cast<QColor>(v) == QColor(Qt::red)); + QCOMPARE(qvariant_cast<QColor>(v), QColor(Qt::red)); } diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 58c595ad07..0e822ced5b 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -140,13 +140,13 @@ void tst_QGuiVariant::constructor_invalid() QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:")); QVariant variant(static_cast<QVariant::Type>(typeId)); QVERIFY(!variant.isValid()); - QVERIFY(variant.userType() == QMetaType::UnknownType); + QCOMPARE(variant.userType(), int(QMetaType::UnknownType)); } { QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:")); QVariant variant(typeId, /* copy */ 0); QVERIFY(!variant.isValid()); - QVERIFY(variant.userType() == QMetaType::UnknownType); + QCOMPARE(variant.userType(), int(QMetaType::UnknownType)); } } @@ -611,9 +611,9 @@ void tst_QGuiVariant::writeToReadFromDataStream() // the uninitialized float can be NaN (observed on Windows Mobile 5 ARMv4i) float readFloat = qvariant_cast<float>(readVariant); float writtenFloat = qvariant_cast<float>(writeVariant); - QVERIFY(qIsNaN(readFloat) == qIsNaN(writtenFloat)); + QCOMPARE(qIsNaN(readFloat), qIsNaN(writtenFloat)); if (!qIsNaN(readFloat)) - QVERIFY(readFloat == writtenFloat); + QCOMPARE(readFloat, writtenFloat); } break; } @@ -632,7 +632,7 @@ void tst_QGuiVariant::writeToReadFromOldDataStream() dataFileStream.setVersion(QDataStream::Qt_4_9); QVariant readVariant; dataFileStream >> readVariant; - QVERIFY(readVariant.userType() == QMetaType::QPolygonF); + QCOMPARE(readVariant.userType(), int(QMetaType::QPolygonF)); QCOMPARE(testVariant, readVariant); file.close(); } @@ -656,7 +656,7 @@ void tst_QGuiVariant::writeToReadFromOldDataStream() QDataStream readVarData(variantData); readVarData >> dummy; readVarData >> polyData50; - QVERIFY(polyData49 == polyData50); + QCOMPARE(polyData49, polyData50); } } diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index a36e31e2e2..ab17edecb6 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -292,6 +292,9 @@ void tst_qinputmethod::inputMethodAccepted() if (qApp->platformName().toLower() == QLatin1String("wayland")) QSKIP("Wayland: This fails. Figure out why."); + if (qApp->platformName().toLower() == QLatin1String("xcb")) + QSKIP("XCB: depends on dedicated platform context."); + InputItem disabledItem; disabledItem.setEnabled(false); diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp index dcead8bfbf..1fc4967b12 100644 --- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp +++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp @@ -248,7 +248,7 @@ public: GLuint fbo = 0xFFFF; QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *) &fbo); - QVERIFY(fbo == 0); + QCOMPARE(fbo, GLuint(0)); } void paintGL() Q_DECL_OVERRIDE { @@ -272,7 +272,7 @@ public: GLuint fbo = 0xFFFF; QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *) &fbo); - QVERIFY(fbo == 0); + QCOMPARE(fbo, GLuint(0)); } }; diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp index 0d5991ef41..a5f86c6c09 100644 --- a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp +++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp @@ -53,7 +53,7 @@ void tst_QPixelFormat::testOperators() { QPixelFormat first = qPixelFormatRgba(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied); QPixelFormat second = qPixelFormatRgba(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied); - QVERIFY(first == second); + QCOMPARE(first, second); QPixelFormat third = qPixelFormatRgba(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtEnd, QPixelFormat::NotPremultiplied); QVERIFY(first != third); diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index fd3cfd55ff..d754e0b3c3 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -39,33 +39,8 @@ #include <QtWidgets/QWidget> #include <QtTest> #include <qpa/qwindowsysteminterface.h> - -// FIXME: Use static functions of QWindowSystemInterface introduced with HighDPI scaling in 5.6 instead. -static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt) -{ - QWindowSystemInterface::TouchPoint p; - p.id = pt.id(); - p.flags = pt.flags(); - p.normalPosition = pt.normalizedPos(); - p.area = pt.screenRect(); - p.pressure = pt.pressure(); - p.state = pt.state(); - p.velocity = pt.velocity(); - p.rawPositions = pt.rawScreenPositions(); - return p; -} - -static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList) -{ - QList<struct QWindowSystemInterface::TouchPoint> newList; - - Q_FOREACH (QTouchEvent::TouchPoint p, pointList) - { - newList.append(touchPoint(p)); - } - return newList; -} - +#include <qpa/qwindowsysteminterface_p.h> +#include <private/qhighdpiscaling_p.h> class tst_QTouchEventWidget : public QWidget { @@ -622,11 +597,10 @@ void tst_QTouchEvent::basicRawEventTranslation() rawPosList << QPointF(12, 34) << QPointF(56, 78); rawTouchPoint.setRawScreenPositions(rawPosList); const ulong timestamp = 1234; - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - timestamp, - touchScreenDevice, - touchPointList( - QList<QTouchEvent::TouchPoint>() << rawTouchPoint)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); + QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -653,16 +627,16 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect()); QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); QCOMPARE(touchBeginPoint.velocity(), QVector2D()); - QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList); + if (!QHighDpiScaling::isActive()) + QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList); // moving the point should translate to TouchUpdate rawTouchPoint.setState(Qt::TouchPointMoved); rawTouchPoint.setScreenPos(screenPos + delta); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(QList<QTouchEvent::TouchPoint>() << rawTouchPoint)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); @@ -692,10 +666,9 @@ void tst_QTouchEvent::basicRawEventTranslation() rawTouchPoint.setState(Qt::TouchPointReleased); rawTouchPoint.setScreenPos(screenPos + delta + delta); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(QList<QTouchEvent::TouchPoint>() << rawTouchPoint)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); @@ -762,10 +735,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -827,10 +800,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -892,10 +864,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -992,10 +963,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchPadDevice, - touchPointList(rawTouchPoints)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -1058,10 +1029,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchPadDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -1123,10 +1093,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchPadDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -1385,10 +1354,10 @@ void tst_QTouchEvent::deleteInRawEventTranslation() rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); // generate begin events on all widgets, the left widget should die - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(leftWidget.isNull()); QVERIFY(!centerWidget.isNull()); @@ -1398,20 +1367,18 @@ void tst_QTouchEvent::deleteInRawEventTranslation() rawTouchPoints[0].setState(Qt::TouchPointMoved); rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[2].setState(Qt::TouchPointMoved); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); // generate end events on all widget, the right widget should die rawTouchPoints[0].setState(Qt::TouchPointReleased); rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[2].setState(Qt::TouchPointReleased); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); } @@ -1447,6 +1414,8 @@ void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin() void tst_QTouchEvent::touchBeginWithGraphicsWidget() { + if (QHighDpiScaling::isActive()) + QSKIP("Fails when scaling is active"); QGraphicsScene scene; QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); @@ -1605,12 +1574,15 @@ void tst_QTouchEvent::testMultiDevice() QWindowSystemInterface::TouchPoint tp; tp.id = 0; tp.state = Qt::TouchPointPressed; - tp.area = QRectF(120, 120, 20, 20); + const QPoint screenOrigin = w.screen()->geometry().topLeft(); + const QRect area0(120, 120, 20, 20); + tp.area = QHighDpi::toNative(area0, QHighDpiScaling::factor(&w), screenOrigin); pointsOne.append(tp); pointsTwo.append(tp); tp.id = 1; - tp.area = QRectF(140, 140, 20, 20); + const QRect area1(140, 140, 20, 20); + tp.area = QHighDpi::toNative(area1, QHighDpiScaling::factor(&w), screenOrigin); pointsTwo.append(tp); QWindowSystemInterface::handleTouchEvent(&w, deviceOne, pointsOne); @@ -1625,12 +1597,12 @@ void tst_QTouchEvent::testMultiDevice() QCOMPARE(filter.d.value(deviceOne).points.count(), 1); QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); - QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), pointsOne[0].area); + QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), QRectF(area0)); QCOMPARE(filter.d.value(deviceOne).points.at(0).state(), pointsOne[0].state); - QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), pointsTwo[0].area); + QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), QRectF(area0)); QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state); - QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), pointsTwo[1].area); + QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), QRectF(area1)); QCOMPARE(filter.d.value(deviceTwo).points.at(1).state(), pointsTwo[1].state); } diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index d361aa12a6..ccb8c759c6 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -35,6 +35,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformintegration.h> #include <private/qguiapplication_p.h> +#include <private/qhighdpiscaling_p.h> #include <QtGui/QPainter> #include <QtTest/QtTest> @@ -265,6 +266,19 @@ void tst_QWindow::positioning_data() #endif } +// Compare a window position that may go through scaling in the platform plugin with fuzz. +static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz) +{ + return (p1 - p2).manhattanLength() <= fuzz; +} + +static QString msgPointMismatch(const QPoint &p1, const QPoint p2) +{ + QString result; + QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength(); + return result; +} + void tst_QWindow::positioning() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability( @@ -327,21 +341,25 @@ void tst_QWindow::positioning() // if our positioning is actually fully respected by the window manager // test whether it correctly handles frame positioning as well if (originalPos == geometry.topLeft() && (originalMargins.top() != 0 || originalMargins.left() != 0)) { - QPoint framePos = QPlatformScreen::platformScreenForWindow(&window)->availableGeometry().center(); + const QScreen *screen = window.screen(); + const QRect availableGeometry = screen->availableGeometry(); + const QPoint framePos = availableGeometry.center(); window.reset(); const QPoint oldFramePos = window.framePosition(); window.setFramePosition(framePos); QTRY_VERIFY(window.received(QEvent::Move)); - if (window.framePosition() != framePos) { + const int fuzz = int(QHighDpiScaling::factor(&window)); + if (!qFuzzyCompareWindowPosition(window.framePosition(), framePos, fuzz)) { qDebug() << "About to fail auto-test. Here is some additional information:"; qDebug() << "window.framePosition() == " << window.framePosition(); qDebug() << "old frame position == " << oldFramePos; qDebug() << "We received " << window.received(QEvent::Move) << " move events"; qDebug() << "frame positions after each move event:" << window.m_framePositionsOnMove; } - QTRY_COMPARE(framePos, window.framePosition()); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(window.framePosition(), framePos, fuzz), + qPrintable(msgPointMismatch(window.framePosition(), framePos))); QTRY_COMPARE(originalMargins, window.frameMargins()); QCOMPARE(window.position(), window.framePosition() + QPoint(originalMargins.left(), originalMargins.top())); @@ -357,7 +375,8 @@ void tst_QWindow::positioning() void tst_QWindow::positioningDuringMinimized() { // QTBUG-39544, setting a geometry in minimized state should work as well. - if (QGuiApplication::platformName().compare("windows", Qt::CaseInsensitive)) + if (QGuiApplication::platformName().compare("windows", Qt::CaseInsensitive) != 0 + && QGuiApplication::platformName().compare("cocoa", Qt::CaseInsensitive) != 0) QSKIP("Not supported on this platform"); Window window; window.setTitle(QStringLiteral("positioningDuringMinimized")); @@ -418,14 +437,14 @@ void tst_QWindow::platformSurface() QCOMPARE(window.geometry(), geometry); window.create(); - QTRY_VERIFY(window.received(QEvent::PlatformSurface) == 1); - QTRY_VERIFY(window.surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated); + QTRY_COMPARE(window.received(QEvent::PlatformSurface), 1); + QTRY_COMPARE(window.surfaceEventType(), QPlatformSurfaceEvent::SurfaceCreated); QTRY_VERIFY(window.handle() != Q_NULLPTR); window.destroy(); - QTRY_VERIFY(window.received(QEvent::PlatformSurface) == 2); - QTRY_VERIFY(window.surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed); - QTRY_VERIFY(window.handle() == Q_NULLPTR); + QTRY_COMPARE(window.received(QEvent::PlatformSurface), 2); + QTRY_COMPARE(window.surfaceEventType(), QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed); + QTRY_VERIFY(!window.handle()); // Check for synchronous delivery of platform surface events and that the platform // surface always existed upon event delivery @@ -487,7 +506,7 @@ void tst_QWindow::isActive() context.swapBuffers(&window); #endif QTRY_COMPARE(window.received(QEvent::Resize), 1); - QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + QTRY_COMPARE(QGuiApplication::focusWindow(), &window); QVERIFY(window.isActive()); Window child; @@ -499,7 +518,7 @@ void tst_QWindow::isActive() child.requestActivate(); - QTRY_VERIFY(QGuiApplication::focusWindow() == &child); + QTRY_COMPARE(QGuiApplication::focusWindow(), &child); QVERIFY(child.isActive()); // parent shouldn't receive new resize events from child being shown @@ -522,7 +541,7 @@ void tst_QWindow::isActive() QTRY_VERIFY(dialog.isExposed()); QCoreApplication::processEvents(); QTRY_COMPARE(dialog.received(QEvent::Resize), 1); - QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog); + QTRY_COMPARE(QGuiApplication::focusWindow(), &dialog); QVERIFY(dialog.isActive()); // transient child has focus @@ -533,7 +552,7 @@ void tst_QWindow::isActive() window.requestActivate(); - QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + QTRY_COMPARE(QGuiApplication::focusWindow(), &window); QCoreApplication::processEvents(); QTRY_COMPARE(dialog.received(QEvent::FocusOut), 1); QTRY_COMPARE(window.received(QEvent::FocusIn), 2); @@ -654,15 +673,13 @@ void tst_QWindow::testInputEvents() window.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyPress, Qt::Key_A, Qt::NoModifier); - QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier); + QTest::keyClick(&window, Qt::Key_A, Qt::NoModifier); QCoreApplication::processEvents(); QCOMPARE(window.keyPressCode, int(Qt::Key_A)); QCOMPARE(window.keyReleaseCode, int(Qt::Key_A)); QPointF local(12, 34); - QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::NoButton); + QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, local.toPoint()); QCoreApplication::processEvents(); QCOMPARE(window.mousePressButton, int(Qt::LeftButton)); QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton)); @@ -688,15 +705,17 @@ void tst_QWindow::testInputEvents() // Now with null pointer as window. local param should not be utilized: // handleMouseEvent() with tlw == 0 means the event is in global coords only. window.mousePressButton = window.mouseReleaseButton = 0; - QPointF nonWindowGlobal(window.geometry().topRight() + QPoint(200, 50)); // not inside the window - QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::NoButton); + const QPointF nonWindowGlobal(window.geometry().topRight() + QPoint(200, 50)); // not inside the window + const QPointF deviceNonWindowGlobal = QHighDpi::toNativePixels(nonWindowGlobal, window.screen()); + QWindowSystemInterface::handleMouseEvent(0, deviceNonWindowGlobal, deviceNonWindowGlobal, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(0, deviceNonWindowGlobal, deviceNonWindowGlobal, Qt::NoButton); QCoreApplication::processEvents(); QCOMPARE(window.mousePressButton, 0); QCOMPARE(window.mouseReleaseButton, 0); - QPointF windowGlobal = window.mapToGlobal(local.toPoint()); - QWindowSystemInterface::handleMouseEvent(0, windowGlobal, windowGlobal, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(0, windowGlobal, windowGlobal, Qt::NoButton); + const QPointF windowGlobal = window.mapToGlobal(local.toPoint()); + const QPointF deviceWindowGlobal = QHighDpi::toNativePixels(windowGlobal, window.screen()); + QWindowSystemInterface::handleMouseEvent(0, deviceWindowGlobal, deviceWindowGlobal, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(0, deviceWindowGlobal, deviceWindowGlobal, Qt::NoButton); QCoreApplication::processEvents(); QCOMPARE(window.mousePressButton, int(Qt::LeftButton)); QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton)); @@ -718,7 +737,7 @@ void tst_QWindow::touchToMouseTranslation() const QRectF moveArea(105, 108, 4, 4); tp1.id = 1; tp1.state = Qt::TouchPointPressed; - tp1.area = pressArea; + tp1.area = QHighDpi::toNativePixels(pressArea, &window); tp2.id = 2; tp2.state = Qt::TouchPointPressed; points << tp1 << tp2; @@ -729,7 +748,7 @@ void tst_QWindow::touchToMouseTranslation() tp1.state = Qt::TouchPointStationary; tp2.id = 1; tp2.state = Qt::TouchPointMoved; - tp2.area = moveArea; + tp2.area = QHighDpi::toNativePixels(moveArea, &window); points.clear(); points << tp1 << tp2; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); @@ -946,12 +965,15 @@ void tst_QWindow::touchCancelWithTouchToMouse() tp1.id = 1; tp1.state = Qt::TouchPointPressed; - tp1.area = QRect(100, 100, 4, 4); + const QRect area(100, 100, 4, 4); + tp1.area = QHighDpi::toNativePixels(area, &window); points << tp1; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); QCoreApplication::processEvents(); QTRY_COMPARE(window.mousePressButton, int(Qt::LeftButton)); - QTRY_COMPARE(window.mousePressScreenPos, points[0].area.center()); + const int fuzz = 2 * int(QHighDpiScaling::factor(&window)); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(window.mousePressScreenPos.toPoint(), area.center(), fuzz), + qPrintable(msgPointMismatch(window.mousePressScreenPos.toPoint(), area.center()))); // Cancel the touch. Should result in a mouse release for windows that have // have an active touch-to-mouse sequence. @@ -1149,8 +1171,9 @@ void tst_QWindow::mouseEventSequence() ulong timestamp = 0; QPointF local(12, 34); - QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + const QPointF deviceLocal = QHighDpi::toNativePixels(local, &window); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, deviceLocal, deviceLocal, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, deviceLocal, deviceLocal, Qt::NoButton); QCoreApplication::processEvents(); QCOMPARE(window.mousePressedCount, 1); QCOMPARE(window.mouseReleasedCount, 1); @@ -1308,14 +1331,14 @@ void tst_QWindow::inputReentrancy() class TabletTestWindow : public QWindow { public: - TabletTestWindow() : eventType(0) { } + TabletTestWindow() : eventType(QEvent::None) { } void tabletEvent(QTabletEvent *ev) { eventType = ev->type(); eventGlobal = ev->globalPosF(); eventLocal = ev->posF(); eventDevice = ev->device(); } - int eventType; + QEvent::Type eventType; QPointF eventGlobal, eventLocal; int eventDevice; bool eventFilter(QObject *obj, QEvent *ev) { @@ -1337,25 +1360,27 @@ void tst_QWindow::tabletEvents() window.setGeometry(QRect(m_availableTopLeft + QPoint(10, 10), m_testWindowSize)); qGuiApp->installEventFilter(&window); - QPoint local(10, 10); - QPoint global = window.mapToGlobal(local); - QWindowSystemInterface::handleTabletEvent(&window, true, local, global, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); + const QPoint local(10, 10); + const QPoint global = window.mapToGlobal(local); + const QPoint deviceLocal = QHighDpi::toNativeLocalPosition(local, &window); + const QPoint deviceGlobal = QHighDpi::toNativePixels(global, window.screen()); + QWindowSystemInterface::handleTabletEvent(&window, true, deviceLocal, deviceGlobal, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); QCoreApplication::processEvents(); QTRY_VERIFY(window.eventType == QEvent::TabletPress); QTRY_COMPARE(window.eventGlobal.toPoint(), global); QTRY_COMPARE(window.eventLocal.toPoint(), local); - QWindowSystemInterface::handleTabletEvent(&window, false, local, global, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); + QWindowSystemInterface::handleTabletEvent(&window, false, deviceLocal, deviceGlobal, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); QCoreApplication::processEvents(); - QTRY_VERIFY(window.eventType == QEvent::TabletRelease); + QTRY_COMPARE(window.eventType, QEvent::TabletRelease); QWindowSystemInterface::handleTabletEnterProximityEvent(1, 2, 3); QCoreApplication::processEvents(); - QTRY_VERIFY(window.eventType == QEvent::TabletEnterProximity); + QTRY_COMPARE(window.eventType, QEvent::TabletEnterProximity); QTRY_COMPARE(window.eventDevice, 1); QWindowSystemInterface::handleTabletLeaveProximityEvent(1, 2, 3); QCoreApplication::processEvents(); - QTRY_VERIFY(window.eventType == QEvent::TabletLeaveProximity); + QTRY_COMPARE(window.eventType, QEvent::TabletLeaveProximity); QTRY_COMPARE(window.eventDevice, 1); #endif @@ -1703,13 +1728,13 @@ void tst_QWindow::requestUpdate() QCoreApplication::processEvents(); QTRY_VERIFY(window.isExposed()); - QVERIFY(window.received(QEvent::UpdateRequest) == 0); + QCOMPARE(window.received(QEvent::UpdateRequest), 0); window.requestUpdate(); - QTRY_VERIFY(window.received(QEvent::UpdateRequest) == 1); + QTRY_COMPARE(window.received(QEvent::UpdateRequest), 1); window.requestUpdate(); - QTRY_VERIFY(window.received(QEvent::UpdateRequest) == 2); + QTRY_COMPARE(window.received(QEvent::UpdateRequest), 2); } #include <tst_qwindow.moc> diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index e7659a25bd..463322ff2a 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -673,7 +673,7 @@ void tst_QMatrixNxN::compare2x2() QMatrix2x2 m2(uniqueValues2); QMatrix2x2 m3(transposedValues2); - QVERIFY(m1 == m2); + QCOMPARE(m1, m2); QVERIFY(!(m1 != m2)); QVERIFY(m1 != m3); QVERIFY(!(m1 == m3)); @@ -686,7 +686,7 @@ void tst_QMatrixNxN::compare3x3() QMatrix3x3 m2(uniqueValues3); QMatrix3x3 m3(transposedValues3); - QVERIFY(m1 == m2); + QCOMPARE(m1, m2); QVERIFY(!(m1 != m2)); QVERIFY(m1 != m3); QVERIFY(!(m1 == m3)); @@ -699,7 +699,7 @@ void tst_QMatrixNxN::compare4x4() QMatrix4x4 m2(uniqueValues4); QMatrix4x4 m3(transposedValues4); - QVERIFY(m1 == m2); + QCOMPARE(m1, m2); QVERIFY(!(m1 != m2)); QVERIFY(m1 != m3); QVERIFY(!(m1 == m3)); @@ -712,7 +712,7 @@ void tst_QMatrixNxN::compare4x3() QMatrix4x3 m2(uniqueValues4x3); QMatrix4x3 m3(transposedValues3x4); - QVERIFY(m1 == m2); + QCOMPARE(m1, m2); QVERIFY(!(m1 != m2)); QVERIFY(m1 != m3); QVERIFY(!(m1 == m3)); @@ -1858,7 +1858,7 @@ void tst_QMatrixNxN::inverted4x4() if (invertible) QVERIFY(m1.determinant() != 0.0f); else - QVERIFY(m1.determinant() == 0.0f); + QCOMPARE(m1.determinant(), 0.0f); Matrix4 m1alt; memcpy(m1alt.v, (const float *)m1Values, sizeof(m1alt.v)); @@ -1992,7 +1992,7 @@ void tst_QMatrixNxN::scale4x4() if (z == 1.0f) { QMatrix4x4 m2b; m2b.scale(x, y); - QVERIFY(m2b == m2); + QCOMPARE(m2b, m2); } QVector3D v1(2.0f, 3.0f, -4.0f); @@ -2051,7 +2051,7 @@ void tst_QMatrixNxN::scale4x4() if (z == 1.0f) { QMatrix4x4 m4b(m3); m4b.scale(x, y); - QVERIFY(m4b == m4); + QCOMPARE(m4b, m4); } // Test coverage when the special matrix type is unknown. @@ -2138,7 +2138,7 @@ void tst_QMatrixNxN::translate4x4() if (z == 0.0f) { QMatrix4x4 m2b; m2b.translate(x, y); - QVERIFY(m2b == m2); + QCOMPARE(m2b, m2); } QVector3D v1(2.0f, 3.0f, -4.0f); @@ -2179,7 +2179,7 @@ void tst_QMatrixNxN::translate4x4() if (z == 0.0f) { QMatrix4x4 m4b(m3); m4b.translate(x, y); - QVERIFY(m4b == m4); + QCOMPARE(m4b, m4); } } @@ -3073,7 +3073,7 @@ void tst_QMatrixNxN::convertQMatrix() QPointF p2 = m2 * QPointF(100.0, 150.0); QCOMPARE((double)p2.x(), 100.0 - 3.5); QCOMPARE((double)p2.y(), 150.0 + 2.0); - QVERIFY(m1 == m2.toAffine()); + QCOMPARE(m1, m2.toAffine()); QMatrix m3; m3.scale(1.5, -2.0); @@ -3085,7 +3085,7 @@ void tst_QMatrixNxN::convertQMatrix() QPointF p4 = m4 * QPointF(100.0, 150.0); QCOMPARE((double)p4.x(), 1.5 * 100.0); QCOMPARE((double)p4.y(), -2.0 * 150.0); - QVERIFY(m3 == m4.toAffine()); + QCOMPARE(m3, m4.toAffine()); QMatrix m5; m5.rotate(45.0); @@ -3120,7 +3120,7 @@ void tst_QMatrixNxN::convertQTransform() QPointF p2 = m2 * QPointF(100.0, 150.0); QCOMPARE((double)p2.x(), 100.0 - 3.5); QCOMPARE((double)p2.y(), 150.0 + 2.0); - QVERIFY(m1 == m2.toTransform()); + QCOMPARE(m1, m2.toTransform()); QTransform m3; m3.scale(1.5, -2.0); @@ -3132,7 +3132,7 @@ void tst_QMatrixNxN::convertQTransform() QPointF p4 = m4 * QPointF(100.0, 150.0); QCOMPARE((double)p4.x(), 1.5 * 100.0); QCOMPARE((double)p4.y(), -2.0 * 150.0); - QVERIFY(m3 == m4.toTransform()); + QCOMPARE(m3, m4.toTransform()); QTransform m5; m5.rotate(45.0); @@ -3206,16 +3206,16 @@ void tst_QMatrixNxN::mapRect() QRect recti(qRound(x), qRound(y), qRound(width), qRound(height)); QMatrix4x4 m1; - QVERIFY(m1.mapRect(rect) == rect); - QVERIFY(m1.mapRect(recti) == recti); + QCOMPARE(m1.mapRect(rect), rect); + QCOMPARE(m1.mapRect(recti), recti); QMatrix4x4 m2; m2.translate(-100.5f, 64.0f); QRectF translated = rect.translated(-100.5f, 64.0f); QRect translatedi = QRect(qRound(recti.x() - 100.5f), recti.y() + 64, recti.width(), recti.height()); - QVERIFY(m2.mapRect(rect) == translated); - QVERIFY(m2.mapRect(recti) == translatedi); + QCOMPARE(m2.mapRect(rect), translated); + QCOMPARE(m2.mapRect(recti), translatedi); QMatrix4x4 m3; m3.scale(-100.5f, 64.0f); @@ -3232,7 +3232,7 @@ void tst_QMatrixNxN::mapRect() scaley -= scaleht; } QRectF scaled(scalex, scaley, scalewid, scaleht); - QVERIFY(m3.mapRect(rect) == scaled); + QCOMPARE(m3.mapRect(rect), scaled); scalex = recti.x() * -100.5f; scaley = recti.y() * 64.0f; scalewid = recti.width() * -100.5f; @@ -3247,7 +3247,7 @@ void tst_QMatrixNxN::mapRect() } QRect scaledi(qRound(scalex), qRound(scaley), qRound(scalewid), qRound(scaleht)); - QVERIFY(m3.mapRect(recti) == scaledi); + QCOMPARE(m3.mapRect(recti), scaledi); QMatrix4x4 m4; m4.translate(-100.5f, 64.0f); @@ -3261,7 +3261,7 @@ void tst_QMatrixNxN::mapRect() if (transy1 > transy2) qSwap(transy1, transy2); QRectF trans(transx1, transy1, transx2 - transx1, transy2 - transy1); - QVERIFY(m4.mapRect(rect) == trans); + QCOMPARE(m4.mapRect(rect), trans); transx1 = recti.x() * -2.5f - 100.5f; transy1 = recti.y() * 4.0f + 64.0f; transx2 = (recti.x() + recti.width()) * -2.5f - 100.5f; @@ -3273,7 +3273,7 @@ void tst_QMatrixNxN::mapRect() QRect transi(qRound(transx1), qRound(transy1), qRound(transx2) - qRound(transx1), qRound(transy2) - qRound(transy1)); - QVERIFY(m4.mapRect(recti) == transi); + QCOMPARE(m4.mapRect(recti), transi); m4.rotate(45.0f, 0.0f, 0.0f, 1.0f); @@ -3290,7 +3290,7 @@ void tst_QMatrixNxN::mapRect() QRect mri = m4.mapRect(recti); QRect tri = t4.mapRect(recti); - QVERIFY(mri == tri); + QCOMPARE(mri, tri); } void tst_QMatrixNxN::mapVector_data() @@ -3389,14 +3389,14 @@ void tst_QMatrixNxN::properties() void tst_QMatrixNxN::metaTypes() { - QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4); + QCOMPARE(QMetaType::type("QMatrix4x4"), int(QMetaType::QMatrix4x4)); QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)), QByteArray("QMatrix4x4")); QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4)); - QVERIFY(qMetaTypeId<QMatrix4x4>() == QMetaType::QMatrix4x4); + QCOMPARE(qMetaTypeId<QMatrix4x4>(), int(QMetaType::QMatrix4x4)); } QTEST_APPLESS_MAIN(tst_QMatrixNxN) diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp index ec7af97f07..1fbad5b829 100644 --- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp @@ -446,7 +446,7 @@ void tst_QQuaternion::compare() QQuaternion v5(8, 1, 2, 3); QQuaternion v6(3, 1, 2, 4); - QVERIFY(v1 == v2); + QCOMPARE(v1, v2); QVERIFY(v1 != v3); QVERIFY(v1 != v4); QVERIFY(v1 != v5); @@ -522,7 +522,7 @@ void tst_QQuaternion::add() QQuaternion v4(v1); v4 += v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() + v2.x()); QCOMPARE(v4.y(), v1.y() + v2.y()); @@ -560,7 +560,7 @@ void tst_QQuaternion::subtract() QQuaternion v4(v3); v4 -= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() - v1.x()); QCOMPARE(v4.y(), v3.y() - v1.y()); @@ -569,7 +569,7 @@ void tst_QQuaternion::subtract() QQuaternion v5(v3); v5 -= v2; - QVERIFY(v5 == v1); + QCOMPARE(v5, v1); QCOMPARE(v5.x(), v3.x() - v2.x()); QCOMPARE(v5.y(), v3.y() - v2.y()); @@ -704,7 +704,7 @@ void tst_QQuaternion::multiplyFactor() QQuaternion v3(v1); v3 *= factor; - QVERIFY(v3 == v2); + QCOMPARE(v3, v2); QCOMPARE(v3.x(), v1.x() * factor); QCOMPARE(v3.y(), v1.y() * factor); @@ -740,7 +740,7 @@ void tst_QQuaternion::divide() QQuaternion v3(v2); v3 /= factor; - QVERIFY(v3 == v1); + QCOMPARE(v3, v1); QCOMPARE(v3.x(), v2.x() / factor); QCOMPARE(v3.y(), v2.y() / factor); @@ -764,7 +764,7 @@ void tst_QQuaternion::negate() QQuaternion v1(w1, x1, y1, z1); QQuaternion v2(-w1, -x1, -y1, -z1); - QVERIFY(-v1 == v2); + QCOMPARE(-v1, v2); } // Test quaternion conjugate calculations. @@ -783,7 +783,7 @@ void tst_QQuaternion::conjugate() QQuaternion v1(w1, x1, y1, z1); QQuaternion v2(w1, -x1, -y1, -z1); - QVERIFY(v1.conjugate() == v2); + QCOMPARE(v1.conjugate(), v2); } // Test quaternion creation from an axis and an angle. @@ -1325,14 +1325,14 @@ void tst_QQuaternion::properties() void tst_QQuaternion::metaTypes() { - QVERIFY(QMetaType::type("QQuaternion") == QMetaType::QQuaternion); + QCOMPARE(QMetaType::type("QQuaternion"), int(QMetaType::QQuaternion)); QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QQuaternion)), QByteArray("QQuaternion")); QVERIFY(QMetaType::isRegistered(QMetaType::QQuaternion)); - QVERIFY(qMetaTypeId<QQuaternion>() == QMetaType::QQuaternion); + QCOMPARE(qMetaTypeId<QQuaternion>(), int(QMetaType::QQuaternion)); } QTEST_APPLESS_MAIN(tst_QQuaternion) diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index d2e0bbe375..eeff2c3bae 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -885,7 +885,7 @@ void tst_QVectorND::compare2() QVector2D v3(3, 2); QVector2D v4(1, 3); - QVERIFY(v1 == v2); + QCOMPARE(v1, v2); QVERIFY(v1 != v3); QVERIFY(v1 != v4); } @@ -899,7 +899,7 @@ void tst_QVectorND::compare3() QVector3D v4(1, 3, 4); QVector3D v5(1, 2, 3); - QVERIFY(v1 == v2); + QCOMPARE(v1, v2); QVERIFY(v1 != v3); QVERIFY(v1 != v4); QVERIFY(v1 != v5); @@ -915,7 +915,7 @@ void tst_QVectorND::compare4() QVector4D v5(1, 2, 3, 8); QVector4D v6(1, 2, 4, 3); - QVERIFY(v1 == v2); + QCOMPARE(v1, v2); QVERIFY(v1 != v3); QVERIFY(v1 != v4); QVERIFY(v1 != v5); @@ -969,7 +969,7 @@ void tst_QVectorND::add2() QVector2D v4(v1); v4 += v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() + v2.x()); QCOMPARE(v4.y(), v1.y() + v2.y()); @@ -1033,7 +1033,7 @@ void tst_QVectorND::add3() QVector3D v4(v1); v4 += v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() + v2.x()); QCOMPARE(v4.y(), v1.y() + v2.y()); @@ -1109,7 +1109,7 @@ void tst_QVectorND::add4() QVector4D v4(v1); v4 += v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() + v2.x()); QCOMPARE(v4.y(), v1.y() + v2.y()); @@ -1141,14 +1141,14 @@ void tst_QVectorND::subtract2() QVector2D v4(v3); v4 -= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() - v1.x()); QCOMPARE(v4.y(), v3.y() - v1.y()); QVector2D v5(v3); v5 -= v2; - QVERIFY(v5 == v1); + QCOMPARE(v5, v1); QCOMPARE(v5.x(), v3.x() - v2.x()); QCOMPARE(v5.y(), v3.y() - v2.y()); @@ -1181,7 +1181,7 @@ void tst_QVectorND::subtract3() QVector3D v4(v3); v4 -= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() - v1.x()); QCOMPARE(v4.y(), v3.y() - v1.y()); @@ -1189,7 +1189,7 @@ void tst_QVectorND::subtract3() QVector3D v5(v3); v5 -= v2; - QVERIFY(v5 == v1); + QCOMPARE(v5, v1); QCOMPARE(v5.x(), v3.x() - v2.x()); QCOMPARE(v5.y(), v3.y() - v2.y()); @@ -1226,7 +1226,7 @@ void tst_QVectorND::subtract4() QVector4D v4(v3); v4 -= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() - v1.x()); QCOMPARE(v4.y(), v3.y() - v1.y()); @@ -1235,7 +1235,7 @@ void tst_QVectorND::subtract4() QVector4D v5(v3); v5 -= v2; - QVERIFY(v5 == v1); + QCOMPARE(v5, v1); QCOMPARE(v5.x(), v3.x() - v2.x()); QCOMPARE(v5.y(), v3.y() - v2.y()); @@ -1290,7 +1290,7 @@ void tst_QVectorND::multiply2() QVector2D v4(v1); v4 *= v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() * v2.x()); QCOMPARE(v4.y(), v1.y() * v2.y()); @@ -1354,7 +1354,7 @@ void tst_QVectorND::multiply3() QVector3D v4(v1); v4 *= v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() * v2.x()); QCOMPARE(v4.y(), v1.y() * v2.y()); @@ -1430,7 +1430,7 @@ void tst_QVectorND::multiply4() QVector4D v4(v1); v4 *= v2; - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); QCOMPARE(v4.x(), v1.x() * v2.x()); QCOMPARE(v4.y(), v1.y() * v2.y()); @@ -1488,7 +1488,7 @@ void tst_QVectorND::multiplyFactor2() QVector2D v3(v1); v3 *= factor; - QVERIFY(v3 == v2); + QCOMPARE(v3, v2); QCOMPARE(v3.x(), v1.x() * factor); QCOMPARE(v3.y(), v1.y() * factor); @@ -1553,7 +1553,7 @@ void tst_QVectorND::multiplyFactor3() QVector3D v3(v1); v3 *= factor; - QVERIFY(v3 == v2); + QCOMPARE(v3, v2); QCOMPARE(v3.x(), v1.x() * factor); QCOMPARE(v3.y(), v1.y() * factor); @@ -1628,7 +1628,7 @@ void tst_QVectorND::multiplyFactor4() QVector4D v3(v1); v3 *= factor; - QVERIFY(v3 == v2); + QCOMPARE(v3, v2); QCOMPARE(v3.x(), v1.x() * factor); QCOMPARE(v3.y(), v1.y() * factor); @@ -1660,7 +1660,7 @@ void tst_QVectorND::divide2() QVector2D v4(v3); v4 /= v2; - QVERIFY(v4 == v1); + QCOMPARE(v4, v1); QCOMPARE(v4.x(), v3.x() / v2.x()); QCOMPARE(v4.y(), v3.y() / v2.y()); @@ -1670,7 +1670,7 @@ void tst_QVectorND::divide2() QVector2D v4(v3); v4 /= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() / v1.x()); QCOMPARE(v4.y(), v3.y() / v1.y()); @@ -1704,7 +1704,7 @@ void tst_QVectorND::divide3() QVector3D v4(v3); v4 /= v2; - QVERIFY(v4 == v1); + QCOMPARE(v4, v1); QCOMPARE(v4.x(), v3.x() / v2.x()); QCOMPARE(v4.y(), v3.y() / v2.y()); @@ -1715,7 +1715,7 @@ void tst_QVectorND::divide3() QVector3D v4(v3); v4 /= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() / v1.x()); QCOMPARE(v4.y(), v3.y() / v1.y()); @@ -1753,7 +1753,7 @@ void tst_QVectorND::divide4() QVector4D v4(v3); v4 /= v2; - QVERIFY(v4 == v1); + QCOMPARE(v4, v1); QCOMPARE(v4.x(), v3.x() / v2.x()); QCOMPARE(v4.y(), v3.y() / v2.y()); @@ -1765,7 +1765,7 @@ void tst_QVectorND::divide4() QVector4D v4(v3); v4 /= v1; - QVERIFY(v4 == v2); + QCOMPARE(v4, v2); QCOMPARE(v4.x(), v3.x() / v1.x()); QCOMPARE(v4.y(), v3.y() / v1.y()); @@ -1798,7 +1798,7 @@ void tst_QVectorND::divideFactor2() QVector2D v3(v2); v3 /= factor; - QVERIFY(v3 == v1); + QCOMPARE(v3, v1); QCOMPARE(v3.x(), v2.x() / factor); QCOMPARE(v3.y(), v2.y() / factor); @@ -1830,7 +1830,7 @@ void tst_QVectorND::divideFactor3() QVector3D v3(v2); v3 /= factor; - QVERIFY(v3 == v1); + QCOMPARE(v3, v1); QCOMPARE(v3.x(), v2.x() / factor); QCOMPARE(v3.y(), v2.y() / factor); @@ -1865,7 +1865,7 @@ void tst_QVectorND::divideFactor4() QVector4D v3(v2); v3 /= factor; - QVERIFY(v3 == v1); + QCOMPARE(v3, v1); QCOMPARE(v3.x(), v2.x() / factor); QCOMPARE(v3.y(), v2.y() / factor); @@ -1887,7 +1887,7 @@ void tst_QVectorND::negate2() QVector2D v1(x1, y1); QVector2D v2(-x1, -y1); - QVERIFY(-v1 == v2); + QCOMPARE(-v1, v2); } // Test vector negation for 3D vectors. @@ -1905,7 +1905,7 @@ void tst_QVectorND::negate3() QVector3D v1(x1, y1, z1); QVector3D v2(-x1, -y1, -z1); - QVERIFY(-v1 == v2); + QCOMPARE(-v1, v2); } // Test vector negation for 4D vectors. @@ -1924,7 +1924,7 @@ void tst_QVectorND::negate4() QVector4D v1(x1, y1, z1, w1); QVector4D v2(-x1, -y1, -z1, -w1); - QVERIFY(-v1 == v2); + QCOMPARE(-v1, v2); } // Test the computation of vector cross-products. @@ -1976,7 +1976,7 @@ void tst_QVectorND::crossProduct() QVector3D v3(x3, y3, z3); QVector3D v4 = QVector3D::crossProduct(v1, v2); - QVERIFY(v4 == v3); + QCOMPARE(v4, v3); // Compute the cross-product long-hand and check again. float xres = y1 * z2 - z1 * y2; @@ -2667,9 +2667,9 @@ void tst_QVectorND::properties() void tst_QVectorND::metaTypes() { - QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); - QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); - QVERIFY(QMetaType::type("QVector4D") == QMetaType::QVector4D); + QCOMPARE(QMetaType::type("QVector2D"), int(QMetaType::QVector2D)); + QCOMPARE(QMetaType::type("QVector3D"), int(QMetaType::QVector3D)); + QCOMPARE(QMetaType::type("QVector4D"), int(QMetaType::QVector4D)); QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector2D)), QByteArray("QVector2D")); @@ -2682,9 +2682,9 @@ void tst_QVectorND::metaTypes() QVERIFY(QMetaType::isRegistered(QMetaType::QVector3D)); QVERIFY(QMetaType::isRegistered(QMetaType::QVector4D)); - QVERIFY(qMetaTypeId<QVector2D>() == QMetaType::QVector2D); - QVERIFY(qMetaTypeId<QVector3D>() == QMetaType::QVector3D); - QVERIFY(qMetaTypeId<QVector4D>() == QMetaType::QVector4D); + QCOMPARE(qMetaTypeId<QVector2D>(), int(QMetaType::QVector2D)); + QCOMPARE(qMetaTypeId<QVector3D>(), int(QMetaType::QVector3D)); + QCOMPARE(qMetaTypeId<QVector4D>(), int(QMetaType::QVector4D)); } QTEST_APPLESS_MAIN(tst_QVectorND) diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index 4f58178f2c..30982f1e24 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -461,8 +461,8 @@ void tst_QBrush::textureBrushComparison() imageBrush1.setTextureImage(image1); imageBrush2.setTextureImage(image2); - QVERIFY(imageBrush1 == imageBrush2); - QVERIFY(pixmapBrush == imageBrush1); + QCOMPARE(imageBrush1, imageBrush2); + QCOMPARE(pixmapBrush, imageBrush1); } QTEST_MAIN(tst_QBrush) diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 4fafbf9827..b81a4e2c4c 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -39,6 +39,7 @@ #include <qcolor.h> #include <qdebug.h> #include <private/qdrawingprimitive_sse2_p.h> +#include <qrgba64.h> class tst_QColor : public QObject { @@ -105,6 +106,10 @@ private slots: void premultiply(); void unpremultiply_sse4(); + void qrgba64(); + void qrgba64MemoryLayout(); + void qrgba64Premultiply(); + void qrgba64Equivalence(); #ifdef Q_DEAD_CODE_FROM_QT4_X11 void setallowX11ColorNames(); @@ -249,7 +254,7 @@ void tst_QColor::isValid() { QFETCH(QColor, color); QFETCH(bool, isValid); - QVERIFY(color.isValid() == isValid); + QCOMPARE(color.isValid(), isValid); } Q_DECLARE_METATYPE(QColor::NameFormat); @@ -1321,19 +1326,19 @@ void tst_QColor::convertTo() QColor color(Qt::black); QColor rgb = color.convertTo(QColor::Rgb); - QVERIFY(rgb.spec() == QColor::Rgb); + QCOMPARE(rgb.spec(), QColor::Rgb); QColor hsv = color.convertTo(QColor::Hsv); - QVERIFY(hsv.spec() == QColor::Hsv); + QCOMPARE(hsv.spec(), QColor::Hsv); QColor cmyk = color.convertTo(QColor::Cmyk); - QVERIFY(cmyk.spec() == QColor::Cmyk); + QCOMPARE(cmyk.spec(), QColor::Cmyk); QColor hsl = color.convertTo(QColor::Hsl); - QVERIFY(hsl.spec() == QColor::Hsl); + QCOMPARE(hsl.spec(), QColor::Hsl); QColor invalid = color.convertTo(QColor::Invalid); - QVERIFY(invalid.spec() == QColor::Invalid); + QCOMPARE(invalid.spec(), QColor::Invalid); } void tst_QColor::light() @@ -1464,5 +1469,102 @@ void tst_QColor::unpremultiply_sse4() QSKIP("SSE4 not supported on this CPU."); } +void tst_QColor::qrgba64() +{ + QRgba64 rgb64 = QRgba64::fromRgba(0x22, 0x33, 0x44, 0xff); + QCOMPARE(rgb64.red(), quint16(0x2222)); + QCOMPARE(rgb64.green(), quint16(0x3333)); + QCOMPARE(rgb64.blue(), quint16(0x4444)); + QCOMPARE(rgb64.alpha(), quint16(0xffff)); + + QColor c(rgb64); + QCOMPARE(c.red(), 0x22); + QCOMPARE(c.green(), 0x33); + QCOMPARE(c.blue(), 0x44); + + QCOMPARE(c.rgba64(), rgb64); + + QColor c2 = QColor::fromRgb(0x22, 0x33, 0x44, 0xff); + QCOMPARE(c, c2); + QCOMPARE(c2.rgba64(), rgb64); + + rgb64.setAlpha(0x8000); + rgb64.setGreen(0x8844); + rgb64 = rgb64.premultiplied(); + QCOMPARE(rgb64.red(), quint16(0x1111)); + QCOMPARE(rgb64.blue(), quint16(0x2222)); + QCOMPARE(rgb64.green(), quint16(0x4422)); +} + +void tst_QColor::qrgba64MemoryLayout() +{ + QRgba64 rgb64 = QRgba64::fromRgba64(0x0123, 0x4567, 0x89ab, 0xcdef); + QCOMPARE(rgb64.red(), quint16(0x0123)); + QCOMPARE(rgb64.green(), quint16(0x4567)); + QCOMPARE(rgb64.blue(), quint16(0x89ab)); + QCOMPARE(rgb64.alpha(), quint16(0xcdef)); + + // Check in-memory order, so it can be used by things like SSE + Q_STATIC_ASSERT(sizeof(QRgba64) == sizeof(quint64)); + quint16 memory[4]; + memcpy(memory, &rgb64, sizeof(QRgba64)); + QCOMPARE(memory[0], quint16(0x0123)); + QCOMPARE(memory[1], quint16(0x4567)); + QCOMPARE(memory[2], quint16(0x89ab)); + QCOMPARE(memory[3], quint16(0xcdef)); +} + +void tst_QColor::qrgba64Premultiply() +{ + // Tests that qPremultiply(qUnpremultiply(rgba64)) returns rgba64. + for (uint a = 0; a < 0x10000; a+=7) { + const uint step = std::max(a/1024, 1u); + for (uint c = 0; c <= a; c+=step) { + QRgba64 p = qRgba64(c, a-c, a-c/2, a); + QRgba64 pp = qPremultiply(qUnpremultiply(p)); + QCOMPARE(pp, p); + } + } +} + +void tst_QColor::qrgba64Equivalence() +{ + // Any ARGB32 converted back and forth. + for (uint a = 0; a < 256; a++) { + for (uint c = 0; c < 256; c++) { + QRgb p1 = qRgba(c, 255-c, 255-c, a); + QRgba64 p64 = QRgba64::fromArgb32(p1); + QCOMPARE(p64.toArgb32(), p1); + } + } + // Any unpremultiplied ARGB32 value premultipled in RGB64 (except alpha 0). + for (uint a = 1; a < 256; a++) { + for (uint c = 0; c < 256; c++) { + QRgb p1 = qRgba(c, 255-c, 255-c, a); + QRgb pp1 = qPremultiply(p1); + QRgba64 pp64 = qPremultiply(QRgba64::fromArgb32(p1)); + QRgb pp2 = pp64.toArgb32(); + // 64bit premultiplied is more accurate than 32bit, so allow slight difference. + QCOMPARE(qAlpha(pp2), qAlpha(pp1)); + QVERIFY(qAbs(qRed(pp2)-qRed(pp1)) <= 1); + QVERIFY(qAbs(qGreen(pp2)-qGreen(pp1)) <= 1); + QVERIFY(qAbs(qBlue(pp2)-qBlue(pp1)) <= 1); + // But verify the added accuracy means we can return to accurate unpremultiplied ARGB32. + QRgba64 pu64 = qUnpremultiply(pp64); + QRgb p2 = pu64.toArgb32(); + QCOMPARE(p2, p1); + } + } + // Any premultiplied ARGB32 value unpremultipled in RGB64. + for (uint a = 0; a < 256; a++) { + for (uint c = 0; c <= a; c++) { + QRgb pp = qRgba(c, a-c, a-c, a); + QRgb pu = qUnpremultiply(pp); + QRgba64 pu64 = qUnpremultiply(QRgba64::fromArgb32(pp)); + QCOMPARE(pu64.toArgb32(), pu); + } + } +} + QTEST_MAIN(tst_QColor) #include "tst_qcolor.moc" diff --git a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp index 964487f566..0f2f51d9b6 100644 --- a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp +++ b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp @@ -76,7 +76,7 @@ void tst_QPageLayout::basics() QCOMPARE(simple.paintRectPixels(72), QRect(0, 0, 595, 842)); const QPageLayout a4portrait = simple; - QVERIFY(a4portrait == simple); + QCOMPARE(a4portrait, simple); // Change orientation simple.setOrientation(QPageLayout::Landscape); diff --git a/tests/auto/gui/painting/qpainter/qpainter.pro b/tests/auto/gui/painting/qpainter/qpainter.pro index 7e9d438e1b..e90b516ef2 100644 --- a/tests/auto/gui/painting/qpainter/qpainter.pro +++ b/tests/auto/gui/painting/qpainter/qpainter.pro @@ -2,7 +2,7 @@ CONFIG += testcase CONFIG += parallel_test TARGET = tst_qpainter -QT += testlib +QT += testlib gui-private core-private qtHaveModule(widgets): QT += widgets widgets-private SOURCES += tst_qpainter.cpp diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 6582755aec..e8d90edd2d 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -53,6 +53,7 @@ #endif #include <qpixmap.h> +#include <private/qdrawhelper_p.h> #include <qpainter.h> #ifndef QT_NO_WIDGETS @@ -125,8 +126,12 @@ private slots: void fillRect3(); void fillRect4_data() { fillRect2_data(); } void fillRect4(); + void fillRectNonPremul_data(); void fillRectNonPremul(); + void fillRectRGB30_data(); + void fillRectRGB30(); + void drawEllipse_data(); void drawEllipse(); void drawClippedEllipse_data(); @@ -198,6 +203,11 @@ private slots: void gradientPixelFormat_data(); void gradientPixelFormat(); + void linearGradientRgb30_data(); + void linearGradientRgb30(); + void radialGradientRgb30_data(); + void radialGradientRgb30(); + void fpe_pixmapTransform(); void fpe_zeroLengthLines(); void fpe_divByZero(); @@ -789,7 +799,7 @@ void tst_QPainter::drawPixmapFragments() QImage origImage = origPixmap.toImage().convertToFormat(QImage::Format_ARGB32); QImage resImage = resPixmap.toImage().convertToFormat(QImage::Format_ARGB32); - QVERIFY(resImage.size() == resPixmap.size()); + QCOMPARE(resImage.size(), resPixmap.size()); QVERIFY(resImage.pixel(5, 5) == origImage.pixel(15, 15)); QVERIFY(resImage.pixel(5, 15) == origImage.pixel(15, 5)); QVERIFY(resImage.pixel(15, 5) == origImage.pixel(5, 15)); @@ -797,16 +807,16 @@ void tst_QPainter::drawPixmapFragments() QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); - QVERIFY(fragment.x == 20); - QVERIFY(fragment.y == 20); - QVERIFY(fragment.sourceLeft == 30); - QVERIFY(fragment.sourceTop == 30); - QVERIFY(fragment.width == 2); - QVERIFY(fragment.height == 2); - QVERIFY(fragment.scaleX == 1); - QVERIFY(fragment.scaleY == 1); - QVERIFY(fragment.rotation == 0); - QVERIFY(fragment.opacity == 1); + QCOMPARE(fragment.x, qreal(20)); + QCOMPARE(fragment.y, qreal(20)); + QCOMPARE(fragment.sourceLeft, qreal(30)); + QCOMPARE(fragment.sourceTop, qreal(30)); + QCOMPARE(fragment.width, qreal(2)); + QCOMPARE(fragment.height, qreal(2)); + QCOMPARE(fragment.scaleX, qreal(1)); + QCOMPARE(fragment.scaleY, qreal(1)); + QCOMPARE(fragment.rotation, qreal(0)); + QCOMPARE(fragment.opacity, qreal(1)); } void tst_QPainter::drawPixmapNegativeScale() @@ -1245,22 +1255,87 @@ void tst_QPainter::fillRect4() QCOMPARE(image, expected); } +void tst_QPainter::fillRectNonPremul_data() +{ + QTest::addColumn<QImage::Format>("format"); + QTest::addColumn<uint>("color"); + + QTest::newRow("argb32 7f1f3f7f") << QImage::Format_ARGB32 << qRgba(31, 63, 127, 127); + QTest::newRow("rgba8888 7f1f3f7f") << QImage::Format_RGBA8888 << qRgba(31, 63, 127, 127); + + QTest::newRow("argb32 3f1f3f7f") << QImage::Format_ARGB32 << qRgba(31, 63, 127, 63); + QTest::newRow("rgba8888 3f1f3f7f") << QImage::Format_RGBA8888 << qRgba(31, 63, 127, 63); + + QTest::newRow("argb32 070375f4") << QImage::Format_ARGB32 << qRgba(3, 117, 244, 7); + QTest::newRow("rgba8888 070375f4") << QImage::Format_RGBA8888 << qRgba(3, 117, 244, 7); + + QTest::newRow("argb32 0301fe0c") << QImage::Format_ARGB32 << qRgba(1, 254, 12, 3); + QTest::newRow("rgba8888 0301fe0c") << QImage::Format_RGBA8888 << qRgba(1, 254, 12, 3); + + QTest::newRow("argb32 01804010") << QImage::Format_ARGB32 << qRgba(128, 64, 32, 1); + QTest::newRow("rgba8888 01804010") << QImage::Format_RGBA8888 << qRgba(128, 64, 32, 1); +} + void tst_QPainter::fillRectNonPremul() { - QImage img1(1, 1, QImage::Format_ARGB32); - QImage img2(1, 1, QImage::Format_RGBA8888); + QFETCH(QImage::Format, format); + QFETCH(uint, color); + + QImage image(1, 1, format); + QRectF rect(0, 0, 1, 1); + + // Fill with CompositionMode_SourceOver tests blend_color + image.fill(Qt::transparent); + QPainter painter(&image); + painter.fillRect(rect, QColor::fromRgba(color)); + painter.end(); + + // Fill with CompositionMode_Source tests rectfill. + painter.begin(&image); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(rect, QColor::fromRgba(color)); + painter.end(); + + QRgb p = image.pixel(0, 0); + QCOMPARE(qAlpha(p), qAlpha(color)); + QVERIFY(qAbs(qRed(p)-qRed(color)) <= 1); + QVERIFY(qAbs(qGreen(p)-qGreen(color)) <= 1); + QVERIFY(qAbs(qBlue(p)-qBlue(color)) <= 1); +} + +void tst_QPainter::fillRectRGB30_data() +{ + QTest::addColumn<uint>("color"); - QPainter p1(&img1); - QPainter p2(&img2); + QTest::newRow("17|43|259") << (0xc0000000 | (17 << 20) | (43 << 10) | 259); + QTest::newRow("2|33|444") << (0xc0000000 | (2 << 20) | (33 << 10) | 444); + QTest::newRow("1000|1000|1000") << (0xc0000000 | (1000 << 20) | (1000 << 10) | 1000); +} +void tst_QPainter::fillRectRGB30() +{ + QFETCH(uint, color); QRectF rect(0, 0, 1, 1); - p1.fillRect(rect, qRgba(31, 63, 127, 127)); - p2.fillRect(rect, qRgba(31, 63, 127, 127)); - p1.end(); - p2.end(); + // Fill with CompositionMode_SourceOver tests blend_color + QImage image1(1, 1, QImage::Format_A2BGR30_Premultiplied); + image1.fill(Qt::transparent); + QPainter painter(&image1); + painter.fillRect(rect, QColor::fromRgba64(qConvertA2rgb30ToRgb64<PixelOrderBGR>(color))); + painter.end(); + + uint pixel1 = ((const uint*)(image1.bits()))[0]; + QCOMPARE(pixel1, color); + + // Fill with CompositionMode_Source tests rectfill. + QImage image2(1, 1, QImage::Format_RGB30); + painter.begin(&image2); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(rect, QColor::fromRgba64(qConvertA2rgb30ToRgb64<PixelOrderRGB>(color))); + painter.end(); - QCOMPARE(img1.pixel(0, 0), img2.pixel(0,0)); + uint pixel2 = ((const uint*)(image2.bits()))[0]; + QCOMPARE(pixel2, color); } void tst_QPainter::drawPath_data() @@ -1406,7 +1481,7 @@ void tst_QPainter::drawPath3() p.drawPath(path); p.end(); - QVERIFY(imgA == imgB); + QCOMPARE(imgA, imgB); imgA.invertPixels(); imgB.fill(0xffffff); @@ -1420,7 +1495,7 @@ void tst_QPainter::drawPath3() p.drawPath(path); p.end(); - QVERIFY(imgA == imgB); + QCOMPARE(imgA, imgB); path.setFillRule(Qt::WindingFill); imgB.fill(0xffffff); @@ -2381,36 +2456,50 @@ void tst_QPainter::setOpacity_data() QTest::newRow("RGBx8888 on RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_RGBX8888; - QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_RGBA8888_Premultiplied + QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_RGBA8888_Premultiplied; + + QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_RGBX8888; + + QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_RGBA8888_Premultiplied << QImage::Format_ARGB32_Premultiplied; - QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_RGBX8888 - << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGBX8888 + << QImage::Format_RGB32; - QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_ARGB32_Premultiplied - << QImage::Format_RGBA8888_Premultiplied; + QTest::newRow("RGB30 on RGB32") << QImage::Format_RGB32 + << QImage::Format_BGR30; - QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32 - << QImage::Format_RGBX8888; + QTest::newRow("BGR30 on ARGB32P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_BGR30; + + QTest::newRow("A2RGB30P on ARGB32P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_A2BGR30_Premultiplied; QTest::newRow("A2RGB30P on A2RGB30P") << QImage::Format_A2RGB30_Premultiplied << QImage::Format_A2RGB30_Premultiplied; - QTest::newRow("ARGB32P on A2RGB30P") << QImage::Format_ARGB32_Premultiplied - << QImage::Format_A2RGB30_Premultiplied; + QTest::newRow("ARGB32P on A2RGB30P") << QImage::Format_A2RGB30_Premultiplied + << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("RGB32 on A2BGR30P") << QImage::Format_A2BGR30_Premultiplied + << QImage::Format_RGB32; - QTest::newRow("RGB32 on A2BGR30P") << QImage::Format_ARGB32_Premultiplied - << QImage::Format_A2BGR30_Premultiplied; + QTest::newRow("RGB30 on A2BGR30P") << QImage::Format_A2BGR30_Premultiplied + << QImage::Format_RGB30; - QTest::newRow("A2RGB30P on A2BGR30P") << QImage::Format_A2RGB30_Premultiplied - << QImage::Format_A2BGR30_Premultiplied; + QTest::newRow("A2RGB30P on A2BGR30P") << QImage::Format_A2BGR30_Premultiplied + << QImage::Format_A2RGB30_Premultiplied; - QTest::newRow("ARGB32P on BGR30") << QImage::Format_ARGB32_Premultiplied - << QImage::Format_BGR30; + QTest::newRow("ARGB32P on BGR30") << QImage::Format_BGR30 + << QImage::Format_ARGB32_Premultiplied; - QTest::newRow("ARGB32P on RGB30") << QImage::Format_A2RGB30_Premultiplied - << QImage::Format_RGB30; + QTest::newRow("ARGB32P on RGB30") << QImage::Format_RGB30 + << QImage::Format_ARGB32_Premultiplied; + + QTest::newRow("A2RGB30P on RGB30") << QImage::Format_RGB30 + << QImage::Format_A2RGB30_Premultiplied; } @@ -2492,7 +2581,7 @@ void tst_QPainter::drawhelper_blend_untransformed() QImage expected(size - 2, size, destFormat); p.begin(&expected); p.fillRect(0, 0, expected.width(), expected.height(), - QColor(dest.pixel(1, 0))); + dest.pixelColor(1, 0)); p.end(); const QImage subDest(dest.bits() + dest.depth() / 8, @@ -2500,9 +2589,7 @@ void tst_QPainter::drawhelper_blend_untransformed() dest.bytesPerLine(), dest.format()); if (dest.format() == QImage::Format_ARGB8565_Premultiplied || - dest.format() == QImage::Format_ARGB8555_Premultiplied || - dest.format() == QImage::Format_A2BGR30_Premultiplied || - dest.format() == QImage::Format_A2RGB30_Premultiplied ) { + dest.format() == QImage::Format_ARGB8555_Premultiplied) { // Test skipped due to rounding errors... continue; } @@ -2551,7 +2638,7 @@ void tst_QPainter::drawhelper_blend_tiled_untransformed() QImage expected(size - 2, size, destFormat); p.begin(&expected); p.fillRect(0, 0, expected.width(), expected.height(), - QColor(dest.pixel(1, 0))); + dest.pixelColor(1, 0)); p.end(); const QImage subDest(dest.bits() + dest.depth() / 8, @@ -2619,28 +2706,6 @@ void tst_QPainter::porterDuff_warning() QVERIFY(qInstallMessageHandler(old) == porterDuff_warningChecker); } -class quint24 -{ -public: - inline quint24(quint32 v) - { - data[0] = qBlue(v); - data[1] = qGreen(v); - data[2] = qRed(v); - } - - inline operator quint32 () - { - return qRgb(data[2], data[1], data[0]); - } - - inline bool operator==(const quint24 &v) const { - return (data[0] == v.data[0] && data[1] == v.data[1] && data[2] == v.data[2]); - } - - uchar data[3]; -}; - void tst_QPainter::drawhelper_blend_color() { QImage dest(32, 32, QImage::Format_ARGB8555_Premultiplied); @@ -3889,6 +3954,65 @@ void tst_QPainter::gradientInterpolation() } } +void tst_QPainter::linearGradientRgb30_data() +{ + QTest::addColumn<QColor>("stop0"); + QTest::addColumn<QColor>("stop1"); + + QTest::newRow("white->black") << QColor(Qt::white) << QColor(Qt::black); + QTest::newRow("blue->black") << QColor(Qt::blue) << QColor(Qt::black); + QTest::newRow("white->red") << QColor(Qt::white) << QColor(Qt::red); +} + +void tst_QPainter::linearGradientRgb30() +{ + QFETCH(QColor, stop0); + QFETCH(QColor, stop1); + + QLinearGradient gradient(0, 0, 1000, 1); + gradient.setColorAt(0.0, stop0); + gradient.setColorAt(1.0, stop1); + + QImage image(1000, 1, QImage::Format_RGB30); + QPainter painter(&image); + painter.fillRect(image.rect(), gradient); + painter.end(); + + for (int i = 1; i < 1000; ++i) { + QColor p1 = image.pixelColor(i - 1, 0); + QColor p2 = image.pixelColor(i, 0); + QVERIFY(p1 != p2); + QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb())); + } +} + +void tst_QPainter::radialGradientRgb30_data() +{ + linearGradientRgb30_data(); +} + +void tst_QPainter::radialGradientRgb30() +{ + QFETCH(QColor, stop0); + QFETCH(QColor, stop1); + + QRadialGradient gradient(0, 0, 1000); + gradient.setColorAt(0.0, stop0); + gradient.setColorAt(1.0, stop1); + + QImage image(1000, 1, QImage::Format_A2BGR30_Premultiplied); + QPainter painter(&image); + painter.fillRect(image.rect(), gradient); + painter.end(); + + for (int i = 1; i < 1000; ++i) { + QColor p1 = image.pixelColor(i - 1, 0); + QColor p2 = image.pixelColor(i, 0); + QVERIFY(p1 != p2); + QVERIFY(qGray(p1.rgb()) >= qGray(p2.rgb())); + } +} + void tst_QPainter::drawPolygon() { QImage img(128, 128, QImage::Format_ARGB32_Premultiplied); @@ -4064,10 +4188,10 @@ void tst_QPainter::extendedBlendModes() QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_Plus, 0.3)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Plus, 0.3)); - QVERIFY(testCompositionMode(127, 128, 165, QPainter::CompositionMode_Plus, 0.3)); - QVERIFY(testCompositionMode(127, 0, 37, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(126, 128, 165, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(127, 0, 38, QPainter::CompositionMode_Plus, 0.3)); QVERIFY(testCompositionMode( 0, 127, 127, QPainter::CompositionMode_Plus, 0.3)); - QVERIFY(testCompositionMode(255, 0, 75, QPainter::CompositionMode_Plus, 0.3)); + QVERIFY(testCompositionMode(255, 0, 76, QPainter::CompositionMode_Plus, 0.3)); QVERIFY(testCompositionMode( 0, 255, 255, QPainter::CompositionMode_Plus, 0.3)); QVERIFY(testCompositionMode(128, 128, 166, QPainter::CompositionMode_Plus, 0.3)); QVERIFY(testCompositionMode(186, 200, 255, QPainter::CompositionMode_Plus, 0.3)); @@ -4752,6 +4876,22 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 125; QTest::newRow("ARGB_PM source-in RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 125; + QTest::newRow("ARGB over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 + << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 85) << 85; + QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85; + QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 + << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85; + QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 + << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85; + QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85; + QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170; + QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32 + << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85; + QTest::newRow("ARGB_PM source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_SourceIn << qRgba(85, 0, 0, 85) << 85; } void tst_QPainter::blendARGBonRGB() diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index 0a073f5c84..ae30719ee7 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -602,16 +602,16 @@ void tst_QPainterPath::testOperatorEquals() { QPainterPath empty1; QPainterPath empty2; - QVERIFY(empty1 == empty2); + QCOMPARE(empty1, empty2); QPainterPath rect1; rect1.addRect(100, 100, 100, 100); - QVERIFY(rect1 == rect1); + QCOMPARE(rect1, rect1); QVERIFY(rect1 != empty1); QPainterPath rect2; rect2.addRect(100, 100, 100, 100); - QVERIFY(rect1 == rect2); + QCOMPARE(rect1, rect2); rect2.setFillRule(Qt::WindingFill); QVERIFY(rect1 != rect2); @@ -622,7 +622,7 @@ void tst_QPainterPath::testOperatorEquals() QPainterPath ellipse2; ellipse2.addEllipse(50, 50, 100, 100); - QVERIFY(ellipse1 == ellipse2); + QCOMPARE(ellipse1, ellipse2); } void tst_QPainterPath::testOperatorEquals_fuzzy() @@ -638,12 +638,12 @@ void tst_QPainterPath::testOperatorEquals_fuzzy() QPainterPath pb; pb.addRect(b); - QVERIFY(pa == pb); + QCOMPARE(pa, pb); QTransform transform; transform.translate(-100, -100); - QVERIFY(transform.map(pa) == transform.map(pb)); + QCOMPARE(transform.map(pa), transform.map(pb)); } // higher tolerance for error when path's bounding rect is big @@ -656,12 +656,12 @@ void tst_QPainterPath::testOperatorEquals_fuzzy() QPainterPath pb; pb.addRect(b); - QVERIFY(pa == pb); + QCOMPARE(pa, pb); QTransform transform; transform.translate(-1, -1); - QVERIFY(transform.map(pa) == transform.map(pb)); + QCOMPARE(transform.map(pa), transform.map(pb)); } // operator== should return true for a path that has @@ -676,7 +676,7 @@ void tst_QPainterPath::testOperatorEquals_fuzzy() QPainterPath b = transform.inverted().map(transform.map(a)); - QVERIFY(a == b); + QCOMPARE(a, b); } { @@ -720,7 +720,7 @@ void tst_QPainterPath::testOperatorDatastream() stream >> other; } - QVERIFY(other == path); + QCOMPARE(other, path); } void tst_QPainterPath::closing() @@ -1066,19 +1066,19 @@ void tst_QPainterPath::setElementPositionAt() { QPainterPath path(QPointF(42., 42.)); QCOMPARE(path.elementCount(), 1); - QVERIFY(path.elementAt(0).type == QPainterPath::MoveToElement); + QCOMPARE(path.elementAt(0).type, QPainterPath::MoveToElement); QCOMPARE(path.elementAt(0).x, qreal(42.)); QCOMPARE(path.elementAt(0).y, qreal(42.)); QPainterPath copy = path; copy.setElementPositionAt(0, qreal(0), qreal(0)); QCOMPARE(copy.elementCount(), 1); - QVERIFY(copy.elementAt(0).type == QPainterPath::MoveToElement); + QCOMPARE(copy.elementAt(0).type, QPainterPath::MoveToElement); QCOMPARE(copy.elementAt(0).x, qreal(0)); QCOMPARE(copy.elementAt(0).y, qreal(0)); QCOMPARE(path.elementCount(), 1); - QVERIFY(path.elementAt(0).type == QPainterPath::MoveToElement); + QCOMPARE(path.elementAt(0).type, QPainterPath::MoveToElement); QCOMPARE(path.elementAt(0).x, qreal(42.)); QCOMPARE(path.elementAt(0).y, qreal(42.)); } @@ -1253,10 +1253,10 @@ void tst_QPainterPath::connectPathMoveTo() path1.connectPath(path2); - QVERIFY(path1.elementAt(0).type == QPainterPath::MoveToElement); - QVERIFY(path2.elementAt(0).type == QPainterPath::MoveToElement); - QVERIFY(path3.elementAt(0).type == QPainterPath::MoveToElement); - QVERIFY(path4.elementAt(0).type == QPainterPath::MoveToElement); + QCOMPARE(path1.elementAt(0).type, QPainterPath::MoveToElement); + QCOMPARE(path2.elementAt(0).type, QPainterPath::MoveToElement); + QCOMPARE(path3.elementAt(0).type, QPainterPath::MoveToElement); + QCOMPARE(path4.elementAt(0).type, QPainterPath::MoveToElement); } void tst_QPainterPath::translate() diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp index c0e3c6d187..33f81cc10e 100644 --- a/tests/auto/gui/painting/qregion/tst_qregion.cpp +++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp @@ -173,7 +173,7 @@ void tst_QRegion::setRects() QRect rect; region.setRects(&rect, 0); QVERIFY(region.isEmpty()); - QVERIFY(region == QRegion()); + QCOMPARE(region, QRegion()); QVERIFY(!region.boundingRect().isValid()); QVERIFY(region.rects().isEmpty()); } diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index 13b15d09dd..60b89aa6ab 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -57,6 +57,7 @@ private slots: void mapRect(); void assignments(); void mapToPolygon(); + void qhash(); void translate(); void scale(); void matrix(); @@ -361,6 +362,22 @@ void tst_QTransform::mapToPolygon() QVERIFY(equal); } +void tst_QTransform::qhash() +{ + QMatrix m1; + m1.shear(3.0, 2.0); + m1.rotate(44); + + QMatrix m2 = m1; + + QTransform t1(m1); + QTransform t2(m2); + + // not really much to test here, so just the bare minimum: + QCOMPARE(qHash(m1), qHash(m2)); + QCOMPARE(qHash(t1), qHash(t2)); +} + void tst_QTransform::translate() { @@ -411,14 +428,14 @@ void tst_QTransform::matrix() mat1.m21(), mat1.m22(), 0, mat1.dx(), mat1.dy(), 1); - QVERIFY(tran1 == dummy); - QVERIFY(tran1.inverted() == dummy.inverted()); - QVERIFY(tran1.inverted() == QTransform(mat1.inverted())); - QVERIFY(tran2.inverted() == QTransform(mat2.inverted())); + QCOMPARE(tran1, dummy); + QCOMPARE(tran1.inverted(), dummy.inverted()); + QCOMPARE(tran1.inverted(), QTransform(mat1.inverted())); + QCOMPARE(tran2.inverted(), QTransform(mat2.inverted())); QMatrix mat3 = mat1 * mat2; QTransform tran3 = tran1 * tran2; - QVERIFY(QTransform(mat3) == tran3); + QCOMPARE(QTransform(mat3), tran3); /* QMatrix::operator==() doesn't use qFuzzyCompare(), which * on win32-g++ results in a failure. So we work around it by @@ -430,15 +447,15 @@ void tst_QTransform::matrix() QRect rect(43, 70, 200, 200); QPoint pt(43, 66); - QVERIFY(tranInv.map(pt) == matInv.map(pt)); - QVERIFY(tranInv.map(pt) == matInv.map(pt)); + QCOMPARE(tranInv.map(pt), matInv.map(pt)); + QCOMPARE(tranInv.map(pt), matInv.map(pt)); QPainterPath path; path.moveTo(55, 60); path.lineTo(110, 110); path.quadTo(220, 50, 10, 20); path.closeSubpath(); - QVERIFY(tranInv.map(path) == matInv.map(path)); + QCOMPARE(tranInv.map(path), matInv.map(path)); } void tst_QTransform::testOffset() @@ -724,8 +741,8 @@ void tst_QTransform::inverted() const QTransform inverted = matrix.inverted(); - QVERIFY(matrix.isIdentity() == inverted.isIdentity()); - QVERIFY(matrix.type() == inverted.type()); + QCOMPARE(matrix.isIdentity(), inverted.isIdentity()); + QCOMPARE(matrix.type(), inverted.type()); QVERIFY((matrix * inverted).isIdentity()); QVERIFY((inverted * matrix).isIdentity()); diff --git a/tests/auto/gui/qopengl/BLACKLIST b/tests/auto/gui/qopengl/BLACKLIST new file mode 100644 index 0000000000..7f167d81df --- /dev/null +++ b/tests/auto/gui/qopengl/BLACKLIST @@ -0,0 +1,8 @@ +[fboRendering] +windows +[QTBUG15621_triangulatingStrokerDivZero] +windows +[imageFormatPainting] +windows +[openGLPaintDevice] +windows diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 8c6c28b492..8103f27911 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -86,6 +86,8 @@ private slots: void fboRenderingRGB30_data(); void fboRenderingRGB30(); void fboHandleNulledAfterContextDestroyed(); + void fboMRT(); + void fboMRT_differentFormats(); void openGLPaintDevice_data(); void openGLPaintDevice(); void aboutToBeDestroyed(); @@ -514,7 +516,7 @@ void tst_QOpenGL::fboTextureOwnership() // pull out the texture GLuint texture = fbo->takeTexture(); QVERIFY(texture != 0); - QVERIFY(fbo->texture() == 0); + QCOMPARE(fbo->texture(), GLuint(0)); // verify that the next bind() creates a new texture fbo->bind(); @@ -594,6 +596,14 @@ void tst_QOpenGL::fboRenderingRGB30_data() common_data(); } +#ifndef GL_RGB5_A1 +#define GL_RGB5_A1 0x8057 +#endif + +#ifndef GL_RGBA8 +#define GL_RGBA8 0x8058 +#endif + #ifndef GL_RGB10_A2 #define GL_RGB10_A2 0x8059 #endif @@ -606,6 +616,24 @@ void tst_QOpenGL::fboRenderingRGB30_data() #define GL_FULL_SUPPORT 0x82B7 #endif +static bool hasRGB10A2(QOpenGLContext *ctx) +{ + if (ctx->format().majorVersion() < 3) + return false; +#ifndef QT_OPENGL_ES_2 + if (!ctx->isOpenGLES() && ctx->format().majorVersion() >= 4) { + GLint value = -1; + QOpenGLFunctions_4_2_Core* vFuncs = ctx->versionFunctions<QOpenGLFunctions_4_2_Core>(); + if (vFuncs && vFuncs->initializeOpenGLFunctions()) { + vFuncs->glGetInternalformativ(GL_TEXTURE_2D, GL_RGB10_A2, GL_FRAMEBUFFER_RENDERABLE, 1, &value); + if (value != GL_FULL_SUPPORT) + return false; + } + } +#endif + return true; +} + void tst_QOpenGL::fboRenderingRGB30() { #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__) @@ -623,24 +651,9 @@ void tst_QOpenGL::fboRenderingRGB30() if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) QSKIP("QOpenGLFramebufferObject not supported on this platform"); - if (ctx.format().majorVersion() < 3) + if (!hasRGB10A2(&ctx)) QSKIP("An internal RGB30_A2 format is not guaranteed on this platform"); -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) - // NVidia currently only supports RGB30 and RGB30_A2 in their Quadro drivers, - // but they do provide an extension for querying the support. We use the query - // in case they implement the required formats later. - if (!ctx.isOpenGLES() && ctx.format().majorVersion() >= 4) { - GLint value = -1; - QOpenGLFunctions_4_2_Core* vFuncs = ctx.versionFunctions<QOpenGLFunctions_4_2_Core>(); - if (vFuncs && vFuncs->initializeOpenGLFunctions()) { - vFuncs->glGetInternalformativ(GL_TEXTURE_2D, GL_RGB10_A2, GL_FRAMEBUFFER_RENDERABLE, 1, &value); - if (value != GL_FULL_SUPPORT) - QSKIP("The required RGB30_A2 format is not supported by this driver"); - } - } -#endif - // No multisample with combined depth/stencil attachment: QOpenGLFramebufferObjectFormat fboFormat; fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); @@ -720,6 +733,150 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed() QCOMPARE(fbo->handle(), 0U); } +void tst_QOpenGL::fboMRT() +{ + QWindow window; + window.setSurfaceType(QWindow::OpenGLSurface); + window.setGeometry(0, 0, 10, 10); + window.create(); + + QOpenGLContext ctx; + QVERIFY(ctx.create()); + ctx.makeCurrent(&window); + + if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) + QSKIP("QOpenGLFramebufferObject not supported on this platform"); + + if (!ctx.functions()->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) + QSKIP("Multiple render targets not supported on this platform"); + + QOpenGLExtraFunctions *ef = ctx.extraFunctions(); + + { + // 3 color attachments, different sizes, same internal format, no depth/stencil. + QVector<QSize> sizes; + sizes << QSize(128, 128) << QSize(192, 128) << QSize(432, 123); + QOpenGLFramebufferObject fbo(sizes[0]); + fbo.addColorAttachment(sizes[1]); + fbo.addColorAttachment(sizes[2]); + QVERIFY(fbo.bind()); + QCOMPARE(fbo.attachment(), QOpenGLFramebufferObject::NoAttachment); + QCOMPARE(sizes, fbo.sizes()); + QCOMPARE(sizes[0], fbo.size()); + // Clear the three buffers to red, green and blue. + GLenum drawBuf = GL_COLOR_ATTACHMENT0; + ef->glDrawBuffers(1, &drawBuf); + ef->glClearColor(1, 0, 0, 1); + ef->glClear(GL_COLOR_BUFFER_BIT); + drawBuf = GL_COLOR_ATTACHMENT0 + 1; + ef->glDrawBuffers(1, &drawBuf); + ef->glClearColor(0, 1, 0, 1); + ef->glClear(GL_COLOR_BUFFER_BIT); + drawBuf = GL_COLOR_ATTACHMENT0 + 2; + ef->glDrawBuffers(1, &drawBuf); + ef->glClearColor(0, 0, 1, 1); + ef->glClear(GL_COLOR_BUFFER_BIT); + // Verify, keeping in mind that only a 128x123 area is touched in the buffers. + // Some drivers do not get this right, unfortunately, so do not rely on it. + const char *vendor = (const char *) ef->glGetString(GL_VENDOR); + bool hasCorrectMRT = false; + if (vendor && strstr(vendor, "NVIDIA")) // maybe others too + hasCorrectMRT = true; + QImage img = fbo.toImage(false, 0); + QCOMPARE(img.size(), sizes[0]); + QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0)); + if (hasCorrectMRT) + QCOMPARE(img.pixel(127, 122), qRgb(255, 0, 0)); + img = fbo.toImage(false, 1); + QCOMPARE(img.size(), sizes[1]); + QCOMPARE(img.pixel(0, 0), qRgb(0, 255, 0)); + if (hasCorrectMRT) + QCOMPARE(img.pixel(127, 122), qRgb(0, 255, 0)); + img = fbo.toImage(false, 2); + QCOMPARE(img.size(), sizes[2]); + QCOMPARE(img.pixel(0, 0), qRgb(0, 0, 255)); + if (hasCorrectMRT) + QCOMPARE(img.pixel(127, 122), qRgb(0, 0, 255)); + fbo.release(); + } + + { + // 2 color attachments, same size, same internal format, depth/stencil. + QVector<QSize> sizes; + sizes.fill(QSize(128, 128), 2); + QOpenGLFramebufferObject fbo(sizes[0], QOpenGLFramebufferObject::CombinedDepthStencil); + fbo.addColorAttachment(sizes[1]); + QVERIFY(fbo.bind()); + QCOMPARE(fbo.attachment(), QOpenGLFramebufferObject::CombinedDepthStencil); + QCOMPARE(sizes, fbo.sizes()); + QCOMPARE(sizes[0], fbo.size()); + ef->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + ef->glFinish(); + fbo.release(); + } +} + +void tst_QOpenGL::fboMRT_differentFormats() +{ + QWindow window; + window.setSurfaceType(QWindow::OpenGLSurface); + window.setGeometry(0, 0, 10, 10); + window.create(); + + QOpenGLContext ctx; + QVERIFY(ctx.create()); + ctx.makeCurrent(&window); + + QOpenGLFunctions *f = ctx.functions(); + const char * vendor = (const char *) f->glGetString(GL_VENDOR); + if (vendor && strstr(vendor, "VMware, Inc.")) + QSKIP("The tested formats may not be supported on this platform"); + + if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()) + QSKIP("QOpenGLFramebufferObject not supported on this platform"); + + if (!f->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) + QSKIP("Multiple render targets not supported on this platform"); + + if (!hasRGB10A2(&ctx)) + QSKIP("RGB10_A2 not supported on this platform"); + + // 3 color attachments, same size, different internal format, depth/stencil. + QVector<QSize> sizes; + sizes.fill(QSize(128, 128), 3); + QOpenGLFramebufferObjectFormat format; + format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + QVector<GLenum> internalFormats; + internalFormats << GL_RGBA8 << GL_RGB10_A2 << GL_RGB5_A1; + format.setInternalTextureFormat(internalFormats[0]); + QOpenGLFramebufferObject fbo(sizes[0], format); + fbo.addColorAttachment(sizes[1], internalFormats[1]); + fbo.addColorAttachment(sizes[2], internalFormats[2]); + + QVERIFY(fbo.bind()); + QCOMPARE(fbo.attachment(), QOpenGLFramebufferObject::CombinedDepthStencil); + QCOMPARE(sizes, fbo.sizes()); + QCOMPARE(sizes[0], fbo.size()); + + QOpenGLExtraFunctions *ef = ctx.extraFunctions(); + QVERIFY(ef->glGetError() == 0); + ef->glClearColor(1, 0, 0, 1); + GLenum drawBuf[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0 + 1, GL_COLOR_ATTACHMENT0 + 2 }; + ef->glDrawBuffers(3, drawBuf); + ef->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + QVERIFY(ef->glGetError() == 0); + + QImage img = fbo.toImage(true, 0); + QCOMPARE(img.size(), sizes[0]); + QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0)); + img = fbo.toImage(true, 1); + QCOMPARE(img.size(), sizes[1]); + QCOMPARE(img.format(), QImage::Format_A2BGR30_Premultiplied); + QCOMPARE(img.pixel(0, 0), qRgb(255, 0, 0)); + + fbo.release(); +} + void tst_QOpenGL::imageFormatPainting() { QScopedPointer<QSurface> surface(createSurface(QSurface::Window)); @@ -1174,18 +1331,18 @@ void tst_QOpenGL::textureblitterPartTargetRectTransform() void tst_QOpenGL::defaultSurfaceFormat() { QSurfaceFormat fmt; - QVERIFY(QSurfaceFormat::defaultFormat() == fmt); + QCOMPARE(QSurfaceFormat::defaultFormat(), fmt); fmt.setDepthBufferSize(16); QSurfaceFormat::setDefaultFormat(fmt); - QVERIFY(QSurfaceFormat::defaultFormat() == fmt); + QCOMPARE(QSurfaceFormat::defaultFormat(), fmt); QCOMPARE(QSurfaceFormat::defaultFormat().depthBufferSize(), 16); QScopedPointer<QWindow> window(new QWindow); - QVERIFY(window->requestedFormat() == fmt); + QCOMPARE(window->requestedFormat(), fmt); QScopedPointer<QOpenGLContext> context(new QOpenGLContext); - QVERIFY(context->format() == fmt); + QCOMPARE(context->format(), fmt); } #ifdef USE_GLX @@ -1214,7 +1371,7 @@ void tst_QOpenGL::glxContextWrap() QOpenGLContext *ctx = new QOpenGLContext; ctx->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(QGLXNativeContext(context))); QVERIFY(ctx->create()); - QVERIFY(ctx->nativeHandle().value<QGLXNativeContext>().context() == context); + QCOMPARE(ctx->nativeHandle().value<QGLXNativeContext>().context(), context); QVERIFY(nativeIf->nativeResourceForContext(QByteArrayLiteral("glxcontext"), ctx) == (void *) context); QVERIFY(ctx->makeCurrent(window)); diff --git a/tests/auto/gui/qopenglconfig/buglist.json b/tests/auto/gui/qopenglconfig/buglist.json index c7b8e61bc8..ef311612b2 100644 --- a/tests/auto/gui/qopenglconfig/buglist.json +++ b/tests/auto/gui/qopenglconfig/buglist.json @@ -103,6 +103,28 @@ ] }, { + "id": 7, + "description": "driver description test", + "driver_description": "Long And Special Driver Description", + "os": { + "type": "win" + }, + "features": [ + "feature2" + ] + }, + { + "id": 8, + "description": "Windows version test", + "os": { + "type": "win", + "release": [ "10" ] + }, + "features": [ + "win10_feature" + ] + }, + { "id": 128, "description": "check for matching GL_VENDOR", "gl_vendor": "The Qt Company", diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp index f88cbdc758..48a15641b2 100644 --- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -47,6 +47,7 @@ #include <QtCore/QVariant> #include <QtCore/QDebug> #include <QtCore/QTextStream> +#include <QtCore/QJsonDocument> #include <algorithm> @@ -107,6 +108,7 @@ private slots: void testConfiguration(); void testGlConfiguration(); void testBugList(); + void testDefaultWindowsBlacklist(); }; static void dumpConfiguration(QTextStream &str) @@ -243,29 +245,61 @@ void tst_QOpenGlConfig::testBugList() QSet<QString> expectedFeatures; expectedFeatures << "feature1"; + // adapter info QVersionNumber driverVersion(QVector<int>() << 9 << 18 << 13 << 4460); - QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromDevice(0x10DE, 0x0DE9, driverVersion); + QOpenGLConfig::Gpu gpu = QOpenGLConfig::Gpu::fromDevice(0x10DE, 0x0DE9, driverVersion, QByteArrayLiteral("Unknown")); QSet<QString> actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"), - QVersionNumber(6, 3), fileName); + QVersionNumber(6, 3), QStringLiteral("7"), fileName); QVERIFY2(expectedFeatures == actualFeatures, msgSetMismatch(expectedFeatures, actualFeatures)); + // driver_description + gpu = QOpenGLConfig::Gpu::fromDevice(0xDEAD, 0xBEEF, driverVersion, QByteArrayLiteral("Very Long And Special Driver Description")); + actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"), + QVersionNumber(6, 3), QStringLiteral("8"), fileName); + expectedFeatures = QSet<QString>() << "feature2"; + QVERIFY2(expectedFeatures == actualFeatures, + msgSetMismatch(expectedFeatures, actualFeatures)); + + // os.release + gpu = QOpenGLConfig::Gpu::fromDevice(0xDEAD, 0xBEEF, driverVersion, QByteArrayLiteral("WinVerTest")); + actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("win"), + QVersionNumber(12, 34), QStringLiteral("10"), fileName); + expectedFeatures = QSet<QString>() << "win10_feature"; + QVERIFY2(expectedFeatures == actualFeatures, + msgSetMismatch(expectedFeatures, actualFeatures)); + + // gl_vendor gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("Somebody Else")); expectedFeatures.clear(); actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"), - QVersionNumber(1, 0), fileName); + QVersionNumber(1, 0), QString(), fileName); QVERIFY2(expectedFeatures == actualFeatures, msgSetMismatch(expectedFeatures, actualFeatures)); gpu = QOpenGLConfig::Gpu::fromGLVendor(QByteArrayLiteral("The Qt Company")); expectedFeatures = QSet<QString>() << "cool_feature"; actualFeatures = QOpenGLConfig::gpuFeatures(gpu, QStringLiteral("linux"), - QVersionNumber(1, 0), fileName); + QVersionNumber(1, 0), QString(), fileName); QVERIFY2(expectedFeatures == actualFeatures, msgSetMismatch(expectedFeatures, actualFeatures)); } +void tst_QOpenGlConfig::testDefaultWindowsBlacklist() +{ + if (qGuiApp->platformName() != QStringLiteral("windows")) + QSKIP("Only applicable to Windows"); + + QFile f(QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json")); + QVERIFY(f.open(QIODevice::ReadOnly | QIODevice::Text)); + QJsonParseError err; + QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &err); + QVERIFY2(err.error == 0, + QStringLiteral("Failed to parse built-in Windows GPU blacklist. %1 : %2") + .arg(err.offset).arg(err.errorString()).toLatin1()); +} + QTEST_MAIN(tst_QOpenGlConfig) #include "tst_qopenglconfig.moc" diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index 5d78bc1d01..b1beb0ffd0 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -203,8 +203,8 @@ void tst_QCssParser::scanner() QCss::Scanner::scan(QCss::Scanner::preprocess(QString::fromUtf8(inputFile.readAll())), &symbols); QVERIFY(symbols.count() > 1); - QVERIFY(symbols.last().token == QCss::S); - QVERIFY(symbols.last().lexem() == QLatin1String("\n")); + QCOMPARE(symbols.last().token, QCss::S); + QCOMPARE(symbols.last().lexem(), QLatin1String("\n")); symbols.remove(symbols.count() - 1, 1); QFile outputFile(output); @@ -861,7 +861,7 @@ void tst_QCssParser::colorValue() QCss::Declaration decl; QVERIFY(parser.parseNextDeclaration(&decl)); const QColor col = decl.colorValue(); - QVERIFY(expectedColor.isValid() == col.isValid()); + QCOMPARE(expectedColor.isValid(), col.isValid()); QCOMPARE(col, expectedColor); } @@ -1304,7 +1304,7 @@ void tst_QCssParser::rulesForNode() decls += rules.at(i).declarations; } - QVERIFY(decls.count() == declCount); + QCOMPARE(decls.count(), declCount); if (declCount > 0) QCOMPARE(decls.at(0).d->values.at(0).variant.toString(), value0); @@ -1364,7 +1364,7 @@ void tst_QCssParser::shorthandBackgroundProperty() v.extractBackground(&brush, &image, &repeat, &alignment, &origin, &attachment, &ignoredOrigin); QFETCH(QBrush, expectedBrush); - QVERIFY(expectedBrush.color() == brush.color()); + QCOMPARE(expectedBrush.color(), brush.color()); QTEST(image, "expectedImage"); QTEST(int(repeat), "expectedRepeatValue"); @@ -1372,7 +1372,7 @@ void tst_QCssParser::shorthandBackgroundProperty() //QTBUG-9674 : a second evaluation should give the same results QVERIFY(v.extractBackground(&brush, &image, &repeat, &alignment, &origin, &attachment, &ignoredOrigin)); - QVERIFY(expectedBrush.color() == brush.color()); + QCOMPARE(expectedBrush.color(), brush.color()); QTEST(image, "expectedImage"); QTEST(int(repeat), "expectedRepeatValue"); QTEST(int(alignment), "expectedAlignment"); @@ -1438,7 +1438,7 @@ void tst_QCssParser::pseudoElement() decls += rules.at(i).declarations; } - QVERIFY(decls.count() == declCount); + QCOMPARE(decls.count(), declCount); } void tst_QCssParser::gradient_data() @@ -1517,21 +1517,21 @@ void tst_QCssParser::gradient() QBrush sbg, abg; QVERIFY(ve.extractPalette(&fg, &sfg, &sbg, &abg)); if (type == "linear") { - QVERIFY(sbg.style() == Qt::LinearGradientPattern); + QCOMPARE(sbg.style(), Qt::LinearGradientPattern); const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient()); QCOMPARE(lg->start(), start); QCOMPARE(lg->finalStop(), finalStop); } else if (type == "conical") { - QVERIFY(sbg.style() == Qt::ConicalGradientPattern); + QCOMPARE(sbg.style(), Qt::ConicalGradientPattern); const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient()); QCOMPARE(cg->center(), start); } const QGradient *g = sbg.gradient(); QCOMPARE(g->spread(), QGradient::Spread(spread)); - QVERIFY(g->stops().at(0).first == stop0); - QVERIFY(g->stops().at(0).second == color0); - QVERIFY(g->stops().at(1).first == stop1); - QVERIFY(g->stops().at(1).second == color1); + QCOMPARE(g->stops().at(0).first, stop0); + QCOMPARE(g->stops().at(0).second, color0); + QCOMPARE(g->stops().at(1).first, stop1); + QCOMPARE(g->stops().at(1).second, color1); } void tst_QCssParser::extractFontFamily_data() @@ -1637,15 +1637,15 @@ void tst_QCssParser::extractBorder() QSize radii[4]; extractor.extractBorder(widths, colors, styles, radii); - QVERIFY(widths[QCss::TopEdge] == expectedTopWidth); - QVERIFY(styles[QCss::TopEdge] == expectedTopStyle); - QVERIFY(colors[QCss::TopEdge] == expectedTopColor); + QCOMPARE(widths[QCss::TopEdge], expectedTopWidth); + QCOMPARE(int(styles[QCss::TopEdge]), expectedTopStyle); + QCOMPARE(colors[QCss::TopEdge].color(), expectedTopColor); //QTBUG-9674 : a second evaluation should give the same results QVERIFY(extractor.extractBorder(widths, colors, styles, radii)); - QVERIFY(widths[QCss::TopEdge] == expectedTopWidth); - QVERIFY(styles[QCss::TopEdge] == expectedTopStyle); - QVERIFY(colors[QCss::TopEdge] == expectedTopColor); + QCOMPARE(widths[QCss::TopEdge], expectedTopWidth); + QCOMPARE(int(styles[QCss::TopEdge]), expectedTopStyle); + QCOMPARE(colors[QCss::TopEdge].color(), expectedTopColor); } void tst_QCssParser::noTextDecoration() diff --git a/tests/auto/gui/text/qfont/BLACKLIST b/tests/auto/gui/text/qfont/BLACKLIST new file mode 100644 index 0000000000..d859dee03e --- /dev/null +++ b/tests/auto/gui/text/qfont/BLACKLIST @@ -0,0 +1,2 @@ +[exactMatch] +opensuse-13.1 diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 64b06e9856..462e5115b4 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -217,15 +217,15 @@ void tst_QFont::exactMatch() || fontinfo.family().isEmpty()); } if (font.pointSize() != -1) { - QVERIFY(font.pointSize() == fontinfo.pointSize()); + QCOMPARE(font.pointSize(), fontinfo.pointSize()); } else { - QVERIFY(font.pixelSize() == fontinfo.pixelSize()); + QCOMPARE(font.pixelSize(), fontinfo.pixelSize()); } - QVERIFY(font.italic() == fontinfo.italic()); + QCOMPARE(font.italic(), fontinfo.italic()); if (font.weight() != fontinfo.weight()) { qDebug("font is %s", font.toString().toLatin1().constData()); } - QVERIFY(font.weight() == fontinfo.weight()); + QCOMPARE(font.weight(), fontinfo.weight()); } else { font.setFixedPitch(!fontinfo.fixedPitch()); QFontInfo fontinfo1(font); @@ -274,12 +274,12 @@ void tst_QFont::exactMatch() || fontinfo.family().contains(font.family()) || fontinfo.family().isEmpty()); if (font.pointSize() != -1) { - QVERIFY(font.pointSize() == fontinfo.pointSize()); + QCOMPARE(font.pointSize(), fontinfo.pointSize()); } else { - QVERIFY(font.pixelSize() == fontinfo.pixelSize()); + QCOMPARE(font.pixelSize(), fontinfo.pixelSize()); } - QVERIFY(font.italic() == fontinfo.italic()); - QVERIFY(font.weight() == fontinfo.weight()); + QCOMPARE(font.italic(), fontinfo.italic()); + QCOMPARE(font.weight(), fontinfo.weight()); } else { font.setFixedPitch(!fontinfo.fixedPitch()); QFontInfo fontinfo1(font, (QFont::Script) script); @@ -371,42 +371,42 @@ void tst_QFont::compare() QVERIFY(font != font2); QCOMPARE(font < font2,!(font2 < font)); font2.setItalic(false); - QVERIFY(font == font2); + QCOMPARE(font, font2); QVERIFY(!(font < font2)); font2.setWeight(QFont::Bold); QVERIFY(font != font2); QCOMPARE(font < font2,!(font2 < font)); font2.setWeight(QFont::Normal); - QVERIFY(font == font2); + QCOMPARE(font, font2); QVERIFY(!(font < font2)); font.setUnderline(true); QVERIFY(font != font2); QCOMPARE(font < font2,!(font2 < font)); font.setUnderline(false); - QVERIFY(font == font2); + QCOMPARE(font, font2); QVERIFY(!(font < font2)); font.setStrikeOut(true); QVERIFY(font != font2); QCOMPARE(font < font2,!(font2 < font)); font.setStrikeOut(false); - QVERIFY(font == font2); + QCOMPARE(font, font2); QVERIFY(!(font < font2)); font.setOverline(true); QVERIFY(font != font2); QCOMPARE(font < font2,!(font2 < font)); font.setOverline(false); - QVERIFY(font == font2); + QCOMPARE(font, font2); QVERIFY(!(font < font2)); font.setCapitalization(QFont::SmallCaps); QVERIFY(font != font2); QCOMPARE(font < font2,!(font2 < font)); font.setCapitalization(QFont::MixedCase); - QVERIFY(font == font2); + QCOMPARE(font, font2); QVERIFY(!(font < font2)); } } @@ -426,27 +426,27 @@ void tst_QFont::resolve() font1.setWeight(QFont::Bold); QFont font2 = font1.resolve(font); - QVERIFY(font2.weight() == font1.weight()); + QCOMPARE(font2.weight(), font1.weight()); - QVERIFY(font2.pointSize() == font.pointSize()); - QVERIFY(font2.italic() == font.italic()); - QVERIFY(font2.underline() == font.underline()); - QVERIFY(font2.overline() == font.overline()); - QVERIFY(font2.strikeOut() == font.strikeOut()); - QVERIFY(font2.stretch() == font.stretch()); + QCOMPARE(font2.pointSize(), font.pointSize()); + QCOMPARE(font2.italic(), font.italic()); + QCOMPARE(font2.underline(), font.underline()); + QCOMPARE(font2.overline(), font.overline()); + QCOMPARE(font2.strikeOut(), font.strikeOut()); + QCOMPARE(font2.stretch(), font.stretch()); QFont font3; font3.setStretch(QFont::UltraCondensed); QFont font4 = font3.resolve(font1).resolve(font); - QVERIFY(font4.stretch() == font3.stretch()); + QCOMPARE(font4.stretch(), font3.stretch()); - QVERIFY(font4.weight() == font.weight()); - QVERIFY(font4.pointSize() == font.pointSize()); - QVERIFY(font4.italic() == font.italic()); - QVERIFY(font4.underline() == font.underline()); - QVERIFY(font4.overline() == font.overline()); - QVERIFY(font4.strikeOut() == font.strikeOut()); + QCOMPARE(font4.weight(), font.weight()); + QCOMPARE(font4.pointSize(), font.pointSize()); + QCOMPARE(font4.italic(), font.italic()); + QCOMPARE(font4.underline(), font.underline()); + QCOMPARE(font4.overline(), font.overline()); + QCOMPARE(font4.strikeOut(), font.strikeOut()); QFont f1,f2,f3; @@ -479,8 +479,8 @@ void tst_QFont::resetFont() child->setFont(QFont()); // reset font - QVERIFY(child->font().resolve() == 0); - QVERIFY(child->font().pointSize() == parent.font().pointSize()); + QCOMPARE(child->font().resolve(), uint(0)); + QCOMPARE(child->font().pointSize(), parent.font().pointSize()); QVERIFY(parent.font().resolve() != 0); } #endif @@ -728,24 +728,24 @@ void tst_QFont::sharing() QCOMPARE(QFontPrivate::get(f)->engineData->ref.load(), 1 + refs_by_cache); QFont f2(f); - QVERIFY(QFontPrivate::get(f2) == QFontPrivate::get(f)); + QCOMPARE(QFontPrivate::get(f2), QFontPrivate::get(f)); QCOMPARE(QFontPrivate::get(f2)->ref.load(), 2); QVERIFY(QFontPrivate::get(f2)->engineData); - QVERIFY(QFontPrivate::get(f2)->engineData == QFontPrivate::get(f)->engineData); + QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData); QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 1 + refs_by_cache); f2.setKerning(!f.kerning()); QVERIFY(QFontPrivate::get(f2) != QFontPrivate::get(f)); QCOMPARE(QFontPrivate::get(f2)->ref.load(), 1); QVERIFY(QFontPrivate::get(f2)->engineData); - QVERIFY(QFontPrivate::get(f2)->engineData == QFontPrivate::get(f)->engineData); + QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData); QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 2 + refs_by_cache); f2 = f; - QVERIFY(QFontPrivate::get(f2) == QFontPrivate::get(f)); + QCOMPARE(QFontPrivate::get(f2), QFontPrivate::get(f)); QCOMPARE(QFontPrivate::get(f2)->ref.load(), 2); QVERIFY(QFontPrivate::get(f2)->engineData); - QVERIFY(QFontPrivate::get(f2)->engineData == QFontPrivate::get(f)->engineData); + QCOMPARE(QFontPrivate::get(f2)->engineData, QFontPrivate::get(f)->engineData); QCOMPARE(QFontPrivate::get(f2)->engineData->ref.load(), 1 + refs_by_cache); if (f.pointSize() > 0) diff --git a/tests/auto/gui/text/qrawfont/BLACKLIST b/tests/auto/gui/text/qrawfont/BLACKLIST new file mode 100644 index 0000000000..a614595689 --- /dev/null +++ b/tests/auto/gui/text/qrawfont/BLACKLIST @@ -0,0 +1,4 @@ +[correctFontData] +osx-10.8 +[unsupportedWritingSystem] +osx-10.8 diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp index 014ed4c7c8..06448d11fe 100644 --- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp +++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp @@ -120,7 +120,7 @@ void tst_QSyntaxHighlighter::cleanup() class TestHighlighter : public QSyntaxHighlighter { public: - inline TestHighlighter(const QList<QTextLayout::FormatRange> &fmts, QTextDocument *parent) + inline TestHighlighter(const QVector<QTextLayout::FormatRange> &fmts, QTextDocument *parent) : QSyntaxHighlighter(parent), formats(fmts), highlighted(false), callCount(0) {} inline TestHighlighter(QObject *parent) : QSyntaxHighlighter(parent) {} @@ -138,24 +138,15 @@ public: ++callCount; } - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; bool highlighted; int callCount; QString highlightedText; }; -QT_BEGIN_NAMESPACE -bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs) -{ - return lhs.start == rhs.start - && lhs.length == rhs.length - && lhs.format == rhs.format; -} -QT_END_NAMESPACE - void tst_QSyntaxHighlighter::basic() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 2; @@ -179,7 +170,7 @@ void tst_QSyntaxHighlighter::basic() QVERIFY(hl->highlighted); QVERIFY(lout->documentChangedCalled); - QVERIFY(doc->begin().layout()->additionalFormats() == formats); + QCOMPARE(doc->begin().layout()->formats(), formats); } class CommentTestHighlighter : public QSyntaxHighlighter @@ -222,7 +213,7 @@ void tst_QSyntaxHighlighter::basicTwo() void tst_QSyntaxHighlighter::removeFormatsOnDelete() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 9; @@ -237,9 +228,9 @@ void tst_QSyntaxHighlighter::removeFormatsOnDelete() QVERIFY(lout->documentChangedCalled); lout->documentChangedCalled = false; - QVERIFY(!doc->begin().layout()->additionalFormats().isEmpty()); + QVERIFY(!doc->begin().layout()->formats().isEmpty()); delete hl; - QVERIFY(doc->begin().layout()->additionalFormats().isEmpty()); + QVERIFY(doc->begin().layout()->formats().isEmpty()); QVERIFY(lout->documentChangedCalled); } @@ -405,7 +396,7 @@ void tst_QSyntaxHighlighter::highlightToEndOfDocument2() void tst_QSyntaxHighlighter::preservePreeditArea() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 8; @@ -432,12 +423,12 @@ void tst_QSyntaxHighlighter::preservePreeditArea() hl->callCount = 0; cursor.beginEditBlock(); - layout->setAdditionalFormats(formats); + layout->setFormats(formats); cursor.endEditBlock(); QCOMPARE(hl->callCount, 1); - formats = layout->additionalFormats(); + formats = layout->formats(); QCOMPARE(formats.count(), 3); range = formats.at(0); @@ -483,7 +474,7 @@ void tst_QSyntaxHighlighter::avoidUnnecessaryRehighlight() void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight() { - QList<QTextLayout::FormatRange> formats; + QVector<QTextLayout::FormatRange> formats; QTextLayout::FormatRange range; range.start = 0; range.length = 10; diff --git a/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp b/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp index 967fe3114e..49300871d9 100644 --- a/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp +++ b/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp @@ -102,7 +102,7 @@ void tst_QTextBlock::fragmentOverBlockBoundaries() // Block separators are always a fragment of their self. Thus: // |Hello|\b|World|\b| #if !defined(Q_OS_WIN) - QVERIFY(doc->docHandle()->fragmentMap().numNodes() == 4); + QCOMPARE(doc->docHandle()->fragmentMap().numNodes(), 4); #endif QCOMPARE(cursor.block().text(), QString("Hello")); cursor.movePosition(QTextCursor::NextBlock); @@ -126,7 +126,7 @@ void tst_QTextBlock::excludeParagraphSeparatorFragment() ++it; QVERIFY(it.atEnd()); - QVERIFY(it == block.end()); + QCOMPARE(it, block.end()); } void tst_QTextBlock::backwardsBlockIterator() diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp index 42b3c53bc5..9396cd678b 100644 --- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp @@ -178,15 +178,15 @@ void tst_QTextCursor::navigation1() QVERIFY(doc->toPlainText() == "Hello World"); cursor.movePosition(QTextCursor::End); - QVERIFY(cursor.position() == 11); + QCOMPARE(cursor.position(), 11); cursor.deletePreviousChar(); - QVERIFY(cursor.position() == 10); + QCOMPARE(cursor.position(), 10); cursor.deletePreviousChar(); cursor.deletePreviousChar(); cursor.deletePreviousChar(); cursor.deletePreviousChar(); cursor.deletePreviousChar(); - QVERIFY(doc->toPlainText() == "Hello"); + QCOMPARE(doc->toPlainText(), QLatin1String("Hello")); QTextCursor otherCursor(doc); otherCursor.movePosition(QTextCursor::Start); @@ -195,12 +195,12 @@ void tst_QTextCursor::navigation1() cursor.movePosition(QTextCursor::Right); QVERIFY(cursor != otherCursor); otherCursor.insertText("Hey"); - QVERIFY(cursor.position() == 5); + QCOMPARE(cursor.position(), 5); doc->undo(); - QVERIFY(cursor.position() == 2); + QCOMPARE(cursor.position(), 2); doc->redo(); - QVERIFY(cursor.position() == 5); + QCOMPARE(cursor.position(), 5); doc->undo(); @@ -209,29 +209,29 @@ void tst_QTextCursor::navigation1() cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 6); - QVERIFY(cursor.position() == 6); + QCOMPARE(cursor.position(), 6); otherCursor = cursor; otherCursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 2); otherCursor.deletePreviousChar(); otherCursor.deletePreviousChar(); otherCursor.deletePreviousChar(); - QVERIFY(cursor.position() == 5); + QCOMPARE(cursor.position(), 5); cursor.movePosition(QTextCursor::End); cursor.insertBlock(); { int oldPos = cursor.position(); cursor.movePosition(QTextCursor::End); - QVERIFY(cursor.position() == oldPos); + QCOMPARE(cursor.position(), oldPos); } QVERIFY(cursor.atBlockStart()); - QVERIFY(cursor.position() == 9); + QCOMPARE(cursor.position(), 9); QTextCharFormat fmt; fmt.setForeground(Qt::blue); cursor.insertText("Test", fmt); - QVERIFY(fmt == cursor.charFormat()); - QVERIFY(cursor.position() == 13); + QCOMPARE(fmt, cursor.charFormat()); + QCOMPARE(cursor.position(), 13); } void tst_QTextCursor::navigation2_data() @@ -497,7 +497,7 @@ void tst_QTextCursor::navigation10() QVERIFY(ok); QCOMPARE(cursor.position(), 99); ok = cursor.movePosition(QTextCursor::NextCell); - QVERIFY(ok == false); + QVERIFY(!ok); QCOMPARE(cursor.position(), 99); // didn't move. QVERIFY(cursor.currentTable()); @@ -573,8 +573,8 @@ void tst_QTextCursor::insertBlock() QTextBlockFormat fmt; fmt.setTopMargin(100); cursor.insertBlock(fmt); - QVERIFY(cursor.position() == 1); - QVERIFY(cursor.blockFormat() == fmt); + QCOMPARE(cursor.position(), 1); + QCOMPARE(cursor.blockFormat(), fmt); } void tst_QTextCursor::insertWithBlockSeparator1() @@ -584,28 +584,28 @@ void tst_QTextCursor::insertWithBlockSeparator1() cursor.insertText(text); cursor.movePosition(QTextCursor::PreviousBlock); - QVERIFY(cursor.position() == 0); + QCOMPARE(cursor.position(), 0); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 6); + QCOMPARE(cursor.position(), 6); } void tst_QTextCursor::insertWithBlockSeparator2() { cursor.insertText(QString(QChar::ParagraphSeparator)); - QVERIFY(cursor.position() == 1); + QCOMPARE(cursor.position(), 1); } void tst_QTextCursor::insertWithBlockSeparator3() { cursor.insertText(QString(QChar::ParagraphSeparator) + "Hi" + QString(QChar::ParagraphSeparator)); - QVERIFY(cursor.position() == 4); + QCOMPARE(cursor.position(), 4); } void tst_QTextCursor::insertWithBlockSeparator4() { cursor.insertText(QString(QChar::ParagraphSeparator) + QString(QChar::ParagraphSeparator)); - QVERIFY(cursor.position() == 2); + QCOMPARE(cursor.position(), 2); } void tst_QTextCursor::clearObjectType1() @@ -656,7 +656,7 @@ void tst_QTextCursor::comparisonOperators1() midCursor.movePosition(QTextCursor::NextWord); QVERIFY(midCursor <= cursor); - QVERIFY(midCursor == cursor); + QCOMPARE(midCursor, cursor); QVERIFY(midCursor >= cursor); QVERIFY(midCursor > startCursor); @@ -690,7 +690,7 @@ void tst_QTextCursor::comparisonOperators2() QTextCursor cursor2(&doc2); QVERIFY(cursor1 != cursor2); - QVERIFY(cursor1 == QTextCursor(&doc1)); + QCOMPARE(cursor1, QTextCursor(&doc1)); } void tst_QTextCursor::selection1() @@ -718,97 +718,97 @@ void tst_QTextCursor::dontCopyTableAttributes() void tst_QTextCursor::checkFrame1() { - QVERIFY(cursor.position() == 0); + QCOMPARE(cursor.position(), 0); QPointer<QTextFrame> frame = cursor.insertFrame(QTextFrameFormat()); QVERIFY(frame != 0); QTextFrame *root = frame->parentFrame(); QVERIFY(root != 0); - QVERIFY(frame->firstPosition() == 1); - QVERIFY(frame->lastPosition() == 1); + QCOMPARE(frame->firstPosition(), 1); + QCOMPARE(frame->lastPosition(), 1); QVERIFY(frame->parentFrame() != 0); - QVERIFY(root->childFrames().size() == 1); + QCOMPARE(root->childFrames().size(), 1); - QVERIFY(cursor.position() == 1); - QVERIFY(cursor.selectionStart() == 1); - QVERIFY(cursor.selectionEnd() == 1); + QCOMPARE(cursor.position(), 1); + QCOMPARE(cursor.selectionStart(), 1); + QCOMPARE(cursor.selectionEnd(), 1); doc->undo(); QVERIFY(!frame); - QVERIFY(root->childFrames().size() == 0); + QCOMPARE(root->childFrames().size(), 0); - QVERIFY(cursor.position() == 0); - QVERIFY(cursor.selectionStart() == 0); - QVERIFY(cursor.selectionEnd() == 0); + QCOMPARE(cursor.position(), 0); + QCOMPARE(cursor.selectionStart(), 0); + QCOMPARE(cursor.selectionEnd(), 0); doc->redo(); frame = doc->frameAt(1); QVERIFY(frame); - QVERIFY(frame->firstPosition() == 1); - QVERIFY(frame->lastPosition() == 1); + QCOMPARE(frame->firstPosition(), 1); + QCOMPARE(frame->lastPosition(), 1); QVERIFY(frame->parentFrame() != 0); - QVERIFY(root->childFrames().size() == 1); + QCOMPARE(root->childFrames().size(), 1); - QVERIFY(cursor.position() == 1); - QVERIFY(cursor.selectionStart() == 1); - QVERIFY(cursor.selectionEnd() == 1); + QCOMPARE(cursor.position(), 1); + QCOMPARE(cursor.selectionStart(), 1); + QCOMPARE(cursor.selectionEnd(), 1); // cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); -// QVERIFY(cursor.position() == 2); -// QVERIFY(cursor.selectionStart() == 0); -// QVERIFY(cursor.selectionEnd() == 2); +// QCOMPARE(cursor.position(), 2); +// QCOMPARE(cursor.selectionStart(), 0); +// QCOMPARE(cursor.selectionEnd(), 2); } void tst_QTextCursor::checkFrame2() { - QVERIFY(cursor.position() == 0); + QCOMPARE(cursor.position(), 0); cursor.insertText("A"); - QVERIFY(cursor.position() == 1); + QCOMPARE(cursor.position(), 1); cursor.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor); QPointer<QTextFrame> frame = cursor.insertFrame(QTextFrameFormat()); QTextFrame *root = frame->parentFrame(); - QVERIFY(frame->firstPosition() == 1); - QVERIFY(frame->lastPosition() == 2); + QCOMPARE(frame->firstPosition(), 1); + QCOMPARE(frame->lastPosition(), 2); QVERIFY(frame->parentFrame() != 0); - QVERIFY(root->childFrames().size() == 1); + QCOMPARE(root->childFrames().size(), 1); - QVERIFY(cursor.position() == 1); - QVERIFY(cursor.selectionStart() == 1); - QVERIFY(cursor.selectionEnd() == 2); + QCOMPARE(cursor.position(), 1); + QCOMPARE(cursor.selectionStart(), 1); + QCOMPARE(cursor.selectionEnd(), 2); doc->undo(); QVERIFY(!frame); - QVERIFY(root->childFrames().size() == 0); + QCOMPARE(root->childFrames().size(), 0); - QVERIFY(cursor.position() == 0); - QVERIFY(cursor.selectionStart() == 0); - QVERIFY(cursor.selectionEnd() == 1); + QCOMPARE(cursor.position(), 0); + QCOMPARE(cursor.selectionStart(), 0); + QCOMPARE(cursor.selectionEnd(), 1); doc->redo(); frame = doc->frameAt(1); QVERIFY(frame); - QVERIFY(frame->firstPosition() == 1); - QVERIFY(frame->lastPosition() == 2); + QCOMPARE(frame->firstPosition(), 1); + QCOMPARE(frame->lastPosition(), 2); QVERIFY(frame->parentFrame() != 0); - QVERIFY(root->childFrames().size() == 1); + QCOMPARE(root->childFrames().size(), 1); - QVERIFY(cursor.position() == 1); - QVERIFY(cursor.selectionStart() == 1); - QVERIFY(cursor.selectionEnd() == 2); + QCOMPARE(cursor.position(), 1); + QCOMPARE(cursor.selectionStart(), 1); + QCOMPARE(cursor.selectionEnd(), 2); cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); - QVERIFY(cursor.position() == 0); - QVERIFY(cursor.selectionStart() == 0); - QVERIFY(cursor.selectionEnd() == 3); + QCOMPARE(cursor.position(), 0); + QCOMPARE(cursor.selectionStart(), 0); + QCOMPARE(cursor.selectionEnd(), 3); } void tst_QTextCursor::insertBlockToUseCharFormat() @@ -833,9 +833,9 @@ void tst_QTextCursor::insertBlockToUseCharFormat() void tst_QTextCursor::tableMovement() { - QVERIFY(cursor.position() == 0); + QCOMPARE(cursor.position(), 0); cursor.insertText("AA"); - QVERIFY(cursor.position() == 2); + QCOMPARE(cursor.position(), 2); cursor.movePosition(QTextCursor::Left); cursor.insertTable(3, 3); @@ -1030,7 +1030,7 @@ void tst_QTextCursor::insertBlockShouldRemoveSelection() cursor.insertBlock(); QVERIFY(!cursor.hasSelection()); - QVERIFY(doc->toPlainText().indexOf("Hello") == -1); + QCOMPARE(doc->toPlainText().indexOf("Hello"), -1); } void tst_QTextCursor::insertBlockShouldRemoveSelection2() @@ -1046,7 +1046,7 @@ void tst_QTextCursor::insertBlockShouldRemoveSelection2() cursor.insertBlock(fmt); QVERIFY(!cursor.hasSelection()); - QVERIFY(doc->toPlainText().indexOf("Hello") == -1); + QCOMPARE(doc->toPlainText().indexOf("Hello"), -1); } void tst_QTextCursor::mergeCellShouldUpdateSelection() @@ -1159,7 +1159,7 @@ void tst_QTextCursor::setBlockFormatInTable() cursor.setBlockFormat(fmt); cursor.movePosition(QTextCursor::Start); - QVERIFY(cursor.blockFormat().background().color() == Qt::blue); + QCOMPARE(cursor.blockFormat().background().color(), QColor(Qt::blue)); } void tst_QTextCursor::blockCharFormat2() @@ -1174,7 +1174,7 @@ void tst_QTextCursor::blockCharFormat2() cursor.movePosition(QTextCursor::Start); cursor.insertText("Red"); cursor.movePosition(QTextCursor::PreviousCharacter); - QVERIFY(cursor.charFormat().foreground().color() == Qt::red); + QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::red)); } void tst_QTextCursor::blockCharFormat3() @@ -1189,21 +1189,23 @@ void tst_QTextCursor::blockCharFormat3() cursor.insertText("Test"); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); - QVERIFY(cursor.charFormat().foreground().color() == Qt::green); + const QColor red(Qt::red); + const QColor green(Qt::green); + QCOMPARE(cursor.charFormat().foreground().color(), green); cursor.movePosition(QTextCursor::Start); - QVERIFY(cursor.charFormat().foreground().color() == Qt::green); + QCOMPARE(cursor.charFormat().foreground().color(), green); fmt.setForeground(Qt::red); cursor.setBlockCharFormat(fmt); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::red); + QCOMPARE(cursor.blockCharFormat().foreground().color(), red); cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::Start); - QVERIFY(cursor.charFormat().foreground().color() == Qt::green); + QCOMPARE(cursor.charFormat().foreground().color(), green); cursor.insertText("Test"); - QVERIFY(cursor.charFormat().foreground().color() == Qt::green); + QCOMPARE(cursor.charFormat().foreground().color(), green); cursor.select(QTextCursor::Document); cursor.removeSelectedText(); @@ -1212,7 +1214,7 @@ void tst_QTextCursor::blockCharFormat3() QVERIFY(cursor.atStart()); cursor.insertText("Test"); - QVERIFY(cursor.charFormat().foreground().color() == Qt::red); + QCOMPARE(cursor.charFormat().foreground().color(), red); } void tst_QTextCursor::blockCharFormat() @@ -1222,12 +1224,12 @@ void tst_QTextCursor::blockCharFormat() cursor.insertBlock(QTextBlockFormat(), fmt); cursor.insertText("Hm"); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::blue); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::blue)); fmt.setForeground(Qt::red); cursor.setBlockCharFormat(fmt); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::red); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::red)); } void tst_QTextCursor::blockCharFormatOnSelection() @@ -1249,11 +1251,11 @@ void tst_QTextCursor::blockCharFormatOnSelection() cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::blue); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::blue)); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::red); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::red)); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::white); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::white)); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextBlock); @@ -1264,17 +1266,17 @@ void tst_QTextCursor::blockCharFormatOnSelection() cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::cyan); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::cyan)); cursor.movePosition(QTextCursor::Right); cursor.movePosition(QTextCursor::Right); - QVERIFY(cursor.charFormat().foreground().color() == Qt::green); + QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::green)); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::cyan); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::cyan)); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockCharFormat().foreground().color() == Qt::white); + QCOMPARE(cursor.blockCharFormat().foreground().color(), QColor(Qt::white)); } void tst_QTextCursor::anchorInitialized1() @@ -1404,7 +1406,7 @@ void tst_QTextCursor::selectBlock() cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter); QCOMPARE(cursor.block().text(), QString("blah")); } @@ -1449,7 +1451,7 @@ void tst_QTextCursor::insertFragmentShouldUseCurrentCharFormat() cursor.insertFragment(fragment); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); - QVERIFY(cursor.charFormat() == fmt); + QCOMPARE(cursor.charFormat(), fmt); } int tst_QTextCursor::blockCount() @@ -1910,15 +1912,15 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo() int cursorPositionAfter = cursor.position(); cursor.endEditBlock(); - QVERIFY(doc->toPlainText() == "*AAAA*BBBB*CCCC*DDDD"); + QCOMPARE(doc->toPlainText(), QLatin1String("*AAAA*BBBB*CCCC*DDDD")); QCOMPARE(12, cursorPositionBefore); QCOMPARE(1, cursorPositionAfter); doc->undo(&cursor); - QVERIFY(doc->toPlainText() == "AAAABBBBCCCCDDDD"); + QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBBCCCCDDDD")); QCOMPARE(cursor.position(), cursorPositionBefore); doc->redo(&cursor); - QVERIFY(doc->toPlainText() == "*AAAA*BBBB*CCCC*DDDD"); + QCOMPARE(doc->toPlainText(), QLatin1String("*AAAA*BBBB*CCCC*DDDD")); QCOMPARE(cursor.position(), cursorPositionAfter); } @@ -1932,11 +1934,11 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2() cursor.insertText("AAAABBBBCCCCDDDD"); cursor.endEditBlock(); doc->undo(&cursor); - QVERIFY(doc->toPlainText() == "AAAABBBB"); + QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBB")); QCOMPARE(cursor.position(), cursorPositionBefore); cursor.insertText("CCCC"); - QVERIFY(doc->toPlainText() == "AAAABBBBCCCC"); + QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBBCCCC")); cursorPositionBefore = cursor.position(); cursor.setPosition(0, QTextCursor::KeepAnchor); @@ -1951,7 +1953,7 @@ void tst_QTextCursor::cursorPositionWithBlockUndoAndRedo2() doc->undo(&cursor); - QVERIFY(doc->toPlainText() == "AAAABBBBCCCC"); + QCOMPARE(doc->toPlainText(), QLatin1String("AAAABBBBCCCC")); QCOMPARE(cursor.position(), cursorPositionBefore); } diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 5e6b606d83..7378ca85ee 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -744,7 +744,7 @@ void tst_QTextDocument::mightBeRichText() { QFETCH(QString, input); QFETCH(bool, result); - QVERIFY(result == Qt::mightBeRichText(input)); + QCOMPARE(result, Qt::mightBeRichText(input)); } Q_DECLARE_METATYPE(QTextDocumentFragment) @@ -2222,7 +2222,7 @@ void tst_QTextDocument::clonePreservesUserStates() b2 = b2.next(); QCOMPARE(b1.userState(), b2.userState()); } - QVERIFY(b2 == clone->end()); + QCOMPARE(b2, clone->end()); delete clone; } @@ -2269,7 +2269,7 @@ void tst_QTextDocument::resolvedFontInEmptyFormat() doc->setDefaultFont(font); QTextCharFormat fmt = doc->begin().charFormat(); QVERIFY(fmt.properties().isEmpty()); - QVERIFY(fmt.font() == font); + QCOMPARE(fmt.font(), font); } void tst_QTextDocument::defaultRootFrameMargin() @@ -2369,6 +2369,7 @@ void tst_QTextDocument::deleteTextObjectsOnClear() void tst_QTextDocument::defaultStyleSheet() { + const QColor green("green"); const QString sheet("p { background-color: green; }"); QVERIFY(doc->defaultStyleSheet().isEmpty()); doc->setDefaultStyleSheet(sheet); @@ -2376,30 +2377,30 @@ void tst_QTextDocument::defaultStyleSheet() cursor.insertHtml("<p>test"); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); doc->clear(); cursor.insertHtml("<p>test"); fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); QTextDocument *clone = doc->clone(); QCOMPARE(clone->defaultStyleSheet(), sheet); cursor = QTextCursor(clone); cursor.insertHtml("<p>test"); fmt = clone->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); delete clone; cursor = QTextCursor(doc); cursor.insertHtml("<p>test"); fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); doc->clear(); cursor.insertHtml("<style>p { background-color: red; }</style><p>test"); fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("red")); + QCOMPARE(fmt.background().color(), QColor(Qt::red)); doc->clear(); doc->setDefaultStyleSheet("invalid style sheet...."); @@ -2567,7 +2568,7 @@ void tst_QTextDocument::setTextPreservesUndoRedoEnabled() void tst_QTextDocument::firstLast() { QCOMPARE(doc->blockCount(), 1); - QVERIFY(doc->firstBlock() == doc->lastBlock()); + QCOMPARE(doc->firstBlock(), doc->lastBlock()); doc->setPlainText("Hello\nTest\nWorld"); @@ -3013,8 +3014,8 @@ void tst_QTextDocument::QTBUG27354_spaceAndSoftSpace() QTextBlock block = td.begin(); while (block.isValid()) { QTextBlockFormat fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::SingleHeight); - QVERIFY(fmt.lineHeight() == 0); + QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::SingleHeight)); + QCOMPARE(fmt.lineHeight(), qreal(0)); block = block.next(); } } @@ -3164,8 +3165,8 @@ void tst_QTextDocument::cssInheritance() QTextBlock block = td.begin(); while (block.isValid()) { QTextBlockFormat fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight); - QVERIFY(fmt.lineHeight() == 200); + QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(fmt.lineHeight(), qreal(200)); block = block.next(); } } @@ -3175,12 +3176,12 @@ void tst_QTextDocument::cssInheritance() "<p style=\"line-height: 40px\">Foo</p><p>Bar</p><p>Baz</p></body></html>"); QTextBlock block = td.begin(); QTextBlockFormat fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::FixedHeight); - QVERIFY(fmt.lineHeight() == 40); + QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::FixedHeight)); + QCOMPARE(fmt.lineHeight(), qreal(40)); block = block.next(); fmt = block.blockFormat(); - QVERIFY(fmt.lineHeightType() == QTextBlockFormat::ProportionalHeight); - QVERIFY(fmt.lineHeight() == 300); + QCOMPARE(fmt.lineHeightType(), int(QTextBlockFormat::ProportionalHeight)); + QCOMPARE(fmt.lineHeight(), qreal(300)); } { QTextDocument td; @@ -3188,7 +3189,7 @@ void tst_QTextDocument::cssInheritance() "<p>Foo</p><p>Bar</p><p>Baz</p></body></html>"); QTextBlock block = td.begin(); while (block.isValid()) { - QVERIFY(block.blockFormat().background() == QBrush()); + QCOMPARE(block.blockFormat().background(), QBrush()); QVERIFY(block.charFormat().font().bold()); block = block.next(); } diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 8f0d306cba..1cd9d9bcbe 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -727,7 +727,7 @@ void tst_QTextDocumentFragment::html_listIndents5() QCOMPARE(list->format().indent(), 1); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.currentList() == list); + QCOMPARE(cursor.currentList(), list); QCOMPARE(cursor.blockFormat().indent(), 0); } @@ -778,7 +778,7 @@ void tst_QTextDocumentFragment::blockCharFormatCopied() cleanup(); init(); cursor.insertFragment(frag); - QVERIFY(cursor.blockCharFormat() == fmt); + QCOMPARE(cursor.blockCharFormat(), fmt); } void tst_QTextDocumentFragment::initialBlock() @@ -794,19 +794,19 @@ void tst_QTextDocumentFragment::clone() mod.setAlignment(Qt::AlignCenter); cursor.mergeBlockFormat(mod); cursor.insertText("Blah"); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignCenter); QTextDocumentFragment frag(doc); cleanup(); init(); cursor.insertFragment(frag); cursor.movePosition(QTextCursor::Start); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignCenter); } void tst_QTextDocumentFragment::dontRemoveInitialBlockIfItHoldsObjectIndexedCharFormat() { const char html[] = "<table><tr><td>cell one<td>cell two</tr><tr><td>cell three<td>cell four</tr></table>"; - QVERIFY(doc->begin().charFormat().objectIndex() == -1); + QCOMPARE(doc->begin().charFormat().objectIndex(), -1); setHtml(QString::fromLatin1(html)); int cnt = 0; @@ -841,13 +841,13 @@ void tst_QTextDocumentFragment::unorderedListEnumeration() setHtml(QString::fromLatin1(html)); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDisc); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDisc); const char html2[] = "<ul><ul><ul type=circle><li>Blah</li></ul></ul>"; setHtml(QString::fromLatin1(html2)); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListCircle); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListCircle); } @@ -873,7 +873,7 @@ void tst_QTextDocumentFragment::hrefAnchor() setHtml(QString::fromLatin1(html)); QVERIFY(doc->begin().begin().fragment().charFormat().isAnchor()); QCOMPARE(doc->begin().begin().fragment().charFormat().anchorHref(), QString::fromLatin1("test")); - QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline() == true); + QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline()); } { @@ -881,7 +881,7 @@ void tst_QTextDocumentFragment::hrefAnchor() const char html[] = "<a>blah</a>"; setHtml(QString::fromLatin1(html)); QVERIFY(doc->begin().begin().fragment().charFormat().isAnchor()); - QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline() == false); + QVERIFY(!doc->begin().begin().fragment().charFormat().fontUnderline()); } } @@ -901,7 +901,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments() // the 'a' QVERIFY(it.fragment().isValid()); QCOMPARE(it.fragment().text(), QString::fromLatin1("a")); - QVERIFY(it.fragment().charFormat().isAnchor() == false); + QVERIFY(!it.fragment().charFormat().isAnchor()); // the 'b' of 'blah' as separate fragment with the anchor attribute ++it; @@ -913,7 +913,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments() ++it; QVERIFY(it.fragment().isValid()); QVERIFY(it.fragment().text().startsWith("lah")); - QVERIFY(it.fragment().charFormat().isAnchor() == false); + QVERIFY(!it.fragment().charFormat().isAnchor()); } void tst_QTextDocumentFragment::namedAnchorFragments2() @@ -982,7 +982,7 @@ void tst_QTextDocumentFragment::cellBlockCount() int blockCount = 0; for (QTextFrame::iterator it = cell.begin(); !it.atEnd(); ++it) { - QVERIFY(it.currentFrame() == 0); + QVERIFY(!it.currentFrame()); QVERIFY(it.currentBlock().isValid()); ++blockCount; } @@ -1003,7 +1003,7 @@ void tst_QTextDocumentFragment::cellBlockCount2() int blockCount = 0; for (QTextFrame::iterator it = cell.begin(); !it.atEnd(); ++it) { - QVERIFY(it.currentFrame() == 0); + QVERIFY(!it.currentFrame()); QVERIFY(it.currentBlock().isValid()); ++blockCount; } @@ -1037,7 +1037,7 @@ void tst_QTextDocumentFragment::emptyTable3() QCOMPARE(table->columns(), 2); QTextTableCell cell = table->cellAt(0, 0); QVERIFY(cell.isValid()); - QVERIFY(cell.firstPosition() == cell.lastPosition()); + QCOMPARE(cell.firstPosition(), cell.lastPosition()); cell = table->cellAt(0, 1); QTextCursor cursor = cell.firstCursorPosition(); cursor.setPosition(cell.lastPosition(), QTextCursor::KeepAnchor); @@ -1065,7 +1065,7 @@ void tst_QTextDocumentFragment::inheritAlignment() const char html[] = "<body align=right><p>Hey"; setHtml(QString::fromLatin1(html)); // html alignment is absolute - QVERIFY(doc->begin().blockFormat().alignment() == Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute)); + QCOMPARE(doc->begin().blockFormat().alignment(), Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute)); } void tst_QTextDocumentFragment::dontEmitEmptyNodeWhenEmptyTagIsFollowedByCloseTag() @@ -1073,8 +1073,8 @@ void tst_QTextDocumentFragment::dontEmitEmptyNodeWhenEmptyTagIsFollowedByCloseTa // make sure the Hey does not end up as tag text for the img tag const char html[] = "<body align=right><p align=left>Blah<img></img><p>Hey"; setHtml(QString::fromLatin1(html)); - QVERIFY(doc->begin().blockFormat().alignment() == Qt::Alignment(Qt::AlignLeft|Qt::AlignAbsolute)); - QVERIFY(doc->begin().next().blockFormat().alignment() == Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute)); + QCOMPARE(doc->begin().blockFormat().alignment(), Qt::Alignment(Qt::AlignLeft|Qt::AlignAbsolute)); + QCOMPARE(doc->begin().next().blockFormat().alignment(), Qt::Alignment(Qt::AlignRight|Qt::AlignAbsolute)); } void tst_QTextDocumentFragment::toPlainText() @@ -1378,8 +1378,8 @@ void tst_QTextDocumentFragment::html_listStart1() { // don't create a block for the <ul> element, even if there's some whitespace between // it and the <li> - const char html[] = "<ul> <li>list item</li><ul>"; - cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0])))); + const QString html = QStringLiteral("<ul> <li>list item</li><ul>"); + cursor.insertFragment(QTextDocumentFragment::fromHtml(html)); QCOMPARE(doc->blockCount(), 1); } @@ -1387,8 +1387,8 @@ void tst_QTextDocumentFragment::html_listStart1() void tst_QTextDocumentFragment::html_listStart2() { // unlike with html_listStart1 we want a block showing the 'buggy' text here - const char html[] = "<ul>buggy, but text should appear<li>list item</li><ul>"; - cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0])))); + const QString html = QStringLiteral("<ul>buggy, but text should appear<li>list item</li><ul>"); + cursor.insertFragment(QTextDocumentFragment::fromHtml(html)); QCOMPARE(doc->blockCount(), 2); } @@ -1480,19 +1480,19 @@ void tst_QTextDocumentFragment::html_subAndSuperScript() const char alignmentInherited[] = "<sub><font face=\"Verdana\">Subby</font></sub>"; setHtml(subHtml); - QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSubScript); + QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSubScript); setHtml(subHtmlCss); - QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSubScript); + QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSubScript); setHtml(superHtml); - QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSuperScript); + QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSuperScript); setHtml(superHtmlCss); - QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSuperScript); + QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSuperScript); setHtml(alignmentInherited); - QVERIFY(cursor.charFormat().verticalAlignment() == QTextCharFormat::AlignSubScript); + QCOMPARE(cursor.charFormat().verticalAlignment(), QTextCharFormat::AlignSubScript); } void tst_QTextDocumentFragment::html_cssColors() @@ -1695,7 +1695,7 @@ void tst_QTextDocumentFragment::html_bodyBackground() const char html[] = "<body background=\"foo.png\">Foo</body>"; doc->setHtml(html); - QVERIFY(doc->rootFrame()->frameFormat().background().style() == Qt::TexturePattern); + QCOMPARE(doc->rootFrame()->frameFormat().background().style(), Qt::TexturePattern); } void tst_QTextDocumentFragment::html_tableCellBackground() @@ -1709,7 +1709,7 @@ void tst_QTextDocumentFragment::html_tableCellBackground() QVERIFY(table); QTextTableCell cell = table->cellAt(0, 0); - QVERIFY(cell.format().background().style() == Qt::TexturePattern); + QCOMPARE(cell.format().background().style(), Qt::TexturePattern); } void tst_QTextDocumentFragment::css_bodyBackground() @@ -1717,7 +1717,7 @@ void tst_QTextDocumentFragment::css_bodyBackground() const char html[] = "<body style=\"background-image:url('foo.png')\">Foo</body>"; doc->setHtml(html); - QVERIFY(doc->rootFrame()->frameFormat().background().style() == Qt::TexturePattern); + QCOMPARE(doc->rootFrame()->frameFormat().background().style(), Qt::TexturePattern); } void tst_QTextDocumentFragment::css_tableCellBackground() @@ -1731,7 +1731,7 @@ void tst_QTextDocumentFragment::css_tableCellBackground() QVERIFY(table); QTextTableCell cell = table->cellAt(0, 0); - QVERIFY(cell.format().background().style() == Qt::TexturePattern); + QCOMPARE(cell.format().background().style(), Qt::TexturePattern); } void tst_QTextDocumentFragment::css_cellPaddings() @@ -1767,7 +1767,7 @@ void tst_QTextDocumentFragment::html_blockLevelDiv() setHtml(html); QCOMPARE(doc->begin().blockFormat().alignment(), Qt::AlignRight|Qt::AlignAbsolute); - QVERIFY(doc->begin().next() == doc->end()); + QCOMPARE(doc->begin().next(), doc->end()); } void tst_QTextDocumentFragment::html_spanNesting() @@ -1805,7 +1805,7 @@ void tst_QTextDocumentFragment::html_nestedLists() cursor.movePosition(QTextCursor::NextBlock); QTextList *thirdList = cursor.currentList(); QVERIFY(thirdList); - QVERIFY(thirdList == firstList); + QCOMPARE(thirdList, firstList); } void tst_QTextDocumentFragment::noSpecialCharactersInPlainText() @@ -1837,7 +1837,7 @@ void tst_QTextDocumentFragment::html_doNotInheritBackground() for (QTextBlock block = doc->begin(); block.isValid(); block = block.next()) { - QVERIFY(block.blockFormat().hasProperty(QTextFormat::BackgroundBrush) == false); + QVERIFY(!block.blockFormat().hasProperty(QTextFormat::BackgroundBrush)); } QVERIFY(doc->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush)); @@ -2022,7 +2022,7 @@ void tst_QTextDocumentFragment::html_frameImport() cursor.insertFragment(frag); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QVERIFY(childFrames.count() == 1); + QCOMPARE(childFrames.count(), 1); QTextFrame *frame = childFrames.first(); QCOMPARE(frame->frameFormat().margin(), ffmt.margin()); QCOMPARE(frame->frameFormat().border(), ffmt.border()); @@ -2050,7 +2050,7 @@ void tst_QTextDocumentFragment::html_frameImport2() cursor.insertFragment(frag); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QVERIFY(childFrames.count() == 1); + QCOMPARE(childFrames.count(), 1); QTextFrame *frame = childFrames.first(); QCOMPARE(frame->frameFormat().topMargin(), ffmt.topMargin()); QCOMPARE(frame->frameFormat().bottomMargin(), ffmt.bottomMargin()); @@ -2065,7 +2065,7 @@ void tst_QTextDocumentFragment::html_dontAddMarginsAcrossTableCells() cursor.insertFragment(QTextDocumentFragment::fromHtml(QString::fromLatin1(html))); QList<QTextFrame *> childFrames = doc->rootFrame()->childFrames(); - QVERIFY(childFrames.count() == 1); + QCOMPARE(childFrames.count(), 1); QTextFrame *frame = childFrames.first(); cursor = frame->firstCursorPosition(); QCOMPARE(cursor.blockFormat().leftMargin(), qreal(50.0)); @@ -2078,7 +2078,7 @@ void tst_QTextDocumentFragment::html_dontMergeCenterBlocks() QCOMPARE(doc->blockCount(), 2); QTextBlock blk = doc->begin(); - QVERIFY(blk.blockFormat().alignment() == Qt::AlignCenter); + QCOMPARE(blk.blockFormat().alignment(), Qt::AlignCenter); blk = blk.next(); QVERIFY(blk.blockFormat().alignment() != Qt::AlignCenter); } @@ -2112,7 +2112,7 @@ void tst_QTextDocumentFragment::html_tableCellBgColor2() QTextFrame::Iterator it = cell.begin(); QVERIFY(!it.atEnd()); - QVERIFY(it.currentFrame() == 0); + QVERIFY(!it.currentFrame()); QVERIFY(it.currentBlock().isValid()); ++it; @@ -2122,9 +2122,9 @@ void tst_QTextDocumentFragment::html_tableCellBgColor2() ++it; QVERIFY(!it.atEnd()); - QVERIFY(it.currentFrame() == 0); + QVERIFY(!it.currentFrame()); QVERIFY(it.currentBlock().isValid()); - QVERIFY(it.currentBlock().blockFormat().background() == QBrush(Qt::NoBrush)); + QCOMPARE(it.currentBlock().blockFormat().background(), QBrush(Qt::NoBrush)); ++it; QVERIFY(it.atEnd()); @@ -2245,8 +2245,8 @@ void tst_QTextDocumentFragment::html_blockVsInline() { { setHtml("<html><body><div><b>Foo<div>Bar"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<html><body><p><b>Foo<p>Bar"); @@ -2255,23 +2255,23 @@ void tst_QTextDocumentFragment::html_blockVsInline() } { setHtml("<html><body><b><center>Foo</center></b>"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<html><body><b><p>Foo"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<html><body><b><p>Foo<p>Bar"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<div><b>Foo<div>Bar"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<p><b>Foo<p>Bar"); @@ -2280,18 +2280,18 @@ void tst_QTextDocumentFragment::html_blockVsInline() } { setHtml("<b><center>Foo</center></b>"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<b><p>Foo"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } { setHtml("<b><p>Foo<p>Bar"); - QVERIFY(cursor.charFormat().fontWeight() == QFont::Bold); - QVERIFY(cursor.blockCharFormat().fontWeight() == QFont::Bold); + QCOMPARE(cursor.charFormat().fontWeight(), int(QFont::Bold)); + QCOMPARE(cursor.blockCharFormat().fontWeight(), int(QFont::Bold)); } } @@ -2338,7 +2338,7 @@ void tst_QTextDocumentFragment::html_nestedTables() QTextTable *firstNestedTable = cursor.currentTable(); QVERIFY(firstNestedTable); - QVERIFY(firstNestedTable->parentFrame() == table); + QCOMPARE(firstNestedTable->parentFrame(), table); QCOMPARE(firstNestedTable->rows(), 1); QCOMPARE(firstNestedTable->columns(), 1); QCOMPARE(firstNestedTable->cellAt(0, 0).firstCursorPosition().block().text(), QString("Hello")); @@ -2348,13 +2348,13 @@ void tst_QTextDocumentFragment::html_nestedTables() ; QVERIFY(!cursor.isNull()); - QVERIFY(cursor.currentTable() == table); + QCOMPARE(cursor.currentTable(), table); cursor.movePosition(QTextCursor::NextBlock); QTextTable *secondNestedTable = cursor.currentTable(); QVERIFY(secondNestedTable); - QVERIFY(secondNestedTable->parentFrame() == table); + QCOMPARE(secondNestedTable->parentFrame(), table); QCOMPARE(secondNestedTable->rows(), 1); QCOMPARE(secondNestedTable->columns(), 1); QCOMPARE(secondNestedTable->cellAt(0, 0).firstCursorPosition().block().text(), QString("World")); @@ -2454,7 +2454,7 @@ void tst_QTextDocumentFragment::html_anchorColor() setHtml("<span style=\"color: red;\"><a href=\"http://www.kde.org/\">Blue</a></span>"); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); - QVERIFY(cursor.charFormat().foreground().color() == QGuiApplication::palette().link().color()); + QCOMPARE(cursor.charFormat().foreground().color(), QGuiApplication::palette().link().color()); setHtml("<span style=\"color: red;\"><a href=\"http://www.kde.org/\" style=\"color: yellow;\">Green</a></span>"); cursor.movePosition(QTextCursor::Start); @@ -2525,17 +2525,17 @@ void tst_QTextDocumentFragment::html_columnWidths() const QVector<QTextLength> columnWidths = fmt.columnWidthConstraints(); QCOMPARE(columnWidths.count(), 2); - QVERIFY(columnWidths.at(0).type() == QTextLength::VariableLength); - QVERIFY(columnWidths.at(1).type() == QTextLength::PercentageLength); - QVERIFY(columnWidths.at(1).rawValue() == 1); + QCOMPARE(columnWidths.at(0).type(), QTextLength::VariableLength); + QCOMPARE(columnWidths.at(1).type(), QTextLength::PercentageLength); + QCOMPARE(columnWidths.at(1).rawValue(), qreal(1)); } void tst_QTextDocumentFragment::css_fontWeight() { setHtml("<p style=\"font-weight:bold\">blah</p>"); - QVERIFY(doc->begin().charFormat().fontWeight() == QFont::Bold); + QCOMPARE(doc->begin().charFormat().fontWeight(), int(QFont::Bold)); setHtml("<p style=\"font-weight:600\">blah</p>"); - QVERIFY(doc->begin().charFormat().fontWeight() == QFont::Bold); + QCOMPARE(doc->begin().charFormat().fontWeight(), int(QFont::Bold)); } @@ -2548,7 +2548,7 @@ void tst_QTextDocumentFragment::css_float() QVERIFY(o); QTextFormat f = o->format(); QVERIFY(f.isFrameFormat()); - QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::FloatRight); + QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::FloatRight); setHtml("<img src=\"foo\" align=right>"); fmt = doc->begin().begin().fragment().charFormat(); @@ -2557,7 +2557,7 @@ void tst_QTextDocumentFragment::css_float() QVERIFY(o); f = o->format(); QVERIFY(f.isFrameFormat()); - QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::FloatRight); + QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::FloatRight); setHtml("<img src=\"foo\" align=left>"); fmt = doc->begin().begin().fragment().charFormat(); @@ -2566,7 +2566,7 @@ void tst_QTextDocumentFragment::css_float() QVERIFY(o); f = o->format(); QVERIFY(f.isFrameFormat()); - QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::FloatLeft); + QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::FloatLeft); } void tst_QTextDocumentFragment::css_textIndent() @@ -2585,7 +2585,7 @@ void tst_QTextDocumentFragment::css_inline() "<p>test</p>" ); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), QColor("green")); } void tst_QTextDocumentFragment::css_external() @@ -2596,11 +2596,12 @@ void tst_QTextDocumentFragment::css_external() "<p>test</p>" ); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), QColor("green")); } void tst_QTextDocumentFragment::css_import() { + const QColor green("green"); doc->addResource(QTextDocument::StyleSheetResource, QUrl("test.css"), QString("@import \"other.css\";")); doc->addResource(QTextDocument::StyleSheetResource, QUrl("other.css"), QString("@import url(\"other2.css\");")); doc->addResource(QTextDocument::StyleSheetResource, QUrl("other2.css"), QString("p { background-color: green; }")); @@ -2609,14 +2610,14 @@ void tst_QTextDocumentFragment::css_import() "<p>test</p>" ); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); doc->setHtml("" "<style>@import \"test.css\" screen;</style>" "<p>test</p>" ); fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); } void tst_QTextDocumentFragment::css_selectors_data() @@ -2662,9 +2663,9 @@ void tst_QTextDocumentFragment::css_selectors() QTextBlockFormat fmt = doc->begin().blockFormat(); if (match) - QVERIFY(fmt.background().color() == QColor("red")); + QCOMPARE(fmt.background().color(), QColor("red")); else - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), QColor("green")); } void tst_QTextDocumentFragment::css_nodeNameCaseInsensitivity() @@ -2674,7 +2675,7 @@ void tst_QTextDocumentFragment::css_nodeNameCaseInsensitivity() "</style>" "<p>test</p>"); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), QColor("green")); } void tst_QTextDocumentFragment::css_textUnderlineStyle_data() @@ -2710,14 +2711,14 @@ void tst_QTextDocumentFragment::css_textUnderlineStyleAndDecoration() QTextFragment fragment = doc->begin().begin().fragment(); QVERIFY(fragment.isValid()); - QVERIFY(fragment.charFormat().underlineStyle() == QTextCharFormat::SingleUnderline); + QCOMPARE(fragment.charFormat().underlineStyle(), QTextCharFormat::SingleUnderline); QVERIFY(fragment.charFormat().fontOverline()); doc->setHtml("<span style=\"text-underline-style: solid; text-decoration: overline\">Test</span>"); fragment = doc->begin().begin().fragment(); QVERIFY(fragment.isValid()); - QVERIFY(fragment.charFormat().underlineStyle() == QTextCharFormat::SingleUnderline); + QCOMPARE(fragment.charFormat().underlineStyle(), QTextCharFormat::SingleUnderline); QVERIFY(fragment.charFormat().fontOverline()); } @@ -2726,48 +2727,48 @@ void tst_QTextDocumentFragment::css_listStyleType() doc->setHtml("<ol style=\"list-style-type: disc\"><li>Blah</li></ol>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDisc); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDisc); doc->setHtml("<ul style=\"list-style-type: square\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListSquare); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListSquare); doc->setHtml("<ul style=\"list-style-type: circle\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListCircle); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListCircle); doc->setHtml("<ul style=\"list-style-type: decimal\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDecimal); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDecimal); doc->setHtml("<ul style=\"list-style-type: lower-alpha\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListLowerAlpha); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListLowerAlpha); doc->setHtml("<ul style=\"list-style-type: upper-alpha\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListUpperAlpha); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListUpperAlpha); doc->setHtml("<ul style=\"list-style-type: upper-roman\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListUpperRoman); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListUpperRoman); doc->setHtml("<ul style=\"list-style-type: lower-roman\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListLowerRoman); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListLowerRoman); // ignore the unsupported list-style-position inside the list-style shorthand property doc->setHtml("<ul style=\"list-style: outside decimal\"><li>Blah</li></ul>"); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListDecimal); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListDecimal); } void tst_QTextDocumentFragment::css_linkPseudo() @@ -2785,13 +2786,13 @@ void tst_QTextDocumentFragment::css_linkPseudo() void tst_QTextDocumentFragment::css_pageBreaks() { doc->setHtml("<p>Foo</p>"); - QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == QTextFormat::PageBreak_Auto); + QCOMPARE(doc->begin().blockFormat().pageBreakPolicy(), QTextFormat::PageBreak_Auto); doc->setHtml("<p style=\" page-break-before:always;\">Foo</p>"); - QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == QTextFormat::PageBreak_AlwaysBefore); + QCOMPARE(doc->begin().blockFormat().pageBreakPolicy(), QTextFormat::PageBreak_AlwaysBefore); doc->setHtml("<p style=\" page-break-after:always;\">Foo</p>"); - QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == QTextFormat::PageBreak_AlwaysAfter); + QCOMPARE(doc->begin().blockFormat().pageBreakPolicy(), QTextFormat::PageBreak_AlwaysAfter); doc->setHtml("<p style=\" page-break-before:always; page-break-after:always;\">Foo</p>"); QVERIFY(doc->begin().blockFormat().pageBreakPolicy() == (QTextFormat::PageBreak_AlwaysAfter | QTextFormat::PageBreak_AlwaysBefore)); @@ -2832,13 +2833,14 @@ void tst_QTextDocumentFragment::universalSelectors() QTextBlockFormat fmt = doc->begin().blockFormat(); if (match) - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), QColor("green")); else QVERIFY(!fmt.hasProperty(QTextFormat::BackgroundBrush)); } void tst_QTextDocumentFragment::screenMedia() { + const QColor green("green"); setHtml("<style>" "@media screen {" "p { background-color: green }" @@ -2847,7 +2849,7 @@ void tst_QTextDocumentFragment::screenMedia() "<p>test</p>" ""); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); setHtml("<style>" "@media foobar {" @@ -2857,7 +2859,7 @@ void tst_QTextDocumentFragment::screenMedia() "<p>test</p>" ""); fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() != QColor("green")); + QVERIFY(fmt.background().color() != green); setHtml("<style>" "@media sCrEeN {" @@ -2867,7 +2869,7 @@ void tst_QTextDocumentFragment::screenMedia() "<p>test</p>" ""); fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), green); } void tst_QTextDocumentFragment::htmlResourceLoading() @@ -2881,7 +2883,7 @@ void tst_QTextDocumentFragment::htmlResourceLoading() doc->clear(); QTextCursor(doc).insertFragment(frag); QTextBlockFormat fmt = doc->begin().blockFormat(); - QVERIFY(fmt.background().color() == QColor("green")); + QCOMPARE(fmt.background().color(), QColor("green")); } void tst_QTextDocumentFragment::someCaseInsensitiveAttributeValues() @@ -2890,7 +2892,7 @@ void tst_QTextDocumentFragment::someCaseInsensitiveAttributeValues() setHtml(QString::fromLatin1(html1)); cursor.movePosition(QTextCursor::End); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->format().style() == QTextListFormat::ListSquare); + QCOMPARE(cursor.currentList()->format().style(), QTextListFormat::ListSquare); const char html2[] = "<div align=ceNTeR><b>Hello World"; setHtml(html2); @@ -2925,7 +2927,7 @@ void tst_QTextDocumentFragment::backgroundImage() doc.testPixmap.fill(Qt::blue); doc.setHtml("<p style=\"background-image: url(testPixmap)\">Hello</p>"); QBrush bg = doc.begin().blockFormat().background(); - QVERIFY(bg.style() == Qt::TexturePattern); + QCOMPARE(bg.style(), Qt::TexturePattern); QCOMPARE(bg.texture().cacheKey(), doc.testPixmap.cacheKey()); } @@ -3109,7 +3111,7 @@ void tst_QTextDocumentFragment::html_tableStrangeNewline() QCOMPARE(table->columns(), 1); const QTextTableCell cell = table->cellAt(0, 0); QCOMPARE(cell.firstCursorPosition().block().text(), QString("Foo")); - QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block()); + QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block()); } void tst_QTextDocumentFragment::html_tableStrangeNewline2() @@ -3123,7 +3125,7 @@ void tst_QTextDocumentFragment::html_tableStrangeNewline2() QCOMPARE(table->columns(), 1); const QTextTableCell cell = table->cellAt(0, 0); QCOMPARE(cell.firstCursorPosition().block().text(), QString("Foo")); - QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block()); + QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block()); } void tst_QTextDocumentFragment::html_tableStrangeNewline3() @@ -3152,11 +3154,11 @@ void tst_QTextDocumentFragment::html_tableStrangeNewline3() QTextTableCell cell = table->cellAt(0, 0); QCOMPARE(cell.firstCursorPosition().block().text(), QString("Meh")); - QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block()); + QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block()); cell = table->cellAt(0, 1); QCOMPARE(cell.firstCursorPosition().block().text(), QString("Foo")); - QVERIFY(cell.firstCursorPosition().block() == cell.lastCursorPosition().block()); + QCOMPARE(cell.firstCursorPosition().block(), cell.lastCursorPosition().block()); } void tst_QTextDocumentFragment::html_caption() @@ -3170,7 +3172,7 @@ void tst_QTextDocumentFragment::html_caption() cursor.movePosition(QTextCursor::NextBlock); QCOMPARE(cursor.block().text(), QString("This is a Caption!")); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter); cursor.movePosition(QTextCursor::NextBlock); QTextTable *table = cursor.currentTable(); @@ -3427,7 +3429,7 @@ void tst_QTextDocumentFragment::html_dontInheritAlignmentForFloatingImages() QVERIFY(o); QTextFormat f = o->format(); QVERIFY(f.isFrameFormat()); - QVERIFY(f.toFrameFormat().position() == QTextFrameFormat::InFlow); + QCOMPARE(f.toFrameFormat().position(), QTextFrameFormat::InFlow); } void tst_QTextDocumentFragment::html_verticalImageAlignment() @@ -3437,35 +3439,35 @@ void tst_QTextDocumentFragment::html_verticalImageAlignment() cursor.movePosition(QTextCursor::NextCharacter); QVERIFY(cursor.charFormat().isImageFormat()); QTextImageFormat fmt = cursor.charFormat().toImageFormat(); - QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignNormal); + QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignNormal); doc->setHtml("<img src=\"foo\" align=middle />"); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); QVERIFY(cursor.charFormat().isImageFormat()); fmt = cursor.charFormat().toImageFormat(); - QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignMiddle); + QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignMiddle); doc->setHtml("<img src=\"foo\" style=\"vertical-align: middle\" />"); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); QVERIFY(cursor.charFormat().isImageFormat()); fmt = cursor.charFormat().toImageFormat(); - QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignMiddle); + QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignMiddle); doc->setHtml("<img src=\"foo\" align=top />"); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); QVERIFY(cursor.charFormat().isImageFormat()); fmt = cursor.charFormat().toImageFormat(); - QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignTop); + QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignTop); doc->setHtml("<img src=\"foo\" style=\"vertical-align: top\" />"); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextCharacter); QVERIFY(cursor.charFormat().isImageFormat()); fmt = cursor.charFormat().toImageFormat(); - QVERIFY(fmt.verticalAlignment() == QTextCharFormat::AlignTop); + QCOMPARE(fmt.verticalAlignment(), QTextCharFormat::AlignTop); } void tst_QTextDocumentFragment::html_verticalCellAlignment() @@ -3944,11 +3946,11 @@ void tst_QTextDocumentFragment::html_directionWithHtml() block = block.next(); QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection)); - QVERIFY(block.blockFormat().layoutDirection() == Qt::RightToLeft); + QCOMPARE(block.blockFormat().layoutDirection(), Qt::RightToLeft); block = block.next(); QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection)); - QVERIFY(block.blockFormat().layoutDirection() == Qt::LeftToRight); + QCOMPARE(block.blockFormat().layoutDirection(), Qt::LeftToRight); } void tst_QTextDocumentFragment::html_directionWithRichText() @@ -3961,11 +3963,11 @@ void tst_QTextDocumentFragment::html_directionWithRichText() block = block.next(); QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection)); - QVERIFY(block.blockFormat().layoutDirection() == Qt::RightToLeft); + QCOMPARE(block.blockFormat().layoutDirection(), Qt::RightToLeft); block = block.next(); QVERIFY(block.blockFormat().hasProperty(QTextFormat::LayoutDirection)); - QVERIFY(block.blockFormat().layoutDirection() == Qt::LeftToRight); + QCOMPARE(block.blockFormat().layoutDirection(), Qt::LeftToRight); } void tst_QTextDocumentFragment::html_metaInBody() diff --git a/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST new file mode 100644 index 0000000000..b13b2497d3 --- /dev/null +++ b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST @@ -0,0 +1,2 @@ +[imageAtRightAlignedTab] +linux diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp index 7c742bc864..5a401031e2 100644 --- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp +++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp @@ -101,7 +101,7 @@ void tst_QTextFormat::defaultAlignment() QTextBlockFormat fmt; QVERIFY(!fmt.hasProperty(QTextFormat::BlockAlignment)); QCOMPARE(fmt.intProperty(QTextFormat::BlockAlignment), 0); - QVERIFY(fmt.alignment() == Qt::AlignLeft); + QCOMPARE(fmt.alignment(), Qt::AlignLeft); } void tst_QTextFormat::testUnderlinePropertyPrecedence() @@ -209,7 +209,7 @@ void tst_QTextFormat::resolveFont() QVector<QTextFormat> formats = doc.allFormats(); QCOMPARE(formats.count(), 3); - QVERIFY(formats.at(2).type() == QTextFormat::CharFormat); + QCOMPARE(formats.at(2).type(), int(QTextFormat::CharFormat)); fmt = formats.at(2).toCharFormat(); QVERIFY(!fmt.font().underline()); diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 51f726ac86..18da61925d 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1675,6 +1675,7 @@ void tst_QTextLayout::testTabDPIScale() case QPaintDevice::PdmPhysicalDpiY: return 72; case QPaintDevice::PdmDevicePixelRatio: + case QPaintDevice::PdmDevicePixelRatioScaled: ; // fall through } return 0; @@ -1744,7 +1745,7 @@ void tst_QTextLayout::capitalization_allUpperCase() QTextEngine *engine = layout.engine(); engine->itemize(); QCOMPARE(engine->layoutData->items.count(), 1); - QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase); + QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Uppercase)); } void tst_QTextLayout::capitalization_allUpperCase_newline() @@ -1764,9 +1765,9 @@ void tst_QTextLayout::capitalization_allUpperCase_newline() QTextEngine *engine = layout.engine(); engine->itemize(); QCOMPARE(engine->layoutData->items.count(), 3); - QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase); - QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::LineOrParagraphSeparator); - QVERIFY(engine->layoutData->items.at(2).analysis.flags == QScriptAnalysis::Uppercase); + QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Uppercase)); + QCOMPARE(engine->layoutData->items.at(1).analysis.flags, ushort(QScriptAnalysis::LineOrParagraphSeparator)); + QCOMPARE(engine->layoutData->items.at(2).analysis.flags, ushort(QScriptAnalysis::Uppercase)); } void tst_QTextLayout::capitalization_allLowerCase() @@ -1782,7 +1783,7 @@ void tst_QTextLayout::capitalization_allLowerCase() QTextEngine *engine = layout.engine(); engine->itemize(); QCOMPARE(engine->layoutData->items.count(), 1); - QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Lowercase); + QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Lowercase)); } void tst_QTextLayout::capitalization_smallCaps() @@ -1798,8 +1799,8 @@ void tst_QTextLayout::capitalization_smallCaps() QTextEngine *engine = layout.engine(); engine->itemize(); QCOMPARE(engine->layoutData->items.count(), 2); - QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::None); - QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::SmallCaps); + QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::None)); + QCOMPARE(engine->layoutData->items.at(1).analysis.flags, ushort(QScriptAnalysis::SmallCaps)); } void tst_QTextLayout::capitalization_capitalize() @@ -1815,11 +1816,11 @@ void tst_QTextLayout::capitalization_capitalize() QTextEngine *engine = layout.engine(); engine->itemize(); QCOMPARE(engine->layoutData->items.count(), 5); - QVERIFY(engine->layoutData->items.at(0).analysis.flags == QScriptAnalysis::Uppercase); - QVERIFY(engine->layoutData->items.at(1).analysis.flags == QScriptAnalysis::None); - QVERIFY(engine->layoutData->items.at(2).analysis.flags == QScriptAnalysis::Tab); - QVERIFY(engine->layoutData->items.at(3).analysis.flags == QScriptAnalysis::Uppercase); - QVERIFY(engine->layoutData->items.at(4).analysis.flags == QScriptAnalysis::None); + QCOMPARE(engine->layoutData->items.at(0).analysis.flags, ushort(QScriptAnalysis::Uppercase)); + QCOMPARE(engine->layoutData->items.at(1).analysis.flags, ushort(QScriptAnalysis::None)); + QCOMPARE(engine->layoutData->items.at(2).analysis.flags, ushort(QScriptAnalysis::Tab)); + QCOMPARE(engine->layoutData->items.at(3).analysis.flags, ushort(QScriptAnalysis::Uppercase)); + QCOMPARE(engine->layoutData->items.at(4).analysis.flags, ushort(QScriptAnalysis::None)); } void tst_QTextLayout::longText() @@ -2096,8 +2097,8 @@ void tst_QTextLayout::cursorInNonStopChars() QTextLine line = layout.createLine(); layout.endLayout(); - QVERIFY(line.cursorToX(1) == line.cursorToX(3)); - QVERIFY(line.cursorToX(2) == line.cursorToX(3)); + QCOMPARE(line.cursorToX(1), line.cursorToX(3)); + QCOMPARE(line.cursorToX(2), line.cursorToX(3)); } void tst_QTextLayout::justifyTrailingSpaces() diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp index c57123af61..03e557d8dd 100644 --- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp +++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp @@ -113,11 +113,11 @@ void tst_QTextList::autoNumbering() for (int i = 0; i < 27; ++i) cursor.insertBlock(); - QVERIFY(list->count() == 28); + QCOMPARE(list->count(), 28); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 27); - QVERIFY(cursor.currentList()->itemText(cursor.block()) == "ab."); + QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 27); + QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("ab.")); } void tst_QTextList::autoNumberingPrefixAndSuffix() @@ -132,11 +132,11 @@ void tst_QTextList::autoNumberingPrefixAndSuffix() for (int i = 0; i < 27; ++i) cursor.insertBlock(); - QVERIFY(list->count() == 28); + QCOMPARE(list->count(), 28); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 27); - QVERIFY(cursor.currentList()->itemText(cursor.block()) == "-ab)"); + QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 27); + QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("-ab)")); } void tst_QTextList::autoNumberingPrefixAndSuffixRTL() @@ -154,9 +154,9 @@ void tst_QTextList::autoNumberingPrefixAndSuffixRTL() cursor.insertBlock(); - QVERIFY(list->count() == 2); + QCOMPARE(list->count(), 2); - QVERIFY(cursor.currentList()->itemText(cursor.block()) == "*B-"); + QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("*B-")); } void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport() @@ -174,7 +174,7 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport() for (int i = 0; i < 27; ++i) cursor.insertBlock(); - QVERIFY(list->count() == 28); + QCOMPARE(list->count(), 28); QString htmlExport = doc->toHtml(); QTextDocument importDoc; @@ -185,9 +185,9 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport() importCursor.movePosition(QTextCursor::NextBlock); QVERIFY(importCursor.currentList()); - QVERIFY(importCursor.currentList()->itemNumber(importCursor.block()) == 27); - QVERIFY(importCursor.currentList()->itemText(importCursor.block()) == "\"ab#"); - QVERIFY(importCursor.currentList()->format().indent() == 10); + QCOMPARE(importCursor.currentList()->itemNumber(importCursor.block()), 27); + QCOMPARE(importCursor.currentList()->itemText(importCursor.block()), QLatin1String("\"ab#")); + QCOMPARE(importCursor.currentList()->format().indent(), 10); } void tst_QTextList::autoNumberingRTL() @@ -203,9 +203,9 @@ void tst_QTextList::autoNumberingRTL() cursor.insertBlock(); - QVERIFY(list->count() == 2); + QCOMPARE(list->count(), 2); - QVERIFY(cursor.currentList()->itemText(cursor.block()) == ".B"); + QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String(".B")); } void tst_QTextList::romanNumbering() @@ -218,11 +218,11 @@ void tst_QTextList::romanNumbering() for (int i = 0; i < 4998; ++i) cursor.insertBlock(); - QVERIFY(list->count() == 4999); + QCOMPARE(list->count(), 4999); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 4998); - QVERIFY(cursor.currentList()->itemText(cursor.block()) == "MMMMCMXCIX."); + QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 4998); + QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("MMMMCMXCIX.")); } void tst_QTextList::romanNumberingLimit() @@ -235,11 +235,11 @@ void tst_QTextList::romanNumberingLimit() for (int i = 0; i < 4999; ++i) cursor.insertBlock(); - QVERIFY(list->count() == 5000); + QCOMPARE(list->count(), 5000); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 4999); - QVERIFY(cursor.currentList()->itemText(cursor.block()) == "?."); + QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 4999); + QCOMPARE(cursor.currentList()->itemText(cursor.block()), QLatin1String("?.")); } void tst_QTextList::formatChange() @@ -257,12 +257,12 @@ void tst_QTextList::formatChange() QVERIFY(list && list->count() == 2); QTextBlockFormat bfmt = cursor.blockFormat(); -// QVERIFY(bfmt.object() == list); +// QCOMPARE(bfmt.object(), list); bfmt.setObjectIndex(-1); cursor.setBlockFormat(bfmt); - QVERIFY(firstList->count() == 1); + QCOMPARE(firstList->count(), 1); } void tst_QTextList::cursorNavigation() @@ -282,7 +282,7 @@ void tst_QTextList::cursorNavigation() QVERIFY(cursor.currentList()); cursor.movePosition(QTextCursor::PreviousBlock); QVERIFY(cursor.currentList()); - QVERIFY(cursor.currentList()->itemNumber(cursor.block()) == 0); + QCOMPARE(cursor.currentList()->itemNumber(cursor.block()), 0); } void tst_QTextList::partialRemoval() diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp index ae8948a61f..cd43849729 100644 --- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp @@ -157,7 +157,7 @@ void tst_QTextPieceTable::insertion3() table->insert(pos, str, charFormatIndex); compare.insert(pos, str); } - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); } void tst_QTextPieceTable::insertion4() @@ -176,7 +176,7 @@ void tst_QTextPieceTable::insertion4() // exit(12); // } } - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); } void tst_QTextPieceTable::insertion5() @@ -196,10 +196,10 @@ void tst_QTextPieceTable::insertion5() } compare.insert(pos, str); } - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); for (QTextBlock it = table->blocksBegin(); it != table->blocksEnd(); it = it.next()) { QTextDocumentPrivate::FragmentIterator fit = table->find(it.position()); - QVERIFY(fit.position() == it.position()); + QCOMPARE(fit.position(), it.position()); } } @@ -260,7 +260,7 @@ void tst_QTextPieceTable::removal3() // exit(12); // } } - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); } void tst_QTextPieceTable::removal4() @@ -294,7 +294,7 @@ void tst_QTextPieceTable::removal4() // exit(12); // } } - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); } void tst_QTextPieceTable::undoRedo1() @@ -392,7 +392,7 @@ void tst_QTextPieceTable::undoRedo6() QTextBlockFormat bfmt; bfmt.setAlignment(Qt::AlignHCenter); cursor.setBlockFormat(bfmt); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter); QTextCursor range = cursor; range.clearSelection(); @@ -404,11 +404,11 @@ void tst_QTextPieceTable::undoRedo6() range.mergeCharFormat(modifier); cursor.movePosition(QTextCursor::Start); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter); doc.undo(); - QVERIFY(cursor.blockFormat().alignment() == Qt::AlignHCenter); + QCOMPARE(cursor.blockFormat().alignment(), Qt::AlignHCenter); } void tst_QTextPieceTable::undoRedo7() @@ -497,13 +497,13 @@ void tst_QTextPieceTable::undoRedo11() } l += remove ? -1 : 2; } - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); for (int i = 0; i < loops; ++i) table->undo(); - QVERIFY(table->plainText() == QString("")); + QCOMPARE(table->plainText(), QString("")); for (int i = 0; i < loops; ++i) table->redo(); - QVERIFY(table->plainText() == compare); + QCOMPARE(table->plainText(), compare); } @@ -693,9 +693,9 @@ void tst_QTextPieceTable::setBlockFormat() QTextBlock b = table->blocksFind(1); table->setBlockFormat(b, b, newbfmt); - QVERIFY(table->blocksFind(0).blockFormat() == bfmt); - QVERIFY(table->blocksFind(1).blockFormat() == newbfmt); - QVERIFY(table->blocksFind(2).blockFormat() == bfmt); + QCOMPARE(table->blocksFind(0).blockFormat(), bfmt); + QCOMPARE(table->blocksFind(1).blockFormat(), newbfmt); + QCOMPARE(table->blocksFind(2).blockFormat(), bfmt); } @@ -705,19 +705,19 @@ void tst_QTextPieceTable::blockInsertion() fmt.setTopMargin(100); int idx = table->formatCollection()->indexForFormat(fmt); int charFormat = table->formatCollection()->indexForFormat(QTextCharFormat()); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); table->insertBlock(0, idx, charFormat); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(1).blockFormat() == fmt); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).blockFormat(), fmt); table->undo(); - QVERIFY(table->blockMap().length() == 1); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); + QCOMPARE(table->blockMap().length(), 1); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); table->redo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(1).blockFormat() == fmt); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).blockFormat(), fmt); } void tst_QTextPieceTable::blockInsertion2() @@ -755,37 +755,37 @@ void tst_QTextPieceTable::blockRemoval1() table->insertBlock(9, idx2, charFormatIndex); table->insert(10, "0123", charFormatIndex); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->beginEditBlock(); table->remove(5, 5); table->endEditBlock(); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt2); - QVERIFY(table->blocksFind(4).position() == 0); - QVERIFY(table->blocksFind(5).position() == 5); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(4).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 5); table->undo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->redo(); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt2); - QVERIFY(table->blocksFind(4).position() == 0); - QVERIFY(table->blocksFind(5).position() == 5); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(4).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 5); } void tst_QTextPieceTable::blockRemoval2() @@ -803,35 +803,35 @@ void tst_QTextPieceTable::blockRemoval2() table->insertBlock(9, idx2, charFormatIndex); table->insert(10, "0123", charFormatIndex); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->remove(4, 1); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(6).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).position() == 0); - QVERIFY(table->blocksFind(6).position() == 0); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(6).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 0); table->undo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->redo(); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(6).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).position() == 0); - QVERIFY(table->blocksFind(6).position() == 0); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(6).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 0); } void tst_QTextPieceTable::blockRemoval3() @@ -849,38 +849,38 @@ void tst_QTextPieceTable::blockRemoval3() table->insertBlock(9, idx2, charFormatIndex); table->insert(10, "0123", charFormatIndex); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->beginEditBlock(); table->remove(3, 4); table->endEditBlock(); - QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(5).position() == 0); + QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 0); table->undo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->redo(); - QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(5).position() == 0); + QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 0); } void tst_QTextPieceTable::blockRemoval4() @@ -899,35 +899,35 @@ void tst_QTextPieceTable::blockRemoval4() table->insertBlock(9, idx2, charFormatIndex); table->insert(10, "0123", charFormatIndex); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->remove(3, 7); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(5).position() == 0); - QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 0); + QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat()); table->undo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->redo(); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(5).position() == 0); - QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 0); + QCOMPARE(table->blocksFind(1).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat()); #endif } @@ -946,38 +946,38 @@ void tst_QTextPieceTable::blockRemoval5() table->insertBlock(9, idx2, charFormatIndex); table->insert(10, "0123", charFormatIndex); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->beginEditBlock(); table->remove(3, 8); table->endEditBlock(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(5).position() == 0); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 0); table->undo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == fmt1); - QVERIFY(table->blocksFind(10).blockFormat() == fmt2); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(6).position() == 5); - QVERIFY(table->blocksFind(11).position() == 10); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), fmt1); + QCOMPARE(table->blocksFind(10).blockFormat(), fmt2); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(6).position(), 5); + QCOMPARE(table->blocksFind(11).position(), 10); table->redo(); - QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); - QVERIFY(table->blocksFind(1).position() == 0); - QVERIFY(table->blocksFind(5).position() == 0); + QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(5).blockFormat(), QTextBlockFormat()); + QCOMPARE(table->blocksFind(1).position(), 0); + QCOMPARE(table->blocksFind(5).position(), 0); } @@ -996,66 +996,66 @@ void tst_QTextPieceTable::checkFrames1() QPointer<QTextFrame> frame = table->insertFrame(1, 3, ffmt); QTextFrame *root = table->rootFrame(); - QVERIFY(root == frame->parentFrame()); + QCOMPARE(root, frame->parentFrame()); QVERIFY(root); - QVERIFY(root->parentFrame() == 0); + QVERIFY(!root->parentFrame()); - QVERIFY(root->childFrames().count() == 1); + QCOMPARE(root->childFrames().count(), 1); QVERIFY(frame->format() == ffmt); - QVERIFY(frame->firstPosition() == 2); - QVERIFY(frame->lastPosition() == 4); + QCOMPARE(frame->firstPosition(), 2); + QCOMPARE(frame->lastPosition(), 4); QPointer<QTextFrame> frame2 = table->insertFrame(2, 3, ffmt); - QVERIFY(root->childFrames().count() == 1); - QVERIFY(root->childFrames().at(0) == frame); - QVERIFY(frame->childFrames().count() == 1); - QVERIFY(frame2->childFrames().count() == 0); - QVERIFY(frame2->parentFrame() == frame); - QVERIFY(frame2->firstPosition() == 3); - QVERIFY(frame2->lastPosition() == 4); + QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().at(0), frame.data()); + QCOMPARE(frame->childFrames().count(), 1); + QCOMPARE(frame2->childFrames().count(), 0); + QCOMPARE(frame2->parentFrame(), frame.data()); + QCOMPARE(frame2->firstPosition(), 3); + QCOMPARE(frame2->lastPosition(), 4); QVERIFY(frame->format() == ffmt); - QVERIFY(frame->firstPosition() == 2); - QVERIFY(frame->lastPosition() == 6); + QCOMPARE(frame->firstPosition(), 2); + QCOMPARE(frame->lastPosition(), 6); table->removeFrame(frame); - QVERIFY(root->childFrames().count() == 1); - QVERIFY(root->childFrames().at(0) == frame2); + QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().at(0), frame2.data()); QVERIFY(!frame); - QVERIFY(frame2->childFrames().count() == 0); - QVERIFY(frame2->parentFrame() == root); - QVERIFY(frame2->firstPosition() == 2); - QVERIFY(frame2->lastPosition() == 3); + QCOMPARE(frame2->childFrames().count(), 0); + QCOMPARE(frame2->parentFrame(), root); + QCOMPARE(frame2->firstPosition(), 2); + QCOMPARE(frame2->lastPosition(), 3); table->undo(); frame = table->frameAt(2); - QVERIFY(root->childFrames().count() == 1); - QVERIFY(root->childFrames().at(0) == frame); - QVERIFY(frame->childFrames().count() == 1); - QVERIFY(frame->childFrames().at(0) == frame2); - QVERIFY(frame2->childFrames().count() == 0); - QVERIFY(frame2->parentFrame() == frame); - QVERIFY(frame2->firstPosition() == 3); - QVERIFY(frame2->lastPosition() == 4); + QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().at(0), frame.data()); + QCOMPARE(frame->childFrames().count(), 1); + QCOMPARE(frame->childFrames().at(0), frame2.data()); + QCOMPARE(frame2->childFrames().count(), 0); + QCOMPARE(frame2->parentFrame(), frame.data()); + QCOMPARE(frame2->firstPosition(), 3); + QCOMPARE(frame2->lastPosition(), 4); - QVERIFY(frame->firstPosition() == 2); - QVERIFY(frame->lastPosition() == 6); + QCOMPARE(frame->firstPosition(), 2); + QCOMPARE(frame->lastPosition(), 6); table->undo(); - QVERIFY(root->childFrames().count() == 1); - QVERIFY(root->childFrames().at(0) == frame); - QVERIFY(frame->childFrames().count() == 0); + QCOMPARE(root->childFrames().count(), 1); + QCOMPARE(root->childFrames().at(0), frame.data()); + QCOMPARE(frame->childFrames().count(), 0); QVERIFY(!frame2); - QVERIFY(frame->firstPosition() == 2); - QVERIFY(frame->lastPosition() == 4); + QCOMPARE(frame->firstPosition(), 2); + QCOMPARE(frame->lastPosition(), 4); } void tst_QTextPieceTable::removeFrameDirect() @@ -1065,7 +1065,7 @@ void tst_QTextPieceTable::removeFrameDirect() QTextFrame *frame = table->insertFrame(1, 5, ffmt); - QVERIFY(frame->parentFrame() == table->rootFrame()); + QCOMPARE(frame->parentFrame(), table->rootFrame()); const int start = frame->firstPosition() - 1; const int end = frame->lastPosition(); diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp index c8d3122e6d..1c099acc56 100644 --- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp @@ -146,87 +146,87 @@ void tst_QTextTable::variousTableModifications() QTextTableFormat tableFmt; QTextTable *tab = cursor.insertTable(2, 2, tableFmt); - QVERIFY(doc->toPlainText().length() == 5); - QVERIFY(tab == cursor.currentTable()); - QVERIFY(tab->columns() == 2); - QVERIFY(tab->rows() == 2); + QCOMPARE(doc->toPlainText().length(), 5); + QCOMPARE(tab, cursor.currentTable()); + QCOMPARE(tab->columns(), 2); + QCOMPARE(tab->rows(), 2); - QVERIFY(cursor.position() == 1); + QCOMPARE(cursor.position(), 1); QTextCharFormat fmt = cursor.charFormat(); - QVERIFY(fmt.objectIndex() == -1); + QCOMPARE(fmt.objectIndex(), -1); QTextTableCell cell = tab->cellAt(cursor); QVERIFY(cell.isValid()); - QVERIFY(cell.row() == 0); - QVERIFY(cell.column() == 0); + QCOMPARE(cell.row(), 0); + QCOMPARE(cell.column(), 0); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 2); + QCOMPARE(cursor.position(), 2); fmt = cursor.charFormat(); - QVERIFY(fmt.objectIndex() == -1); + QCOMPARE(fmt.objectIndex(), -1); cell = tab->cellAt(cursor); QVERIFY(cell.isValid()); - QVERIFY(cell.row() == 0); - QVERIFY(cell.column() == 1); + QCOMPARE(cell.row(), 0); + QCOMPARE(cell.column(), 1); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 3); + QCOMPARE(cursor.position(), 3); fmt = cursor.charFormat(); - QVERIFY(fmt.objectIndex() == -1); + QCOMPARE(fmt.objectIndex(), -1); cell = tab->cellAt(cursor); QVERIFY(cell.isValid()); - QVERIFY(cell.row() == 1); - QVERIFY(cell.column() == 0); + QCOMPARE(cell.row(), 1); + QCOMPARE(cell.column(), 0); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 4); + QCOMPARE(cursor.position(), 4); fmt = cursor.charFormat(); - QVERIFY(fmt.objectIndex() == -1); + QCOMPARE(fmt.objectIndex(), -1); cell = tab->cellAt(cursor); QVERIFY(cell.isValid()); - QVERIFY(cell.row() == 1); - QVERIFY(cell.column() == 1); + QCOMPARE(cell.row(), 1); + QCOMPARE(cell.column(), 1); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 5); + QCOMPARE(cursor.position(), 5); fmt = cursor.charFormat(); - QVERIFY(fmt.objectIndex() == -1); + QCOMPARE(fmt.objectIndex(), -1); cell = tab->cellAt(cursor); QVERIFY(!cell.isValid()); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 5); + QCOMPARE(cursor.position(), 5); // check we can't delete the cells with the cursor cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 1); + QCOMPARE(cursor.position(), 1); cursor.deleteChar(); - QVERIFY(doc->toPlainText().length() == 5); + QCOMPARE(doc->toPlainText().length(), 5); cursor.movePosition(QTextCursor::NextBlock); - QVERIFY(cursor.position() == 2); + QCOMPARE(cursor.position(), 2); cursor.deleteChar(); - QVERIFY(doc->toPlainText().length() == 5); + QCOMPARE(doc->toPlainText().length(), 5); cursor.deletePreviousChar(); - QVERIFY(cursor.position() == 2); - QVERIFY(doc->toPlainText().length() == 5); + QCOMPARE(cursor.position(), 2); + QCOMPARE(doc->toPlainText().length(), 5); QTextTable *table = cursor.currentTable(); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 2); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 2); table->insertRows(2, 1); - QVERIFY(table->rows() == 3); - QVERIFY(table->columns() == 2); - QVERIFY(doc->toPlainText().length() == 7); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 2); + QCOMPARE(doc->toPlainText().length(), 7); table->insertColumns(2, 2); - QVERIFY(table->rows() == 3); - QVERIFY(table->columns() == 4); - QVERIFY(doc->toPlainText().length() == 13); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 4); + QCOMPARE(doc->toPlainText().length(), 13); table->resize(4, 5); - QVERIFY(table->rows() == 4); - QVERIFY(table->columns() == 5); - QVERIFY(doc->toPlainText().length() == 21); + QCOMPARE(table->rows(), 4); + QCOMPARE(table->columns(), 5); + QCOMPARE(doc->toPlainText().length(), 21); } void tst_QTextTable::tableShrinking() @@ -234,25 +234,25 @@ void tst_QTextTable::tableShrinking() QTextTableFormat tableFmt; cursor.insertTable(3, 4, tableFmt); - QVERIFY(doc->toPlainText().length() == 13); + QCOMPARE(doc->toPlainText().length(), 13); QTextTable *table = cursor.currentTable(); - QVERIFY(table->rows() == 3); - QVERIFY(table->columns() == 4); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 4); table->removeRows(1, 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 4); - QVERIFY(doc->toPlainText().length() == 9); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 4); + QCOMPARE(doc->toPlainText().length(), 9); table->removeColumns(1, 2); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 2); - QVERIFY(doc->toPlainText().length() == 5); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 2); + QCOMPARE(doc->toPlainText().length(), 5); table->resize(1, 1); - QVERIFY(table->rows() == 1); - QVERIFY(table->columns() == 1); - QVERIFY(doc->toPlainText().length() == 2); + QCOMPARE(table->rows(), 1); + QCOMPARE(table->columns(), 1); + QCOMPARE(doc->toPlainText().length(), 2); } void tst_QTextTable::spans() @@ -264,12 +264,12 @@ void tst_QTextTable::spans() QTextTable *table = cursor.currentTable(); QVERIFY(table->cellAt(0, 0) != table->cellAt(0, 1)); table->mergeCells(0, 0, 1, 2); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 2); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 2); QVERIFY(table->cellAt(0, 0) == table->cellAt(0, 1)); table->mergeCells(0, 0, 2, 2); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 2); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 2); } void tst_QTextTable::variousModifications2() @@ -277,45 +277,45 @@ void tst_QTextTable::variousModifications2() QTextTableFormat tableFmt; cursor.insertTable(2, 5, tableFmt); - QVERIFY(doc->toPlainText().length() == 11); + QCOMPARE(doc->toPlainText().length(), 11); QTextTable *table = cursor.currentTable(); - QVERIFY(cursor.position() == 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 5); + QCOMPARE(cursor.position(), 1); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 5); table->insertColumns(0, 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 6); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 6); table->insertColumns(6, 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 7); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 7); table->insertRows(0, 1); - QVERIFY(table->rows() == 3); - QVERIFY(table->columns() == 7); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 7); table->insertRows(3, 1); - QVERIFY(table->rows() == 4); - QVERIFY(table->columns() == 7); + QCOMPARE(table->rows(), 4); + QCOMPARE(table->columns(), 7); table->removeRows(0, 1); - QVERIFY(table->rows() == 3); - QVERIFY(table->columns() == 7); + QCOMPARE(table->rows(), 3); + QCOMPARE(table->columns(), 7); table->removeRows(2, 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 7); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 7); table->removeColumns(0, 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 6); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 6); table->removeColumns(5, 1); - QVERIFY(table->rows() == 2); - QVERIFY(table->columns() == 5); + QCOMPARE(table->rows(), 2); + QCOMPARE(table->columns(), 5); tableFmt = table->format(); table->insertColumns(2, 1); table->setFormat(tableFmt); table->insertColumns(2, 1); - QVERIFY(table->columns() == 7); + QCOMPARE(table->columns(), 7); } void tst_QTextTable::tableManager_undo() @@ -325,16 +325,16 @@ void tst_QTextTable::tableManager_undo() QTextTable *table = cursor.insertTable(2, 2, fmt); QVERIFY(table); - QVERIFY(table->format().border() == 10); + QCOMPARE(table->format().border(), qreal(10)); fmt.setBorder(20); table->setFormat(fmt); - QVERIFY(table->format().border() == 20); + QCOMPARE(table->format().border(), qreal(20)); doc->undo(); - QVERIFY(table->format().border() == 10); + QCOMPARE(table->format().border(), qreal(10)); } void tst_QTextTable::tableManager_removeCell() @@ -360,10 +360,10 @@ void tst_QTextTable::rowAt() QTextCursor cell20Cursor = table->cellAt(2, 0).firstCursorPosition(); QTextCursor cell21Cursor = table->cellAt(2, 1).firstCursorPosition(); QTextCursor cell30Cursor = table->cellAt(3, 0).firstCursorPosition(); - QVERIFY(table->cellAt(cell00Cursor).firstCursorPosition() == cell00Cursor); - QVERIFY(table->cellAt(cell10Cursor).firstCursorPosition() == cell10Cursor); - QVERIFY(table->cellAt(cell20Cursor).firstCursorPosition() == cell20Cursor); - QVERIFY(table->cellAt(cell30Cursor).firstCursorPosition() == cell30Cursor); + QCOMPARE(table->cellAt(cell00Cursor).firstCursorPosition(), cell00Cursor); + QCOMPARE(table->cellAt(cell10Cursor).firstCursorPosition(), cell10Cursor); + QCOMPARE(table->cellAt(cell20Cursor).firstCursorPosition(), cell20Cursor); + QCOMPARE(table->cellAt(cell30Cursor).firstCursorPosition(), cell30Cursor); table->mergeCells(1, 0, 2, 1); @@ -433,16 +433,16 @@ void tst_QTextTable::insertRows() QVERIFY(cursor == table->cellAt(0, 0).firstCursorPosition()); table->insertRows(0, 1); - QVERIFY(table->rows() == 3); + QCOMPARE(table->rows(), 3); table->insertRows(1, 1); - QVERIFY(table->rows() == 4); + QCOMPARE(table->rows(), 4); table->insertRows(-1, 1); - QVERIFY(table->rows() == 5); + QCOMPARE(table->rows(), 5); table->insertRows(5, 2); - QVERIFY(table->rows() == 7); + QCOMPARE(table->rows(), 7); } @@ -552,9 +552,9 @@ void tst_QTextTable::mergeCells() QTextBlock block = table->cellAt(0, 0).firstCursorPosition().block(); - QVERIFY(block.text() == "Blah Foo"); - QVERIFY(block.next().text() == "Hah"); - QVERIFY(block.next().next().text() == "Bar"); + QCOMPARE(block.text(), QLatin1String("Blah Foo")); + QCOMPARE(block.next().text(), QLatin1String("Hah")); + QCOMPARE(block.next().next().text(), QLatin1String("Bar")); table = create4x4Table(); @@ -580,7 +580,7 @@ void tst_QTextTable::mergeCells() if (table) { cursor = table->cellAt(0, 0).firstCursorPosition(); - QVERIFY(cursor.block().text() == "Test"); + QCOMPARE(cursor.block().text(), QLatin1String("Test")); } table = create2x2Table(); @@ -750,7 +750,7 @@ void tst_QTextTable::setCellFormat() fmt.setTableCellColumnSpan(25); fmt.setTableCellRowSpan(42); cell.setFormat(fmt); - QVERIFY(cell.format().background().color() == QColor(Qt::blue)); + QCOMPARE(cell.format().background().color(), QColor(Qt::blue)); QCOMPARE(cell.format().tableCellColumnSpan(), 1); QCOMPARE(cell.format().tableCellRowSpan(), 1); } @@ -1086,6 +1086,8 @@ public: { if (PdmDevicePixelRatio == metric) return 1; + if (PdmDevicePixelRatioScaled == metric) + return 1 * QPaintDevice::devicePixelRatioFScale(); if (PdmDpiY == metric) return 96; if (PdmDpiX == metric) diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp index 90e93881b9..8381c93bc2 100644 --- a/tests/auto/gui/text/qzip/tst_qzip.cpp +++ b/tests/auto/gui/text/qzip/tst_qzip.cpp @@ -39,9 +39,6 @@ class tst_QZip : public QObject { Q_OBJECT -public slots: - void init(); - void cleanup(); private slots: void basicUnpack(); @@ -50,18 +47,10 @@ private slots: void createArchive(); }; -void tst_QZip::init() -{ -} - -void tst_QZip::cleanup() -{ -} - void tst_QZip::basicUnpack() { QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly); - QList<QZipReader::FileInfo> files = zip.fileInfoList(); + QVector<QZipReader::FileInfo> files = zip.fileInfoList(); QCOMPARE(files.count(), 2); QZipReader::FileInfo fi = files.at(0); @@ -97,7 +86,7 @@ void tst_QZip::basicUnpack() void tst_QZip::symlinks() { QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly); - QList<QZipReader::FileInfo> files = zip.fileInfoList(); + QVector<QZipReader::FileInfo> files = zip.fileInfoList(); QCOMPARE(files.count(), 2); QZipReader::FileInfo fi = files.at(0); @@ -120,7 +109,7 @@ void tst_QZip::symlinks() void tst_QZip::readTest() { QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file. - QList<QZipReader::FileInfo> files = zip.fileInfoList(); + QVector<QZipReader::FileInfo> files = zip.fileInfoList(); QCOMPARE(files.count(), 0); QByteArray b = zip.fileData("foobar"); QCOMPARE(b.size(), 0); @@ -139,7 +128,7 @@ void tst_QZip::createArchive() QBuffer buffer2(&zipFile); QZipReader zip2(&buffer2); - QList<QZipReader::FileInfo> files = zip2.fileInfoList(); + QVector<QZipReader::FileInfo> files = zip2.fileInfoList(); QCOMPARE(files.count(), 1); QZipReader::FileInfo file = files.at(0); QCOMPARE(file.filePath, QString("My Filename")); diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp index c2833d9e67..78ab769137 100644 --- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp +++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp @@ -256,41 +256,41 @@ void tst_QDoubleValidator::notifySignals() dv.setTop(0.8); QCOMPARE(topSpy.count(), 1); QCOMPARE(changedSpy.count(), 1); - QVERIFY(dv.top() == 0.8); + QCOMPARE(dv.top(), 0.8); dv.setBottom(0.2); QCOMPARE(bottomSpy.count(), 1); QCOMPARE(changedSpy.count(), 2); - QVERIFY(dv.bottom() == 0.2); + QCOMPARE(dv.bottom(), 0.2); dv.setRange(0.2, 0.7); QCOMPARE(topSpy.count(), 2); QCOMPARE(bottomSpy.count(), 1); QCOMPARE(decSpy.count(), 1); QCOMPARE(changedSpy.count(), 3); - QVERIFY(dv.bottom() == 0.2); - QVERIFY(dv.top() == 0.7); - QVERIFY(dv.decimals() == 0.); + QCOMPARE(dv.bottom(), 0.2); + QCOMPARE(dv.top(), 0.7); + QCOMPARE(dv.decimals(), 0); dv.setRange(0.3, 0.7); QCOMPARE(topSpy.count(), 2); QCOMPARE(bottomSpy.count(), 2); QCOMPARE(changedSpy.count(), 4); - QVERIFY(dv.bottom() == 0.3); - QVERIFY(dv.top() == 0.7); - QVERIFY(dv.decimals() == 0.); + QCOMPARE(dv.bottom(), 0.3); + QCOMPARE(dv.top(), 0.7); + QCOMPARE(dv.decimals(), 0); dv.setRange(0.4, 0.6); QCOMPARE(topSpy.count(), 3); QCOMPARE(bottomSpy.count(), 3); QCOMPARE(changedSpy.count(), 5); - QVERIFY(dv.bottom() == 0.4); - QVERIFY(dv.top() == 0.6); - QVERIFY(dv.decimals() == 0.); + QCOMPARE(dv.bottom(), 0.4); + QCOMPARE(dv.top(), 0.6); + QCOMPARE(dv.decimals(), 0); dv.setDecimals(10); QCOMPARE(decSpy.count(), 2); QCOMPARE(changedSpy.count(), 6); - QVERIFY(dv.decimals() == 10.); + QCOMPARE(dv.decimals(), 10); dv.setRange(0.4, 0.6, 100); @@ -298,14 +298,14 @@ void tst_QDoubleValidator::notifySignals() QCOMPARE(bottomSpy.count(), 3); QCOMPARE(decSpy.count(), 3); QCOMPARE(changedSpy.count(), 7); - QVERIFY(dv.bottom() == 0.4); - QVERIFY(dv.top() == 0.6); - QVERIFY(dv.decimals() == 100.); + QCOMPARE(dv.bottom(), 0.4); + QCOMPARE(dv.top(), 0.6); + QCOMPARE(dv.decimals(), 100); dv.setNotation(QDoubleValidator::StandardNotation); QCOMPARE(notSpy.count(), 1); QCOMPARE(changedSpy.count(), 8); - QVERIFY(dv.notation() == QDoubleValidator::StandardNotation); + QCOMPARE(dv.notation(), QDoubleValidator::StandardNotation); dv.setRange(dv.bottom(), dv.top(), dv.decimals()); QCOMPARE(topSpy.count(), 3); diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp index 43f7b58439..a683d903df 100644 --- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp @@ -239,32 +239,32 @@ void tst_QIntValidator::notifySignals() iv.setTop(9); QCOMPARE(topSpy.count(), 1); QCOMPARE(changedSpy.count(), 1); - QVERIFY(iv.top() == 9); + QCOMPARE(iv.top(), 9); iv.setBottom(1); QCOMPARE(bottomSpy.count(), 1); QCOMPARE(changedSpy.count(), 2); - QVERIFY(iv.bottom() == 1); + QCOMPARE(iv.bottom(), 1); iv.setRange(1, 8); QCOMPARE(topSpy.count(), 2); QCOMPARE(bottomSpy.count(), 1); QCOMPARE(changedSpy.count(), 3); - QVERIFY(iv.top() == 8); - QVERIFY(iv.bottom() == 1); + QCOMPARE(iv.top(), 8); + QCOMPARE(iv.bottom(), 1); iv.setRange(2, 8); QCOMPARE(topSpy.count(), 2); QCOMPARE(bottomSpy.count(), 2); QCOMPARE(changedSpy.count(), 4); - QVERIFY(iv.top() == 8); - QVERIFY(iv.bottom() == 2); + QCOMPARE(iv.top(), 8); + QCOMPARE(iv.bottom(), 2); iv.setRange(3, 7); QCOMPARE(topSpy.count(), 3); QCOMPARE(bottomSpy.count(), 3); QCOMPARE(changedSpy.count(), 5); - QVERIFY(iv.top() == 7); - QVERIFY(iv.bottom() == 3); + QCOMPARE(iv.top(), 7); + QCOMPARE(iv.bottom(), 3); iv.setRange(3, 7); QCOMPARE(topSpy.count(), 3); diff --git a/tests/auto/network/access/qabstractnetworkcache/BLACKLIST b/tests/auto/network/access/qabstractnetworkcache/BLACKLIST new file mode 100644 index 0000000000..3bd3350e4b --- /dev/null +++ b/tests/auto/network/access/qabstractnetworkcache/BLACKLIST @@ -0,0 +1,9 @@ +[cacheControl] +windows +osx +[expires] +osx +[etag] +osx +[lastModified] +osx diff --git a/tests/auto/network/access/qftp/BLACKLIST b/tests/auto/network/access/qftp/BLACKLIST new file mode 100644 index 0000000000..a67c22265c --- /dev/null +++ b/tests/auto/network/access/qftp/BLACKLIST @@ -0,0 +1,11 @@ +# QTBUG-15111 + +[activeMode:WithoutProxy] +opensuse-13.1 64bit +redhatenterpriselinuxworkstation-6.6 +osx-10.10 + +[activeMode:WithoutProxyWithSession] +opensuse-13.1 64bit +redhatenterpriselinuxworkstation-6.6 +osx-10.10 diff --git a/tests/auto/network/access/qftp/qftp.pro b/tests/auto/network/access/qftp/qftp.pro index 850e1a9417..4294f27e74 100644 --- a/tests/auto/network/access/qftp/qftp.pro +++ b/tests/auto/network/access/qftp/qftp.pro @@ -11,4 +11,3 @@ wince { DEPLOYMENT += addFiles } -CONFIG+=insignificant_test # QTBUG-15111: uses live qt-test-server, inherently unstable diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 7ea1859938..795548ccc8 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -390,8 +390,7 @@ void tst_QFtp::connectToUnresponsiveHost() a lot of other stuff in QFtp, so we just expect this test to fail on Windows. */ QEXPECT_FAIL("", "timeout not working due to strange Windows socket behaviour (see source file of this test for explanation)", Abort); -#else - QEXPECT_FAIL("", "QTBUG-20687", Abort); + #endif QVERIFY2(! QTestEventLoop::instance().timeout(), "Network timeout longer than expected (should have been 60 seconds)"); diff --git a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp index 1d04921c9a..be3e839725 100644 --- a/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/network/access/qnetworkcookie/tst_qnetworkcookie.cpp @@ -83,7 +83,7 @@ void tst_QNetworkCookie::getterSetter() QNetworkCookie cookie; QNetworkCookie otherCookie; - QVERIFY(cookie == otherCookie); + QCOMPARE(cookie, otherCookie); QCOMPARE(cookie, otherCookie); QVERIFY(!(cookie != otherCookie)); @@ -133,7 +133,7 @@ void tst_QNetworkCookie::getterSetter() cookie.setSecure(false); QVERIFY(!cookie.isSecure()); - QVERIFY(cookie == otherCookie); + QCOMPARE(cookie, otherCookie); } void tst_QNetworkCookie::parseSingleCookie_data() diff --git a/tests/auto/network/access/qnetworkreply/element.xml b/tests/auto/network/access/qnetworkreply/element.xml new file mode 100644 index 0000000000..071ffae057 --- /dev/null +++ b/tests/auto/network/access/qnetworkreply/element.xml @@ -0,0 +1 @@ +<root attr="value" attr2="value2"><person /><fruit /></root> diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 4ed175ff7f..debdc6bcb3 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -129,6 +129,14 @@ class tst_QNetworkReply: public QObject return s; }; + static QString tempRedirectReplyStr() { + QString s = "HTTP/1.1 307 Temporary Redirect\r\n" + "Content-Type: text/plain\r\n" + "location: %1\r\n" + "\r\n"; + return s; + }; + QEventLoop *loop; enum RunSimpleRequestReturn { Timeout = 0, Success, Failure }; int returnCode; @@ -426,6 +434,8 @@ private Q_SLOTS: void qtbug28035browserDoesNotLoadQtProjectOrgCorrectly(); + void qtbug45581WrongReplyStatusCode(); + void synchronousRequest_data(); void synchronousRequest(); #ifndef QT_NO_SSL @@ -464,6 +474,10 @@ private Q_SLOTS: void putWithRateLimiting(); + void ioHttpSingleRedirect(); + void ioHttpChangeMaxRedirects(); + void ioHttpRedirectErrors_data(); + void ioHttpRedirectErrors(); #ifndef QT_NO_SSL void putWithServerClosingConnectionImmediately(); #endif @@ -605,10 +619,16 @@ protected: virtual void reply() { Q_ASSERT(!client.isNull()); // we need to emulate the bytesWrittenSlot call if the data is empty. - if (dataToTransmit.size() == 0) + if (dataToTransmit.size() == 0) { QMetaObject::invokeMethod(this, "bytesWrittenSlot", Qt::QueuedConnection); - else + } else { client->write(dataToTransmit); + // FIXME: For SSL connections, if we don't flush the socket, the + // client never receives the data and since we're doing a disconnect + // immediately afterwards, it causes a RemoteHostClosedError for the + // client + client->flush(); + } } private: void connectSocketSignals() @@ -1666,7 +1686,7 @@ void tst_QNetworkReply::getFromFile() static const char fileData[] = "This is some data that is in the file.\r\n"; QByteArray data = QByteArray::fromRawData(fileData, sizeof fileData - 1); - QVERIFY(file.write(data) == data.size()); + QCOMPARE(file.write(data), data.size()); file.flush(); QCOMPARE(file.size(), qint64(data.size())); @@ -2914,9 +2934,9 @@ void tst_QNetworkReply::connectToIPv6Address() //qDebug() << server.receivedData; QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n"; QVERIFY(server.receivedData.contains(hostinfo)); - QVERIFY(content == dataToSend); + QCOMPARE(content, dataToSend); QCOMPARE(reply->url(), request.url()); - QVERIFY(reply->error() == error); + QCOMPARE(reply->error(), error); } void tst_QNetworkReply::sendCustomRequestToHttp_data() @@ -3048,7 +3068,7 @@ void tst_QNetworkReply::ioGetFromFile() QVERIFY(file.open()); QFETCH(QByteArray, data); - QVERIFY(file.write(data) == data.size()); + QCOMPARE(file.write(data), data.size()); file.flush(); QCOMPARE(file.size(), qint64(data.size())); @@ -3118,8 +3138,8 @@ void tst_QNetworkReply::ioGetFromFtpWithReuse() DataReader reader2(reply2); QSignalSpy spy(reply1.data(), SIGNAL(finished())); - QVERIFY(waitForFinish(reply1) == Success); - QVERIFY(waitForFinish(reply2) == Success); + QCOMPARE(waitForFinish(reply1), int(Success)); + QCOMPARE(waitForFinish(reply2), int(Success)); QCOMPARE(reply1->url(), request.url()); QCOMPARE(reply2->url(), request.url()); @@ -3169,8 +3189,8 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseParallel() DataReader reader2(reply2); QSignalSpy spy(reply1.data(), SIGNAL(finished())); - QVERIFY(waitForFinish(reply2) == Success); - QVERIFY(waitForFinish(reply1) == Success); + QCOMPARE(waitForFinish(reply2), int(Success)); + QCOMPARE(waitForFinish(reply1), int(Success)); QCOMPARE(reply1->url(), request.url()); QCOMPARE(reply2->url(), request.url()); @@ -3272,8 +3292,8 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); - QVERIFY(waitForFinish(reply2) == Success); - QVERIFY(waitForFinish(reply1) == Success); + QCOMPARE(waitForFinish(reply2), int(Success)); + QCOMPARE(waitForFinish(reply1), int(Success)); manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); @@ -3402,8 +3422,8 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth() connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); - QVERIFY(waitForFinish(reply2) == Success); - QVERIFY(waitForFinish(reply1) == Success); + QCOMPARE(waitForFinish(reply2), int(Success)); + QCOMPARE(waitForFinish(reply1), int(Success)); manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); @@ -3525,7 +3545,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy() connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); @@ -3613,7 +3633,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError() QSignalSpy sslspy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); connect(reply, SIGNAL(metaDataChanged()), SLOT(storeSslConfiguration())); - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError); QCOMPARE(sslspy.count(), 0); @@ -3671,7 +3691,7 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer() QNetworkReplyPtr reply(manager.get(request)); QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); QCOMPARE(reply->url(), request.url()); QCOMPARE(spy.count(), 1); @@ -4722,7 +4742,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag() connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); @@ -5092,7 +5112,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress() QVERIFY(!QTestEventLoop::instance().timeout()); // final check: only 1 uploadProgress has been emitted - QVERIFY(spy.length() == 1); + QCOMPARE(spy.length(), 1); QList<QVariant> args = spy.last(); QVERIFY(!args.isEmpty()); QCOMPARE(args.at(0).toLongLong(), buffer.size()); @@ -5336,7 +5356,7 @@ void tst_QNetworkReply::chaining() QVERIFY(sourceFile.open()); QFETCH(QByteArray, data); - QVERIFY(sourceFile.write(data) == data.size()); + QCOMPARE(sourceFile.write(data), data.size()); sourceFile.flush(); QCOMPARE(sourceFile.size(), qint64(data.size())); @@ -5348,7 +5368,7 @@ void tst_QNetworkReply::chaining() request.setUrl(url); QNetworkReplyPtr putReply(manager.put(request, getReply.data())); - QVERIFY(waitForFinish(putReply) == Success); + QCOMPARE(waitForFinish(putReply), int(Success)); QCOMPARE(getReply->url(), QUrl::fromLocalFile(sourceFile.fileName())); QCOMPARE(getReply->error(), QNetworkReply::NoError); @@ -5755,7 +5775,7 @@ void tst_QNetworkReply::proxyChange() // verify that the replies succeeded QCOMPARE(reply1->error(), QNetworkReply::NoError); QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QVERIFY(reply1->size() == 1); + QCOMPARE(reply1->size(), 1); QCOMPARE(reply2->error(), QNetworkReply::NoError); QCOMPARE(reply2->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); @@ -5772,7 +5792,7 @@ void tst_QNetworkReply::proxyChange() manager.setProxy(dummyProxy); QNetworkReplyPtr reply3(manager.get(req)); - QVERIFY(waitForFinish(reply3) == Failure); + QCOMPARE(waitForFinish(reply3), int(Failure)); QVERIFY(int(reply3->error()) > 0); } @@ -5808,7 +5828,7 @@ void tst_QNetworkReply::authorizationError() QSignalSpy errorSpy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); QSignalSpy finishedSpy(reply.data(), SIGNAL(finished())); // now run the request: - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); QFETCH(int, errorSignalCount); QCOMPARE(errorSpy.count(), errorSignalCount); @@ -5983,7 +6003,7 @@ public slots: QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QVERIFY(!reply->error()); - QVERIFY(reply->bytesAvailable() == 27906); + QCOMPARE(reply->bytesAvailable(), 27906); if (requestsFinishedCount == 60) { QTestEventLoop::instance().exitLoop(); @@ -6153,6 +6173,10 @@ void tst_QNetworkReply::sslSessionSharing_data() void tst_QNetworkReply::sslSessionSharing() { +#ifdef QT_SECURETRANSPORT + QSKIP("Not implemented with SecureTransport"); +#endif + QString urlString("https://" + QtNetworkSettings::serverName()); QList<QNetworkReplyPtr> replies; @@ -6217,6 +6241,10 @@ void tst_QNetworkReply::sslSessionSharingFromPersistentSession_data() void tst_QNetworkReply::sslSessionSharingFromPersistentSession() { +#ifdef QT_SECURETRANSPORT + QSKIP("Not implemented with SecureTransport"); +#endif + QString urlString("https://" + QtNetworkSettings::serverName()); // warm up SSL session cache to get a working session @@ -6501,7 +6529,7 @@ public: void finishedSlot() { // We should have already received all readyRead QVERIFY(!bytesAvailableList.isEmpty()); - QVERIFY(bytesAvailableList.last() == uploadSize); + QCOMPARE(bytesAvailableList.last(), uploadSize); } }; @@ -6584,7 +6612,7 @@ void tst_QNetworkReply::ioGetFromHttpWithoutContentLength() QCOMPARE(reply->url(), request.url()); QVERIFY(reply->isFinished()); - QVERIFY(reply->error() == QNetworkReply::NoError); + QCOMPARE(reply->error(), QNetworkReply::NoError); } // Is handled somewhere else too, introduced this special test to have it more accessible @@ -6651,7 +6679,7 @@ void tst_QNetworkReply::compressedHttpReplyBrokenGzip() QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); QNetworkReplyPtr reply(manager.get(request)); - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); QCOMPARE(reply->error(), QNetworkReply::ProtocolFailure); } @@ -6664,7 +6692,7 @@ void tst_QNetworkReply::getFromUnreachableIp() QNetworkRequest request(QUrl("http://255.255.255.255/42/23/narf/narf/narf")); QNetworkReplyPtr reply(manager.get(request)); - QVERIFY(waitForFinish(reply) == Failure); + QCOMPARE(waitForFinish(reply), int(Failure)); QVERIFY(reply->error() != QNetworkReply::NoError); } @@ -7255,6 +7283,34 @@ void tst_QNetworkReply::qtbug28035browserDoesNotLoadQtProjectOrgCorrectly() { QCOMPARE(reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool(), true); } +void tst_QNetworkReply::qtbug45581WrongReplyStatusCode() +{ + const QUrl url("file:" + testDataDir + "/element.xml"); + QNetworkRequest request(url); + + QNetworkReplyPtr reply; + QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*))); + QSignalSpy sslErrorsSpy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>))); + RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::GetOperation, request, reply, 0)); + QVERIFY(reply->isFinished()); + + const QByteArray expectedContent = + "<root attr=\"value\" attr2=\"value2\">" + "<person /><fruit /></root>\n"; + + QCOMPARE(reply->readAll(), expectedContent); + + QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(sslErrorsSpy.count(), 0); + + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), expectedContent.size()); + + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + QCOMPARE(reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(), QLatin1String("OK")); + + reply->deleteLater(); +} + void tst_QNetworkReply::synchronousRequest_data() { QTest::addColumn<QUrl>("url"); @@ -7425,7 +7481,7 @@ void tst_QNetworkReply::httpAbort() QNetworkRequest request3("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); QNetworkReplyPtr reply3(manager.get(request3)); - QVERIFY(waitForFinish(reply3) == Success); + QCOMPARE(waitForFinish(reply3), int(Success)); QVERIFY(reply3->isFinished()); reply3->abort(); @@ -7980,7 +8036,142 @@ void tst_QNetworkReply::putWithRateLimiting() QCOMPARE(uploadedData, data); } +void tst_QNetworkReply::ioHttpSingleRedirect() +{ + QUrl localhost = QUrl("http://localhost"); + QByteArray http200Reply = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; + + // Setup server to which the second server will redirect to + MiniHttpServer server2(http200Reply); + + QUrl redirectUrl = QUrl(localhost); + redirectUrl.setPort(server2.serverPort()); + + QByteArray tempRedirectReply = + tempRedirectReplyStr().arg(QString(redirectUrl.toEncoded())).toLatin1(); + + + // Setup redirect server + MiniHttpServer server(tempRedirectReply); + + localhost.setPort(server.serverPort()); + QNetworkRequest request(localhost); + request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); + + QNetworkReplyPtr reply(manager.get(request)); + QSignalSpy redSpy(reply.data(), SIGNAL(redirected(QUrl))); + QSignalSpy finSpy(reply.data(), SIGNAL(finished())); + + QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); + + // Redirected and finished should be emitted exactly once + QCOMPARE(redSpy.count(), 1); + QCOMPARE(finSpy.count(), 1); + + // Original URL should not be changed after redirect + QCOMPARE(request.url(), localhost); + // Verify Redirect url + QList<QVariant> args = redSpy.takeFirst(); + QCOMPARE(args.at(0).toUrl(), redirectUrl); + + // Reply url is set to the redirect url + QCOMPARE(reply->url(), redirectUrl); + QCOMPARE(reply->error(), QNetworkReply::NoError); +} + +void tst_QNetworkReply::ioHttpChangeMaxRedirects() +{ + QUrl localhost = QUrl("http://localhost"); + + QByteArray http200Reply = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; + + MiniHttpServer server1(""); + MiniHttpServer server2(""); + MiniHttpServer server3(http200Reply); + + QUrl server2Url(localhost); + server2Url.setPort(server2.serverPort()); + server1.setDataToTransmit(tempRedirectReplyStr().arg( + QString(server2Url.toEncoded())).toLatin1()); + + QUrl server3Url(localhost); + server3Url.setPort(server3.serverPort()); + server2.setDataToTransmit(tempRedirectReplyStr().arg( + QString(server3Url.toEncoded())).toLatin1()); + + localhost.setPort(server1.serverPort()); + QNetworkRequest request(localhost); + request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); + + // Set Max redirects to 1. This will cause TooManyRedirectsError + request.setMaximumRedirectsAllowed(1); + + QNetworkReplyPtr reply(manager.get(request)); + QSignalSpy redSpy(reply.data(), SIGNAL(redirected(QUrl))); + QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); + + QCOMPARE(waitForFinish(reply), int(Failure)); + + QCOMPARE(redSpy.count(), request.maximumRedirectsAllowed()); + QCOMPARE(spy.count(), 1); + QCOMPARE(reply->error(), QNetworkReply::TooManyRedirectsError); + + // Increase max redirects to allow successful completion + request.setMaximumRedirectsAllowed(3); + + QNetworkReplyPtr reply2(manager.get(request)); + QSignalSpy redSpy2(reply2.data(), SIGNAL(redirected(QUrl))); + + QVERIFY2(waitForFinish(reply2) == Success, msgWaitForFinished(reply2)); + + QCOMPARE(redSpy2.count(), 2); + QCOMPARE(reply2->url(), server3Url); + QCOMPARE(reply2->error(), QNetworkReply::NoError); +} + +void tst_QNetworkReply::ioHttpRedirectErrors_data() +{ + QTest::addColumn<QString>("url"); + QTest::addColumn<QString>("dataToSend"); + QTest::addColumn<QNetworkReply::NetworkError>("error"); + + QString tempRedirectReply = QString("HTTP/1.1 307 Temporary Redirect\r\n" + "Content-Type: text/plain\r\n" + "location: http://localhost:%1\r\n\r\n"); + + QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError; + QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError; + QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError; +} + +void tst_QNetworkReply::ioHttpRedirectErrors() +{ + QFETCH(QString, url); + QFETCH(QString, dataToSend); + QFETCH(QNetworkReply::NetworkError, error); + + QUrl localhost(url); + MiniHttpServer server("", localhost.scheme() == "https"); + + localhost.setPort(server.serverPort()); + + QByteArray d2s = dataToSend.arg( + QString::number(server.serverPort())).toLatin1(); + server.setDataToTransmit(d2s); + + QNetworkRequest request(localhost); + request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); + QNetworkReplyPtr reply(manager.get(request)); + if (localhost.scheme() == "https") + reply.data()->ignoreSslErrors(); + QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); + + QCOMPARE(waitForFinish(reply), int(Failure)); + + QCOMPARE(spy.count(), 1); + QCOMPARE(reply->error(), error); +} #ifndef QT_NO_SSL class PutWithServerClosingConnectionImmediatelyHandler: public QObject diff --git a/tests/auto/network/access/spdy/BLACKLIST b/tests/auto/network/access/spdy/BLACKLIST new file mode 100644 index 0000000000..b13eae1000 --- /dev/null +++ b/tests/auto/network/access/spdy/BLACKLIST @@ -0,0 +1,4 @@ +[download] +linux +[upload] +linux diff --git a/tests/auto/network/access/spdy/spdy.pro b/tests/auto/network/access/spdy/spdy.pro index 6bfc6d84e0..23efa85b47 100644 --- a/tests/auto/network/access/spdy/spdy.pro +++ b/tests/auto/network/access/spdy/spdy.pro @@ -5,3 +5,5 @@ SOURCES += tst_spdy.cpp QT = core core-private network network-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +win32:CONFIG += insignificant_test # QTBUG-47128 diff --git a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index 7dfc02463e..09ccff4968 100644 --- a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -68,7 +68,7 @@ void tst_QNetworkConfiguration::invalidPoint() QVERIFY(pt.name().isEmpty()); QVERIFY(!pt.isValid()); - QVERIFY(pt.type() == QNetworkConfiguration::Invalid); + QCOMPARE(pt.type(), QNetworkConfiguration::Invalid); QVERIFY(!(pt.state() & QNetworkConfiguration::Defined)); QVERIFY(!(pt.state() & QNetworkConfiguration::Discovered)); QVERIFY(!(pt.state() & QNetworkConfiguration::Active)); @@ -77,7 +77,7 @@ void tst_QNetworkConfiguration::invalidPoint() QNetworkConfiguration pt2(pt); QVERIFY(pt2.name().isEmpty()); QVERIFY(!pt2.isValid()); - QVERIFY(pt2.type() == QNetworkConfiguration::Invalid); + QCOMPARE(pt2.type(), QNetworkConfiguration::Invalid); QVERIFY(!(pt2.state() & QNetworkConfiguration::Defined)); QVERIFY(!(pt2.state() & QNetworkConfiguration::Discovered)); QVERIFY(!(pt2.state() & QNetworkConfiguration::Active)); @@ -91,27 +91,27 @@ void tst_QNetworkConfiguration::comparison() //compare invalid connection points QNetworkConfiguration pt1; QVERIFY(!pt1.isValid()); - QVERIFY(pt1.type() == QNetworkConfiguration::Invalid); + QCOMPARE(pt1.type(), QNetworkConfiguration::Invalid); QNetworkConfiguration pt2(pt1); QVERIFY(pt1==pt2); QVERIFY(!(pt1!=pt2)); - QVERIFY(pt1.name() == pt2.name()); - QVERIFY(pt1.isValid() == pt2.isValid()); - QVERIFY(pt1.type() == pt2.type()); - QVERIFY(pt1.state() == pt2.state()); - QVERIFY(pt1.purpose() == pt2.purpose()); + QCOMPARE(pt1.name(), pt2.name()); + QCOMPARE(pt1.isValid(), pt2.isValid()); + QCOMPARE(pt1.type(), pt2.type()); + QCOMPARE(pt1.state(), pt2.state()); + QCOMPARE(pt1.purpose(), pt2.purpose()); QNetworkConfiguration pt3; pt3 = pt1; QVERIFY(pt1==pt3); QVERIFY(!(pt1!=pt3)); - QVERIFY(pt1.name() == pt3.name()); - QVERIFY(pt1.isValid() == pt3.isValid()); - QVERIFY(pt1.type() == pt3.type()); - QVERIFY(pt1.state() == pt3.state()); - QVERIFY(pt1.purpose() == pt3.purpose()); + QCOMPARE(pt1.name(), pt3.name()); + QCOMPARE(pt1.isValid(), pt3.isValid()); + QCOMPARE(pt1.type(), pt3.type()); + QCOMPARE(pt1.state(), pt3.state()); + QCOMPARE(pt1.purpose(), pt3.purpose()); //test case must run on machine that has valid connection points QNetworkConfigurationManager manager; @@ -131,11 +131,11 @@ void tst_QNetworkConfiguration::comparison() pt3 = defaultConfig; QVERIFY(defaultConfig==pt3); QVERIFY(!(defaultConfig!=pt3)); - QVERIFY(defaultConfig.name() == pt3.name()); - QVERIFY(defaultConfig.isValid() == pt3.isValid()); - QVERIFY(defaultConfig.type() == pt3.type()); - QVERIFY(defaultConfig.state() == pt3.state()); - QVERIFY(defaultConfig.purpose() == pt3.purpose()); + QCOMPARE(defaultConfig.name(), pt3.name()); + QCOMPARE(defaultConfig.isValid(), pt3.isValid()); + QCOMPARE(defaultConfig.type(), pt3.type()); + QCOMPARE(defaultConfig.state(), pt3.state()); + QCOMPARE(defaultConfig.purpose(), pt3.purpose()); } void tst_QNetworkConfiguration::children() @@ -178,7 +178,7 @@ void tst_QNetworkConfiguration::isRoamingAvailable() if ( c.children().count() <= 1 ) QVERIFY(!c.isRoamingAvailable()); foreach(QNetworkConfiguration child, c.children()) { - QVERIFY(QNetworkConfiguration::InternetAccessPoint == child.type()); + QCOMPARE(QNetworkConfiguration::InternetAccessPoint, child.type()); QCOMPARE(child.children().count(), 0); } } else { diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index afe1fc274e..94c4d903b2 100644 --- a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -168,7 +168,7 @@ void tst_QNetworkConfigurationManager::defaultConfiguration() QVERIFY(!defaultConfig.isRoamingAvailable()); QCOMPARE(defaultConfig.state(), QNetworkConfiguration::Discovered); QNetworkConfiguration copy = manager.configurationFromIdentifier(defaultConfig.identifier()); - QVERIFY(copy == defaultConfig); + QCOMPARE(copy, defaultConfig); } } @@ -190,7 +190,7 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier() QNetworkConfiguration direct = manager.configurationFromIdentifier(c.identifier()); QVERIFY(direct.isValid()); - QVERIFY(direct == c); + QCOMPARE(direct, c); } //assume that there is no item with identifier 'FooBar' diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp index 2fd80b3e71..cd510ddfa8 100644 --- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp @@ -187,19 +187,19 @@ void tst_QNetworkSession::invalidSession() // 1. Verify that session created with invalid configuration remains in invalid state QNetworkSession session(QNetworkConfiguration(), 0); QVERIFY(!session.isOpen()); - QVERIFY(session.state() == QNetworkSession::Invalid); - QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError); + QCOMPARE(session.state(), QNetworkSession::Invalid); + QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError); // 2. Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror and 2) sets session's state as invalid. QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError))); session.open(); session.waitForOpened(1000); // Should bail out right away - QVERIFY(errorSpy.count() == 1); + QCOMPARE(errorSpy.count(), 1); QNetworkSession::SessionError error = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0)); - QVERIFY(error == QNetworkSession::InvalidConfigurationError); - QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError); - QVERIFY(session.state() == QNetworkSession::Invalid); + QCOMPARE(error, QNetworkSession::InvalidConfigurationError); + QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError); + QCOMPARE(session.state(), QNetworkSession::Invalid); #ifdef QNETWORKSESSION_MANUAL_TESTS @@ -210,7 +210,7 @@ void tst_QNetworkSession::invalidSession() qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name(); QTest::qWait(60000); QVERIFY(!invalidatedConfig.isValid()); - QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid); + QCOMPARE(invalidatedSession.state(), QNetworkSession::Invalid); qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name(); QTest::qWait(60000); } @@ -235,11 +235,11 @@ void tst_QNetworkSession::invalidSession() QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0)); - QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError); + QCOMPARE(sessionError, QNetworkSession::InvalidConfigurationError); qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name(); QTest::qWait(60000); updateConfigurations(); - QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered); + QCOMPARE(definedConfig.state(), QNetworkConfiguration::Discovered); } #endif } @@ -260,7 +260,7 @@ void tst_QNetworkSession::sessionProperties() { QFETCH(QNetworkConfiguration, configuration); QNetworkSession session(configuration); - QVERIFY(session.configuration() == configuration); + QCOMPARE(session.configuration(), configuration); QStringList validBearerNames = QStringList() << QLatin1String("Unknown") << QLatin1String("Ethernet") << QLatin1String("WLAN") @@ -303,10 +303,10 @@ void tst_QNetworkSession::sessionProperties() } else { switch (configuration.state()) { case QNetworkConfiguration::Undefined: - QVERIFY(session.state() == QNetworkSession::NotAvailable); + QCOMPARE(session.state(), QNetworkSession::NotAvailable); break; case QNetworkConfiguration::Defined: - QVERIFY(session.state() == QNetworkSession::NotAvailable); + QCOMPARE(session.state(), QNetworkSession::NotAvailable); break; case QNetworkConfiguration::Discovered: QVERIFY(session.state() == QNetworkSession::Connecting || @@ -372,12 +372,12 @@ void tst_QNetworkSession::userChoiceSession() { QFETCH(QNetworkConfiguration, configuration); - QVERIFY(configuration.type() == QNetworkConfiguration::UserChoice); + QCOMPARE(configuration.type(), QNetworkConfiguration::UserChoice); QNetworkSession session(configuration); // Check that configuration was really set - QVERIFY(session.configuration() == configuration); + QCOMPARE(session.configuration(), configuration); QVERIFY(!session.isOpen()); @@ -431,7 +431,7 @@ void tst_QNetworkSession::userChoiceSession() if (expectStateChange) QTRY_VERIFY_WITH_TIMEOUT(!stateChangedSpy.isEmpty(), TestTimeOut); - QVERIFY(session.state() == QNetworkSession::Connected); + QCOMPARE(session.state(), QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE QVERIFY(session.interface().isValid()); #endif @@ -462,16 +462,16 @@ void tst_QNetworkSession::userChoiceSession() manager.configurationFromIdentifier(activeIdentifier); QVERIFY(activeConfiguration.isValid()); - QVERIFY(activeConfiguration.type() == QNetworkConfiguration::InternetAccessPoint); + QCOMPARE(activeConfiguration.type(), QNetworkConfiguration::InternetAccessPoint); //resetting ActiveConfiguration is ignored (read only property) session.setSessionProperty("ActiveConfiguration", testIdentifier); QVERIFY(session.sessionProperty("ActiveConfiguration").toString() != testIdentifier); if (userChoiceConfiguration.type() == QNetworkConfiguration::InternetAccessPoint) { - QVERIFY(userChoiceConfiguration == activeConfiguration); + QCOMPARE(userChoiceConfiguration, activeConfiguration); } else { - QVERIFY(userChoiceConfiguration.type() == QNetworkConfiguration::ServiceNetwork); + QCOMPARE(userChoiceConfiguration.type(), QNetworkConfiguration::ServiceNetwork); QVERIFY(userChoiceConfiguration.children().contains(activeConfiguration)); } } else { @@ -500,18 +500,21 @@ void tst_QNetworkSession::sessionOpenCloseStop() { QFETCH(QNetworkConfiguration, configuration); QFETCH(bool, forceSessionStop); +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) + QSKIP("Deadlocks on Linux due to QTBUG-45655"); +#endif QNetworkSession session(configuration); // Test initial state of the session. { - QVERIFY(session.configuration() == configuration); + QCOMPARE(session.configuration(), configuration); QVERIFY(!session.isOpen()); // session may be invalid if configuration is removed between when // sessionOpenCloseStop_data() is called and here. QVERIFY((configuration.isValid() && (session.state() != QNetworkSession::Invalid)) || (!configuration.isValid() && (session.state() == QNetworkSession::Invalid))); - QVERIFY(session.error() == QNetworkSession::UnknownSessionError); + QCOMPARE(session.error(), QNetworkSession::UnknownSessionError); } // The remaining tests require the session to be not NotAvailable. @@ -541,7 +544,7 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession::SessionError error = qvariant_cast<QNetworkSession::SessionError>(errorSpy.first().at(0)); - QVERIFY(session.state() == previousState); + QCOMPARE(session.state(), previousState); if (error == QNetworkSession::OperationNotSupportedError) { // The session needed to bring up the interface, @@ -571,13 +574,13 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession::State state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(0).at(0)); - QVERIFY(state == QNetworkSession::Connecting); + QCOMPARE(state, QNetworkSession::Connecting); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0)); - QVERIFY(state == QNetworkSession::Connected); + QCOMPARE(state, QNetworkSession::Connected); } - QVERIFY(session.state() == QNetworkSession::Connected); + QCOMPARE(session.state(), QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE QVERIFY(session.interface().isValid()); #endif @@ -600,10 +603,10 @@ void tst_QNetworkSession::sessionOpenCloseStop() // Test opening a second session. { - QVERIFY(session2.configuration() == configuration); + QCOMPARE(session2.configuration(), configuration); QVERIFY(!session2.isOpen()); - QVERIFY(session2.state() == QNetworkSession::Connected); - QVERIFY(session.error() == QNetworkSession::UnknownSessionError); + QCOMPARE(session2.state(), QNetworkSession::Connected); + QCOMPARE(session.error(), QNetworkSession::UnknownSessionError); session2.open(); @@ -611,10 +614,10 @@ void tst_QNetworkSession::sessionOpenCloseStop() if (errorSpy2.isEmpty()) { QVERIFY(session2.isOpen()); - QVERIFY(session2.state() == QNetworkSession::Connected); + QCOMPARE(session2.state(), QNetworkSession::Connected); } QVERIFY(session.isOpen()); - QVERIFY(session.state() == QNetworkSession::Connected); + QCOMPARE(session.state(), QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE QVERIFY(session.interface().isValid()); if (errorSpy2.isEmpty()) { @@ -648,8 +651,8 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession::SessionError error2 = qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0)); - QVERIFY(error == QNetworkSession::SessionAbortedError); - QVERIFY(error2 == QNetworkSession::SessionAbortedError); + QCOMPARE(error, QNetworkSession::SessionAbortedError); + QCOMPARE(error2, QNetworkSession::SessionAbortedError); QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy2.count(), 1); @@ -668,8 +671,8 @@ void tst_QNetworkSession::sessionOpenCloseStop() QTRY_VERIFY_WITH_TIMEOUT(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty(), TestTimeOut); if (!errorSpy2.isEmpty()) { - QVERIFY(session2.state() == previousState); - QVERIFY(session.state() == previousState); + QCOMPARE(session2.state(), previousState); + QCOMPARE(session.state(), previousState); QNetworkSession::SessionError error = qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0)); @@ -697,22 +700,22 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession::State state; if (stateChangedSpy2.count() == 4) { state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Connecting); + QCOMPARE(state, QNetworkSession::Connecting); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Connected); + QCOMPARE(state, QNetworkSession::Connected); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(2).at(0)); - QVERIFY(state == QNetworkSession::Closing); + QCOMPARE(state, QNetworkSession::Closing); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QCOMPARE(state, QNetworkSession::Disconnected); } else if (stateChangedSpy2.count() == 2) { state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Closing); + QCOMPARE(state, QNetworkSession::Closing); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QCOMPARE(state, QNetworkSession::Disconnected); } else { QFAIL("Unexpected amount of state changes when roaming."); } @@ -748,7 +751,7 @@ void tst_QNetworkSession::sessionOpenCloseStop() if (stateChangedSpy.count() > 1) { state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); - QVERIFY(state == QNetworkSession::Roaming); + QCOMPARE(state, QNetworkSession::Roaming); } roamedSuccessfully = true; } @@ -776,9 +779,9 @@ void tst_QNetworkSession::sessionOpenCloseStop() if (stateChangedSpy2.count() == 2) { QNetworkSession::State state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Closing); + QCOMPARE(state, QNetworkSession::Closing); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QCOMPARE(state, QNetworkSession::Disconnected); } else { QVERIFY(stateChangedSpy2.count() >= 1); @@ -791,7 +794,7 @@ void tst_QNetworkSession::sessionOpenCloseStop() QNetworkSession::State state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); + QCOMPARE(state, QNetworkSession::Disconnected); } } @@ -818,14 +821,14 @@ void tst_QNetworkSession::sessionOpenCloseStop() session2.close(); QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy2.isEmpty(), TestTimeOut); - QVERIFY(stateChangedSpy2.count() == stateChangedCountBeforeClose); + QCOMPARE(stateChangedSpy2.count(), stateChangedCountBeforeClose); QVERIFY(sessionClosedSpy.isEmpty()); QVERIFY(session.isOpen()); QVERIFY(!session2.isOpen()); - QVERIFY(session.state() == QNetworkSession::Connected); - QVERIFY(session2.state() == QNetworkSession::Connected); + QCOMPARE(session.state(), QNetworkSession::Connected); + QCOMPARE(session2.state(), QNetworkSession::Connected); #ifndef QT_NO_NETWORKINTERFACE QVERIFY(session.interface().isValid()); QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress()); @@ -1233,7 +1236,7 @@ void tst_QNetworkSession::sessionAutoClose() QNetworkSession session(configuration); - QVERIFY(session.configuration() == configuration); + QCOMPARE(session.configuration(), configuration); QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); @@ -1259,7 +1262,7 @@ void tst_QNetworkSession::sessionAutoClose() QVERIFY(!session.isOpen()); - QVERIFY(session.configuration() == configuration); + QCOMPARE(session.configuration(), configuration); autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index f6b7dfa3af..026a2a2722 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -82,7 +82,7 @@ void tst_QAuthenticator::basicAuth() QAuthenticator auth; auth.detach(); QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth); - QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + QCOMPARE(priv->phase, QAuthenticatorPrivate::Start); QList<QPair<QByteArray, QByteArray> > headers; headers << qMakePair<QByteArray, QByteArray>(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); @@ -94,7 +94,7 @@ void tst_QAuthenticator::basicAuth() auth.setUser(user); auth.setPassword(password); - QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + QCOMPARE(priv->phase, QAuthenticatorPrivate::Start); QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData()); } @@ -125,7 +125,7 @@ void tst_QAuthenticator::ntlmAuth() auth.detach(); QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth); - QVERIFY(priv->phase == QAuthenticatorPrivate::Start); + QCOMPARE(priv->phase, QAuthenticatorPrivate::Start); QList<QPair<QByteArray, QByteArray> > headers; diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index ef24cbf3c8..8069865d93 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -83,22 +83,12 @@ private slots: void isInSubnet(); void isLoopback_data(); void isLoopback(); + void isMulticast_data(); + void isMulticast(); void convertv4v6_data(); void convertv4v6(); }; -QT_BEGIN_NAMESPACE -namespace QTest { - template<> - char *toString(const QHostAddress &addr) - { - if (addr.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) - return qstrdup("<invalid>"); - return qstrdup(addr.toString().toLatin1()); - } -} -QT_END_NAMESPACE - tst_QHostAddress::tst_QHostAddress() { } @@ -234,7 +224,7 @@ void tst_QHostAddress::setAddress_QString() QFETCH(int, protocol); QHostAddress hostAddr; - QVERIFY(hostAddr.setAddress(address) == ok); + QCOMPARE(hostAddr.setAddress(address), ok); if (ok) QTEST(hostAddr.toString(), "resAddr"); @@ -316,7 +306,7 @@ void tst_QHostAddress::compare_data() QTest::newRow("6") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(QHostAddress::LocalHostIPv6) << false; QTest::newRow("7") << QHostAddress() << QHostAddress(QHostAddress::LocalHostIPv6) << false; - Q_IPV6ADDR localhostv4mapped = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1 }; + Q_IPV6ADDR localhostv4mapped = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 127, 0, 0, 1 } }; QTest::newRow("v4-v4mapped") << QHostAddress(QHostAddress::LocalHost) << QHostAddress("::ffff:127.0.0.1") << false; QTest::newRow("v4-v4mapped-2") << QHostAddress(QHostAddress::LocalHost) << QHostAddress(localhostv4mapped) << false; } @@ -330,7 +320,7 @@ void tst_QHostAddress::compare() QCOMPARE(first == second, result); QCOMPARE(second == first, result); if (result == true) - QVERIFY(qHash(first) == qHash(second)); + QCOMPARE(qHash(first), qHash(second)); } void tst_QHostAddress::assignment() @@ -399,11 +389,11 @@ void tst_QHostAddress::streaming() QByteArray ba; QDataStream ds1(&ba, QIODevice::WriteOnly); ds1 << address; - QVERIFY(ds1.status() == QDataStream::Ok); + QCOMPARE(ds1.status(), QDataStream::Ok); QDataStream ds2(&ba, QIODevice::ReadOnly); QHostAddress address2; ds2 >> address2; - QVERIFY(ds2.status() == QDataStream::Ok); + QCOMPARE(ds2.status(), QDataStream::Ok); QCOMPARE(address, address2); } @@ -631,6 +621,9 @@ void tst_QHostAddress::isLoopback_data() QTest::addColumn<QHostAddress>("address"); QTest::addColumn<bool>("result"); + QTest::newRow("default") << QHostAddress() << false; + QTest::newRow("invalid") << QHostAddress("&&&") << false; + QTest::newRow("ipv6_loop") << QHostAddress(QHostAddress::LocalHostIPv6) << true; QTest::newRow("::1") << QHostAddress("::1") << true; @@ -639,7 +632,6 @@ void tst_QHostAddress::isLoopback_data() QTest::newRow("127.0.0.2") << QHostAddress("127.0.0.2") << true; QTest::newRow("127.3.2.1") << QHostAddress("127.3.2.1") << true; - QTest::newRow("default") << QHostAddress() << false; QTest::newRow("1.2.3.4") << QHostAddress("1.2.3.4") << false; QTest::newRow("10.0.0.4") << QHostAddress("10.0.0.4") << false; QTest::newRow("192.168.3.4") << QHostAddress("192.168.3.4") << false; @@ -650,10 +642,12 @@ void tst_QHostAddress::isLoopback_data() QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << false; QTest::newRow("Broadcast") << QHostAddress(QHostAddress::Broadcast) << false; QTest::newRow("Null") << QHostAddress(QHostAddress::Null) << false; + QTest::newRow("ipv6-all-ffff") << QHostAddress("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") << false; QTest::newRow("::ffff:127.0.0.1") << QHostAddress("::ffff:127.0.0.1") << true; QTest::newRow("::ffff:127.0.0.2") << QHostAddress("::ffff:127.0.0.2") << true; QTest::newRow("::ffff:127.3.2.1") << QHostAddress("::ffff:127.3.2.1") << true; + } void tst_QHostAddress::isLoopback() @@ -664,6 +658,50 @@ void tst_QHostAddress::isLoopback() QCOMPARE(address.isLoopback(), result); } +void tst_QHostAddress::isMulticast_data() +{ + QTest::addColumn<QHostAddress>("address"); + QTest::addColumn<bool>("result"); + + QTest::newRow("default") << QHostAddress() << false; + QTest::newRow("invalid") << QHostAddress("&&&") << false; + + QTest::newRow("ipv6_loop") << QHostAddress(QHostAddress::LocalHostIPv6) << false; + QTest::newRow("::1") << QHostAddress("::1") << false; + QTest::newRow("ipv4_loop") << QHostAddress(QHostAddress::LocalHost) << false; + QTest::newRow("127.0.0.1") << QHostAddress("127.0.0.1") << false; + QTest::newRow("::") << QHostAddress("::") << false; + QTest::newRow("Any") << QHostAddress(QHostAddress::Any) << false; + QTest::newRow("AnyIPv4") << QHostAddress(QHostAddress::AnyIPv4) << false; + QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << false; + QTest::newRow("Broadcast") << QHostAddress(QHostAddress::Broadcast) << false; + QTest::newRow("Null") << QHostAddress(QHostAddress::Null) << false; + + QTest::newRow("223.255.255.255") << QHostAddress("223.255.255.255") << false; + QTest::newRow("224.0.0.0") << QHostAddress("224.0.0.0") << true; + QTest::newRow("239.255.255.255") << QHostAddress("239.255.255.255") << true; + QTest::newRow("240.0.0.0") << QHostAddress("240.0.0.0") << false; + + QTest::newRow("::ffff:223.255.255.255") << QHostAddress("::ffff:223.255.255.255") << false; + QTest::newRow("::ffff:224.0.0.0") << QHostAddress("::ffff:224.0.0.0") << true; + QTest::newRow("::ffff:239.255.255.255") << QHostAddress("::ffff:239.255.255.255") << true; + QTest::newRow("::ffff:240.0.0.0") << QHostAddress("::ffff:240.0.0.0") << false; + + QTest::newRow("fc00::") << QHostAddress("fc00::") << false; + QTest::newRow("fe80::") << QHostAddress("fe80::") << false; + QTest::newRow("fec0::") << QHostAddress("fec0::") << false; + QTest::newRow("ff00::") << QHostAddress("ff00::") << true; + QTest::newRow("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") << QHostAddress("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") << true; +} + +void tst_QHostAddress::isMulticast() +{ + QFETCH(QHostAddress, address); + QFETCH(bool, result); + + QCOMPARE(address.isMulticast(), result); +} + void tst_QHostAddress::convertv4v6_data() { QTest::addColumn<QHostAddress>("source"); diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 599e475beb..5f0addba98 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -561,13 +561,13 @@ void tst_QHostInfo::cache() QHostInfo result = qt_qhostinfo_lookup("localhost", this, SLOT(resultsReady(QHostInfo)), &valid, &id); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(valid == false); + QVERIFY(!valid); QVERIFY(result.addresses().isEmpty()); // loopkup second time, result should come directly valid = false; result = qt_qhostinfo_lookup("localhost", this, SLOT(resultsReady(QHostInfo)), &valid, &id); - QVERIFY(valid == true); + QVERIFY(valid); QVERIFY(!result.addresses().isEmpty()); // clear the cache @@ -578,7 +578,7 @@ void tst_QHostInfo::cache() result = qt_qhostinfo_lookup("localhost", this, SLOT(resultsReady(QHostInfo)), &valid, &id); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(valid == false); + QVERIFY(!valid); QVERIFY(result.addresses().isEmpty()); // the slot should have been called 2 times. diff --git a/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp b/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp index d88b2e222c..cca670e13a 100644 --- a/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp +++ b/tests/auto/network/kernel/qnetworkaddressentry/tst_qnetworkaddressentry.cpp @@ -76,7 +76,7 @@ void tst_QNetworkAddressEntry::getSetCheck() entry = entry2; QCOMPARE(entry, entry2); - QVERIFY(entry == entry); + QCOMPARE(entry, entry); QVERIFY(!(entry != entry2)); } diff --git a/tests/auto/network/kernel/qnetworkinterface/BLACKLIST b/tests/auto/network/kernel/qnetworkinterface/BLACKLIST new file mode 100644 index 0000000000..23bb688d9a --- /dev/null +++ b/tests/auto/network/kernel/qnetworkinterface/BLACKLIST @@ -0,0 +1,2 @@ +[localAddress] +linux diff --git a/tests/auto/network/socket/platformsocketengine/BLACKLIST b/tests/auto/network/socket/platformsocketengine/BLACKLIST new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/tests/auto/network/socket/platformsocketengine/BLACKLIST @@ -0,0 +1 @@ +windows diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index 9bd89cdf4f..71125f463a 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -130,18 +130,18 @@ void tst_PlatformSocketEngine::construction() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(socketDevice.isValid()); - QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol); - QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol); + QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); QVERIFY(socketDevice.socketDescriptor() != -1); - QVERIFY(socketDevice.localAddress() == QHostAddress()); - QVERIFY(socketDevice.localPort() == 0); - QVERIFY(socketDevice.peerAddress() == QHostAddress()); - QVERIFY(socketDevice.peerPort() == 0); - QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError); + QCOMPARE(socketDevice.localAddress(), QHostAddress()); + QCOMPARE(socketDevice.localPort(), quint16(0)); + QCOMPARE(socketDevice.peerAddress(), QHostAddress()); + QCOMPARE(socketDevice.peerPort(), quint16(0)); + QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError); QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState"); - QVERIFY(socketDevice.bytesAvailable() == -1); + QCOMPARE(socketDevice.bytesAvailable(), -1); QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState"); QVERIFY(!socketDevice.hasPendingDatagrams()); @@ -154,16 +154,16 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); const bool isConnected = socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143); if (!isConnected) { - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); } - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -200,8 +200,8 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.waitForRead()); char c; QVERIFY(socketDevice.read(&c, sizeof(c)) == -1); - QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } //--------------------------------------------------------------------------- @@ -213,13 +213,13 @@ void tst_PlatformSocketEngine::udpLoopbackTest() QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket)); QVERIFY(udpSocket.isValid()); QVERIFY(udpSocket.socketDescriptor() != -1); - QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol); - QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket); - QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol); + QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket); + QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState); // Bind #1 to localhost QVERIFY(udpSocket.bind(QHostAddress("127.0.0.1"), 0)); - QVERIFY(udpSocket.state() == QAbstractSocket::BoundState); + QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState); quint16 port = udpSocket.localPort(); QVERIFY(port != 0); @@ -229,7 +229,7 @@ void tst_PlatformSocketEngine::udpLoopbackTest() // Connect device #2 to #1 QVERIFY(udpSocket2.connectToHost(QHostAddress("127.0.0.1"), port)); - QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState); + QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState); // Write a message to #1 QByteArray message1 = "hei der"; @@ -243,13 +243,13 @@ void tst_PlatformSocketEngine::udpLoopbackTest() QVERIFY(available > 0); QByteArray answer; answer.resize(available); - QHostAddress senderAddress; - quint16 senderPort = 0; - QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(), - &senderAddress, - &senderPort) == message1.size()); - QVERIFY(senderAddress == QHostAddress("127.0.0.1")); - QVERIFY(senderPort != 0); + QIpPacketHeader header; + QCOMPARE(udpSocket.readDatagram(answer.data(), answer.size(), + &header, QAbstractSocketEngine::WantDatagramSender), + qint64(message1.size())); + QVERIFY(header.senderAddress == QHostAddress("127.0.0.1")); + QCOMPARE(header.senderAddress, QHostAddress("127.0.0.1")); + QVERIFY(header.senderPort != 0); } //--------------------------------------------------------------------------- @@ -261,13 +261,13 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest() bool init = udpSocket.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol); if (!init) { - QVERIFY(udpSocket.error() == QAbstractSocket::UnsupportedSocketOperationError); + QCOMPARE(udpSocket.error(), QAbstractSocket::UnsupportedSocketOperationError); } else { - QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv6Protocol); + QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv6Protocol); // Bind #1 to localhost QVERIFY(udpSocket.bind(QHostAddress("::1"), 0)); - QVERIFY(udpSocket.state() == QAbstractSocket::BoundState); + QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState); quint16 port = udpSocket.localPort(); QVERIFY(port != 0); @@ -277,7 +277,7 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest() // Connect device #2 to #1 QVERIFY(udpSocket2.connectToHost(QHostAddress("::1"), port)); - QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState); + QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState); // Write a message to #1 QByteArray message1 = "hei der"; @@ -291,13 +291,13 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest() QVERIFY(available > 0); QByteArray answer; answer.resize(available); - QHostAddress senderAddress; - quint16 senderPort = 0; - QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(), - &senderAddress, - &senderPort) == message1.size()); - QVERIFY(senderAddress == QHostAddress("::1")); - QVERIFY(senderPort != 0); + QIpPacketHeader header; + QCOMPARE(udpSocket.readDatagram(answer.data(), answer.size(), + &header, QAbstractSocketEngine::WantDatagramSender), + qint64(message1.size())); + QVERIFY(header.senderAddress == QHostAddress("::1")); + QCOMPARE(header.senderAddress, QHostAddress("::1")); + QVERIFY(header.senderPort != 0); } } @@ -314,7 +314,7 @@ void tst_PlatformSocketEngine::broadcastTest() // Bind to any port on all interfaces QVERIFY(broadcastSocket.bind(QHostAddress::Any, 0)); - QVERIFY(broadcastSocket.state() == QAbstractSocket::BoundState); + QCOMPARE(broadcastSocket.state(), QAbstractSocket::BoundState); quint16 port = broadcastSocket.localPort(); QVERIFY(port > 0); @@ -323,9 +323,9 @@ void tst_PlatformSocketEngine::broadcastTest() = "MOOT wtf is a MOOT? talk english not your sutpiD ENGLISH."; qint64 written = broadcastSocket.writeDatagram(trollMessage.data(), trollMessage.size(), - QHostAddress::Broadcast, - port); + QIpPacketHeader(QHostAddress::Broadcast, port)); + QVERIFY2(written != -1, qt_error_string().toLocal8Bit()); QCOMPARE((int)written, trollMessage.size()); // Wait until we receive it ourselves @@ -354,20 +354,20 @@ void tst_PlatformSocketEngine::serverTest() // Bind to any port on all interfaces QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0)); - QVERIFY(server.state() == QAbstractSocket::BoundState); + QCOMPARE(server.state(), QAbstractSocket::BoundState); quint16 port = server.localPort(); // Listen for incoming connections QVERIFY(server.listen()); - QVERIFY(server.state() == QAbstractSocket::ListeningState); + QCOMPARE(server.state(), QAbstractSocket::ListeningState); // Initialize a Tcp socket PLATFORMSOCKETENGINE client; QVERIFY(client.initialize(QAbstractSocket::TcpSocket)); if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) { - QVERIFY(client.state() == QAbstractSocket::ConnectingState); + QCOMPARE(client.state(), QAbstractSocket::ConnectingState); QVERIFY(client.waitForWrite()); - QVERIFY(client.state() == QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); } // The server accepts the connection @@ -378,7 +378,7 @@ void tst_PlatformSocketEngine::serverTest() // socket descriptor from accept(). It's pre-connected. PLATFORMSOCKETENGINE serverSocket; QVERIFY(serverSocket.initialize(socketDescriptor)); - QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState); // The server socket sends a greeting to the clietn QByteArray greeting = "Greetings!"; @@ -407,13 +407,13 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance() QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket)); QVERIFY(udpSocket.isValid()); QVERIFY(udpSocket.socketDescriptor() != -1); - QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol); - QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket); - QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol); + QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket); + QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState); // Bind #1 to localhost QVERIFY(udpSocket.bind(QHostAddress("127.0.0.1"), 0)); - QVERIFY(udpSocket.state() == QAbstractSocket::BoundState); + QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState); quint16 port = udpSocket.localPort(); QVERIFY(port != 0); @@ -423,7 +423,7 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance() // Connect device #2 to #1 QVERIFY(udpSocket2.connectToHost(QHostAddress("127.0.0.1"), port)); - QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState); + QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState); const int messageSize = 8192; QByteArray message1(messageSize, '@'); @@ -459,12 +459,12 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance() // Bind to any port on all interfaces QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0)); - QVERIFY(server.state() == QAbstractSocket::BoundState); + QCOMPARE(server.state(), QAbstractSocket::BoundState); quint16 port = server.localPort(); // Listen for incoming connections QVERIFY(server.listen()); - QVERIFY(server.state() == QAbstractSocket::ListeningState); + QCOMPARE(server.state(), QAbstractSocket::ListeningState); // Initialize a Tcp socket PLATFORMSOCKETENGINE client; @@ -472,9 +472,9 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance() // Connect to our server if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) { - QVERIFY(client.state() == QAbstractSocket::ConnectingState); + QCOMPARE(client.state(), QAbstractSocket::ConnectingState); QVERIFY(client.waitForWrite()); - QVERIFY(client.state() == QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); } // The server accepts the connection @@ -485,7 +485,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance() // socket descriptor from accept(). It's pre-connected. PLATFORMSOCKETENGINE serverSocket; QVERIFY(serverSocket.initialize(socketDescriptor)); - QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState); const int messageSize = 1024 * 256; QByteArray message1(messageSize, '@'); @@ -562,7 +562,7 @@ void tst_PlatformSocketEngine::bind() PLATFORMSOCKETENGINE binder; QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(!binder.bind(QHostAddress::AnyIPv4, 82)); - QVERIFY(binder.error() == QAbstractSocket::SocketAccessError); + QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError); #endif PLATFORMSOCKETENGINE binder2; @@ -572,7 +572,7 @@ void tst_PlatformSocketEngine::bind() PLATFORMSOCKETENGINE binder3; QVERIFY(binder3.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(!binder3.bind(QHostAddress::AnyIPv4, 31180)); - QVERIFY(binder3.error() == QAbstractSocket::AddressInUseError); + QCOMPARE(binder3.error(), QAbstractSocket::AddressInUseError); if (QtNetworkSettings::hasIPv6()) { PLATFORMSOCKETENGINE binder4; @@ -582,7 +582,7 @@ void tst_PlatformSocketEngine::bind() PLATFORMSOCKETENGINE binder5; QVERIFY(binder5.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv6Protocol)); QVERIFY(!binder5.bind(QHostAddress::AnyIPv6, 31180)); - QVERIFY(binder5.error() == QAbstractSocket::AddressInUseError); + QCOMPARE(binder5.error(), QAbstractSocket::AddressInUseError); } PLATFORMSOCKETENGINE binder6; @@ -599,11 +599,11 @@ void tst_PlatformSocketEngine::networkError() const bool isConnected = client.connectToHost(QtNetworkSettings::serverIP(), 143); if (!isConnected) { - QVERIFY(client.state() == QAbstractSocket::ConnectingState); + QCOMPARE(client.state(), QAbstractSocket::ConnectingState); QVERIFY(client.waitForWrite()); - QVERIFY(client.state() == QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); } - QVERIFY(client.state() == QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); // An unexpected network error! #ifdef Q_OS_WINRT @@ -636,7 +636,7 @@ void tst_PlatformSocketEngine::invalidSend() QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::writeDatagram() was" " called by a socket other than QAbstractSocket::UdpSocket"); - QCOMPARE(socket.writeDatagram("hei", 3, QHostAddress::LocalHost, 143), + QCOMPARE(socket.writeDatagram("hei", 3, QIpPacketHeader(QHostAddress::LocalHost, 143)), (qlonglong) -1); } @@ -650,19 +650,19 @@ void tst_PlatformSocketEngine::receiveUrgentData() // Bind to any port on all interfaces QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0)); - QVERIFY(server.state() == QAbstractSocket::BoundState); + QCOMPARE(server.state(), QAbstractSocket::BoundState); quint16 port = server.localPort(); QVERIFY(server.listen()); - QVERIFY(server.state() == QAbstractSocket::ListeningState); + QCOMPARE(server.state(), QAbstractSocket::ListeningState); PLATFORMSOCKETENGINE client; QVERIFY(client.initialize(QAbstractSocket::TcpSocket)); if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) { - QVERIFY(client.state() == QAbstractSocket::ConnectingState); + QCOMPARE(client.state(), QAbstractSocket::ConnectingState); QVERIFY(client.waitForWrite()); - QVERIFY(client.state() == QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); } int socketDescriptor = server.accept(); @@ -670,7 +670,7 @@ void tst_PlatformSocketEngine::receiveUrgentData() PLATFORMSOCKETENGINE serverSocket; QVERIFY(serverSocket.initialize(socketDescriptor)); - QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState); char msg; int available; diff --git a/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp b/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp index 76c36831bd..1c79b6c016 100644 --- a/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp +++ b/tests/auto/network/socket/qabstractsocket/tst_qabstractsocket.cpp @@ -37,11 +37,6 @@ #include <qcoreapplication.h> #include <qdebug.h> #include <qabstractsocket.h> -#include <qtcpserver.h> -#include <qtcpsocket.h> -#ifndef QT_NO_SSL -#include <qsslsocket.h> -#endif class tst_QAbstractSocket : public QObject { @@ -52,9 +47,7 @@ public: virtual ~tst_QAbstractSocket(); private slots: - void initTestCase(); void getSetCheck(); - void serverDisconnectWithBuffered(); }; tst_QAbstractSocket::tst_QAbstractSocket() @@ -73,11 +66,6 @@ public: void setPeerPort(quint16 port) { QAbstractSocket::setPeerPort(port); } }; -void tst_QAbstractSocket::initTestCase() -{ - qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState"); -} - // Testing get/set functions void tst_QAbstractSocket::getSetCheck() { @@ -106,46 +94,5 @@ void tst_QAbstractSocket::getSetCheck() QCOMPARE(quint16(0xffff), obj1.peerPort()); } -// Test buffered socket being properly closed on remote disconnect -void tst_QAbstractSocket::serverDisconnectWithBuffered() -{ - QTcpServer tcpServer; -#ifndef QT_NO_SSL - QSslSocket testSocket; -#else - QTcpSocket testSocket; -#endif - - QVERIFY(tcpServer.listen(QHostAddress::LocalHost)); - testSocket.connectToHost(tcpServer.serverAddress(), tcpServer.serverPort()); - // Accept connection on server side - QVERIFY(tcpServer.waitForNewConnection(5000)); - QTcpSocket *newConnection = tcpServer.nextPendingConnection(); - // Send one char and drop link - QVERIFY(newConnection != NULL); - QVERIFY(newConnection->putChar(0)); - QVERIFY(newConnection->flush()); - delete newConnection; - - QVERIFY(testSocket.waitForConnected(5000)); // ready for write - QVERIFY(testSocket.state() == QAbstractSocket::ConnectedState); - - QSignalSpy spyStateChanged(&testSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState))); - QSignalSpy spyDisconnected(&testSocket, SIGNAL(disconnected())); - - QVERIFY(testSocket.waitForReadyRead(5000)); // have one char already in internal buffer - char buf[128]; - QCOMPARE(testSocket.read(buf, sizeof(buf)), Q_INT64_C(1)); - if (testSocket.state() != QAbstractSocket::UnconnectedState) { - QVERIFY(testSocket.waitForDisconnected(5000)); - QVERIFY(testSocket.state() == QAbstractSocket::UnconnectedState); - } - // Test signal emitting - QVERIFY(spyDisconnected.count() == 1); - QVERIFY(spyStateChanged.count() > 0); - QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first()) - == QAbstractSocket::UnconnectedState); -} - QTEST_MAIN(tst_QAbstractSocket) #include "tst_qabstractsocket.moc" diff --git a/tests/auto/network/socket/qhttpsocketengine/BLACKLIST b/tests/auto/network/socket/qhttpsocketengine/BLACKLIST new file mode 100644 index 0000000000..8e1a55995e --- /dev/null +++ b/tests/auto/network/socket/qhttpsocketengine/BLACKLIST @@ -0,0 +1 @@ +windows diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 10e8c95fc0..179cdb76bc 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -164,18 +164,18 @@ void tst_QHttpSocketEngine::construction() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(socketDevice.isValid()); - QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol); - QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol); + QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); // QVERIFY(socketDevice.socketDescriptor() != -1); - QVERIFY(socketDevice.localAddress() == QHostAddress()); - QVERIFY(socketDevice.localPort() == 0); - QVERIFY(socketDevice.peerAddress() == QHostAddress()); - QVERIFY(socketDevice.peerPort() == 0); - QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError); + QCOMPARE(socketDevice.localAddress(), QHostAddress()); + QCOMPARE(socketDevice.localPort(), quint16(0)); + QCOMPARE(socketDevice.peerAddress(), QHostAddress()); + QCOMPARE(socketDevice.peerPort(), quint16(0)); + QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError); //QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::bytesAvailable() was called in QAbstractSocket::UnconnectedState"); - QVERIFY(socketDevice.bytesAvailable() == 0); + QCOMPARE(socketDevice.bytesAvailable(), 0); //QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState"); QVERIFY(!socketDevice.hasPendingDatagrams()); @@ -299,15 +299,15 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); QVERIFY(!socketDevice.localAddress().isNull()); QVERIFY(socketDevice.localPort() > 0); @@ -345,8 +345,8 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.waitForRead()); char c; QCOMPARE(socketDevice.read(&c, sizeof(c)), (qint64) -1); - QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } //--------------------------------------------------------------------------- @@ -360,14 +360,14 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); if (socketDevice.waitForWrite(30000)) { QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState || socketDevice.state() == QAbstractSocket::UnconnectedState); } else { - QVERIFY(socketDevice.error() == QAbstractSocket::SocketTimeoutError); + QCOMPARE(socketDevice.error(), QAbstractSocket::SocketTimeoutError); } } @@ -381,12 +381,12 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance() // Bind to any port on all interfaces QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0)); - QVERIFY(server.state() == QAbstractSocket::BoundState); + QCOMPARE(server.state(), QAbstractSocket::BoundState); quint16 port = server.localPort(); // Listen for incoming connections QVERIFY(server.listen()); - QVERIFY(server.state() == QAbstractSocket::ListeningState); + QCOMPARE(server.state(), QAbstractSocket::ListeningState); // Initialize a Tcp socket QHttpSocketEngine client; @@ -408,7 +408,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance() // socket descriptor from accept(). It's pre-connected. QSocketLayer serverSocket; QVERIFY(serverSocket.initialize(socketDescriptor)); - QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState); const int messageSize = 1024 * 256; QByteArray message1(messageSize, '@'); @@ -544,7 +544,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() QFAIL("Timed out"); } - QVERIFY(tcpSocketNonBlocking_totalWritten == 8); + QCOMPARE(tcpSocketNonBlocking_totalWritten, 8); QTestEventLoop::instance().enterLoop(30); @@ -569,7 +569,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() QFAIL("Timed out"); } - QVERIFY(tcpSocketNonBlocking_totalWritten == 10); + QCOMPARE(tcpSocketNonBlocking_totalWritten, 10); // Wait for greeting QTestEventLoop::instance().enterLoop(30); @@ -637,7 +637,7 @@ void tst_QHttpSocketEngine::downloadBigFile() QFAIL("Network operation timed out"); QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); - QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); + QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("Host: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); @@ -659,7 +659,7 @@ void tst_QHttpSocketEngine::downloadBigFile() QVERIFY(bytesAvailable >= 10000000); - QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); + QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s", bytesAvailable / (1024.0 * 1024.0), @@ -689,15 +689,15 @@ void tst_QHttpSocketEngine::passwordAuth() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password")); QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -733,8 +733,8 @@ void tst_QHttpSocketEngine::passwordAuth() QVERIFY(socketDevice.waitForRead()); char c; QVERIFY(socketDevice.read(&c, sizeof(c)) == -1); - QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } //---------------------------------------------------------------------------------- diff --git a/tests/auto/network/socket/qlocalsocket/BLACKLIST b/tests/auto/network/socket/qlocalsocket/BLACKLIST new file mode 100644 index 0000000000..11ddef30a5 --- /dev/null +++ b/tests/auto/network/socket/qlocalsocket/BLACKLIST @@ -0,0 +1,2 @@ +[processConnection:1 client] +windows diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 4881d86937..847e065aa8 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -246,8 +246,8 @@ void tst_QLocalSocket::socket_basic() QCOMPARE(socket.serverName(), QString()); QCOMPARE(socket.fullServerName(), QString()); socket.abort(); - QVERIFY(socket.bytesAvailable() == 0); - QVERIFY(socket.bytesToWrite() == 0); + QCOMPARE(socket.bytesAvailable(), 0); + QCOMPARE(socket.bytesToWrite(), 0); QCOMPARE(socket.canReadLine(), false); socket.close(); socket.disconnectFromServer(); @@ -255,7 +255,7 @@ void tst_QLocalSocket::socket_basic() QVERIFY(!socket.errorString().isEmpty()); QCOMPARE(socket.flush(), false); QCOMPARE(socket.isValid(), false); - QVERIFY(socket.readBufferSize() == 0); + QCOMPARE(socket.readBufferSize(), 0); socket.setReadBufferSize(0); //QCOMPARE(socket.socketDescriptor(), (qintptr)-1); QCOMPARE(socket.state(), QLocalSocket::UnconnectedState); @@ -375,13 +375,13 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(!socket->errorString().isEmpty()); QVERIFY(socket->error() != QLocalSocket::UnknownSocketError); QCOMPARE(socket->state(), QLocalSocket::UnconnectedState); - //QVERIFY(socket->socketDescriptor() == -1); + //QCOMPARE(socket->socketDescriptor(), -1); QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]), QLocalSocket::ServerNotFoundError); } - QVERIFY(socket->bytesAvailable() == 0); - QVERIFY(socket->bytesToWrite() == 0); + QCOMPARE(socket->bytesAvailable(), 0); + QCOMPARE(socket->bytesToWrite(), 0); QCOMPARE(socket->canReadLine(), false); QCOMPARE(socket->flush(), false); QCOMPARE(socket->isValid(), canListen); @@ -432,7 +432,7 @@ void tst_QLocalSocket::listenAndConnect() } else { QVERIFY(server.serverName().isEmpty()); QVERIFY(server.fullServerName().isEmpty()); - QVERIFY(server.nextPendingConnection() == (QLocalSocket*)0); + QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0); QCOMPARE(spyNewConnection.count(), 0); QCOMPARE(server.hits.count(), 0); QVERIFY(!server.errorString().isEmpty()); @@ -616,7 +616,7 @@ void tst_QLocalSocket::readBufferOverflow() QVERIFY(client.waitForReadyRead()); QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); // no more bytes available - QVERIFY(client.bytesAvailable() == 0); + QCOMPARE(client.bytesAvailable(), 0); } // QLocalSocket/Server can take a name or path, check that it works as expected @@ -912,7 +912,7 @@ void tst_QLocalSocket::waitForDisconnectByServer() QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); serverSocket->close(); - QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState); + QCOMPARE(serverSocket->state(), QLocalSocket::UnconnectedState); QVERIFY(socket.waitForDisconnected(3000)); QCOMPARE(spy.count(), 1); } @@ -1197,11 +1197,12 @@ void tst_QLocalSocket::verifyListenWithDescriptor() QVERIFY2(server.listen(listenSocket), "failed to start create QLocalServer with local socket"); #ifdef Q_OS_LINUX + const QChar at(QLatin1Char('@')); if (!bound) { - QVERIFY(server.serverName().at(0) == QLatin1Char('@')); - QVERIFY(server.fullServerName().at(0) == QLatin1Char('@')); + QCOMPARE(server.serverName().at(0), at); + QCOMPARE(server.fullServerName().at(0), at); } else if (abstract) { - QVERIFY2(server.fullServerName().at(0) == QLatin1Char('@'), "abstract sockets should start with a '@'"); + QVERIFY2(server.fullServerName().at(0) == at, "abstract sockets should start with a '@'"); } else { QCOMPARE(server.fullServerName(), path); if (path.contains(QLatin1String("/"))) { diff --git a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST index bf4afa8c45..2a32a326d0 100644 --- a/tests/auto/network/socket/qsocks5socketengine/BLACKLIST +++ b/tests/auto/network/socket/qsocks5socketengine/BLACKLIST @@ -2,3 +2,5 @@ * [passwordAuth] * +[serverTest] +windows diff --git a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp index 0ae9887773..8da656aab7 100644 --- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -193,18 +193,18 @@ void tst_QSocks5SocketEngine::construction() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(socketDevice.isValid()); - QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol); - QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol); + QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); // QVERIFY(socketDevice.socketDescriptor() != -1); - QVERIFY(socketDevice.localAddress() == QHostAddress()); - QVERIFY(socketDevice.localPort() == 0); - QVERIFY(socketDevice.peerAddress() == QHostAddress()); - QVERIFY(socketDevice.peerPort() == 0); - QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError); + QCOMPARE(socketDevice.localAddress(), QHostAddress()); + QCOMPARE(socketDevice.localPort(), quint16(0)); + QCOMPARE(socketDevice.peerAddress(), QHostAddress()); + QCOMPARE(socketDevice.peerPort(), quint16(0)); + QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError); //QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::bytesAvailable() was called in QAbstractSocket::UnconnectedState"); - QVERIFY(socketDevice.bytesAvailable() == 0); + QCOMPARE(socketDevice.bytesAvailable(), 0); //QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState"); QVERIFY(!socketDevice.hasPendingDatagrams()); @@ -334,15 +334,15 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -377,8 +377,8 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.waitForRead()); char c; QVERIFY(socketDevice.read(&c, sizeof(c)) == -1); - QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } //--------------------------------------------------------------------------- @@ -392,14 +392,14 @@ void tst_QSocks5SocketEngine::simpleErrorsAndStates() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(), 8088)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); if (socketDevice.waitForWrite(15000)) { QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState || socketDevice.state() == QAbstractSocket::ConnectedState); } else { - QVERIFY(socketDevice.error() == QAbstractSocket::SocketTimeoutError); + QCOMPARE(socketDevice.error(), QAbstractSocket::SocketTimeoutError); } } @@ -413,12 +413,12 @@ void tst_QSocks5SocketEngine::tcpLoopbackPerformance() // Bind to any port on all interfaces QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0)); - QVERIFY(server.state() == QAbstractSocket::BoundState); + QCOMPARE(server.state(), QAbstractSocket::BoundState); quint16 port = server.localPort(); // Listen for incoming connections QVERIFY(server.listen()); - QVERIFY(server.state() == QAbstractSocket::ListeningState); + QCOMPARE(server.state(), QAbstractSocket::ListeningState); // Initialize a Tcp socket QSocks5SocketEngine client; @@ -440,7 +440,7 @@ void tst_QSocks5SocketEngine::tcpLoopbackPerformance() // socket descriptor from accept(). It's pre-connected. QSocketLayer serverSocket; QVERIFY(serverSocket.initialize(socketDescriptor)); - QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState); const int messageSize = 1024 * 256; QByteArray message1(messageSize, '@'); @@ -482,11 +482,11 @@ void tst_QSocks5SocketEngine::serverTest() // Bind to any port on all interfaces QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0)); - QVERIFY(server.state() == QAbstractSocket::BoundState); + QCOMPARE(server.state(), QAbstractSocket::BoundState); // Listen for incoming connections QVERIFY(server.listen()); - QVERIFY(server.state() == QAbstractSocket::ListeningState); + QCOMPARE(server.state(), QAbstractSocket::ListeningState); // Initialize a Tcp socket QSocks5SocketEngine client; @@ -501,7 +501,7 @@ void tst_QSocks5SocketEngine::serverTest() if (!client.connectToHost(server.localAddress(), server.localPort())) { QVERIFY(client.waitForWrite()); // QTest::wait(100); // ### timing problem on win32 - QVERIFY(client.state() == QAbstractSocket::ConnectedState); + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); //QTest::wait(100); } @@ -516,14 +516,14 @@ void tst_QSocks5SocketEngine::serverTest() QSocks5SocketEngine serverSocket; QVERIFY(serverSocket.initialize(socketDescriptor)); - QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState); - QVERIFY(serverSocket.localAddress() == client.peerAddress()); - QVERIFY(serverSocket.localPort() == client.peerPort()); + QCOMPARE(serverSocket.localAddress(), client.peerAddress()); + QCOMPARE(serverSocket.localPort(), client.peerPort()); // this seems depends on the socks server implementation, especially // when connecting /to/ the socks server /through/ the same socks server - //QVERIFY(serverSocket.peerAddress() == client.localAddress()); - //QVERIFY(serverSocket.peerPort() == client.localPort()); + //QCOMPARE(serverSocket.peerAddress(), client.localAddress()); + //QCOMPARE(serverSocket.peerPort(), client.localPort()); // The server socket sends a greeting to the client QByteArray greeting = "Greetings!"; @@ -557,16 +557,16 @@ void tst_QSocks5SocketEngine::udpTest() udpSocket.setProxy(proxy); - QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol); - QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket); - QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol); + QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket); + QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState); // Bind #1 bool bindSuccessful = udpSocket.bind(QHostAddress("0.0.0.0"), 0); if (!bindSuccessful) QEXPECT_FAIL("", "QTBUG-23380 / QTBUG-35490: Fails on some Ubuntu 11.10 x64 configurations and on new network test server", Abort); QVERIFY(bindSuccessful); - QVERIFY(udpSocket.state() == QAbstractSocket::BoundState); + QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState); QVERIFY(udpSocket.localPort() != 0); // Initialize device #2 @@ -577,7 +577,7 @@ void tst_QSocks5SocketEngine::udpTest() // Connect device #2 to #1 QVERIFY(udpSocket2.connectToHost(udpSocket.localAddress(), udpSocket.localPort())); - QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState); + QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState); // Write a message to #1 QByteArray message1 = "hei der"; @@ -591,13 +591,13 @@ void tst_QSocks5SocketEngine::udpTest() QVERIFY(available > 0); QByteArray answer; answer.resize(available); - QHostAddress senderAddress; - quint16 senderPort = 0; - QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(), - &senderAddress, - &senderPort) == message1.size()); - QVERIFY(senderAddress == udpSocket2.localAddress()); - QVERIFY(senderPort == udpSocket2.localPort()); + QIpPacketHeader header; + QCOMPARE(udpSocket.readDatagram(answer.data(), answer.size(), + &header, QAbstractSocketEngine::WantDatagramSender), + qint64(message1.size())); + QVERIFY(header.senderAddress == udpSocket2.localAddress()); + QCOMPARE(header.senderAddress, udpSocket2.localAddress()); + QCOMPARE(header.senderPort, udpSocket2.localPort()); } void tst_QSocks5SocketEngine::tcpSocketBlockingTest() @@ -705,7 +705,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() QFAIL("Timed out"); } - QVERIFY(tcpSocketNonBlocking_totalWritten == 8); + QCOMPARE(tcpSocketNonBlocking_totalWritten, 8); QTestEventLoop::instance().enterLoop(30); @@ -729,7 +729,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() QFAIL("Timed out"); } - QVERIFY(tcpSocketNonBlocking_totalWritten == 10); + QCOMPARE(tcpSocketNonBlocking_totalWritten, 10); // Wait for greeting QTestEventLoop::instance().enterLoop(30); @@ -797,7 +797,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QFAIL("Network operation timed out"); QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); - QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); + QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); @@ -819,7 +819,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QCOMPARE(bytesAvailable, qint64(10000000)); - QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); + QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); /*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s", bytesAvailable / (1024.0 * 1024.0), @@ -852,19 +852,19 @@ void tst_QSocks5SocketEngine::passwordAuth() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password")); // Connect to imap.trolltech.com's IP QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) { qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); } - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -899,8 +899,8 @@ void tst_QSocks5SocketEngine::passwordAuth() QVERIFY(socketDevice.waitForRead()); char c; QVERIFY(socketDevice.read(&c, sizeof(c)) == -1); - QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } //---------------------------------------------------------------------------------- @@ -918,21 +918,21 @@ void tst_QSocks5SocketEngine::passwordAuth2() // Initialize device QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081)); socketDevice.setReceiver(this); QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState); while (socketDevice.state() == QAbstractSocket::ConnectingState) { QVERIFY(socketDevice.waitForWrite()); socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143); } if (socketDevice.state() != QAbstractSocket::ConnectedState) qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData()); - QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState); - QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP()); + QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState); + QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP()); // Wait for the greeting QVERIFY(socketDevice.waitForRead()); @@ -967,8 +967,8 @@ void tst_QSocks5SocketEngine::passwordAuth2() QVERIFY(socketDevice.waitForRead()); char c; QVERIFY(socketDevice.read(&c, sizeof(c)) == -1); - QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError); - QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState); } void tst_QSocks5SocketEngine::fragmentation_data() @@ -1017,7 +1017,7 @@ void tst_QSocks5SocketEngine::fragmentation() QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(socket.localAddress() == QHostAddress("1.2.3.4") || socket.localAddress() == QHostAddress("0123:4567:89ab:cdef:0123:4567:89ab:cdef")); - QVERIFY(socket.localPort() == 0x0506); + QCOMPARE(socket.localPort(), quint16(0x0506)); } void tst_QSocks5SocketEngine::incomplete_data() diff --git a/tests/auto/network/socket/qtcpserver/BLACKLIST b/tests/auto/network/socket/qtcpserver/BLACKLIST new file mode 100644 index 0000000000..f8b61808cc --- /dev/null +++ b/tests/auto/network/socket/qtcpserver/BLACKLIST @@ -0,0 +1,13 @@ +windows +[linkLocal] +linux +[listenWhileListening:WithSocks5Proxy] +linux +windows +[ipv6Server:WithoutProxy] +windows +osx +[clientServerLoop:WithSocks5Proxy] +linux +[crashTests:WithSocks5Proxy] +linux diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index e0a6e3699d..5df5432cdd 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -265,11 +265,11 @@ void tst_QTcpServer::ipv6Server() //### need to enter the event loop for the server to get the connection ?? ( windows) QTcpServer server; if (!server.listen(QHostAddress::LocalHostIPv6, 8944)) { - QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError); + QCOMPARE(server.serverError(), QAbstractSocket::UnsupportedSocketOperationError); return; } - QVERIFY(server.serverPort() == 8944); + QCOMPARE(server.serverPort(), quint16(8944)); QVERIFY(server.serverAddress() == QHostAddress::LocalHostIPv6); QTcpSocket client; @@ -835,17 +835,17 @@ void tst_QTcpServer::qtbug14268_peek() client.write("abc\n"); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(helper.lastDataPeeked == QByteArray("6162630a")); + QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a")); client.write("def\n"); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a")); + QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a6465660a")); client.write("ghi\n"); QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a6768690a")); + QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a6465660a6768690a")); } void tst_QTcpServer::serverAddress_data() diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 3e64b87b53..325abcaab8 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -21,3 +21,5 @@ win32 { } else { DESTDIR = ../ } + +win32: CONFIG += insignificant_test # Hangs in release builds diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 0ba9b6a58c..abbc560414 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -200,6 +200,7 @@ private slots: void setSocketOption(); void clientSendDataOnDelayedDisconnect(); + void serverDisconnectWithBuffered(); protected slots: void nonBlockingIMAP_hostFound(); @@ -241,7 +242,6 @@ private: mutable int proxyAuthCalled; - int numConnections; static int loopLevel; SocketPair *earlyConstructedSockets; @@ -483,9 +483,9 @@ void tst_QTcpSocket::constructing() QCOMPARE(socket->readLine(), QByteArray()); QCOMPARE(socket->socketDescriptor(), (qintptr)-1); QCOMPARE((int) socket->localPort(), 0); - QVERIFY(socket->localAddress() == QHostAddress()); + QCOMPARE(socket->localAddress(), QHostAddress()); QCOMPARE((int) socket->peerPort(), 0); - QVERIFY(socket->peerAddress() == QHostAddress()); + QCOMPARE(socket->peerAddress(), QHostAddress()); QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError); QCOMPARE(socket->errorString(), QString("Unknown error")); @@ -755,7 +755,7 @@ void tst_QTcpSocket::socketDescriptor() QVERIFY(socket->state() == QAbstractSocket::HostLookupState || socket->state() == QAbstractSocket::ConnectingState); QVERIFY(socket->waitForConnected(10000)); - QVERIFY(socket->state() == QAbstractSocket::ConnectedState); + QCOMPARE(socket->state(), QAbstractSocket::ConnectedState); QVERIFY(socket->socketDescriptor() != -1); delete socket; @@ -936,7 +936,7 @@ void tst_QTcpSocket::nonBlockingIMAP() QFAIL("Timed out"); } - QVERIFY(nonBlockingIMAP_totalWritten == 8); + QCOMPARE(nonBlockingIMAP_totalWritten, 8); enterLoop(30); @@ -961,7 +961,7 @@ void tst_QTcpSocket::nonBlockingIMAP() QFAIL("Timed out"); } - QVERIFY(nonBlockingIMAP_totalWritten == 10); + QCOMPARE(nonBlockingIMAP_totalWritten, 10); // Wait for greeting enterLoop(30); @@ -1086,7 +1086,7 @@ void tst_QTcpSocket::partialRead() QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForConnected(10000)); - QVERIFY(socket->state() == QTcpSocket::ConnectedState); + QCOMPARE(socket->state(), QTcpSocket::ConnectedState); char buf[512]; QByteArray greeting = expectedReplyIMAP(); @@ -1110,7 +1110,7 @@ void tst_QTcpSocket::unget() QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForConnected(10000)); - QVERIFY(socket->state() == QTcpSocket::ConnectedState); + QCOMPARE(socket->state(), QTcpSocket::ConnectedState); char buf[512]; QByteArray greeting = expectedReplyIMAP(); @@ -1168,7 +1168,7 @@ void tst_QTcpSocket::openCloseOpenClose() QCOMPARE(int(socket->openMode()), int(QIODevice::NotOpen)); QVERIFY(socket->isSequential()); QVERIFY(!socket->isOpen()); - QVERIFY(socket->socketType() == QTcpSocket::TcpSocket); + QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket); char c; QCOMPARE(socket->getChar(&c), false); @@ -1177,13 +1177,13 @@ void tst_QTcpSocket::openCloseOpenClose() QCOMPARE(socket->readLine(), QByteArray()); QCOMPARE(socket->socketDescriptor(), (qintptr)-1); QCOMPARE((int) socket->localPort(), 0); - QVERIFY(socket->localAddress() == QHostAddress()); + QCOMPARE(socket->localAddress(), QHostAddress()); QCOMPARE((int) socket->peerPort(), 0); - QVERIFY(socket->peerAddress() == QHostAddress()); + QCOMPARE(socket->peerAddress(), QHostAddress()); QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError); QCOMPARE(socket->errorString(), QString("Unknown error")); - QVERIFY(socket->state() == QTcpSocket::UnconnectedState); + QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForConnected(10000)); @@ -1200,7 +1200,7 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect() for (int i = 0; i < 3; ++i) { QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); - QVERIFY(socket->socketType() == QTcpSocket::TcpSocket); + QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket); socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForReadyRead(10000)); @@ -1260,7 +1260,7 @@ void tst_QTcpSocket::disconnectWhileConnecting() connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); enterLoop(10); QVERIFY2(!timeout(), "Network timeout"); - QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); if (!closeDirectly) { QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite)); socket->close(); @@ -1272,7 +1272,7 @@ void tst_QTcpSocket::disconnectWhileConnecting() QTcpSocket *othersocket = server.nextPendingConnection(); if (othersocket->state() != QAbstractSocket::UnconnectedState) QVERIFY2(othersocket->waitForDisconnected(10000), "Network timeout"); - QVERIFY(othersocket->state() == QAbstractSocket::UnconnectedState); + QCOMPARE(othersocket->state(), QAbstractSocket::UnconnectedState); QCOMPARE(othersocket->readAll(), data); delete socket; @@ -1375,7 +1375,7 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop() } QVERIFY2(socket->waitForDisconnected(10000), "Network timeout"); - QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); if (!closeDirectly) { QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite)); socket->close(); @@ -1414,10 +1414,10 @@ void tst_QTcpSocket::disconnectWhileLookingUp() QFETCH(bool, doClose); if (doClose) { socket->close(); - QVERIFY(socket->openMode() == QIODevice::NotOpen); + QCOMPARE(socket->openMode(), QIODevice::NotOpen); } else { socket->disconnectFromHost(); - QVERIFY(socket->openMode() == QIODevice::ReadWrite); + QCOMPARE(socket->openMode(), QIODevice::ReadWrite); QVERIFY(socket->waitForDisconnected(5000)); } @@ -1428,12 +1428,12 @@ void tst_QTcpSocket::disconnectWhileLookingUp() // recheck if (doClose) { - QVERIFY(socket->openMode() == QIODevice::NotOpen); + QCOMPARE(socket->openMode(), QIODevice::NotOpen); } else { - QVERIFY(socket->openMode() == QIODevice::ReadWrite); + QCOMPARE(socket->openMode(), QIODevice::ReadWrite); } - QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } //---------------------------------------------------------------------------------- @@ -1457,7 +1457,7 @@ void tst_QTcpSocket::downloadBigFile() } QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); - QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); + QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); @@ -1830,7 +1830,6 @@ private slots: } #endif // !QT_NO_NETWORKPROXY private: - int exitCode; QTcpSocket *socket; QByteArray socketData; }; @@ -2686,12 +2685,12 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting() socket->connectToHost(QtNetworkSettings::serverName(), 443); QVERIFY(socket->waitForConnected(5*1000)); - QVERIFY(socket->error() == QAbstractSocket::UnknownSocketError); + QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError); // We connected to the HTTPS port. Wait two seconds to receive data. We will receive // nothing because we would need to start the SSL handshake QVERIFY(!socket->waitForReadyRead(2*1000)); - QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError); + QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError); // Now write some crap to make the server disconnect us. 4 lines are enough. socket->write("a\r\nb\r\nc\r\nd\r\n"); @@ -2701,7 +2700,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting() // should get a better error since the server disconnected us QVERIFY(!socket->waitForReadyRead(2*1000)); // It must NOT be the SocketTimeoutError that had been set before - QVERIFY(socket->error() == QAbstractSocket::RemoteHostClosedError); + QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError); } #ifndef QT_NO_NETWORKPROXY @@ -2895,25 +2894,25 @@ void tst_QTcpSocket::qtbug14268_peek() QTcpSocket *outgoing = socketPair.endPoints[0]; QTcpSocket *incoming = socketPair.endPoints[1]; - QVERIFY(incoming->state() == QTcpSocket::ConnectedState); - QVERIFY(outgoing->state() == QTcpSocket::ConnectedState); + QCOMPARE(incoming->state(), QTcpSocket::ConnectedState); + QCOMPARE(outgoing->state(), QTcpSocket::ConnectedState); outgoing->write("abc\n"); QVERIFY(outgoing->waitForBytesWritten(2000)); QVERIFY(incoming->waitForReadyRead(2000)); - QVERIFY(incoming->peek(128*1024) == QByteArray("abc\n")); + QCOMPARE(incoming->peek(128*1024), QByteArray("abc\n")); outgoing->write("def\n"); QVERIFY(outgoing->waitForBytesWritten(2000)); QVERIFY(incoming->waitForReadyRead(2000)); - QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\n")); + QCOMPARE(incoming->peek(128*1024), QByteArray("abc\ndef\n")); outgoing->write("ghi\n"); QVERIFY(outgoing->waitForBytesWritten(2000)); QVERIFY(incoming->waitForReadyRead(2000)); - QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\nghi\n")); + QCOMPARE(incoming->peek(128*1024), QByteArray("abc\ndef\nghi\n")); - QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n")); + QCOMPARE(incoming->read(128*1024), QByteArray("abc\ndef\nghi\n")); } void tst_QTcpSocket::setSocketOption() @@ -2927,8 +2926,8 @@ void tst_QTcpSocket::setSocketOption() QTcpSocket *outgoing = socketPair.endPoints[0]; QTcpSocket *incoming = socketPair.endPoints[1]; - QVERIFY(incoming->state() == QTcpSocket::ConnectedState); - QVERIFY(outgoing->state() == QTcpSocket::ConnectedState); + QCOMPARE(incoming->state(), QTcpSocket::ConnectedState); + QCOMPARE(outgoing->state(), QTcpSocket::ConnectedState); outgoing->setSocketOption(QAbstractSocket::LowDelayOption, true); QVariant v = outgoing->socketOption(QAbstractSocket::LowDelayOption); @@ -2984,5 +2983,50 @@ void tst_QTcpSocket::clientSendDataOnDelayedDisconnect() delete socket; } +// Test buffered socket being properly closed on remote disconnect +void tst_QTcpSocket::serverDisconnectWithBuffered() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState"); + + QTcpServer tcpServer; + QTcpSocket *socket = newSocket(); + + QVERIFY(tcpServer.listen(QHostAddress::LocalHost)); + socket->connectToHost(tcpServer.serverAddress(), tcpServer.serverPort()); + // Accept connection on server side + QVERIFY(tcpServer.waitForNewConnection(5000)); + QTcpSocket *newConnection = tcpServer.nextPendingConnection(); + // Send one char and drop link + QVERIFY(newConnection != NULL); + QVERIFY(newConnection->putChar(0)); + QVERIFY(newConnection->flush()); + delete newConnection; + + QVERIFY(socket->waitForConnected(5000)); // ready for write + QCOMPARE(socket->state(), QAbstractSocket::ConnectedState); + + QSignalSpy spyStateChanged(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState))); + QSignalSpy spyDisconnected(socket, SIGNAL(disconnected())); + + QVERIFY(socket->waitForReadyRead(5000)); // have one char already in internal buffer + char buf[128]; + QCOMPARE(socket->read(buf, sizeof(buf)), Q_INT64_C(1)); + if (socket->state() != QAbstractSocket::UnconnectedState) { + QVERIFY(socket->waitForDisconnected(5000)); + QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); + } + // Test signal emitting + QCOMPARE(spyDisconnected.count(), 1); + QVERIFY(spyStateChanged.count() > 0); + QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first()) + == QAbstractSocket::UnconnectedState); + + delete socket; +} + QTEST_MAIN(tst_QTcpSocket) #include "tst_qtcpsocket.moc" diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index b6129bec08..2331bc19aa 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -223,7 +223,7 @@ void tst_QUdpSocket::constructing() QVERIFY(socket.isSequential()); QVERIFY(!socket.isOpen()); - QVERIFY(socket.socketType() == QUdpSocket::UdpSocket); + QCOMPARE(socket.socketType(), QUdpSocket::UdpSocket); QCOMPARE((int) socket.bytesAvailable(), 0); QCOMPARE(socket.canReadLine(), false); QCOMPARE(socket.readLine(), QByteArray()); @@ -749,7 +749,7 @@ void tst_QUdpSocket::writeDatagram() QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError); break; } - QVERIFY(bytesspy.count() == 1); + QCOMPARE(bytesspy.count(), 1); QCOMPARE(*static_cast<const qint64 *>(bytesspy.at(0).at(0).constData()), qint64(i * 1024)); QCOMPARE(errorspy.count(), 0); diff --git a/tests/auto/network/ssl/qsslcertificate/BLACKLIST b/tests/auto/network/ssl/qsslcertificate/BLACKLIST new file mode 100644 index 0000000000..2e376fa2a9 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/BLACKLIST @@ -0,0 +1,3 @@ +# OpenSSL version is too new. Rich will fix :) +[subjectAndIssuerAttributes] +osx diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 748c240f3d..4c288fffaf 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -775,7 +775,7 @@ void tst_QSslCertificate::certInfo() QVERIFY(cert.expiryDate() < QDateTime::currentDateTime()); // cert has expired QSslCertificate copy = cert; - QVERIFY(cert == copy); + QCOMPARE(cert, copy); QVERIFY(!(cert != copy)); QCOMPARE(cert, QSslCertificate(pem, QSsl::Pem)); @@ -833,6 +833,9 @@ void tst_QSslCertificate::task256066toPem() void tst_QSslCertificate::nulInCN() { +#ifdef QT_SECURETRANSPORT + QSKIP("Generic QSslCertificatePrivate fails this test"); +#endif QList<QSslCertificate> certList = QSslCertificate::fromPath(testDataDir + "/more-certificates/badguy-nul-cn.crt"); QCOMPARE(certList.size(), 1); @@ -849,6 +852,9 @@ void tst_QSslCertificate::nulInCN() void tst_QSslCertificate::nulInSan() { +#ifdef QT_SECURETRANSPORT + QSKIP("Generic QSslCertificatePrivate fails this test"); +#endif QList<QSslCertificate> certList = QSslCertificate::fromPath(testDataDir + "/more-certificates/badguy-nul-san.crt"); QCOMPARE(certList.size(), 1); @@ -976,6 +982,9 @@ void tst_QSslCertificate::subjectAndIssuerAttributes() void tst_QSslCertificate::verify() { +#ifdef QT_SECURETRANSPORT + QSKIP("Not implemented in SecureTransport"); +#endif QList<QSslError> errors; QList<QSslCertificate> toVerify; @@ -1069,7 +1078,7 @@ void tst_QSslCertificate::extensions() QSslCertificate cert = certList[0]; QList<QSslCertificateExtension> extensions = cert.extensions(); - QVERIFY(extensions.count() == 9); + QCOMPARE(extensions.count(), 9); int unknown_idx = -1; int authority_info_idx = -1; @@ -1101,8 +1110,8 @@ void tst_QSslCertificate::extensions() // Unknown QSslCertificateExtension unknown = extensions[unknown_idx]; - QVERIFY(unknown.oid() == QStringLiteral("1.3.6.1.5.5.7.1.12")); - QVERIFY(unknown.name() == QStringLiteral("1.3.6.1.5.5.7.1.12")); + QCOMPARE(unknown.oid(), QStringLiteral("1.3.6.1.5.5.7.1.12")); + QCOMPARE(unknown.name(), QStringLiteral("1.3.6.1.5.5.7.1.12")); QVERIFY(!unknown.isCritical()); QVERIFY(!unknown.isSupported()); @@ -1114,8 +1123,8 @@ void tst_QSslCertificate::extensions() // Authority Info Access QSslCertificateExtension aia = extensions[authority_info_idx]; - QVERIFY(aia.oid() == QStringLiteral("1.3.6.1.5.5.7.1.1")); - QVERIFY(aia.name() == QStringLiteral("authorityInfoAccess")); + QCOMPARE(aia.oid(), QStringLiteral("1.3.6.1.5.5.7.1.1")); + QCOMPARE(aia.name(), QStringLiteral("authorityInfoAccess")); QVERIFY(!aia.isCritical()); QVERIFY(aia.isSupported()); @@ -1124,32 +1133,32 @@ void tst_QSslCertificate::extensions() QString ocsp = aiaValue[QStringLiteral("OCSP")].toString(); QString caIssuers = aiaValue[QStringLiteral("caIssuers")].toString(); - QVERIFY(ocsp == QStringLiteral("http://EVIntl-ocsp.verisign.com")); - QVERIFY(caIssuers == QStringLiteral("http://EVIntl-aia.verisign.com/EVIntl2006.cer")); + QCOMPARE(ocsp, QStringLiteral("http://EVIntl-ocsp.verisign.com")); + QCOMPARE(caIssuers, QStringLiteral("http://EVIntl-aia.verisign.com/EVIntl2006.cer")); // Basic constraints QSslCertificateExtension basic = extensions[basic_constraints_idx]; - QVERIFY(basic.oid() == QStringLiteral("2.5.29.19")); - QVERIFY(basic.name() == QStringLiteral("basicConstraints")); + QCOMPARE(basic.oid(), QStringLiteral("2.5.29.19")); + QCOMPARE(basic.name(), QStringLiteral("basicConstraints")); QVERIFY(!basic.isCritical()); QVERIFY(basic.isSupported()); QVariantMap basicValue = basic.value().toMap(); QCOMPARE(basicValue.keys(), QList<QString>() << QStringLiteral("ca")); - QVERIFY(basicValue[QStringLiteral("ca")].toBool() == false); + QVERIFY(!basicValue[QStringLiteral("ca")].toBool()); // Subject key identifier QSslCertificateExtension subjectKey = extensions[subject_key_idx]; - QVERIFY(subjectKey.oid() == QStringLiteral("2.5.29.14")); - QVERIFY(subjectKey.name() == QStringLiteral("subjectKeyIdentifier")); + QCOMPARE(subjectKey.oid(), QStringLiteral("2.5.29.14")); + QCOMPARE(subjectKey.name(), QStringLiteral("subjectKeyIdentifier")); QVERIFY(!subjectKey.isCritical()); QVERIFY(subjectKey.isSupported()); - QVERIFY(subjectKey.value().toString() == QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0")); + QCOMPARE(subjectKey.value().toString(), QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0")); // Authority key identifier QSslCertificateExtension authKey = extensions[auth_key_idx]; - QVERIFY(authKey.oid() == QStringLiteral("2.5.29.35")); - QVERIFY(authKey.name() == QStringLiteral("authorityKeyIdentifier")); + QCOMPARE(authKey.oid(), QStringLiteral("2.5.29.35")); + QCOMPARE(authKey.name(), QStringLiteral("authorityKeyIdentifier")); QVERIFY(!authKey.isCritical()); QVERIFY(authKey.isSupported()); @@ -1167,7 +1176,7 @@ void tst_QSslCertificate::extensionsCritical() QSslCertificate cert = certList[0]; QList<QSslCertificateExtension> extensions = cert.extensions(); - QVERIFY(extensions.count() == 9); + QCOMPARE(extensions.count(), 9); int basic_constraints_idx = -1; int key_usage_idx = -1; @@ -1186,19 +1195,19 @@ void tst_QSslCertificate::extensionsCritical() // Basic constraints QSslCertificateExtension basic = extensions[basic_constraints_idx]; - QVERIFY(basic.oid() == QStringLiteral("2.5.29.19")); - QVERIFY(basic.name() == QStringLiteral("basicConstraints")); + QCOMPARE(basic.oid(), QStringLiteral("2.5.29.19")); + QCOMPARE(basic.name(), QStringLiteral("basicConstraints")); QVERIFY(basic.isCritical()); QVERIFY(basic.isSupported()); QVariantMap basicValue = basic.value().toMap(); QCOMPARE(basicValue.keys(), QList<QString>() << QStringLiteral("ca")); - QVERIFY(basicValue[QStringLiteral("ca")].toBool() == false); + QVERIFY(!basicValue[QStringLiteral("ca")].toBool()); // Key Usage QSslCertificateExtension keyUsage = extensions[key_usage_idx]; - QVERIFY(keyUsage.oid() == QStringLiteral("2.5.29.15")); - QVERIFY(keyUsage.name() == QStringLiteral("keyUsage")); + QCOMPARE(keyUsage.oid(), QStringLiteral("2.5.29.15")); + QCOMPARE(keyUsage.name(), QStringLiteral("keyUsage")); QVERIFY(keyUsage.isCritical()); QVERIFY(!keyUsage.isSupported()); } @@ -1257,21 +1266,21 @@ void tst_QSslCertificate::threadSafeConstMethods() 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); + QCOMPARE(t1.cert, t2.cert); + QCOMPARE(t1.effectiveDate, t2.effectiveDate); + QCOMPARE(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); + QCOMPARE(t1.isBlacklisted, t2.isBlacklisted); + QCOMPARE(t1.issuerInfo, t2.issuerInfo); + QCOMPARE(t1.issuerInfoAttributes, t2.issuerInfoAttributes); + QCOMPARE(t1.publicKey, t2.publicKey); + QCOMPARE(t1.serialNumber, t2.serialNumber); + QCOMPARE(t1.subjectInfo, t2.subjectInfo); + QCOMPARE(t1.subjectInfoAttributes, t2.subjectInfoAttributes); + QCOMPARE(t1.toDer, t2.toDer); + QCOMPARE(t1.toPem, t2.toPem); + QCOMPARE(t1.toText, t2.toText); + QCOMPARE(t1.version, t2.version); } diff --git a/tests/auto/network/ssl/qsslkey/BLACKLIST b/tests/auto/network/ssl/qsslkey/BLACKLIST new file mode 100644 index 0000000000..a08e1f35eb --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/BLACKLIST @@ -0,0 +1 @@ +linux diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index d570037015..a7957d3288 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -39,7 +39,7 @@ #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qnetworkproxy.h> -#if !defined(QT_NO_SSL) && defined(QT_NO_OPENSSL) && defined(QT_BUILD_INTERNAL) +#if !defined(QT_NO_SSL) && defined(QT_BUILD_INTERNAL) #include "private/qsslkey_p.h" #define TEST_CRYPTO #endif diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 17b606e2be..4146a352e9 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -1,2 +1,3 @@ +windows [waitForConnectedEncryptedReadyRead:WithSocks5ProxyAuth] * diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index b95b72a41e..c7d655af3d 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -170,6 +170,9 @@ private slots: void protocol(); void protocolServerSide_data(); void protocolServerSide(); +#ifndef QT_NO_OPENSSL + void serverCipherPreferences(); +#endif // QT_NO_OPENSSL void setCaCertificates(); void setLocalCertificate(); void localCertificateChain(); @@ -817,7 +820,7 @@ void tst_QSslSocket::peerCertificateChain() this->socket = socket.data(); QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); - QVERIFY(caCertificates.count() == 1); + QCOMPARE(caCertificates.count(), 1); socket->addCaCertificates(caCertificates); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)), @@ -863,7 +866,7 @@ void tst_QSslSocket::peerCertificateChain() QSKIP("Skipping flaky test - See QTBUG-29941"); QCOMPARE(socket->peerCertificateChain().first(), socket->peerCertificate()); - QVERIFY(socket->peerCertificateChain() == certChain); + QCOMPARE(socket->peerCertificateChain(), certChain); socket->disconnectFromHost(); QVERIFY(socket->waitForDisconnected()); @@ -1063,6 +1066,7 @@ public: const QString &certFile = SRCDIR "certs/fluke.cert", const QString &interFile = QString()) : socket(0), + config(QSslConfiguration::defaultConfiguration()), ignoreSslErrors(true), peerVerifyMode(QSslSocket::AutoVerifyPeer), protocol(QSsl::TlsV1_0), @@ -1071,6 +1075,7 @@ public: m_interFile(interFile) { } QSslSocket *socket; + QSslConfiguration config; QString addCaCertificates; bool ignoreSslErrors; QSslSocket::PeerVerifyMode peerVerifyMode; @@ -1084,6 +1089,7 @@ protected: void incomingConnection(qintptr socketDescriptor) { socket = new QSslSocket(this); + socket->setSslConfiguration(config); socket->setPeerVerifyMode(peerVerifyMode); socket->setProtocol(protocol); if (ignoreSslErrors) @@ -1254,6 +1260,78 @@ void tst_QSslSocket::protocolServerSide() QCOMPARE(client->isEncrypted(), works); } +#ifndef QT_NO_OPENSSL + +void tst_QSslSocket::serverCipherPreferences() +{ + if (!QSslSocket::supportsSsl()) { + qWarning("SSL not supported, skipping test"); + return; + } + + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + // First using the default (server preference) + { + SslServer server; + server.ciphers = QString("AES128-SHA:AES256-SHA"); + QVERIFY(server.listen()); + + QEventLoop loop; + QTimer::singleShot(5000, &loop, SLOT(quit())); + + QSslSocketPtr client(new QSslSocket); + socket = client.data(); + socket->setCiphers("AES256-SHA:AES128-SHA"); + + // upon SSL wrong version error, error will be triggered, not sslErrors + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); + + client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + + loop.exec(); + + QVERIFY(client->isEncrypted()); + QCOMPARE(client->sessionCipher().name(), QString("AES128-SHA")); + } + + { + // Now using the client preferences + SslServer server; + QSslConfiguration config = QSslConfiguration::defaultConfiguration(); + config.setSslOption(QSsl::SslOptionDisableServerCipherPreference, true); + server.config = config; + server.ciphers = QString("AES128-SHA:AES256-SHA"); + QVERIFY(server.listen()); + + QEventLoop loop; + QTimer::singleShot(5000, &loop, SLOT(quit())); + + QSslSocketPtr client(new QSslSocket); + socket = client.data(); + socket->setCiphers("AES256-SHA:AES128-SHA"); + + // upon SSL wrong version error, error will be triggered, not sslErrors + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit())); + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot())); + connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit())); + + client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); + + loop.exec(); + + QVERIFY(client->isEncrypted()); + QCOMPARE(client->sessionCipher().name(), QString("AES256-SHA")); + } +} + +#endif // QT_NO_OPENSSL + + void tst_QSslSocket::setCaCertificates() { if (!QSslSocket::supportsSsl()) @@ -1655,7 +1733,7 @@ void tst_QSslSocket::spontaneousWrite() QSslSocket *sender = server.socket; QVERIFY(sender); - QVERIFY(sender->state() == QAbstractSocket::ConnectedState); + QCOMPARE(sender->state(), QAbstractSocket::ConnectedState); receiver->setObjectName("receiver"); sender->setObjectName("sender"); receiver->ignoreSslErrors(); @@ -1700,7 +1778,7 @@ void tst_QSslSocket::setReadBufferSize() QSslSocket *sender = server.socket; QVERIFY(sender); - QVERIFY(sender->state() == QAbstractSocket::ConnectedState); + QCOMPARE(sender->state(), QAbstractSocket::ConnectedState); receiver->setObjectName("receiver"); sender->setObjectName("sender"); receiver->ignoreSslErrors(); @@ -2254,7 +2332,7 @@ void tst_QSslSocket::readFromClosedSocket() socket->close(); QVERIFY(!socket->bytesAvailable()); QVERIFY(!socket->bytesToWrite()); - QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); + QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } void tst_QSslSocket::writeBigChunk() @@ -2281,7 +2359,7 @@ void tst_QSslSocket::writeBigChunk() QString errorBefore = socket->errorString(); int ret = socket->write(data.constData(), data.size()); - QVERIFY(data.size() == ret); + QCOMPARE(data.size(), ret); // spin the event loop once so QSslSocket::transmit() gets called QCoreApplication::processEvents(); @@ -2298,7 +2376,7 @@ void tst_QSslSocket::writeBigChunk() QByteArray("unexpected error: ").append(qPrintable(errorAfter))); // check that everything has been written to OpenSSL - QVERIFY(socket->bytesToWrite() == 0); + QCOMPARE(socket->bytesToWrite(), 0); socket->close(); } @@ -2322,7 +2400,7 @@ void tst_QSslSocket::blacklistedCertificates() QSslSocket *sender = server.socket; QVERIFY(sender); - QVERIFY(sender->state() == QAbstractSocket::ConnectedState); + QCOMPARE(sender->state(), QAbstractSocket::ConnectedState); receiver->setObjectName("receiver"); sender->setObjectName("sender"); receiver->startClientEncryption(); @@ -2354,28 +2432,28 @@ void tst_QSslSocket::sslOptions() #ifdef SSL_OP_NO_COMPRESSION QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSslConfigurationPrivate::defaultSslOptions), - long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION)); + long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION|SSL_OP_CIPHER_SERVER_PREFERENCE)); #else QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSslConfigurationPrivate::defaultSslOptions), - long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3)); + long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_CIPHER_SERVER_PREFERENCE)); #endif QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableEmptyFragments |QSsl::SslOptionDisableLegacyRenegotiation), - long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3)); + long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_CIPHER_SERVER_PREFERENCE)); #ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableEmptyFragments), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION|SSL_OP_CIPHER_SERVER_PREFERENCE))); #endif #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableLegacyRenegotiation), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_CIPHER_SERVER_PREFERENCE) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); #endif #ifdef SSL_OP_NO_TICKET @@ -2383,7 +2461,7 @@ void tst_QSslSocket::sslOptions() QSsl::SslOptionDisableEmptyFragments |QSsl::SslOptionDisableLegacyRenegotiation |QSsl::SslOptionDisableSessionTickets), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET))); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_CIPHER_SERVER_PREFERENCE))); #endif #ifdef SSL_OP_NO_TICKET @@ -2393,7 +2471,7 @@ void tst_QSslSocket::sslOptions() |QSsl::SslOptionDisableLegacyRenegotiation |QSsl::SslOptionDisableSessionTickets |QSsl::SslOptionDisableCompression), - long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION))); + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION|SSL_OP_CIPHER_SERVER_PREFERENCE))); #endif #endif } @@ -2648,9 +2726,9 @@ void tst_QSslSocket::qtbug18498_peek2() while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000) QTest::qWait(100); char c; - QVERIFY(client->peek(&c,1) == 1); + QCOMPARE(client->peek(&c,1), 1); QCOMPARE(c, 'H'); - QVERIFY(client->read(&c,1) == 1); + QCOMPARE(client->read(&c,1), 1); QCOMPARE(c, 'H'); QByteArray b = client->peek(2); QCOMPARE(b, QByteArray("EL")); @@ -2686,7 +2764,7 @@ void tst_QSslSocket::qtbug18498_peek2() // ### Qt5 use QTRY_VERIFY while (server->bytesAvailable() < 10 && stopwatch.elapsed() < 5000) QTest::qWait(100); - QVERIFY(server->peek(&c,1) == 1); + QCOMPARE(server->peek(&c,1), 1); QCOMPARE(c, 'S'); b = server->peek(3); QCOMPARE(b, QByteArray("STA")); @@ -2722,9 +2800,9 @@ void tst_QSslSocket::qtbug18498_peek2() while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000) QTest::qWait(100); QVERIFY(server->mode() == QSslSocket::SslServerMode && client->mode() == QSslSocket::SslClientMode); - QVERIFY(client->peek(&c,1) == 1); + QCOMPARE(client->peek(&c,1), 1); QCOMPARE(c, 'h'); - QVERIFY(client->read(&c,1) == 1); + QCOMPARE(client->read(&c,1), 1); QCOMPARE(c, 'h'); b = client->peek(2); QCOMPARE(b, QByteArray("el")); @@ -2734,7 +2812,7 @@ void tst_QSslSocket::qtbug18498_peek2() stopwatch.start(); while (server->bytesAvailable() < 9 && stopwatch.elapsed() < 5000) QTest::qWait(100); - QVERIFY(server->peek(&c,1) == 1); + QCOMPARE(server->peek(&c,1), 1); QCOMPARE(c, 'g'); QCOMPARE(server->readAll(), QByteArray("goodbye\r\n")); client->disconnectFromHost(); @@ -2768,7 +2846,7 @@ void tst_QSslSocket::dhServer() client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QVERIFY(client->state() == QAbstractSocket::ConnectedState); + QCOMPARE(client->state(), QAbstractSocket::ConnectedState); } void tst_QSslSocket::ecdhServer() @@ -2798,7 +2876,7 @@ void tst_QSslSocket::ecdhServer() client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort()); loop.exec(); - QVERIFY(client->state() == QAbstractSocket::ConnectedState); + QCOMPARE(client->state(), QAbstractSocket::ConnectedState); } void tst_QSslSocket::verifyClientCertificate_data() diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST new file mode 100644 index 0000000000..c9b628d79b --- /dev/null +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/BLACKLIST @@ -0,0 +1,2 @@ +[onDemandRootCertLoadingMemberMethods] +linux diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST new file mode 100644 index 0000000000..52bd2bc86d --- /dev/null +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/BLACKLIST @@ -0,0 +1,2 @@ +[onDemandRootCertLoadingStaticMethods:WithSocks5ProxyAuth] +windows diff --git a/tests/auto/opengl/qgl/BLACKLIST b/tests/auto/opengl/qgl/BLACKLIST new file mode 100644 index 0000000000..fa7c829b30 --- /dev/null +++ b/tests/auto/opengl/qgl/BLACKLIST @@ -0,0 +1,16 @@ +[glWidgetRendering] +windows +[glFBORendering] +windows +[multipleFBOInterleavedRendering] +windows +[glPBufferRendering] +windows +[replaceClipping] +windows +[clipTest] +windows +[graphicsViewClipping] +windows +[glFBOUseInGLWidget] +windows diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index 9bd82559b7..7970725355 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -459,113 +459,113 @@ void tst_QGL::getSetCheck() QGLFormat format1; QGLFormat format2; - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setDoubleBuffer(false); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setDoubleBuffer(false); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setDepthBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setDepthBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setAccumBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setAccumBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setRedBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setRedBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setGreenBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setGreenBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setBlueBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setBlueBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setAlphaBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setAlphaBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setStencilBufferSize(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setStencilBufferSize(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setSamples(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setSamples(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setSwapInterval(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setSwapInterval(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setPlane(8); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setPlane(8); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setVersion(3, 2); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setVersion(3, 2); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setProfile(QGLFormat::CoreProfile); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setProfile(QGLFormat::CoreProfile); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); format1.setOption(QGL::NoDeprecatedFunctions); QVERIFY(!(format1 == format2)); QVERIFY(format1 != format2); format2.setOption(QGL::NoDeprecatedFunctions); - QVERIFY(format1 == format2); + QCOMPARE(format1, format2); QVERIFY(!(format1 != format2)); // Copy constructor and assignment for QGLFormat. QGLFormat format3(format1); QGLFormat format4; - QVERIFY(format1 == format3); + QCOMPARE(format1, format3); QVERIFY(format1 != format4); format4 = format1; - QVERIFY(format1 == format4); + QCOMPARE(format1, format4); // Check that modifying a copy doesn't affect the original. format3.setRedBufferSize(16); @@ -584,15 +584,15 @@ void tst_QGL::getSetCheck() QCOMPARE(format5.plane(), 3); // The default format should be the same as QGLFormat(). - QVERIFY(QGLFormat::defaultFormat() == QGLFormat()); + QCOMPARE(QGLFormat::defaultFormat(), QGLFormat()); // Modify the default format and check that it was changed. QGLFormat::setDefaultFormat(format1); - QVERIFY(QGLFormat::defaultFormat() == format1); + QCOMPARE(QGLFormat::defaultFormat(), format1); // Restore the default format. QGLFormat::setDefaultFormat(QGLFormat()); - QVERIFY(QGLFormat::defaultFormat() == QGLFormat()); + QCOMPARE(QGLFormat::defaultFormat(), QGLFormat()); // Check the default overlay format's expected values. QGLFormat overlay(QGLFormat::defaultOverlayFormat()); @@ -618,11 +618,11 @@ void tst_QGL::getSetCheck() // Modify the default overlay format and check that it was changed. QGLFormat::setDefaultOverlayFormat(format1); - QVERIFY(QGLFormat::defaultOverlayFormat() == format1); + QCOMPARE(QGLFormat::defaultOverlayFormat(), format1); // Restore the default overlay format. QGLFormat::setDefaultOverlayFormat(overlay); - QVERIFY(QGLFormat::defaultOverlayFormat() == overlay); + QCOMPARE(QGLFormat::defaultOverlayFormat(), overlay); MyGLContext obj2(obj1); // bool QGLContext::windowCreated() @@ -1512,9 +1512,9 @@ void tst_QGL::colormap() QGLColormap cmap1; QVERIFY(cmap1.isEmpty()); QCOMPARE(cmap1.size(), 0); - QVERIFY(cmap1.entryRgb(0) == 0); - QVERIFY(cmap1.entryRgb(-1) == 0); - QVERIFY(cmap1.entryRgb(100) == 0); + QCOMPARE(cmap1.entryRgb(0), QRgb(0)); + QCOMPARE(cmap1.entryRgb(-1), QRgb(0)); + QCOMPARE(cmap1.entryRgb(100), QRgb(0)); QVERIFY(!cmap1.entryColor(0).isValid()); QVERIFY(!cmap1.entryColor(-1).isValid()); QVERIFY(!cmap1.entryColor(100).isValid()); @@ -1529,7 +1529,7 @@ void tst_QGL::colormap() // not to detect when it is empty! QVERIFY(cmap1.isEmpty()); QCOMPARE(cmap1.size(), 256); - QVERIFY(cmap1.entryRgb(0) == 0); + QCOMPARE(cmap1.entryRgb(0), QRgb(0)); QVERIFY(cmap1.entryColor(0) == QColor(0, 0, 0, 255)); QVERIFY(cmap1.entryRgb(56) == qRgb(255, 0, 0)); QVERIFY(cmap1.entryColor(56) == QColor(255, 0, 0, 255)); @@ -1611,7 +1611,7 @@ void tst_QGL::colormap() QVERIFY(cmap4.isEmpty()); QCOMPARE(cmap4.size(), 256); cmap4.setHandle(Qt::HANDLE(42)); - QVERIFY(cmap4.handle() == Qt::HANDLE(42)); + QCOMPARE(cmap4.handle(), Qt::HANDLE(42)); QVERIFY(!cmap4.isEmpty()); QCOMPARE(cmap4.size(), 256); } @@ -1629,7 +1629,7 @@ void tst_QGL::fboFormat() // Check the initial conditions. QGLFramebufferObjectFormat format1; QCOMPARE(format1.samples(), 0); - QVERIFY(format1.attachment() == QGLFramebufferObject::NoAttachment); + QCOMPARE(format1.attachment(), QGLFramebufferObject::NoAttachment); QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_2D)); int expectedFormat = #ifdef QT_OPENGL_ES_2 @@ -1645,7 +1645,7 @@ void tst_QGL::fboFormat() format1.setTextureTarget(GL_TEXTURE_3D); format1.setInternalTextureFormat(GL_RGB16); QCOMPARE(format1.samples(), 8); - QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil); + QCOMPARE(format1.attachment(), QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16)); @@ -1653,12 +1653,12 @@ void tst_QGL::fboFormat() QGLFramebufferObjectFormat format2(format1); QGLFramebufferObjectFormat format3; QCOMPARE(format2.samples(), 8); - QVERIFY(format2.attachment() == QGLFramebufferObject::CombinedDepthStencil); + QCOMPARE(format2.attachment(), QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format2.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format2.internalTextureFormat()), int(GL_RGB16)); format3 = format1; QCOMPARE(format3.samples(), 8); - QVERIFY(format3.attachment() == QGLFramebufferObject::CombinedDepthStencil); + QCOMPARE(format3.attachment(), QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format3.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format3.internalTextureFormat()), int(GL_RGB16)); @@ -1666,7 +1666,7 @@ void tst_QGL::fboFormat() format2.setSamples(9); format3.setTextureTarget(GL_TEXTURE_2D); QCOMPARE(format1.samples(), 8); - QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil); + QCOMPARE(format1.attachment(), QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16)); @@ -1674,39 +1674,39 @@ void tst_QGL::fboFormat() QGLFramebufferObjectFormat format1c; QGLFramebufferObjectFormat format2c; - QVERIFY(format1c == format2c); + QCOMPARE(format1c, format2c); QVERIFY(!(format1c != format2c)); format1c.setSamples(8); QVERIFY(!(format1c == format2c)); QVERIFY(format1c != format2c); format2c.setSamples(8); - QVERIFY(format1c == format2c); + QCOMPARE(format1c, format2c); QVERIFY(!(format1c != format2c)); format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); QVERIFY(!(format1c == format2c)); QVERIFY(format1c != format2c); format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - QVERIFY(format1c == format2c); + QCOMPARE(format1c, format2c); QVERIFY(!(format1c != format2c)); format1c.setTextureTarget(GL_TEXTURE_3D); QVERIFY(!(format1c == format2c)); QVERIFY(format1c != format2c); format2c.setTextureTarget(GL_TEXTURE_3D); - QVERIFY(format1c == format2c); + QCOMPARE(format1c, format2c); QVERIFY(!(format1c != format2c)); format1c.setInternalTextureFormat(GL_RGB16); QVERIFY(!(format1c == format2c)); QVERIFY(format1c != format2c); format2c.setInternalTextureFormat(GL_RGB16); - QVERIFY(format1c == format2c); + QCOMPARE(format1c, format2c); QVERIFY(!(format1c != format2c)); QGLFramebufferObjectFormat format3c(format1c); QGLFramebufferObjectFormat format4c; - QVERIFY(format1c == format3c); + QCOMPARE(format1c, format3c); QVERIFY(!(format1c != format3c)); format3c.setInternalTextureFormat( #ifdef QT_OPENGL_ES_2 @@ -1719,7 +1719,7 @@ void tst_QGL::fboFormat() QVERIFY(format1c != format3c); format4c = format1c; - QVERIFY(format1c == format4c); + QCOMPARE(format1c, format4c); QVERIFY(!(format1c != format4c)); format4c.setInternalTextureFormat( #ifdef QT_OPENGL_ES_2 @@ -1947,7 +1947,7 @@ void tst_QGL::destroyFBOAfterContext() delete glw; // The handle should now be zero. - QVERIFY(fbo->handle() == 0); + QVERIFY(!fbo->handle()); QVERIFY(!fbo->isValid()); delete fbo; @@ -1984,14 +1984,14 @@ void tst_QGL::shareRegister() // Create a guard for the first context. QOpenGLSharedResourceGuard guard(glw1->context()->contextHandle()); - QVERIFY(guard.id() == 0); + QCOMPARE(guard.id(), 0); guard.setId(3); - QVERIFY(guard.id() == 3); + QCOMPARE(guard.id(), 3); // Request a tst_QGLResource object for the first context. tst_QGLResource *res1 = qt_shared_test()->value(glw1->context()->contextHandle()); QVERIFY(res1); - QVERIFY(qt_shared_test()->value(glw1->context()->contextHandle()) == res1); + QCOMPARE(qt_shared_test()->value(glw1->context()->contextHandle()), res1); // Create another context that shares with the first. QVERIFY(!glw1->isSharing()); @@ -2005,12 +2005,12 @@ void tst_QGL::shareRegister() QVERIFY(glw1->context() != glw2->context()); // Check that the first context's resource is also on the second. - QVERIFY(qt_shared_test()->value(glw1->context()) == res1); - QVERIFY(qt_shared_test()->value(glw2->context()) == res1); + QCOMPARE(qt_shared_test()->value(glw1->context()), res1); + QCOMPARE(qt_shared_test()->value(glw2->context()), res1); // Guard should still be the same. - QVERIFY(guard.context() == glw1->context()); - QVERIFY(guard.id() == 3); + QCOMPARE(guard.context(), glw1->context()); + QCOMPARE(guard.id(), 3); // Check the sharing relationships. QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context())); @@ -2032,9 +2032,9 @@ void tst_QGL::shareRegister() // Request a resource to the third context. tst_QGLResource *res3 = qt_shared_test()->value(glw3->context()); QVERIFY(res3); - QVERIFY(qt_shared_test()->value(glw1->context()) == res1); - QVERIFY(qt_shared_test()->value(glw2->context()) == res1); - QVERIFY(qt_shared_test()->value(glw3->context()) == res3); + QCOMPARE(qt_shared_test()->value(glw1->context()), res1); + QCOMPARE(qt_shared_test()->value(glw2->context()), res1); + QCOMPARE(qt_shared_test()->value(glw3->context()), res3); // Check the sharing relationships again. QVERIFY(QGLContext::areSharing(glw1->context(), glw1->context())); @@ -2053,8 +2053,8 @@ void tst_QGL::shareRegister() QVERIFY(!QGLContext::areSharing(0, 0)); // Shared guard should still be the same. - QVERIFY(guard.context() == glw1->context()); - QVERIFY(guard.id() == 3); + QCOMPARE(guard.context(), glw1->context()); + QCOMPARE(guard.id(), 3); // Delete the first context. delete glw1; @@ -2064,14 +2064,14 @@ void tst_QGL::shareRegister() // The first context's resource should transfer to the second context. QCOMPARE(tst_QGLResource::deletions, 0); - QVERIFY(qt_shared_test()->value(glw2->context()) == res1); - QVERIFY(qt_shared_test()->value(glw3->context()) == res3); + QCOMPARE(qt_shared_test()->value(glw2->context()), res1); + QCOMPARE(qt_shared_test()->value(glw3->context()), res3); // Shared guard should now be the second context, with the id the same. - QVERIFY(guard.context() == glw2->context()); - QVERIFY(guard.id() == 3); - QVERIFY(guard3.context() == glw3->context()); - QVERIFY(guard3.id() == 5); + QCOMPARE(guard.context(), glw2->context()); + QCOMPARE(guard.id(), 3); + QCOMPARE(guard3.context(), glw3->context()); + QCOMPARE(guard3.id(), 5); // Clean up and check that the resources are properly deleted. delete glw2; @@ -2115,25 +2115,25 @@ void tst_QGL::qglContextDefaultBindTexture() QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); // Make sure the texture IDs returned are valid: - QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE); - QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE); + QCOMPARE(funcs->glIsTexture(boundImageTextureId), GLboolean(GL_TRUE)); + QCOMPARE(funcs->glIsTexture(boundPixmapTextureId), GLboolean(GL_TRUE)); // Make sure the textures are still valid after we delete the image/pixmap: // Also check that although the textures are left intact, the cache entries are removed: delete boundImage; boundImage = 0; - QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE); + QCOMPARE(funcs->glIsTexture(boundImageTextureId), GLboolean(GL_TRUE)); QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1); delete boundPixmap; boundPixmap = 0; - QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE); + QCOMPARE(funcs->glIsTexture(boundPixmapTextureId), GLboolean(GL_TRUE)); QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount); // Finally, make sure QGLContext::deleteTexture deletes the texture IDs: ctx->deleteTexture(boundImageTextureId); ctx->deleteTexture(boundPixmapTextureId); - QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_FALSE); - QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_FALSE); + QCOMPARE(funcs->glIsTexture(boundImageTextureId), GLboolean(GL_FALSE)); + QCOMPARE(funcs->glIsTexture(boundPixmapTextureId), GLboolean(GL_FALSE)); } #endif diff --git a/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp b/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp index b0409d46d0..f96e3514a7 100644 --- a/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp +++ b/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp @@ -86,14 +86,14 @@ void tst_QGLBuffer::testBuffer(QGLBuffer::Type type) // Create the local object, but not the buffer in the server. QGLBuffer buffer(type); - QVERIFY(buffer.usagePattern() == QGLBuffer::StaticDraw); + QCOMPARE(buffer.usagePattern(), QGLBuffer::StaticDraw); buffer.setUsagePattern(QGLBuffer::UsagePattern(usagePattern)); // Check the initial state. - QVERIFY(buffer.type() == type); + QCOMPARE(buffer.type(), type); QVERIFY(!buffer.isCreated()); - QVERIFY(buffer.bufferId() == 0); - QVERIFY(buffer.usagePattern() == QGLBuffer::UsagePattern(usagePattern)); + QCOMPARE(buffer.bufferId(), GLuint(0)); + QCOMPARE(buffer.usagePattern(), QGLBuffer::UsagePattern(usagePattern)); QCOMPARE(buffer.size(), -1); // Should not be able to bind it yet because it isn't created. @@ -253,7 +253,7 @@ void tst_QGLBuffer::bufferSharing() delete w2; // The buffer should now be invalid. - QVERIFY(buffer.bufferId() == 0); + QCOMPARE(buffer.bufferId(), GLuint(0)); QVERIFY(!buffer.isCreated()); } diff --git a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp index 866cd57381..07fdba4664 100644 --- a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp +++ b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp @@ -200,13 +200,13 @@ void tst_QGLFunctions::multitexture() GLint active = 0; funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active); - QVERIFY(active == GL_TEXTURE1); + QCOMPARE(active, GL_TEXTURE1); funcs.glActiveTexture(GL_TEXTURE0); active = 0; funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active); - QVERIFY(active == GL_TEXTURE0); + QCOMPARE(active, GL_TEXTURE0); } // Verify that the glBlendColor() function appears to resolve and work. diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index 8f7dcdb3c5..5ef247483d 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -336,17 +336,17 @@ struct Qxxx {}; void tst_Compiler::detectDataStream() { - QVERIFY(QtTestInternal::DataStreamChecker<int>::HasDataStream == true); - QVERIFY(QtTestInternal::DataStreamChecker<uint>::HasDataStream == true); + QVERIFY(QtTestInternal::DataStreamChecker<int>::HasDataStream); + QVERIFY(QtTestInternal::DataStreamChecker<uint>::HasDataStream); QVERIFY(QtTestInternal::DataStreamChecker<char *>::HasDataStream == true); QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasInDataStream == true); QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasOutDataStream == false); QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasDataStream == false); - QVERIFY(QtTestInternal::DataStreamChecker<double>::HasDataStream == true); + QVERIFY(QtTestInternal::DataStreamChecker<double>::HasDataStream); - QVERIFY(QtTestInternal::DataStreamChecker<QString>::HasDataStream == true); - QVERIFY(QtTestInternal::DataStreamChecker<MyString>::HasDataStream == true); - QVERIFY(QtTestInternal::DataStreamChecker<Qxxx>::HasDataStream == false); + QVERIFY(QtTestInternal::DataStreamChecker<QString>::HasDataStream); + QVERIFY(QtTestInternal::DataStreamChecker<MyString>::HasDataStream); + QVERIFY(!QtTestInternal::DataStreamChecker<Qxxx>::HasDataStream); QVERIFY(QtTestInternal::getSaveOperator<int>() != 0); QVERIFY(QtTestInternal::getSaveOperator<uint>() != 0); @@ -354,7 +354,7 @@ void tst_Compiler::detectDataStream() QVERIFY(QtTestInternal::getSaveOperator<double>() != 0); QVERIFY(QtTestInternal::getSaveOperator<QString>() != 0); QVERIFY(QtTestInternal::getSaveOperator<MyString>() != 0); - QVERIFY(QtTestInternal::getSaveOperator<Qxxx>() == 0); + QVERIFY(!QtTestInternal::getSaveOperator<Qxxx>()); } #else void tst_Compiler::detectDataStream() @@ -637,7 +637,7 @@ void tst_Compiler::cxx11_alignas() QSKIP("Compiler does not support C++11 feature"); #else alignas(double) char c; - QVERIFY(Q_ALIGNOF(c) == Q_ALIGNOF(double)); + QCOMPARE(Q_ALIGNOF(c), Q_ALIGNOF(double)); #endif } diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST new file mode 100644 index 0000000000..4e8745ca78 --- /dev/null +++ b/tests/auto/other/gestures/BLACKLIST @@ -0,0 +1,2 @@ +[customGesture] +opensuse-13.1 diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 43ce6b2d72..2a4f88c627 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -1461,7 +1461,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget QPointer<QGesture> customGestureB; customGestureB = *(b->gestures.begin()); QVERIFY(!customGestureB.isNull()); - QVERIFY(customGestureA.data() == customGestureB.data()); + QCOMPARE(customGestureA.data(), customGestureB.data()); QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType); a->gestures.clear(); diff --git a/tests/auto/other/macgui/tst_macgui.cpp b/tests/auto/other/macgui/tst_macgui.cpp index 56035f4be4..ba6ac536f2 100644 --- a/tests/auto/other/macgui/tst_macgui.cpp +++ b/tests/auto/other/macgui/tst_macgui.cpp @@ -146,7 +146,7 @@ void tst_MacGui::splashScreenModality() connect(wn.getWidget(interface), SIGNAL(clicked()), SLOT(exitLoopSlot())); const int timeout = 4; QTestEventLoop::instance().enterLoop(timeout); - QVERIFY(QTestEventLoop::instance().timeout() == false); + QVERIFY(!QTestEventLoop::instance().timeout()); } class PrimaryWindowDialog : public QDialog @@ -231,7 +231,7 @@ void tst_MacGui::spinBoxArrowButtons() const QRect lessRect = lessInterface->rect(); const QRect lessLocalRect(colorWidget.mapFromGlobal(lessRect.topLeft()), colorWidget.mapFromGlobal(lessRect.bottomRight())); const QRect compareRect = lessLocalRect.adjusted(5, 3, -5, -7); - QVERIFY(noFocus.copy(compareRect) == focus.copy(compareRect)); + QCOMPARE(noFocus.copy(compareRect), focus.copy(compareRect)); } QTEST_MAIN(tst_MacGui) diff --git a/tests/auto/other/macnativeevents/BLACKLIST b/tests/auto/other/macnativeevents/BLACKLIST index 2820457075..4129868022 100644 --- a/tests/auto/other/macnativeevents/BLACKLIST +++ b/tests/auto/other/macnativeevents/BLACKLIST @@ -3,9 +3,22 @@ osx [testMouseEnter] osx-10.9 +osx-10.8 [testChildDialogInFrontOfModalParent] osx [testChildWindowInFrontOfStaysOnTopParentWindow] osx [testModifierCtrlWithDontSwapCtrlAndMeta] osx +[testMouseMoveLocation] +osx +[testMouseLeftDoubleClick] +osx +[stressTestMouseLeftDoubleClick] +osx +[testMouseDragInside] +osx +[testMouseDragOutside] +osx +[testMouseDragToNonClientArea] +osx diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp index 5d24655144..d1c5e4a35e 100644 --- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp @@ -457,8 +457,8 @@ void tst_MacNativeEvents::testModifierCtrl() QWidget w; w.show(); - QVERIFY(kControlUnicode == QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText)[0]); - QVERIFY(kCommandUnicode == QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText)[0]); + QCOMPARE(ushort(kControlUnicode), QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText).at(0).unicode()); + QCOMPARE(ushort(kCommandUnicode), QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText).at(0).unicode()); NativeEventList native; native.append(new QNativeModifierEvent(Qt::ControlModifier)); @@ -490,8 +490,8 @@ void tst_MacNativeEvents::testModifierCtrlWithDontSwapCtrlAndMeta() QWidget w; w.show(); - QVERIFY(kCommandUnicode == QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText)[0]); - QVERIFY(kControlUnicode == QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText)[0]); + QCOMPARE(ushort(kCommandUnicode), QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText).at(0).unicode()); + QCOMPARE(ushort(kControlUnicode), QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText).at(0).unicode()); NativeEventList native; native.append(new QNativeModifierEvent(Qt::ControlModifier)); diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp index 72a4a0ad29..c119fdaa4e 100644 --- a/tests/auto/other/modeltest/modeltest.cpp +++ b/tests/auto/other/modeltest/modeltest.cpp @@ -569,7 +569,7 @@ void ModelTest::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto QVERIFY(topLeft.isValid()); QVERIFY(bottomRight.isValid()); QModelIndex commonParent = bottomRight.parent(); - QVERIFY(topLeft.parent() == commonParent); + QCOMPARE(topLeft.parent(), commonParent); QVERIFY(topLeft.row() <= bottomRight.row()); QVERIFY(topLeft.column() <= bottomRight.column()); int rowCount = model->rowCount(commonParent); diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 5612260cca..7ce385121c 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -34,6 +34,8 @@ #include <QtTest/QtTest> #include <QtNetwork/QtNetwork> #include <QtCore/QDateTime> +#include <QtCore/QTextStream> +#include <QtCore/QStandardPaths> #include <QtCore/private/qiodevice_p.h> #ifndef QT_NO_BEARERMANAGEMENT @@ -460,7 +462,7 @@ void tst_NetworkSelfTest::remotePortsOpen() else QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit()); } - QVERIFY(socket.state() == QAbstractSocket::ConnectedState); + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); } static QList<Chat> ftpChat(const QByteArray &userSuffix = QByteArray()) @@ -960,6 +962,25 @@ void tst_NetworkSelfTest::supportsSsl() #endif } +#ifndef QT_NO_PROCESS +static const QByteArray msgProcessError(const QProcess &process, const char *what) +{ + QString result; + QTextStream(&result) << what << ": \"" << process.program() << ' ' + << process.arguments().join(QLatin1Char(' ')) << "\": " << process.errorString(); + return result.toLocal8Bit(); +} + +static void ensureTermination(QProcess &process) +{ + if (process.state() == QProcess::Running) { + process.terminate(); + if (!process.waitForFinished(300)) + process.kill(); + } +} +#endif // !QT_NO_PROCESS + void tst_NetworkSelfTest::smbServer() { static const char contents[] = "This is 34 bytes. Do not change..."; @@ -977,19 +998,24 @@ void tst_NetworkSelfTest::smbServer() QVERIFY(memcmp(buf, contents, strlen(contents)) == 0); #else #ifndef QT_NO_PROCESS + enum { sambaTimeOutSecs = 5 }; // try to use Samba - QString progname = "smbclient"; - QProcess smbclient; - smbclient.start(progname, QIODevice::ReadOnly); - if (!smbclient.waitForStarted(2000)) + const QString progname = "smbclient"; + const QString binary = QStandardPaths::findExecutable(progname); + if (binary.isEmpty()) QSKIP("Could not find smbclient (from Samba), cannot continue testing"); - if (!smbclient.waitForFinished(2000) || smbclient.exitStatus() != QProcess::NormalExit) - QSKIP("smbclient isn't working, cannot continue testing"); - smbclient.close(); // try listing the server - smbclient.start(progname, QStringList() << "-g" << "-N" << "-L" << QtNetworkSettings::winServerName(), QIODevice::ReadOnly); - QVERIFY(smbclient.waitForFinished(5000)); + const QStringList timeOutArguments = QStringList() + << "--timeout" << QString::number(sambaTimeOutSecs); + QStringList arguments = timeOutArguments; + arguments << "-g" << "-N" << "-L" << QtNetworkSettings::winServerName(); + QProcess smbclient; + smbclient.start(binary, arguments, QIODevice::ReadOnly); + QVERIFY2(smbclient.waitForStarted(), msgProcessError(smbclient, "Unable to start")); + const bool listFinished = smbclient.waitForFinished((1 + sambaTimeOutSecs) * 1000); + ensureTermination(smbclient); + QVERIFY2(listFinished, msgProcessError(smbclient, "Listing servers timed out")); if (smbclient.exitStatus() != QProcess::NormalExit) QSKIP("smbclient crashed"); QVERIFY2(smbclient.exitCode() == 0, "Test server not found"); @@ -1004,9 +1030,13 @@ void tst_NetworkSelfTest::smbServer() QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("PAGER", "/bin/cat"); // just in case smbclient.setProcessEnvironment(env); - smbclient.start(progname, QStringList() << "-N" << "-c" << "more test.pri" - << QString("\\\\%1\\testshare").arg(QtNetworkSettings::winServerName()), QIODevice::ReadOnly); - QVERIFY(smbclient.waitForFinished(5000)); + arguments = timeOutArguments; + arguments << "-N" << "-c" << "more test.pri" + << ("\\\\" + QtNetworkSettings::winServerName() + "\\testshare"); + smbclient.start(binary, arguments, QIODevice::ReadOnly); + const bool fileFinished = smbclient.waitForFinished((1 + sambaTimeOutSecs) * 1000); + ensureTermination(smbclient); + QVERIFY2(fileFinished, msgProcessError(smbclient, "Timed out")); if (smbclient.exitStatus() != QProcess::NormalExit) QSKIP("smbclient crashed"); QVERIFY2(smbclient.exitCode() == 0, "File //qt-test-server/testshare/test.pri not found"); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4f891fcda0..62c2c0a916 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -162,16 +162,6 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, return true; } -static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *childWidget) -{ - if (!parentInterface || !childWidget) - return -1; - QAccessibleInterface *childInterface(QAccessible::queryAccessibleInterface(childWidget)); - if (!childInterface) - return -1; - return parentInterface->indexOfChild(childInterface); -} - #define EXPECT(cond) \ do { \ if (!errorAt && !(cond)) { \ @@ -462,15 +452,15 @@ void tst_QAccessibility::statesStructTest() QVERIFY(s1.modal == 0); QAccessible::State s2; - QVERIFY(s2 == s1); + QCOMPARE(s2, s1); s2.busy = true; QVERIFY(!(s2 == s1)); s1.busy = true; - QVERIFY(s2 == s1); + QCOMPARE(s2, s1); s1 = QAccessible::State(); QVERIFY(!(s2 == s1)); s1 = s2; - QVERIFY(s2 == s1); + QCOMPARE(s2, s1); QVERIFY(s1.busy == 1); } @@ -533,9 +523,9 @@ void tst_QAccessibility::navigateHierarchy() QVERIFY(ifaceW->isValid()); QAccessibleInterface *target = ifaceW->child(14); - QVERIFY(target == 0); + QVERIFY(!target); target = ifaceW->child(-1); - QVERIFY(target == 0); + QVERIFY(!target); target = ifaceW->child(0); QAccessibleInterface *interfaceW1(ifaceW->child(0)); QVERIFY(target); @@ -551,7 +541,7 @@ void tst_QAccessibility::navigateHierarchy() QCOMPARE(target->object(), (QObject*)w3); QAccessibleInterface *child = target->child(1); - QVERIFY(child == 0); + QVERIFY(!child); child = target->child(0); QVERIFY(child != 0); QVERIFY(child->isValid()); @@ -969,7 +959,7 @@ void tst_QAccessibility::mainWindowTest() QWindow window; window.setGeometry(80, 80, 40, 40); window.show(); - QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + QTRY_COMPARE(QGuiApplication::focusWindow(), &window); // We currently don't have an accessible interface for QWindow // the active state is either in the QMainWindow or QQuickView @@ -1313,7 +1303,7 @@ void tst_QAccessibility::tabTest() QCOMPARE(child1->text(QAccessible::Description), QLatin1String("Cool tool tip")); QCOMPARE(child1->text(QAccessible::Help), QLatin1String("I don't know")); - QVERIFY((child1->state().invisible) == false); + QVERIFY(!(child1->state().invisible)); tabBar->hide(); QCoreApplication::processEvents(); @@ -1660,7 +1650,7 @@ void tst_QAccessibility::spinBoxTest() // make sure that the line edit is not there const int numChildren = interface->childCount(); QCOMPARE(numChildren, 0); - QVERIFY(interface->child(0) == Q_NULLPTR); + QVERIFY(!interface->child(0)); QVERIFY(interface->valueInterface()); QCOMPARE(interface->valueInterface()->currentValue().toInt(), 3); @@ -1746,6 +1736,13 @@ static bool fuzzyRectCompare(const QRect &a, const QRect &b) && qAbs(delta.right()) <= MAX_ACCEPTABLE_DELTA && qAbs(delta.bottom()) <= MAX_ACCEPTABLE_DELTA; } +static QByteArray msgRectMismatch(const QRect &a, const QRect &b) +{ + QString result; + QDebug(&result) << a << "!=" << b; + return result.toLocal8Bit(); +} + void tst_QAccessibility::textEditTest() { for (int pass = 0; pass < 2; ++pass) { @@ -1791,16 +1788,24 @@ void tst_QAccessibility::textEditTest() int offset = 10; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual10 = textIface->characterRect(offset); + const QRect expected10 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual10, expected10), msgRectMismatch(actual10, expected10).constData()); offset = 13; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("H")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual13 = textIface->characterRect(offset); + const QRect expected13 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual13, expected13), msgRectMismatch(actual13, expected13).constData()); offset = 21; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("y")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual21 = textIface->characterRect(offset); + const QRect expected21 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual21, expected21), msgRectMismatch(actual21, expected21).constData()); offset = 32; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("I")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual32 = textIface->characterRect(offset); + const QRect expected32 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual32, expected32), msgRectMismatch(actual32, expected32).constData()); QTestAccessibility::clearEvents(); @@ -2481,7 +2486,7 @@ void tst_QAccessibility::groupBoxTest() QCOMPARE(iface->text(QAccessible::Name), QLatin1String("Test QGroupBox")); QCOMPARE(iface->text(QAccessible::Description), QLatin1String("This group box will be used to test accessibility")); QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations = rButtonIface->relations(); - QVERIFY(relations.size() == 1); + QCOMPARE(relations.size(), 1); QPair<QAccessibleInterface*, QAccessible::Relation> relation = relations.first(); QCOMPARE(relation.first->object(), groupBox); QCOMPARE(relation.second, QAccessible::Label); @@ -3526,13 +3531,13 @@ void tst_QAccessibility::dockWidgetTest() QPoint buttonPoint = pb2->mapToGlobal(QPoint(pb2->width()/2, pb2->height()/2)); QAccessibleInterface *childAt = accDock2->childAt(buttonPoint.x(), buttonPoint.y()); QVERIFY(childAt); - QVERIFY(childAt->object() == pb2); + QCOMPARE(childAt->object(), pb2); QWidget *close1 = qobject_cast<QWidget*>(dock1Close->object()); QPoint close1ButtonPoint = close1->mapToGlobal(QPoint(close1->width()/2, close1->height()/2)); QAccessibleInterface *childAt2 = accDock1->childAt(close1ButtonPoint.x(), close1ButtonPoint.y()); QVERIFY(childAt2); - QVERIFY(childAt2->object() == close1); + QCOMPARE(childAt2->object(), close1); // custom title bar widget QDockWidget *dock3 = new QDockWidget(mw); diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp index a9234b7060..1428a63123 100644 --- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp @@ -173,7 +173,7 @@ void tst_QComplexText::bidiCursor_qtbug2795() qreal x2 = line2.cursorToX(0) - line2.cursorToX(str.size()); // The cursor should remain at the same position after a digit is appended - QVERIFY(x1 == x2); + QCOMPARE(x1, x2); } void tst_QComplexText::bidiCursorMovement_data() diff --git a/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp index b161dccb88..acb0d28c6b 100644 --- a/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp +++ b/tests/auto/other/windowsmobile/test/tst_windowsmobile.cpp @@ -132,7 +132,7 @@ void compareScreenshots(const QString &image1, const QString &image2) //screenShot.save("scr2.png", "PNG"); //original.save("orig1.png", "PNG"); - QVERIFY(original == screenShot); + QCOMPARE(original, screenShot); } void takeScreenShot(const QString filename) diff --git a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp index 598abca43b..f3b865ed92 100644 --- a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp +++ b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp @@ -57,7 +57,6 @@ void tst_QPrintDevice::basics() if (defaultId.isEmpty()) { qDebug() << "No default printer found"; } else { - qDebug() << "Default Printer ID :" << defaultId; QVERIFY(ps->availablePrintDeviceIds().contains(defaultId)); } @@ -66,7 +65,9 @@ void tst_QPrintDevice::basics() // Just exercise the api for now as we don't know what is installed foreach (const QString id, ps->availablePrintDeviceIds()) { QPrintDevice printDevice = ps->createPrintDevice(id); - qDebug() << "Created printer" << id; + const char quote = id == defaultId ? '*' : '"'; + qDebug().noquote().nospace() << "\nCreated printer " << quote << id + << quote << ":\n" << printDevice << '\n'; QCOMPARE(printDevice.isValid(), true); printDevice.id(); printDevice.name(); diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index c256d9ba82..318f87467c 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -425,12 +425,12 @@ void tst_QPrinter::outputFormatFromSuffix() if (QPrinterInfo::availablePrinters().size() == 0) QSKIP("No printers available."); QPrinter p; - QVERIFY(p.outputFormat() == QPrinter::NativeFormat); + QCOMPARE(p.outputFormat(), QPrinter::NativeFormat); p.setOutputFileName("test.pdf"); TempFileCleanup tmpFile("test.pdf"); - QVERIFY(p.outputFormat() == QPrinter::PdfFormat); + QCOMPARE(p.outputFormat(), QPrinter::PdfFormat); p.setOutputFileName(QString()); - QVERIFY(p.outputFormat() == QPrinter::NativeFormat); + QCOMPARE(p.outputFormat(), QPrinter::NativeFormat); } void tst_QPrinter::testPageMargins_data() diff --git a/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb b/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb Binary files differindex f388f192ac..f388f192ac 100755..100644 --- a/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb +++ b/tests/auto/sql/kernel/qsqldatabase/testdata/qtest.mdb diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index c499aed481..fe8a3689b0 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -261,8 +261,8 @@ public: // addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org" ); // addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3307 ); -// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3308, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 4.1.1 -// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3309, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 5.0.18 Linux +// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3308, "CLIENT_COMPRESS=1" ); // MySQL 4.1.1 +// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.qt-project.org", 3309, "CLIENT_COMPRESS=1" ); // MySQL 5.0.18 Linux // addDb( "QMYSQL3", "testdb", "troll", "trond", "silence.qt-project.org" ); // MySQL 5.1.36 Windows // addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "bq-mysql41.qt-project.org" ); // MySQL 4.1.22-2.el4 linux diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 1993f23672..83cf0394f9 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -1569,11 +1569,11 @@ void tst_QSqlDatabase::ibase_numericFields() QCOMPARE(q.value(2).toString(), QString("%1").arg(num2)); QCOMPARE(QString("%1").arg(q.value(3).toDouble()), QString("%1").arg(num3)); QCOMPARE(QString("%1").arg(q.value(4).toDouble()), QString("%1").arg(num4)); - QVERIFY(q.value(0).type() == QVariant::Int); - QVERIFY(q.value(1).type() == QVariant::Double); - QVERIFY(q.value(2).type() == QVariant::Double); - QVERIFY(q.value(3).type() == QVariant::Double); - QVERIFY(q.value(4).type() == QVariant::Double); + QCOMPARE(q.value(0).type(), QVariant::Int); + QCOMPARE(q.value(1).type(), QVariant::Double); + QCOMPARE(q.value(2).type(), QVariant::Double); + QCOMPARE(q.value(3).type(), QVariant::Double); + QCOMPARE(q.value(4).type(), QVariant::Double); QCOMPARE(q.record().field(1).length(), 2); QCOMPARE(q.record().field(1).precision(), 1); @@ -1583,16 +1583,16 @@ void tst_QSqlDatabase::ibase_numericFields() QCOMPARE(q.record().field(3).precision(), 3); QCOMPARE(q.record().field(4).length(), 18); QCOMPARE(q.record().field(4).precision(), 4); - QVERIFY(q.record().field(0).requiredStatus() == QSqlField::Required); - QVERIFY(q.record().field(1).requiredStatus() == QSqlField::Optional); + QCOMPARE(q.record().field(0).requiredStatus(), QSqlField::Required); + QCOMPARE(q.record().field(1).requiredStatus(), QSqlField::Optional); } QSqlRecord r = db.record(tableName); - QVERIFY(r.field(0).type() == QVariant::Int); - QVERIFY(r.field(1).type() == QVariant::Double); - QVERIFY(r.field(2).type() == QVariant::Double); - QVERIFY(r.field(3).type() == QVariant::Double); - QVERIFY(r.field(4).type() == QVariant::Double); + QCOMPARE(r.field(0).type(), QVariant::Int); + QCOMPARE(r.field(1).type(), QVariant::Double); + QCOMPARE(r.field(2).type(), QVariant::Double); + QCOMPARE(r.field(3).type(), QVariant::Double); + QCOMPARE(r.field(4).type(), QVariant::Double); QCOMPARE(r.field(1).length(), 2); QCOMPARE(r.field(1).precision(), 1); QCOMPARE(r.field(2).length(), 5); @@ -1601,8 +1601,8 @@ void tst_QSqlDatabase::ibase_numericFields() QCOMPARE(r.field(3).precision(), 3); QCOMPARE(r.field(4).length(), 18); QCOMPARE(r.field(4).precision(), 4); - QVERIFY(r.field(0).requiredStatus() == QSqlField::Required); - QVERIFY(r.field(1).requiredStatus() == QSqlField::Optional); + QCOMPARE(r.field(0).requiredStatus(), QSqlField::Required); + QCOMPARE(r.field(1).requiredStatus(), QSqlField::Optional); } void tst_QSqlDatabase::ibase_fetchBlobs() @@ -2086,7 +2086,7 @@ void tst_QSqlDatabase::eventNotificationIBase() QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toString() == procedureName); + QCOMPARE(arguments.at(0).toString(), procedureName); QVERIFY_SQL(*driver, unsubscribeFromNotification(procedureName)); q.exec(QString("DROP PROCEDURE %1").arg(procedureName)); } diff --git a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp index 7a12f66452..70e09a2b80 100644 --- a/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp +++ b/tests/auto/sql/kernel/qsqlerror/tst_qsqlerror.cpp @@ -160,7 +160,7 @@ void tst_QSqlError::operators() error2.setType(QSqlError::NoError); error3.setType(QSqlError::UnknownError); - QVERIFY(error1 == error2); + QCOMPARE(error1, error2); QVERIFY(error1 != error3); } diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 61586eb841..b98ab68ae9 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -241,6 +241,10 @@ private slots: void aggregateFunctionTypes_data() { generic_data(); } void aggregateFunctionTypes(); + + void integralTypesMysql_data() { generic_data("QMYSQL"); } + void integralTypesMysql(); + private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -3974,5 +3978,65 @@ void tst_QSqlQuery::aggregateFunctionTypes() } } +template<typename T> +void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QString &type, const bool withPreparedStatement, + const T min = std::numeric_limits<T>::min(), const T max = std::numeric_limits<T>::max()) +{ + QSqlQuery q(db); + QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName)); + QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ")")); + + const int steps = 20; + const T increment = max / steps - min / steps; + + // insert some values + QVector<T> values; + values.resize(steps); + T v = min; + if (withPreparedStatement) { + QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (id) VALUES (?)")); + } + for (int i = 0; i < values.size(); ++i) { + if (withPreparedStatement) { + q.bindValue(0, v); + QVERIFY_SQL(q, exec()); + } else { + QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + ")")); + } + values[i] = v; + v += increment; + } + + // ensure we can read them back properly + QVERIFY_SQL(q, exec("SELECT id FROM " + tableName)); + QVector<T> actualValues; + actualValues.reserve(values.size()); + while (q.next()) { + actualValues << q.value(0).value<T>(); + } + QCOMPARE(actualValues, values); +} + +void tst_QSqlQuery::integralTypesMysql() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + for (int i = 0; i < 2; ++i) { + const bool withPreparedStatement = (i == 1); + runIntegralTypesMysqlTest<char>(db, "tinyIntTest", "TINYINT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned char>(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<char>(db, "smallIntTest", "SMALLINT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned char>(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<int>(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1); + runIntegralTypesMysqlTest<unsigned int>(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1); + runIntegralTypesMysqlTest<int>(db, "intTest", "INT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned int>(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<long long>(db, "bigIntTest", "BIGINT", withPreparedStatement); + runIntegralTypesMysqlTest<unsigned long long>(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement); + } +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index 71ec2b6588..3702631275 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -858,7 +858,7 @@ static void testRevert(QSqlRelationalTableModel &model) /* Now revert the newly inserted rows */ model.revertAll(); - QVERIFY(model.rowCount() == initialRowCount); + QCOMPARE(model.rowCount(), initialRowCount); /* Insert rows again */ QVERIFY(model.insertRows(4, 4)); @@ -1026,7 +1026,7 @@ void tst_QSqlRelationalTableModel::invalidData() QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr")); //try to set data in non valid index - QVERIFY(model.setData(model.index(0,10),5) == false); + QVERIFY(!model.setData(model.index(0,10),5)); //same test with LeftJoin mode model.setJoinMode(QSqlRelationalTableModel::LeftJoin); @@ -1037,7 +1037,7 @@ void tst_QSqlRelationalTableModel::invalidData() QCOMPARE(model.data(model.index(0, 2)).toString(), QString("herr")); //try to set data in non valid index - QVERIFY(model.setData(model.index(0,10),5) == false); + QVERIFY(!model.setData(model.index(0,10),5)); } void tst_QSqlRelationalTableModel::relationModel() @@ -1051,20 +1051,20 @@ void tst_QSqlRelationalTableModel::relationModel() model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); - QVERIFY(model.relationModel(0) == NULL); - QVERIFY(model.relationModel(1) == NULL); + QVERIFY(!model.relationModel(0)); + QVERIFY(!model.relationModel(1)); QVERIFY(model.relationModel(2) != NULL); - QVERIFY(model.relationModel(3) == NULL); - QVERIFY(model.relationModel(4) == NULL); + QVERIFY(!model.relationModel(3)); + QVERIFY(!model.relationModel(4)); model.setRelation(3, QSqlRelation(reltest4, "id", "name")); QVERIFY_SQL(model, select()); - QVERIFY(model.relationModel(0) == NULL); - QVERIFY(model.relationModel(1) == NULL); + QVERIFY(!model.relationModel(0)); + QVERIFY(!model.relationModel(1)); QVERIFY(model.relationModel(2) != NULL); QVERIFY(model.relationModel(3) != NULL); - QVERIFY(model.relationModel(4) == NULL); + QVERIFY(!model.relationModel(4)); QSqlTableModel *rel_model = model.relationModel(2); QCOMPARE(rel_model->data(rel_model->index(0,1)).toString(), QString("herr")); @@ -1073,11 +1073,11 @@ void tst_QSqlRelationalTableModel::relationModel() model.setJoinMode(QSqlRelationalTableModel::LeftJoin); QVERIFY_SQL(model, select()); - QVERIFY(model.relationModel(0) == NULL); - QVERIFY(model.relationModel(1) == NULL); + QVERIFY(!model.relationModel(0)); + QVERIFY(!model.relationModel(1)); QVERIFY(model.relationModel(2) != NULL); QVERIFY(model.relationModel(3) != NULL); - QVERIFY(model.relationModel(4) == NULL); + QVERIFY(!model.relationModel(4)); QSqlTableModel *rel_model2 = model.relationModel(2); QCOMPARE(rel_model2->data(rel_model->index(0,1)).toString(), QString("herr")); @@ -1487,13 +1487,13 @@ void tst_QSqlRelationalTableModel::selectAfterUpdate() model.setTable(reltest1); model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); - QVERIFY(model.relationModel(2)->rowCount() == 2); + QCOMPARE(model.relationModel(2)->rowCount(), 2); { QSqlQuery q(db); QVERIFY_SQL(q, exec("insert into " + reltest2 + " values(3, 'mrs')")); model.relationModel(2)->select(); } - QVERIFY(model.relationModel(2)->rowCount() == 3); + QCOMPARE(model.relationModel(2)->rowCount(), 3); QVERIFY(model.setData(model.index(0,2), 3)); QVERIFY(model.submitAll()); QCOMPARE(model.data(model.index(0,2)), QVariant("mrs")); diff --git a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp index 9c351f4657..2ace79973b 100644 --- a/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/sql/models/qsqltablemodel/tst_qsqltablemodel.cpp @@ -533,7 +533,7 @@ void tst_QSqlTableModel::setData() idx = model.index(0, 0); QVERIFY_SQL(model, setData(idx, QVariant(QVariant::Int))); val = model.data(idx); - QVERIFY(val == QVariant(QVariant::Int)); + QCOMPARE(val, QVariant(QVariant::Int)); QVERIFY(val.isNull()); QVERIFY_SQL(model, isDirty(idx)); QVERIFY_SQL(model, submitAll()); @@ -560,13 +560,13 @@ void tst_QSqlTableModel::setData() // initial state idx = model.index(0, 0); QSqlRecord rec = model.record(0); - QVERIFY(rec.value(0) == QVariant(QVariant::Int)); + QCOMPARE(rec.value(0), QVariant(QVariant::Int)); QVERIFY(rec.isNull(0)); QVERIFY(!rec.isGenerated(0)); // unchanged value, but causes column to be included in INSERT QVERIFY_SQL(model, setData(idx, QVariant(QVariant::Int))); rec = model.record(0); - QVERIFY(rec.value(0) == QVariant(QVariant::Int)); + QCOMPARE(rec.value(0), QVariant(QVariant::Int)); QVERIFY(rec.isNull(0)); QVERIFY(rec.isGenerated(0)); QVERIFY_SQL(model, submitAll()); @@ -1136,8 +1136,8 @@ void tst_QSqlTableModel::removeRows() QVERIFY_SQL(model, removeRows(0, 1)); QVERIFY_SQL(model, removeRows(1, 1)); QCOMPARE(beforeDeleteSpy.count(), 2); - QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 0); - QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 1); + QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0); + QCOMPARE(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("")); @@ -1172,11 +1172,11 @@ void tst_QSqlTableModel::removeRows() QCOMPARE(headerDataChangedSpy.at(1).at(1).toInt(), 0); QCOMPARE(headerDataChangedSpy.at(1).at(2).toInt(), 0); QCOMPARE(model.rowCount(), 3); - QVERIFY(beforeDeleteSpy.count() == 0); + QCOMPARE(beforeDeleteSpy.count(), 0); QVERIFY(model.submitAll()); - QVERIFY(beforeDeleteSpy.count() == 2); - QVERIFY(beforeDeleteSpy.at(0).at(0).toInt() == 0); - QVERIFY(beforeDeleteSpy.at(1).at(0).toInt() == 1); + QCOMPARE(beforeDeleteSpy.count(), 2); + QCOMPARE(beforeDeleteSpy.at(0).at(0).toInt(), 0); + QCOMPARE(beforeDeleteSpy.at(1).at(0).toInt(), 1); QCOMPARE(model.rowCount(), 1); QCOMPARE(model.data(model.index(0, 1)).toString(), QString("vohi")); } diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 6b94dfb529..6446fec510 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -124,6 +124,8 @@ class tst_Cmptest: public QObject Q_OBJECT private slots: + void compare_unregistered_enums(); + void compare_registered_enums(); void compare_boolfuncs(); void compare_pointerfuncs(); void compare_tostring(); @@ -138,8 +140,26 @@ private slots: void compareQImages(); void compareQImages_data(); #endif + void verify(); + void verify2(); + void tryVerify(); + void tryVerify2(); }; +enum MyUnregisteredEnum { MyUnregisteredEnumValue1, MyUnregisteredEnumValue2 }; + +void tst_Cmptest::compare_unregistered_enums() +{ + QCOMPARE(MyUnregisteredEnumValue1, MyUnregisteredEnumValue1); + QCOMPARE(MyUnregisteredEnumValue1, MyUnregisteredEnumValue2); +} + +void tst_Cmptest::compare_registered_enums() +{ + QCOMPARE(Qt::ArrowCursor, Qt::ArrowCursor); + QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor); +} + static bool boolfunc() { return true; } static bool boolfunc2() { return true; } @@ -371,7 +391,36 @@ void tst_Cmptest::compareQImages() QCOMPARE(opA, opB); } -#endif +#endif // QT_GUI_LIB + +static int opaqueFunc() +{ + return 42; +} + +void tst_Cmptest::verify() +{ + QVERIFY(opaqueFunc() > 2); + QVERIFY(opaqueFunc() < 2); +} + +void tst_Cmptest::verify2() +{ + QVERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData()); + QVERIFY2(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData()); +} + +void tst_Cmptest::tryVerify() +{ + QTRY_VERIFY(opaqueFunc() > 2); + QTRY_VERIFY_WITH_TIMEOUT(opaqueFunc() < 2, 1); +} + +void tst_Cmptest::tryVerify2() +{ + QTRY_VERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData()); + QTRY_VERIFY2_WITH_TIMEOUT(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData(), 1); +} QTEST_MAIN(tst_Cmptest) #include "tst_cmptest.moc" diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 4a376b5c8b..36929cec6b 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -5,18 +5,32 @@ </Environment> <TestFunction name="initTestCase"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compare_unregistered_enums"> +<Incident type="fail" file="tst_cmptest.cpp" line="154"> + <Description><![CDATA[Compared values are not the same]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compare_registered_enums"> +<Incident type="fail" file="tst_cmptest.cpp" line="160"> + <Description><![CDATA[Compared values are not the same + Actual (Qt::ArrowCursor): ArrowCursor + Expected (Qt::BusyCursor) : BusyCursor]]></Description> +</Incident> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_boolfuncs"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_pointerfuncs"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_tostring"> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[int, string]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(int,123) @@ -25,25 +39,25 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both invalid]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[null hash, invalid]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QVariantHash) Expected (expected): QVariant()]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[string, null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass)]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[both non-null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Expected (expected): QVariant(PhonyClass,<value not representable as string>)]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQStringLists"> <Incident type="pass" file="" line="0"> @@ -52,65 +66,65 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal lists]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[second-last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[prefix]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 2 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[short list second]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 12 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[short list first]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 1 Expected (opB) size: 12]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListInt"> -<Incident type="fail" file="tst_cmptest.cpp" line="320"> +<Incident type="fail" file="tst_cmptest.cpp" line="332"> <Description><![CDATA[Compared lists differ at index 2. Actual (int1): 3 Expected (int2): 4]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListDouble"> -<Incident type="fail" file="tst_cmptest.cpp" line="327"> +<Incident type="fail" file="tst_cmptest.cpp" line="339"> <Description><![CDATA[Compared lists differ at index 0. Actual (double1): 1.5 Expected (double2): 1]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQPixmaps"> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 0 @@ -119,29 +133,29 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QPixmaps differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQImages"> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 0 @@ -150,26 +164,50 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QImages differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[different format]]></DataTag> <Description><![CDATA[Compared QImages differ in format. Actual (opA): 6 Expected (opB): 3]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="verify"> +<Incident type="fail" file="tst_cmptest.cpp" line="404"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="verify2"> +<Incident type="fail" file="tst_cmptest.cpp" line="410"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="tryVerify"> +<Incident type="fail" file="tst_cmptest.cpp" line="416"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="tryVerify2"> +<Incident type="fail" file="tst_cmptest.cpp" line="422"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> +</Incident> + <Duration msecs="0"/> </TestFunction> <TestFunction name="cleanupTestCase"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 9e8c56ed99..70c54704f9 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -1,91 +1,105 @@ ********* Start testing of tst_Cmptest ********* -Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +Config: Using QtTest library PASS : tst_Cmptest::initTestCase() +FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same + Loc: [tst_cmptest.cpp(154)] +FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same + Actual (Qt::ArrowCursor): ArrowCursor + Expected (Qt::BusyCursor) : BusyCursor + Loc: [tst_cmptest.cpp(160)] PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same Actual (actual) : QVariant(int,123) Expected (expected): QVariant(QString,hi) - Loc: [tst_cmptest.cpp(219)] + Loc: [tst_cmptest.cpp(231)] PASS : tst_Cmptest::compare_tostring(both invalid) FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same Actual (actual) : QVariant(QVariantHash) Expected (expected): QVariant() - Loc: [tst_cmptest.cpp(219)] + Loc: [tst_cmptest.cpp(231)] FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same Actual (actual) : QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass) - Loc: [tst_cmptest.cpp(219)] + Loc: [tst_cmptest.cpp(231)] FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Expected (expected): QVariant(PhonyClass,<value not representable as string>) - Loc: [tst_cmptest.cpp(219)] + Loc: [tst_cmptest.cpp(231)] PASS : tst_Cmptest::compareQStringLists(empty lists) PASS : tst_Cmptest::compareQStringLists(equal lists) FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS" - Loc: [tst_cmptest.cpp(313)] + Loc: [tst_cmptest.cpp(325)] FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS" - Loc: [tst_cmptest.cpp(313)] + Loc: [tst_cmptest.cpp(325)] FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared lists have different sizes. Actual (opA) size: 2 Expected (opB) size: 1 - Loc: [tst_cmptest.cpp(313)] + Loc: [tst_cmptest.cpp(325)] FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared lists have different sizes. Actual (opA) size: 12 Expected (opB) size: 1 - Loc: [tst_cmptest.cpp(313)] + Loc: [tst_cmptest.cpp(325)] FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared lists have different sizes. Actual (opA) size: 1 Expected (opB) size: 12 - Loc: [tst_cmptest.cpp(313)] + Loc: [tst_cmptest.cpp(325)] FAIL! : tst_Cmptest::compareQListInt() Compared lists differ at index 2. Actual (int1): 3 Expected (int2): 4 - Loc: [tst_cmptest.cpp(320)] + Loc: [tst_cmptest.cpp(332)] FAIL! : tst_Cmptest::compareQListDouble() Compared lists differ at index 0. Actual (double1): 1.5 Expected (double2): 1 - Loc: [tst_cmptest.cpp(327)] + Loc: [tst_cmptest.cpp(339)] PASS : tst_Cmptest::compareQPixmaps(both null) FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0 - Loc: [tst_cmptest.cpp(353)] + Loc: [tst_cmptest.cpp(365)] FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ. Actual (opA).isNull(): 0 Expected (opB).isNull(): 1 - Loc: [tst_cmptest.cpp(353)] + Loc: [tst_cmptest.cpp(365)] PASS : tst_Cmptest::compareQPixmaps(equal) FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size. Actual (opA): 11x20 Expected (opB): 20x20 - Loc: [tst_cmptest.cpp(353)] + Loc: [tst_cmptest.cpp(365)] FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same - Loc: [tst_cmptest.cpp(353)] + Loc: [tst_cmptest.cpp(365)] PASS : tst_Cmptest::compareQImages(both null) FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0 - Loc: [tst_cmptest.cpp(380)] + Loc: [tst_cmptest.cpp(392)] FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ. Actual (opA).isNull(): 0 Expected (opB).isNull(): 1 - Loc: [tst_cmptest.cpp(380)] + Loc: [tst_cmptest.cpp(392)] PASS : tst_Cmptest::compareQImages(equal) FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size. Actual (opA): 11x20 Expected (opB): 20x20 - Loc: [tst_cmptest.cpp(380)] + Loc: [tst_cmptest.cpp(392)] FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format. Actual (opA): 6 Expected (opB): 3 - Loc: [tst_cmptest.cpp(380)] + Loc: [tst_cmptest.cpp(392)] FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same - Loc: [tst_cmptest.cpp(380)] + Loc: [tst_cmptest.cpp(392)] +FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. () + Loc: [tst_cmptest.cpp(404)] +FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42) + Loc: [tst_cmptest.cpp(410)] +FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. () + Loc: [tst_cmptest.cpp(416)] +FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42) + Loc: [tst_cmptest.cpp(422)] PASS : tst_Cmptest::cleanupTestCase() -Totals: 11 passed, 20 failed, 0 skipped, 0 blacklisted +Totals: 11 passed, 26 failed, 0 skipped, 0 blacklisted ********* Finished testing of tst_Cmptest ********* diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index aefb1b5f4c..9437e8e4b7 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -7,18 +7,32 @@ </Environment> <TestFunction name="initTestCase"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compare_unregistered_enums"> +<Incident type="fail" file="tst_cmptest.cpp" line="154"> + <Description><![CDATA[Compared values are not the same]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compare_registered_enums"> +<Incident type="fail" file="tst_cmptest.cpp" line="160"> + <Description><![CDATA[Compared values are not the same + Actual (Qt::ArrowCursor): ArrowCursor + Expected (Qt::BusyCursor) : BusyCursor]]></Description> +</Incident> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_boolfuncs"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_pointerfuncs"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compare_tostring"> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[int, string]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(int,123) @@ -27,25 +41,25 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both invalid]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[null hash, invalid]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QVariantHash) Expected (expected): QVariant()]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[string, null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass)]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="219"> +<Incident type="fail" file="tst_cmptest.cpp" line="231"> <DataTag><![CDATA[both non-null user type]]></DataTag> <Description><![CDATA[Compared values are not the same Actual (actual) : QVariant(PhonyClass,<value not representable as string>) Expected (expected): QVariant(PhonyClass,<value not representable as string>)]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQStringLists"> <Incident type="pass" file="" line="0"> @@ -54,65 +68,65 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal lists]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[second-last item different]]></DataTag> <Description><![CDATA[Compared lists differ at index 2. Actual (opA): "string3" Expected (opB): "DIFFERS"]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[prefix]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 2 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[short list second]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 12 Expected (opB) size: 1]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="313"> +<Incident type="fail" file="tst_cmptest.cpp" line="325"> <DataTag><![CDATA[short list first]]></DataTag> <Description><![CDATA[Compared lists have different sizes. Actual (opA) size: 1 Expected (opB) size: 12]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListInt"> -<Incident type="fail" file="tst_cmptest.cpp" line="320"> +<Incident type="fail" file="tst_cmptest.cpp" line="332"> <Description><![CDATA[Compared lists differ at index 2. Actual (int1): 3 Expected (int2): 4]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQListDouble"> -<Incident type="fail" file="tst_cmptest.cpp" line="327"> +<Incident type="fail" file="tst_cmptest.cpp" line="339"> <Description><![CDATA[Compared lists differ at index 0. Actual (double1): 1.5 Expected (double2): 1]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQPixmaps"> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QPixmaps differ. Actual (opA).isNull(): 0 @@ -121,29 +135,29 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QPixmaps differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="353"> +<Incident type="fail" file="tst_cmptest.cpp" line="365"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <TestFunction name="compareQImages"> <Incident type="pass" file="" line="0"> <DataTag><![CDATA[both null]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[one null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 1 Expected (opB).isNull(): 0]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[other null]]></DataTag> <Description><![CDATA[Compared QImages differ. Actual (opA).isNull(): 0 @@ -152,27 +166,51 @@ <Incident type="pass" file="" line="0"> <DataTag><![CDATA[equal]]></DataTag> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[different size]]></DataTag> <Description><![CDATA[Compared QImages differ in size. Actual (opA): 11x20 Expected (opB): 20x20]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[different format]]></DataTag> <Description><![CDATA[Compared QImages differ in format. Actual (opA): 6 Expected (opB): 3]]></Description> </Incident> -<Incident type="fail" file="tst_cmptest.cpp" line="380"> +<Incident type="fail" file="tst_cmptest.cpp" line="392"> <DataTag><![CDATA[different pixels]]></DataTag> <Description><![CDATA[Compared values are not the same]]></Description> </Incident> -<Duration msecs="0"/> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="verify"> +<Incident type="fail" file="tst_cmptest.cpp" line="404"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="verify2"> +<Incident type="fail" file="tst_cmptest.cpp" line="410"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="tryVerify"> +<Incident type="fail" file="tst_cmptest.cpp" line="416"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="tryVerify2"> +<Incident type="fail" file="tst_cmptest.cpp" line="422"> + <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> +</Incident> + <Duration msecs="0"/> </TestFunction> <TestFunction name="cleanupTestCase"> <Incident type="pass" file="" line="0" /> -<Duration msecs="0"/> + <Duration msecs="0"/> </TestFunction> <Duration msecs="0"/> </TestCase> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index 7502d3cc54..fa970d4172 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -1,11 +1,19 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="0" failures="20" tests="10" name="tst_Cmptest"> +<testsuite errors="0" failures="26" tests="16" name="tst_Cmptest"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> + <testcase result="fail" name="compare_unregistered_enums"> + <failure message="Compared values are not the same" result="fail"/> + </testcase> + <testcase result="fail" name="compare_registered_enums"> + <failure message="Compared values are not the same + Actual (Qt::ArrowCursor): ArrowCursor + Expected (Qt::BusyCursor) : BusyCursor" result="fail"/> + </testcase> <testcase result="pass" name="compare_boolfuncs"/> <testcase result="pass" name="compare_pointerfuncs"/> <testcase result="fail" name="compare_tostring"> @@ -76,6 +84,18 @@ Expected (opB): 3" result="fail"/> <failure tag="different pixels" message="Compared values are not the same" result="fail"/> </testcase> + <testcase result="fail" name="verify"> + <failure message="'opaqueFunc() < 2' returned FALSE. ()" result="fail"/> + </testcase> + <testcase result="fail" name="verify2"> + <failure message="'opaqueFunc() < 2' returned FALSE. (42)" result="fail"/> + </testcase> + <testcase result="fail" name="tryVerify"> + <failure message="'opaqueFunc() < 2' returned FALSE. ()" result="fail"/> + </testcase> + <testcase result="fail" name="tryVerify2"> + <failure message="'opaqueFunc() < 2' returned FALSE. (42)" result="fail"/> + </testcase> <testcase result="pass" name="cleanupTestCase"/> <system-err/> </testsuite> diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 6536f103ac..9b76bca28c 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -571,7 +571,9 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge #endif QProcess proc; - static const QProcessEnvironment environment = processEnvironment(); + QProcessEnvironment environment = processEnvironment(); + if (crashes) + environment.insert("QTEST_DISABLE_STACK_DUMP", "1"); proc.setProcessEnvironment(environment); const QString path = subdir + QLatin1Char('/') + subdir; proc.start(path, arguments); @@ -626,8 +628,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge QList<QByteArray> res = splitLines(actualOutputs[n]); const QString expectedFileName = expectedFileNameFromTest(subdir, logger); QList<QByteArray> exp = expectedResult(expectedFileName); -#if defined (Q_CC_MSVC) || defined(Q_CC_MINGW) - // MSVC, MinGW format double numbers differently +#if (defined (Q_CC_MSVC) && _MSC_VER < 1900)|| defined(Q_CC_MINGW) + // MSVC up to MSVC2013, MinGW format double numbers differently if (n == 0 && subdir == QStringLiteral("float")) { for (int i = 0; i < exp.size(); ++i) { exp[i].replace("e-07", "e-007"); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 350c6142d2..fa1b68b4f9 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -880,7 +880,7 @@ void tst_Moc::preprocessorConditionals() QVERIFY(mobj->indexOfSignal("signalInIf1()") != -1); QVERIFY(mobj->indexOfSignal("signalInIf2()") != -1); QVERIFY(mobj->indexOfSignal("signalInIf3()") != -1); - QVERIFY(mobj->indexOfSignal("doNotExist()") == -1); + QCOMPARE(mobj->indexOfSignal("doNotExist()"), -1); } void tst_Moc::blackslashNewlines() @@ -888,7 +888,7 @@ void tst_Moc::blackslashNewlines() BackslashNewlines tst; const QMetaObject *mobj = tst.metaObject(); QVERIFY(mobj->indexOfSlot("works()") != -1); - QVERIFY(mobj->indexOfSlot("buggy()") == -1); + QCOMPARE(mobj->indexOfSlot("buggy()"), -1); } void tst_Moc::slotWithSillyConst() @@ -928,8 +928,8 @@ void tst_Moc::testExtraDataForEnum() const QMetaObject * const *objects = mobjUser->d.relatedMetaObjects; QVERIFY(objects); - QVERIFY(objects[0] == mobjSource); - QVERIFY(objects[1] == 0); + QCOMPARE(objects[0], mobjSource); + QVERIFY(!objects[1]); } void tst_Moc::namespaceTypeProperty() @@ -982,7 +982,7 @@ void tst_Moc::namespacedFlags() const QVariant v = bar.property("flags"); QVERIFY(v.isValid()); QVERIFY(baz.setProperty("flags", v)); - QVERIFY(baz.flags() == bar.flags()); + QCOMPARE(baz.flags(), bar.flags()); QList<Foo::Bar::Flags> l; l << baz.flags(); @@ -1104,7 +1104,7 @@ void tst_Moc::winNewline() if (data.at(i) == QLatin1Char('\r')) { QVERIFY(i < data.count() - 1); ++i; - QVERIFY(data.at(i) == '\n'); + QCOMPARE(data.at(i), '\n'); } else { QVERIFY(data.at(i) != '\n'); } @@ -1255,14 +1255,14 @@ void tst_Moc::invokable() { const QMetaObject &mobj = InvokableBeforeReturnType::staticMetaObject; QCOMPARE(mobj.methodCount(), 6); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("foo()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()")); } { const QMetaObject &mobj = InvokableBeforeInline::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("foo()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("bar()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("bar()")); } } @@ -1271,22 +1271,22 @@ void tst_Moc::singleFunctionKeywordSignalAndSlot() { const QMetaObject &mobj = SingleFunctionKeywordBeforeReturnType::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); } { const QMetaObject &mobj = SingleFunctionKeywordBeforeInline::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); } { const QMetaObject &mobj = SingleFunctionKeywordAfterInline::staticMetaObject; QCOMPARE(mobj.methodCount(), 7); - QVERIFY(mobj.method(5).methodSignature() == QByteArray("mySignal()")); - QVERIFY(mobj.method(6).methodSignature() == QByteArray("mySlot()")); + QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); } } @@ -1740,34 +1740,34 @@ template <class T> void tst_Moc::revisions_T() { int idx = T::staticMetaObject.indexOfProperty("prop1"); - QVERIFY(T::staticMetaObject.property(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.property(idx).revision(), 0); idx = T::staticMetaObject.indexOfProperty("prop2"); - QVERIFY(T::staticMetaObject.property(idx).revision() == 2); + QCOMPARE(T::staticMetaObject.property(idx).revision(), 2); idx = T::staticMetaObject.indexOfMethod("method1()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfMethod("method2()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 4); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 4); idx = T::staticMetaObject.indexOfSlot("slot1()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfSlot("slot2()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 3); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 3); idx = T::staticMetaObject.indexOfSlot("slot3()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 6); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 6); idx = T::staticMetaObject.indexOfSlot("slot4()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 6); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 6); idx = T::staticMetaObject.indexOfSignal("signal1()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 0); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 0); idx = T::staticMetaObject.indexOfSignal("signal2()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 5); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 5); idx = T::staticMetaObject.indexOfSignal("signal3()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 7); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 7); idx = T::staticMetaObject.indexOfSignal("signal4()"); - QVERIFY(T::staticMetaObject.method(idx).revision() == 7); + QCOMPARE(T::staticMetaObject.method(idx).revision(), 7); idx = T::staticMetaObject.indexOfEnumerator("TestEnum"); QCOMPARE(T::staticMetaObject.enumerator(idx).keyCount(), 2); @@ -1947,7 +1947,7 @@ public: void tst_Moc::privateClass() { - QVERIFY(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()") == 0); + QCOMPARE(PrivateClass::staticMetaObject.indexOfConstructor("PrivateClass()"), 0); QVERIFY(PrivateClass::staticMetaObject.indexOfSignal("someSignal()") > 0); } @@ -3068,7 +3068,7 @@ void tst_Moc::parseDefines() int index = mo->indexOfSlot("stringMethod()"); QVERIFY(index != -1); - QVERIFY(mo->method(index).returnType() == QMetaType::QString); + QCOMPARE(mo->method(index).returnType(), int(QMetaType::QString)); index = mo->indexOfSlot("combined1()"); QVERIFY(index != -1); @@ -3127,7 +3127,7 @@ void tst_Moc::parseDefines() QVERIFY(!qstrcmp(mci.value(), "TestValue")); } } - QVERIFY(count == 3); + QCOMPARE(count, 3); index = mo->indexOfSlot("PD_DEFINE_ITSELF_SUFFIX(int)"); QVERIFY(index != -1); @@ -3253,7 +3253,7 @@ void tst_Moc::relatedMetaObjectsWithinNamespaces() const QMetaObject *testMo = &QTBUG_2151::B::staticMetaObject; QVERIFY(testMo->d.relatedMetaObjects); - QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo); + QCOMPARE(testMo->d.relatedMetaObjects[0], relatedMo); } void tst_Moc::relatedMetaObjectsInGadget() @@ -3262,7 +3262,7 @@ void tst_Moc::relatedMetaObjectsInGadget() const QMetaObject *testMo = &QTBUG_35657::B::staticMetaObject; QVERIFY(testMo->d.relatedMetaObjects); - QVERIFY(testMo->d.relatedMetaObjects[0] == relatedMo); + QCOMPARE(testMo->d.relatedMetaObjects[0], relatedMo); } void tst_Moc::relatedMetaObjectsNameConflict_data() diff --git a/tests/auto/tools/qmake/qmake.pro b/tests/auto/tools/qmake/qmake.pro index 5ed3073e20..d0817247db 100644 --- a/tests/auto/tools/qmake/qmake.pro +++ b/tests/auto/tools/qmake/qmake.pro @@ -8,5 +8,11 @@ SOURCES += tst_qmake.cpp testcompiler.cpp QT = core testlib cross_compile: DEFINES += QMAKE_CROSS_COMPILED +debug_and_release { + CONFIG(debug, debug|release): \ + DEFINES += DEBUG_BUILD + else: \ + DEFINES += RELEASE_BUILD +} TESTDATA += testdata/* diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp b/tests/auto/tools/qmake/testdata/resources/main.cpp index 2d86b46875..78f9814396 100644 --- a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp +++ b/tests/auto/tools/qmake/testdata/resources/main.cpp @@ -30,17 +30,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QApplication> -#include <stdio.h> -int main(int argc, char *argv[]) + + +#include <qguiapplication.h> + +int main( int argc, char **argv ) { - QApplication app(argc, argv); - if (argc > 1) - fprintf(stderr, "%s", argv[1]); - else - fprintf(stderr, "Failed"); - fflush(stderr); - return 0; + QGuiApplication a( argc, argv ); + return a.exec(); } - diff --git a/tests/auto/tools/qmake/testdata/resources/resources.pro b/tests/auto/tools/qmake/testdata/resources/resources.pro new file mode 100644 index 0000000000..f024fe5617 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/resources.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +SOURCES = main.cpp + +pro_file.files = resources.pro +pro_file.prefix = /prefix + +subdir.files = subdir/file.txt +subdir.base = subdir + +RESOURCES = test.qrc main.cpp pro_file subdir diff --git a/tests/auto/tools/qmake/testdata/resources/subdir/file.txt b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/subdir/file.txt diff --git a/tests/auto/tools/qmake/testdata/resources/test.qrc b/tests/auto/tools/qmake/testdata/resources/test.qrc new file mode 100644 index 0000000000..decde3dd24 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/resources/test.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>test.qrc</file> + </qresource> +</RCC> diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index da5314c83b..ac94d1a2b9 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -39,6 +39,14 @@ #include <QStandardPaths> #include <QDir> +#if defined(DEBUG_BUILD) +# define DIR_INFIX "debug/" +#elif defined(RELEASE_BUILD) +# define DIR_INFIX "release/" +#else +# define DIR_INFIX "" +#endif + class tst_qmake : public QObject { Q_OBJECT @@ -77,6 +85,7 @@ private slots: void substitutes(); void project(); void proFileCache(); + void resources(); private: TestCompiler test_compiler; @@ -490,5 +499,38 @@ void tst_qmake::proFileCache() QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" )); } +void tst_qmake::resources() +{ + QString workDir = base_path + "/testdata/resources"; + QVERIFY(test_compiler.qmake(workDir, "resources")); + + { + QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_pro_file.qrc"); + QVERIFY(qrcFile.exists()); + QVERIFY(qrcFile.open(QFile::ReadOnly)); + QByteArray qrcXml = qrcFile.readAll(); + QVERIFY(qrcXml.contains("alias=\"resources.pro\"")); + QVERIFY(qrcXml.contains("prefix=\"/prefix\"")); + } + + { + QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_subdir.qrc"); + QVERIFY(qrcFile.exists()); + QVERIFY(qrcFile.open(QFile::ReadOnly)); + QByteArray qrcXml = qrcFile.readAll(); + QVERIFY(qrcXml.contains("alias=\"file.txt\"")); + } + + { + QFile qrcFile(workDir + "/.rcc/" DIR_INFIX "qmake_qmake_immediate.qrc"); + QVERIFY(qrcFile.exists()); + QVERIFY(qrcFile.open(QFile::ReadOnly)); + QByteArray qrcXml = qrcFile.readAll(); + QVERIFY(qrcXml.contains("alias=\"main.cpp\"")); + } + + QVERIFY(test_compiler.make(workDir)); +} + QTEST_MAIN(tst_qmake) #include "tst_qmake.moc" diff --git a/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro b/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro index 22f6bab497..c379e67ec5 100644 --- a/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro +++ b/tests/auto/widgets/dialogs/qcolordialog/qcolordialog.pro @@ -4,5 +4,4 @@ TARGET = tst_qcolordialog QT += widgets testlib SOURCES += tst_qcolordialog.cpp - - +linux*: CONFIG += insignificant_test # Crashes on different Linux distros diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp index 59227a6168..c5e31a4bd4 100644 --- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp +++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp @@ -98,7 +98,7 @@ void tst_QColorDialog::testNativeActiveModalWidget() TestNativeDialog d; QTimer::singleShot(1000, &d, SLOT(hide())); d.exec(); - QVERIFY(&d == d.m_activeModalWidget); + QCOMPARE(&d, d.m_activeModalWidget); } void tst_QColorDialog::native_activeModalWidget() diff --git a/tests/auto/widgets/dialogs/qdialog/BLACKLIST b/tests/auto/widgets/dialogs/qdialog/BLACKLIST new file mode 100644 index 0000000000..3da7337784 --- /dev/null +++ b/tests/auto/widgets/dialogs/qdialog/BLACKLIST @@ -0,0 +1,2 @@ +[snapToDefaultButton] +osx diff --git a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro index 3a96827352..2a11a29420 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro +++ b/tests/auto/widgets/dialogs/qfiledialog/qfiledialog.pro @@ -21,3 +21,5 @@ wince* { } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } + +linux*: CONFIG += insignificant_test # Crashes on different Linux distros diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index ffc000a418..cc321bb137 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -677,7 +677,7 @@ void tst_QFiledialog::filters() // effects QList<QComboBox*> views = fd.findChildren<QComboBox*>("fileTypeCombo"); - QVERIFY(views.count() == 1); + QCOMPARE(views.count(), 1); QCOMPARE(views.at(0)->isVisible(), false); QStringList filters; @@ -1296,7 +1296,7 @@ void tst_QFiledialog::clearLineEdit() QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QVERIFY(lineEdit); - QVERIFY(lineEdit->text() == "foo"); + QCOMPARE(lineEdit->text(), QLatin1String("foo")); fd.setDirectory(QDir::home()); QListView* list = fd.findChild<QListView*>("listView"); @@ -1393,12 +1393,12 @@ void tst_QFiledialog::trailingDotsAndSpaces() QTest::keyClick(lineEdit, Qt::Key_Space); QTest::keyClick(lineEdit, Qt::Key_Period); QTest::qWait(1000); - QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex())); + QCOMPARE(currentChildrenCount, list->model()->rowCount(list->rootIndex())); lineEdit->clear(); QTest::keyClick(lineEdit, Qt::Key_Period); QTest::keyClick(lineEdit, Qt::Key_Space); QTest::qWait(1000); - QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex())); + QCOMPARE(currentChildrenCount, list->model()->rowCount(list->rootIndex())); } #ifdef Q_OS_UNIX diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 03f0d25375..0e7f760b4e 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -167,7 +167,7 @@ void tst_QFileSystemModel::cleanup() QVERIFY(dir.rmdir(list.at(i))); } list = dir.entryList(QDir::AllEntries | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot); - QVERIFY(list.count() == 0); + QCOMPARE(list.count(), 0); } } @@ -523,8 +523,14 @@ void tst_QFileSystemModel::rowsInserted() QVERIFY(createFiles(tmp, QStringList(".hidden_file"), 5 + count)); - if (count != 0) QTRY_VERIFY(spy0.count() >= 1); else QTRY_VERIFY(spy0.count() == 0); - if (count != 0) QTRY_VERIFY(spy1.count() >= 1); else QTRY_VERIFY(spy1.count() == 0); + if (count != 0) + QTRY_VERIFY(spy0.count() >= 1); + else + QTRY_COMPARE(spy0.count(), 0); + if (count != 0) + QTRY_VERIFY(spy1.count() >= 1); + else + QTRY_COMPARE(spy1.count(), 0); } void tst_QFileSystemModel::rowsRemoved_data() @@ -563,8 +569,8 @@ void tst_QFileSystemModel::rowsRemoved() } } else { if (i == 10 || spy0.count() == 0) { - QVERIFY(spy0.count() == 0); - QVERIFY(spy1.count() == 0); + QCOMPARE(spy0.count(), 0); + QCOMPARE(spy1.count(), 0); } } QStringList lst; @@ -583,8 +589,8 @@ void tst_QFileSystemModel::rowsRemoved() QVERIFY(QFile::remove(tmp + '/' + QString(".c"))); QTest::qWait(WAITTIME); - if (count != 0) QVERIFY(spy0.count() >= 1); else QVERIFY(spy0.count() == 0); - if (count != 0) QVERIFY(spy1.count() >= 1); else QVERIFY(spy1.count() == 0); + if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0); + if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0); } void tst_QFileSystemModel::dataChanged_data() @@ -614,7 +620,7 @@ void tst_QFileSystemModel::dataChanged() QTest::qWait(WAITTIME); - if (count != 0) QVERIFY(spy.count() >= 1); else QVERIFY(spy.count() == 0); + if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0); */ } diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST new file mode 100644 index 0000000000..31fbc428c9 --- /dev/null +++ b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST @@ -0,0 +1,4 @@ +[task256466_wrongStyle] +opensuse-13.1 +[setFont] +ubuntu-14.04 diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm index 6e4ad29190..0d29f5b7a2 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog_mac_helpers.mm @@ -36,7 +36,7 @@ void click_cocoa_button() { - QMacCocoaAutoReleasePool pool; + QMacAutoReleasePool pool; NSArray *windows = [NSApp windows]; for (NSWindow *window in windows) { // This is NOT how one should do RTTI, but since I don't want to leak the class too much... diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index cb816a7e85..97cfec8171 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -216,7 +216,7 @@ void tst_QMessageBox::button() // remove the cancel, should not exist anymore msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - QVERIFY(msgBox.button(QMessageBox::Cancel) == 0); + QVERIFY(!msgBox.button(QMessageBox::Cancel)); QVERIFY(msgBox.button(QMessageBox::Yes) != 0); // should not crash @@ -228,10 +228,10 @@ void tst_QMessageBox::button() void tst_QMessageBox::defaultButton() { QMessageBox msgBox; - QVERIFY(msgBox.defaultButton() == 0); + QVERIFY(!msgBox.defaultButton()); msgBox.addButton(QMessageBox::Ok); msgBox.addButton(QMessageBox::Cancel); - QVERIFY(msgBox.defaultButton() == 0); + QVERIFY(!msgBox.defaultButton()); QPushButton pushButton; msgBox.setDefaultButton(&pushButton); QVERIFY(msgBox.defaultButton() == 0); // we have not added it yet @@ -250,27 +250,27 @@ void tst_QMessageBox::defaultButton() exec(&msgBox, Qt::Key_Enter); QCOMPARE(msgBox.clickedButton(), okButton); msgBox.setDefaultButton(QMessageBox::Yes); // its not in there! - QVERIFY(msgBox.defaultButton() == okButton); + QCOMPARE(msgBox.defaultButton(), okButton); msgBox.removeButton(okButton); delete okButton; okButton = 0; - QVERIFY(msgBox.defaultButton() == 0); + QVERIFY(!msgBox.defaultButton()); msgBox.setDefaultButton(QMessageBox::Ok); - QVERIFY(msgBox.defaultButton() == 0); + QVERIFY(!msgBox.defaultButton()); } void tst_QMessageBox::escapeButton() { QMessageBox msgBox; - QVERIFY(msgBox.escapeButton() == 0); + QVERIFY(!msgBox.escapeButton()); msgBox.addButton(QMessageBox::Ok); exec(&msgBox); QVERIFY(msgBox.clickedButton() == msgBox.button(QMessageBox::Ok)); // auto detected (one button only) msgBox.addButton(QMessageBox::Cancel); - QVERIFY(msgBox.escapeButton() == 0); + QVERIFY(!msgBox.escapeButton()); QPushButton invalidButton; msgBox.setEscapeButton(&invalidButton); - QVERIFY(msgBox.escapeButton() == 0); + QVERIFY(!msgBox.escapeButton()); QAbstractButton *retryButton = msgBox.addButton(QMessageBox::Retry); exec(&msgBox); @@ -293,13 +293,13 @@ void tst_QMessageBox::escapeButton() exec(&msgBox, Qt::Key_Escape); QCOMPARE(msgBox.clickedButton(), okButton); msgBox.setEscapeButton(QMessageBox::Yes); // its not in there! - QVERIFY(msgBox.escapeButton() == okButton); + QCOMPARE(msgBox.escapeButton(), okButton); msgBox.removeButton(okButton); delete okButton; okButton = 0; - QVERIFY(msgBox.escapeButton() == 0); + QVERIFY(!msgBox.escapeButton()); msgBox.setEscapeButton(QMessageBox::Ok); - QVERIFY(msgBox.escapeButton() == 0); + QVERIFY(!msgBox.escapeButton()); QMessageBox msgBox2; msgBox2.addButton(QMessageBox::Yes); @@ -527,13 +527,13 @@ void tst_QMessageBox::testSymbols() QCOMPARE(mb1.text(), text); icon = mb1.icon(); - QVERIFY(icon == QMessageBox::NoIcon); + QCOMPARE(icon, QMessageBox::NoIcon); mb1.setIcon(QMessageBox::Question); - QVERIFY(mb1.icon() == QMessageBox::Question); + QCOMPARE(mb1.icon(), QMessageBox::Question); QPixmap iconPixmap = mb1.iconPixmap(); mb1.setIconPixmap(iconPixmap); - QVERIFY(mb1.icon() == QMessageBox::NoIcon); + QCOMPARE(mb1.icon(), QMessageBox::NoIcon); QCOMPARE(mb1.buttonText(QMessageBox::Ok), QLatin1String("OK")); QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString()); diff --git a/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST b/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST new file mode 100644 index 0000000000..a2670e8f36 --- /dev/null +++ b/tests/auto/widgets/dialogs/qprogressdialog/BLACKLIST @@ -0,0 +1,2 @@ +[autoShow:50_to_100_fast_0_compat] +osx diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 21c15edff2..b2bdbac79a 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -400,7 +400,7 @@ void tst_QWizard::setButton() // revert to default button wizard.setButton(QWizard::NextButton, 0); - QVERIFY(toolButton == 0); + QVERIFY(toolButton.isNull()); QVERIFY(qobject_cast<QPushButton *>(wizard.button(QWizard::NextButton))); QVERIFY(wizard.button(QWizard::NextButton)->text().contains("Next")); } @@ -408,16 +408,16 @@ void tst_QWizard::setButton() void tst_QWizard::setTitleFormatEtc() { QWizard wizard; - QVERIFY(wizard.titleFormat() == Qt::AutoText); - QVERIFY(wizard.subTitleFormat() == Qt::AutoText); + QCOMPARE(wizard.titleFormat(), Qt::AutoText); + QCOMPARE(wizard.subTitleFormat(), Qt::AutoText); wizard.setTitleFormat(Qt::RichText); - QVERIFY(wizard.titleFormat() == Qt::RichText); - QVERIFY(wizard.subTitleFormat() == Qt::AutoText); + QCOMPARE(wizard.titleFormat(), Qt::RichText); + QCOMPARE(wizard.subTitleFormat(), Qt::AutoText); wizard.setSubTitleFormat(Qt::PlainText); - QVERIFY(wizard.titleFormat() == Qt::RichText); - QVERIFY(wizard.subTitleFormat() == Qt::PlainText); + QCOMPARE(wizard.titleFormat(), Qt::RichText); + QCOMPARE(wizard.subTitleFormat(), Qt::PlainText); } void tst_QWizard::setPixmap() @@ -439,7 +439,7 @@ void tst_QWizard::setPixmap() QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull()); #ifdef Q_OS_OSX - QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false); + QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); #else QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull()); #endif @@ -448,7 +448,7 @@ void tst_QWizard::setPixmap() QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull()); #ifdef Q_OS_OSX - QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false); + QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); #else QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); #endif @@ -459,20 +459,20 @@ void tst_QWizard::setPixmap() page->setPixmap(QWizard::LogoPixmap, p5); - QVERIFY(wizard.pixmap(QWizard::BannerPixmap).size() == p1.size()); - QVERIFY(wizard.pixmap(QWizard::LogoPixmap).size() == p2.size()); - QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).size() == p3.size()); - QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).size() == p4.size()); + QCOMPARE(wizard.pixmap(QWizard::BannerPixmap).size(), p1.size()); + QCOMPARE(wizard.pixmap(QWizard::LogoPixmap).size(), p2.size()); + QCOMPARE(wizard.pixmap(QWizard::WatermarkPixmap).size(), p3.size()); + QCOMPARE(wizard.pixmap(QWizard::BackgroundPixmap).size(), p4.size()); - QVERIFY(page->pixmap(QWizard::BannerPixmap).size() == p1.size()); - QVERIFY(page->pixmap(QWizard::LogoPixmap).size() == p5.size()); - QVERIFY(page->pixmap(QWizard::WatermarkPixmap).size() == p3.size()); - QVERIFY(page->pixmap(QWizard::BackgroundPixmap).size() == p4.size()); + QCOMPARE(page->pixmap(QWizard::BannerPixmap).size(), p1.size()); + QCOMPARE(page->pixmap(QWizard::LogoPixmap).size(), p5.size()); + QCOMPARE(page->pixmap(QWizard::WatermarkPixmap).size(), p3.size()); + QCOMPARE(page->pixmap(QWizard::BackgroundPixmap).size(), p4.size()); - QVERIFY(page2->pixmap(QWizard::BannerPixmap).size() == p1.size()); - QVERIFY(page2->pixmap(QWizard::LogoPixmap).size() == p2.size()); - QVERIFY(page2->pixmap(QWizard::WatermarkPixmap).size() == p3.size()); - QVERIFY(page2->pixmap(QWizard::BackgroundPixmap).size() == p4.size()); + QCOMPARE(page2->pixmap(QWizard::BannerPixmap).size(), p1.size()); + QCOMPARE(page2->pixmap(QWizard::LogoPixmap).size(), p2.size()); + QCOMPARE(page2->pixmap(QWizard::WatermarkPixmap).size(), p3.size()); + QCOMPARE(page2->pixmap(QWizard::BackgroundPixmap).size(), p4.size()); } class MyPage1 : public QWizardPage @@ -571,7 +571,7 @@ void tst_QWizard::addPage() } for (int i = 0; i < N; ++i) { - QVERIFY(pages[i] == wizard.page(i)); + QCOMPARE(pages[i], wizard.page(i)); } QVERIFY(!wizard.page(-1)); QVERIFY(!wizard.page(N)); @@ -667,7 +667,7 @@ void tst_QWizard::setPage() QCOMPARE(wizard.page(-2), page); QCOMPARE(wizard.startId(), -2); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == page); + QCOMPARE(wizard.currentPage(), page); QCOMPARE(wizard.nextId(), 0); CHECK_VISITED(wizard, QList<int>() << -2); @@ -679,14 +679,14 @@ void tst_QWizard::setPage() QCOMPARE(wizard.page(2), page); QCOMPARE(wizard.startId(), -2); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == wizard.page(-2)); + QCOMPARE(wizard.currentPage(), wizard.page(-2)); QCOMPARE(wizard.nextId(), 0); CHECK_VISITED(wizard, QList<int>() << -2); wizard.restart(); QCOMPARE(wizard.startId(), -2); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == wizard.page(-2)); + QCOMPARE(wizard.currentPage(), wizard.page(-2)); QCOMPARE(wizard.nextId(), 0); CHECK_VISITED(wizard, QList<int>() << -2); @@ -698,28 +698,28 @@ void tst_QWizard::setPage() QCOMPARE(wizard.page(-3), page); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == wizard.page(-2)); + QCOMPARE(wizard.currentPage(), wizard.page(-2)); QCOMPARE(wizard.nextId(), 0); CHECK_VISITED(wizard, QList<int>() << -2); wizard.restart(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -3); - QVERIFY(wizard.currentPage() == wizard.page(-3)); + QCOMPARE(wizard.currentPage(), wizard.page(-3)); QCOMPARE(wizard.nextId(), -2); CHECK_VISITED(wizard, QList<int>() << -3); wizard.next(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == wizard.page(-2)); + QCOMPARE(wizard.currentPage(), wizard.page(-2)); QCOMPARE(wizard.nextId(), 0); CHECK_VISITED(wizard, QList<int>() << -3 << -2); wizard.next(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), 0); - QVERIFY(wizard.currentPage() == wizard.page(0)); + QCOMPARE(wizard.currentPage(), wizard.page(0)); QCOMPARE(wizard.nextId(), 2); CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0); @@ -727,7 +727,7 @@ void tst_QWizard::setPage() wizard.next(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), 2); - QVERIFY(wizard.currentPage() == wizard.page(2)); + QCOMPARE(wizard.currentPage(), wizard.page(2)); QCOMPARE(wizard.nextId(), -1); CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0 << 2); } @@ -735,14 +735,14 @@ void tst_QWizard::setPage() wizard.back(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), 0); - QVERIFY(wizard.currentPage() == wizard.page(0)); + QCOMPARE(wizard.currentPage(), wizard.page(0)); QCOMPARE(wizard.nextId(), 2); CHECK_VISITED(wizard, QList<int>() << -3 << -2 << 0); wizard.back(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == wizard.page(-2)); + QCOMPARE(wizard.currentPage(), wizard.page(-2)); QCOMPARE(wizard.nextId(), 0); CHECK_VISITED(wizard, QList<int>() << -3 << -2); @@ -750,7 +750,7 @@ void tst_QWizard::setPage() wizard.back(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -3); - QVERIFY(wizard.currentPage() == wizard.page(-3)); + QCOMPARE(wizard.currentPage(), wizard.page(-3)); QCOMPARE(wizard.nextId(), -2); CHECK_VISITED(wizard, QList<int>() << -3); } @@ -759,7 +759,7 @@ void tst_QWizard::setPage() wizard.restart(); QCOMPARE(wizard.startId(), -3); QCOMPARE(wizard.currentId(), -3); - QVERIFY(wizard.currentPage() == wizard.page(-3)); + QCOMPARE(wizard.currentPage(), wizard.page(-3)); QCOMPARE(wizard.nextId(), -2); CHECK_VISITED(wizard, QList<int>() << -3); } @@ -808,31 +808,31 @@ void tst_QWizard::setStartId() wizard.restart(); QCOMPARE(wizard.startId(), -2); QCOMPARE(wizard.currentId(), -2); - QVERIFY(wizard.currentPage() == wizard.page(-2)); + QCOMPARE(wizard.currentPage(), wizard.page(-2)); QCOMPARE(wizard.nextId(), 0); wizard.next(); QCOMPARE(wizard.startId(), -2); QCOMPARE(wizard.currentId(), 0); - QVERIFY(wizard.currentPage() == wizard.page(0)); + QCOMPARE(wizard.currentPage(), wizard.page(0)); QCOMPARE(wizard.nextId(), 1); wizard.setStartId(INT_MIN); QCOMPARE(wizard.startId(), INT_MIN); QCOMPARE(wizard.currentId(), 0); - QVERIFY(wizard.currentPage() == wizard.page(0)); + QCOMPARE(wizard.currentPage(), wizard.page(0)); QCOMPARE(wizard.nextId(), 1); wizard.next(); QCOMPARE(wizard.startId(), INT_MIN); QCOMPARE(wizard.currentId(), 1); - QVERIFY(wizard.currentPage() == wizard.page(1)); + QCOMPARE(wizard.currentPage(), wizard.page(1)); QCOMPARE(wizard.nextId(), INT_MAX); wizard.next(); QCOMPARE(wizard.startId(), INT_MIN); QCOMPARE(wizard.currentId(), INT_MAX); - QVERIFY(wizard.currentPage() == wizard.page(INT_MAX)); + QCOMPARE(wizard.currentPage(), wizard.page(INT_MAX)); QCOMPARE(wizard.nextId(), -1); CHECK_VISITED(wizard, QList<int>() << -2 << 0 << 1 << INT_MAX); } @@ -1143,12 +1143,12 @@ void tst_QWizard::setOption_ExtendedWatermarkPixmap() } if (wizard1.wizardStyle() == QWizard::MacStyle) { - QVERIFY(i1[0] == i1[1]); - QVERIFY(i2[0] == i2[1]); - QVERIFY(i1[0] == i2[0]); + QCOMPARE(i1[0], i1[1]); + QCOMPARE(i2[0], i2[1]); + QCOMPARE(i1[0], i2[0]); } else { QVERIFY(i1[0] != i1[1]); - QVERIFY(i2[0] == i2[1]); + QCOMPARE(i2[0], i2[1]); QVERIFY(i1[0] != i2[0]); QVERIFY(i1[1] != i2[1]); } @@ -2425,19 +2425,19 @@ void tst_QWizard::sideWidget() QWizard wizard; wizard.setSideWidget(0); - QVERIFY(wizard.sideWidget() == 0); + QVERIFY(!wizard.sideWidget()); QScopedPointer<QWidget> w1(new QWidget(&wizard)); wizard.setSideWidget(w1.data()); QCOMPARE(wizard.sideWidget(), w1.data()); QWidget *w2 = new QWidget(&wizard); wizard.setSideWidget(w2); - QVERIFY(wizard.sideWidget() == w2); + QCOMPARE(wizard.sideWidget(), w2); QVERIFY(w1->parent() != 0); QCOMPARE(w1->window(), static_cast<QWidget *>(&wizard)); QCOMPARE(w2->window(), static_cast<QWidget *>(&wizard)); w1->setParent(0); wizard.setSideWidget(0); - QVERIFY(wizard.sideWidget() == 0); + QVERIFY(!wizard.sideWidget()); } void tst_QWizard::objectNames_data() @@ -2558,7 +2558,7 @@ void tst_QWizard::task183550_stretchFactor() page2->disableVerticalExpansion(); wizard.next(); QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2)); - QVERIFY(page2->treeWidgetHeight() == page2->treeWidgetSizeHintHeight()); + QCOMPARE(page2->treeWidgetHeight(), page2->treeWidgetSizeHintHeight()); wizard.back(); QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page1)); @@ -2576,7 +2576,7 @@ void tst_QWizard::task183550_stretchFactor() page2->disableVerticalExpansion(); wizard.next(); QCOMPARE(wizard.currentPage(), static_cast<QWizardPage*>(page2)); - QVERIFY(page2->treeWidgetHeight() == page2->treeWidgetSizeHintHeight()); + QCOMPARE(page2->treeWidgetHeight(), page2->treeWidgetSizeHintHeight()); } void tst_QWizard::task161658_alignments() diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp index 4d7f55f37d..c7d1dd0aa1 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp @@ -520,7 +520,7 @@ public: void draw(QPainter *painter) { - QVERIFY(sourcePixmap(Qt::LogicalCoordinates).handle() == pixmap.handle()); + QCOMPARE(sourcePixmap(Qt::LogicalCoordinates).handle(), pixmap.handle()); QVERIFY((painter->worldTransform().type() <= QTransform::TxTranslate) == (sourcePixmap(Qt::DeviceCoordinates).handle() == pixmap.handle())); ++repaints; @@ -595,7 +595,7 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() item->translate(10, 0); - QTRY_VERIFY(item->numRepaints == numRepaints); + QTRY_COMPARE(item->numRepaints, numRepaints); } void tst_QGraphicsEffect::inheritOpacity() diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST new file mode 100644 index 0000000000..7f55c2dae0 --- /dev/null +++ b/tests/auto/widgets/gestures/qgesturerecognizer/BLACKLIST @@ -0,0 +1,2 @@ +[panGesture:Two finger] +xcb diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index ca01b27bee..f71308cdaf 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -133,7 +133,6 @@ static bool checkReverseDirection(QGraphicsWidget *widget) layout->getContentsMargins(&left, &top, &right, &bottom); widget->setLayoutDirection(Qt::LeftToRight); QApplication::processEvents(); - const QRectF layoutGeometry = layout->geometry(); QMap<QGraphicsLayoutItem *, QRectF> geometries; for (int i = 0; i < layout->count(); ++i) { QGraphicsLayoutItem *item = layout->itemAt(i); @@ -141,7 +140,7 @@ static bool checkReverseDirection(QGraphicsWidget *widget) } widget->setLayoutDirection(Qt::RightToLeft); QApplication::processEvents(); - layoutGeometry.adjusted(+right, +top, -left, -bottom); + const QRectF layoutGeometry = layout->geometry().adjusted(+right, +top, -left, -bottom); for (int i = 0; i < layout->count(); ++i) { QGraphicsLayoutItem *item = layout->itemAt(i); const QRectF rightToLeftGeometry = item->geometry(); @@ -653,7 +652,7 @@ void tst_QGraphicsAnchorLayout::snake() QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); - QVERIFY(layoutHasConflict(l) == false); + QVERIFY(!layoutHasConflict(l)); // Test QSizePolicy::ExpandFlag, it shouldn't change the extreme // points of the layout... @@ -2041,9 +2040,9 @@ void tst_QGraphicsAnchorLayout::graphicsAnchorHandling() QGraphicsAnchor *invalidAnchor = l->anchor(a, Qt::AnchorTop, l, Qt::AnchorBottom); // Ensure none of these anchors are accessible. - QVERIFY(layoutAnchor == 0); - QVERIFY(itemAnchor == 0); - QVERIFY(invalidAnchor == 0); + QVERIFY(!layoutAnchor); + QVERIFY(!itemAnchor); + QVERIFY(!invalidAnchor); // Hook the anchors to a QObject QObject object; diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index a2108dd494..a58f295575 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -715,7 +715,7 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases() widget1->setGeometry(QRectF(0,0,100,100)); QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98)); - QVERIFY(childWidget->parentLayoutItem() == layout1); + QCOMPARE(childWidget->parentLayoutItem(), layout1); QGraphicsWidget *widget2 = new QGraphicsWidget; TheAnchorLayout *layout2 = new TheAnchorLayout(); widget2->setLayout(layout2); @@ -739,10 +739,10 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases() widget2->setGeometry(QRectF(0,0,100,100)); QCOMPARE(childWidget->geometry(), QRectF(1,1,98,98)); - QVERIFY(childWidget->parentLayoutItem() == layout2); + QCOMPARE(childWidget->parentLayoutItem(), layout2); QCOMPARE(widget4->geometry(), QRectF(1,1,98,98)); - QVERIFY(widget4->parentLayoutItem() == layout2); - QVERIFY(widget4->parentItem() == widget2); + QCOMPARE(widget4->parentLayoutItem(), layout2); + QCOMPARE(widget4->parentItem(), widget2); delete widget4; delete widget3; diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 0dd1161dcf..835aeaa4df 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -4274,7 +4274,7 @@ void tst_QGraphicsItem::cursor() void tst_QGraphicsItem::textControlGetterSetter() { QGraphicsTextItem *item = new QGraphicsTextItem; - QVERIFY(item->textControl()->parent() == item); + QCOMPARE(item->textControl()->parent(), item); QPointer<QWidgetTextControl> control = item->textControl(); delete item; QVERIFY(!control); @@ -4285,7 +4285,7 @@ void tst_QGraphicsItem::textControlGetterSetter() control = new QWidgetTextControl; item->setTextControl(control); - QVERIFY(item->textControl() == control); + QCOMPARE(item->textControl(), control); QVERIFY(!control->parent()); QVERIFY(!oldControl); @@ -5141,19 +5141,19 @@ void tst_QGraphicsItem::paint() //nominal case, update call paint tester2.update(); qApp->processEvents(); - QTRY_VERIFY(tester2.painted == 2); + QTRY_COMPARE(tester2.painted, 2); //we remove the item from the scene, number of updates is still the same tester2.update(); scene2.removeItem(&tester2); qApp->processEvents(); - QTRY_VERIFY(tester2.painted == 2); + QTRY_COMPARE(tester2.painted, 2); //We re-add the item, the number of paint should increase scene2.addItem(&tester2); tester2.update(); qApp->processEvents(); - QTRY_VERIFY(tester2.painted == 3); + QTRY_COMPARE(tester2.painted, 3); } class HarakiriItem : public QGraphicsRectItem @@ -5878,7 +5878,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape() scene.setItemIndexMethod(QGraphicsScene::NoIndex); scene.addItem(parent); - QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls); + QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls); int oldParentBoundingRectCalls = parent->boundingRectCalls; int oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls; @@ -5886,10 +5886,10 @@ void tst_QGraphicsItem::itemContainsChildrenInShape() // First test that both items are searched if no optimization flags are set QGraphicsItem* item = scene.itemAt(25,5); - QVERIFY(item == childOutsideShape); + QCOMPARE(item, childOutsideShape); QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls); QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls); - QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls); + QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls); oldParentBoundingRectCalls = parent->boundingRectCalls; oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls; @@ -5897,10 +5897,10 @@ void tst_QGraphicsItem::itemContainsChildrenInShape() // Repeat the test to make sure that no caching/indexing is in effect item = scene.itemAt(25,5); - QVERIFY(item == childOutsideShape); + QCOMPARE(item, childOutsideShape); QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls); QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls); - QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls); + QCOMPARE(parent->boundingRectCalls, childOutsideShape->boundingRectCalls); oldParentBoundingRectCalls = parent->boundingRectCalls; oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls; @@ -5912,7 +5912,7 @@ void tst_QGraphicsItem::itemContainsChildrenInShape() QVERIFY(!(item)); QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls); - QVERIFY(childOutsideShape->boundingRectCalls == oldChildBoundingRectCalls); + QCOMPARE(childOutsideShape->boundingRectCalls, oldChildBoundingRectCalls); QVERIFY(parent->boundingRectCalls > childOutsideShape->boundingRectCalls); } @@ -11205,21 +11205,21 @@ void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() child2->setVisible(false); child2->setParentItem(child); - QTRY_VERIFY(view.repaints == 1); + QTRY_COMPARE(view.repaints, 1); // test case #2 view.reset(); child3->setOpacity(0.0); child3->setParentItem(child); - QTRY_VERIFY(view.repaints == 1); + QTRY_COMPARE(view.repaints, 1); // test case #3 view.reset(); child4->setParentItem(child); child4->setVisible(false); - QTRY_VERIFY(view.repaints == 1); + QTRY_COMPARE(view.repaints, 1); } void tst_QGraphicsItem::QT_2653_fullUpdateDiscardingOpacityUpdate() @@ -11469,9 +11469,9 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation() QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove); event.setScenePos(item->boundingRect().center()); QApplication::sendEvent(&scene, &event); - QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == item); + QCOMPARE(QGraphicsScenePrivate::get(&scene)->dragDropItem, item); delete item; - QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0); + QVERIFY(!QGraphicsScenePrivate::get(&scene)->dragDropItem); } void tst_QGraphicsItem::QTBUG_12112_focusItem() diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp index bd104539ac..a2740edc54 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp @@ -948,7 +948,7 @@ void tst_QGraphicsLayout::ownership() destructedSet.clear(); window->setLayout(0); - QVERIFY(destructedSet.count() == 0); + QCOMPARE(destructedSet.count(), 0); delete window; } diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 6a8b690560..8bebd4eddd 100644 --- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -1230,8 +1230,8 @@ void tst_QGraphicsLinearLayout::testStretch() layout->addStretch(2); layout->addItem(w2); QCOMPARE(layout->count(), 2); - QVERIFY(layout->itemAt(0) == w1); - QVERIFY(layout->itemAt(1) == w2); + QCOMPARE(layout->itemAt(0), w1); + QCOMPARE(layout->itemAt(1), w2); layout->activate(); //view->setSceneRect(-50, -50, 800, 800); diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp index 84c39bbb98..0f9e8c101e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp @@ -102,7 +102,7 @@ void tst_QGraphicsObject::pos() QCOMPARE(xSpy.count(), 1); QCOMPARE(ySpy.count(), 1); - QVERIFY(object.pos() == QPointF(10,10)); + QCOMPARE(object.pos(), QPointF(10,10)); object.setPos(10, 10); QCOMPARE(xSpy.count(), 1); @@ -111,12 +111,12 @@ void tst_QGraphicsObject::pos() object.setProperty("pos", QPointF(0, 0)); QCOMPARE(xSpy.count(), 2); QCOMPARE(ySpy.count(), 2); - QVERIFY(object.property("pos") == QPointF(0,0)); + QCOMPARE(object.property("pos").toPointF(), QPointF(0,0)); object.setProperty("pos", QPointF(10, 0)); QCOMPARE(xSpy.count(), 3); QCOMPARE(ySpy.count(), 2); - QVERIFY(object.property("pos") == QPointF(10,0)); + QCOMPARE(object.property("pos").toPointF(), QPointF(10,0)); object.setProperty("pos", QPointF(10, 10)); QCOMPARE(xSpy.count(), 3); @@ -135,7 +135,7 @@ void tst_QGraphicsObject::x() QCOMPARE(ySpy.count(), 0); QVERIFY(object.pos() == QPointF(10, 0)); - QVERIFY(object.x() == 10); + QCOMPARE(object.x(), qreal(10)); object.setX(10); QCOMPARE(xSpy.count(), 1); @@ -144,7 +144,7 @@ void tst_QGraphicsObject::x() object.setProperty("x", 0); QCOMPARE(xSpy.count(), 2); QCOMPARE(ySpy.count(), 0); - QVERIFY(object.property("x") == 0); + QCOMPARE(object.property("x").toDouble(), double(0)); } void tst_QGraphicsObject::y() @@ -158,7 +158,7 @@ void tst_QGraphicsObject::y() QCOMPARE(ySpy.count(), 1); QVERIFY(object.pos() == QPointF(0, 10)); - QVERIFY(object.y() == 10); + QCOMPARE(object.y(), qreal(10)); object.setY(10); QCOMPARE(xSpy.count(), 0); @@ -167,79 +167,79 @@ void tst_QGraphicsObject::y() object.setProperty("y", 0); QCOMPARE(xSpy.count(), 0); QCOMPARE(ySpy.count(), 2); - QVERIFY(object.property("y") == 0); + QCOMPARE(object.property("y").toDouble(), qreal(0)); } void tst_QGraphicsObject::z() { MyGraphicsObject object; QSignalSpy zSpy(&object, SIGNAL(zChanged())); - QVERIFY(object.zValue() == 0); + QCOMPARE(object.zValue(), qreal(0)); object.setZValue(10); QCOMPARE(zSpy.count(), 1); - QVERIFY(object.zValue() == 10); + QCOMPARE(object.zValue(), qreal(10)); object.setZValue(10); QCOMPARE(zSpy.count(), 1); object.setProperty("z", 0); QCOMPARE(zSpy.count(), 2); - QVERIFY(object.property("z") == 0); + QCOMPARE(object.property("z").toDouble(), double(0)); } void tst_QGraphicsObject::opacity() { MyGraphicsObject object; QSignalSpy spy(&object, SIGNAL(opacityChanged())); - QVERIFY(object.opacity() == 1.); + QCOMPARE(object.opacity(), 1.); object.setOpacity(0); QCOMPARE(spy.count(), 1); - QVERIFY(object.opacity() == 0.); + QCOMPARE(object.opacity(), 0.); object.setOpacity(0); QCOMPARE(spy.count(), 1); object.setProperty("opacity", .5); QCOMPARE(spy.count(), 2); - QVERIFY(object.property("opacity") == .5); + QCOMPARE(object.property("opacity").toDouble(), .5); } void tst_QGraphicsObject::enabled() { MyGraphicsObject object; QSignalSpy spy(&object, SIGNAL(enabledChanged())); - QVERIFY(object.isEnabled() == true); + QVERIFY(object.isEnabled()); object.setEnabled(false); QCOMPARE(spy.count(), 1); - QVERIFY(object.isEnabled() == false); + QVERIFY(!object.isEnabled()); object.setEnabled(false); QCOMPARE(spy.count(), 1); object.setProperty("enabled", true); QCOMPARE(spy.count(), 2); - QVERIFY(object.property("enabled") == true); + QVERIFY(object.property("enabled").toBool()); } void tst_QGraphicsObject::visible() { MyGraphicsObject object; QSignalSpy spy(&object, SIGNAL(visibleChanged())); - QVERIFY(object.isVisible() == true); + QVERIFY(object.isVisible()); object.setVisible(false); QCOMPARE(spy.count(), 1); - QVERIFY(object.isVisible() == false); + QVERIFY(!object.isVisible()); object.setVisible(false); QCOMPARE(spy.count(), 1); object.setProperty("visible", true); QCOMPARE(spy.count(), 2); - QVERIFY(object.property("visible") == true); + QVERIFY(object.property("visible").toBool()); } class DeleteTester : public QGraphicsObject diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index cd40c5541c..4896d52343 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -97,8 +97,8 @@ private slots: void paint_2(); void setWidget_data(); void setWidget(); - void eventFilter_data(); - void eventFilter(); + void testEventFilter_data(); + void testEventFilter(); void focusInEvent_data(); void focusInEvent(); void focusInEventNoWidget(); @@ -314,7 +314,7 @@ void tst_QGraphicsProxyWidget::qgraphicsproxywidget() SubQGraphicsProxyWidget proxy; proxy.paint(0, 0, 0); proxy.setWidget(0); - QVERIFY(proxy.type() == QGraphicsProxyWidget::Type); + QCOMPARE(proxy.type(), int(QGraphicsProxyWidget::Type)); QVERIFY(!proxy.widget()); QEvent event(QEvent::None); proxy.call_eventFilter(0, &event); @@ -533,7 +533,7 @@ void tst_QGraphicsProxyWidget::setWidget() } Q_DECLARE_METATYPE(QEvent::Type) -void tst_QGraphicsProxyWidget::eventFilter_data() +void tst_QGraphicsProxyWidget::testEventFilter_data() { QTest::addColumn<QEvent::Type>("eventType"); QTest::addColumn<bool>("fromObject"); // big grin evil @@ -552,7 +552,7 @@ void tst_QGraphicsProxyWidget::eventFilter_data() } // protected bool eventFilter(QObject* object, QEvent* event) -void tst_QGraphicsProxyWidget::eventFilter() +void tst_QGraphicsProxyWidget::testEventFilter() { QFETCH(QEvent::Type, eventType); QFETCH(bool, fromObject); @@ -1223,6 +1223,7 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent() QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(500, 500); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); @@ -1231,7 +1232,6 @@ void tst_QGraphicsProxyWidget::mousePressReleaseEvent() QPushButton *widget = new QPushButton; QSignalSpy spy(widget, SIGNAL(clicked())); widget->resize(50, 50); - view.resize(100, 100); if (hasWidget) { proxy->setWidget(widget); proxy->show(); @@ -3017,36 +3017,36 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget() layout->addWidget(rightDial); window.setLayout(layout); - QVERIFY(window.graphicsProxyWidget() == 0); - QVERIFY(checkbox->graphicsProxyWidget() == 0); + QVERIFY(!window.graphicsProxyWidget()); + QVERIFY(!checkbox->graphicsProxyWidget()); QGraphicsProxyWidget *windowProxy = scene.addWidget(&window); QGraphicsView view(&scene); view.show(); view.resize(500,500); - QVERIFY(window.graphicsProxyWidget() == windowProxy); - QVERIFY(box->graphicsProxyWidget() == 0); - QVERIFY(checkbox->graphicsProxyWidget() == 0); + QCOMPARE(window.graphicsProxyWidget(), windowProxy); + QVERIFY(!box->graphicsProxyWidget()); + QVERIFY(!checkbox->graphicsProxyWidget()); QPointer<QGraphicsProxyWidget> checkboxProxy = windowProxy->createProxyForChildWidget(checkbox); QGraphicsProxyWidget *boxProxy = box->graphicsProxyWidget(); QVERIFY(boxProxy); - QVERIFY(checkbox->graphicsProxyWidget() == checkboxProxy); - QVERIFY(checkboxProxy->parentItem() == boxProxy); - QVERIFY(boxProxy->parentItem() == windowProxy); + QCOMPARE(checkbox->graphicsProxyWidget(), checkboxProxy.data()); + QCOMPARE(checkboxProxy->parentItem(), boxProxy); + QCOMPARE(boxProxy->parentItem(), windowProxy); QVERIFY(checkboxProxy->mapToScene(QPointF()) == checkbox->mapTo(&window, QPoint())); - QVERIFY(checkboxProxy->size() == checkbox->size()); - QVERIFY(boxProxy->size() == box->size()); + QCOMPARE(checkboxProxy->size().toSize(), checkbox->size()); + QCOMPARE(boxProxy->size().toSize(), box->size()); window.resize(500,500); - QVERIFY(windowProxy->size() == QSize(500,500)); + QCOMPARE(windowProxy->size().toSize(), QSize(500,500)); QVERIFY(checkboxProxy->mapToScene(QPointF()) == checkbox->mapTo(&window, QPoint())); - QVERIFY(checkboxProxy->size() == checkbox->size()); - QVERIFY(boxProxy->size() == box->size()); + QCOMPARE(checkboxProxy->size().toSize(), checkbox->size()); + QCOMPARE(boxProxy->size().toSize(), box->size()); QTest::qWait(10); @@ -3064,9 +3064,9 @@ void tst_QGraphicsProxyWidget::createProxyForChildWidget() boxProxy->setWidget(0); - QVERIFY(checkbox->graphicsProxyWidget() == 0); - QVERIFY(box->graphicsProxyWidget() == 0); - QVERIFY(checkboxProxy == 0); + QVERIFY(!checkbox->graphicsProxyWidget()); + QVERIFY(!box->graphicsProxyWidget()); + QVERIFY(checkboxProxy.isNull()); delete boxProxy; } diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 7bd0393760..ae71b0412f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1282,33 +1282,16 @@ void tst_QGraphicsScene::removeItem() view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); - QTest::mouseMove(view.viewport(), QPoint(-1, -1)); - { - QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton, 0, 0); - QApplication::sendEvent(view.viewport(), &moveEvent); - } - qApp->processEvents(); // update - qApp->processEvents(); // draw - QVERIFY(!hoverItem->isHovered); + QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton); + QTRY_VERIFY(!hoverItem->isHovered); - { - QTest::qWait(250); - QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton); - QTest::qWait(10); - QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos()), Qt::NoButton, 0, 0); - QApplication::sendEvent(view.viewport(), &moveEvent); - } - qApp->processEvents(); // update - qApp->processEvents(); // draw - QVERIFY(hoverItem->isHovered); + QTest::mouseMove(view.viewport(), view.mapFromScene(hoverItem->scenePos()), Qt::NoButton); + QTRY_VERIFY(hoverItem->isHovered); scene.removeItem(hoverItem); hoverItem->setAcceptsHoverEvents(false); scene.addItem(hoverItem); - qApp->processEvents(); // <- delayed update is called - qApp->processEvents(); // <- scene schedules pending update - qApp->processEvents(); // <- pending update is sent to view - QVERIFY(!hoverItem->isHovered); + QTRY_VERIFY(!hoverItem->isHovered); } void tst_QGraphicsScene::focusItem() @@ -3509,6 +3492,8 @@ void tst_QGraphicsScene::task160653_selectionChanged() QSignalSpy spy(&scene, SIGNAL(selectionChanged())); QGraphicsView view(&scene); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::mouseClick( view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.items().first()->scenePos())); QCOMPARE(spy.count(), 1); @@ -4742,9 +4727,9 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); - QVERIFY(viewRepaints == smallChild->repaints); - QVERIFY(viewRepaints == smallerGrandChild->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); + QCOMPARE(viewRepaints, smallChild->repaints); + QCOMPARE(viewRepaints, smallerGrandChild->repaints); // Setting a minimum render size should cause a repaint scene.setMinimumRenderSize(0.5); @@ -4753,9 +4738,9 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); - QVERIFY(viewRepaints == smallChild->repaints); - QVERIFY(viewRepaints == smallerGrandChild->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); + QCOMPARE(viewRepaints, smallChild->repaints); + QCOMPARE(viewRepaints, smallerGrandChild->repaints); // Scaling should cause a repaint of big items only. view.scale(0.1, 0.1); @@ -4764,8 +4749,8 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); - QVERIFY(viewRepaints == smallChild->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); + QCOMPARE(viewRepaints, smallChild->repaints); QVERIFY(smallChild->repaints > smallerGrandChild->repaints); // Scaling further should cause even fewer items to be repainted @@ -4775,7 +4760,7 @@ void tst_QGraphicsScene::minimumRenderSize() QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; - QVERIFY(viewRepaints == bigParent->repaints); + QCOMPARE(viewRepaints, bigParent->repaints); QVERIFY(bigParent->repaints > smallChild->repaints); QVERIFY(smallChild->repaints > smallerGrandChild->repaints); } diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST index be7a7e398b..3cba8bad7e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -1,4 +1,18 @@ [task255529_transformationAnchorMouseAndViewportMargins] -ubuntu-14.04 +xcb [cursor] -ubuntu-14.04 +xcb +[cursor2] +xcb +[rubberBandExtendSelection] +xcb +[rotated_rubberBand] +xcb +[sendEvent] +xcb +[forwardMousePress] +xcb +[hoverLeave] +xcb +[resizeAnchor] +xcb diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index d1d4c1ab86..6db4295286 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -3525,7 +3525,7 @@ void tst_QGraphicsView::embeddedViews() v2->QWidget::render(&actual); QTransform b = item->transform; - QVERIFY(a == b); + QCOMPARE(a, b); delete v1; } diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 9b92c34fb5..ec2203e615 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -182,14 +182,6 @@ private slots: void QTBUG_45867_send_itemChildAddedChange_to_parent(); }; - -static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0) -{ - QTest::mouseMove(widget, point); - QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0); - QApplication::sendEvent(widget, &event); -} - // Subclass that exposes the protected functions. class SubQGraphicsWidget : public QGraphicsWidget { public: @@ -197,7 +189,7 @@ public: : QGraphicsWidget(parent, windowFlags), eventCount(0) { } - void initStyleOption(QStyleOption *option) + void initStyleOption(QStyleOption *option) const { QGraphicsWidget::initStyleOption(option); } void call_changeEvent(QEvent* event) @@ -1110,8 +1102,8 @@ void tst_QGraphicsWidget::initStyleOption() { QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(300, 300); view.show(); - QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); view.setAlignment(Qt::AlignTop | Qt::AlignLeft); @@ -1133,10 +1125,8 @@ void tst_QGraphicsWidget::initStyleOption() } QFETCH(bool, underMouse); if (underMouse) { - view.resize(300, 300); - view.show(); - QVERIFY(QTest::qWaitForWindowActive(&view)); - sendMouseMove(view.viewport(), view.mapFromScene(widget->mapToScene(widget->boundingRect().center()))); + QCursor::setPos(view.viewport()->mapToGlobal(view.mapFromScene(widget->mapToScene(widget->boundingRect().center())))); + QTest::qWait(100); } QFETCH(QPalette, palette); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index eed38752d9..fac3f5857b 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -1036,7 +1036,7 @@ void tst_QAbstractItemView::dragAndDropOnChild() ++successes; } - QVERIFY(successes == 0); + QCOMPARE(successes, 0); } #endif // 0 @@ -1214,7 +1214,7 @@ void tst_QAbstractItemView::setCurrentIndex() view->setModel(model); view->setCurrentIndex(model->index(0,0)); - QVERIFY(view->currentIndex() == model->index(0,0)); + QCOMPARE(view->currentIndex(), model->index(0,0)); view->setCurrentIndex(model->index(1,0)); QVERIFY(view->currentIndex() == model->index(result ? 1 : 0,0)); } diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp index f5e6facaad..6645da727c 100644 --- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp @@ -292,7 +292,7 @@ void tst_QColumnView::grips() for (int i = 0 ; i < list.count(); ++i) { if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) { if (view->isVisible()) - QVERIFY(view->cornerWidget() == 0); + QVERIFY(!view->cornerWidget()); } } } @@ -587,7 +587,7 @@ void tst_QColumnView::selectAll() QVERIFY(view.selectionModel()->selectedIndexes().count() > 0); view.setCurrentIndex(QModelIndex()); - QVERIFY(view.selectionModel()->selectedIndexes().count() == 0); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0); } void tst_QColumnView::clicked() diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 21e4b82366..7e73c19539 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -403,7 +403,7 @@ void tst_QHeaderView::init() view = new QHeaderView(Qt::Vertical,topLevel); // Some initial value tests before a model is added QCOMPARE(view->length(), 0); - QVERIFY(view->sizeHint() == QSize(0,0)); + QCOMPARE(view->sizeHint(), QSize(0,0)); QCOMPARE(view->sectionSizeHint(0), -1); /* @@ -925,9 +925,9 @@ void tst_QHeaderView::moveSection() QFETCH(QList<int>, logical); QFETCH(int, count); - QVERIFY(from.count() == to.count()); - QVERIFY(from.count() == moved.count()); - QVERIFY(view->count() == logical.count()); + QCOMPARE(from.count(), to.count()); + QCOMPARE(from.count(), moved.count()); + QCOMPARE(view->count(), logical.count()); QSignalSpy spy1(view, SIGNAL(sectionMoved(int,int,int))); QCOMPARE(view->sectionsMoved(), false); @@ -1370,15 +1370,15 @@ void tst_QHeaderView::unhideSection() QCOMPARE(view->sectionsHidden(), false); view->setSectionHidden(0, true); QCOMPARE(view->sectionsHidden(), true); - QVERIFY(view->sectionSize(0) == 0); + QCOMPARE(view->sectionSize(0), 0); view->setSectionResizeMode(QHeaderView::Interactive); view->setSectionHidden(0, false); QVERIFY(view->sectionSize(0) > 0); view->setSectionHidden(0, true); - QVERIFY(view->sectionSize(0) == 0); + QCOMPARE(view->sectionSize(0), 0); view->setSectionHidden(0, true); - QVERIFY(view->sectionSize(0) == 0); + QCOMPARE(view->sectionSize(0), 0); view->setSectionResizeMode(QHeaderView::Stretch); view->setSectionHidden(0, false); QVERIFY(view->sectionSize(0) > 0); @@ -1645,7 +1645,7 @@ void tst_QHeaderView::saveRestore() QByteArray s2 = h2.saveState(); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage"))); // QTBUG-40462 @@ -1659,7 +1659,7 @@ void tst_QHeaderView::saveRestore() int sectionItemsLengthTotal = 0; for (int i = 0; i < h2.count(); ++i) sectionItemsLengthTotal += h2.sectionSize(i); - QVERIFY(sectionItemsLengthTotal == h2.length()); + QCOMPARE(sectionItemsLengthTotal, h2.length()); // Buggy setting where sum(sectionItems) != length. Check false is returned and this corrupted // state isn't restored @@ -1676,8 +1676,8 @@ void tst_QHeaderView::saveRestore() // Check setting is correctly recognized as corrupted QVERIFY(!h2.restoreState(settings_buggy_length)); // Check nothing has been actually restored - QVERIFY(h2.length() == old_length); - QVERIFY(h2.saveState() == old_state); + QCOMPARE(h2.length(), old_length); + QCOMPARE(h2.saveState(), old_state); } void tst_QHeaderView::defaultSectionSizeTest() @@ -1699,7 +1699,7 @@ void tst_QHeaderView::defaultSectionSizeTest() // no hidden Sections hv->resizeSection(1, 0); hv->setDefaultSectionSize(defaultSize); - QVERIFY(hv->sectionSize(1) == defaultSize); + QCOMPARE(hv->sectionSize(1), defaultSize); // with hidden sections hv->resizeSection(1, 0); @@ -2277,7 +2277,7 @@ void tst_QHeaderView::QTBUG14242_hideSectionAutoSize() for (int u = 0; u < hv->count(); ++u) calced_length += hv->sectionSize(u); - QVERIFY(calced_length == afterlength); + QCOMPARE(calced_length, afterlength); } void tst_QHeaderView::ensureNoIndexAtLength() @@ -2286,9 +2286,9 @@ void tst_QHeaderView::ensureNoIndexAtLength() QStandardItemModel amodel(4, 4); qtv.setModel(&amodel); QHeaderView *hv = qtv.verticalHeader(); - QVERIFY(hv->visualIndexAt(hv->length()) == -1); + QCOMPARE(hv->visualIndexAt(hv->length()), -1); hv->resizeSection(hv->count() - 1, 0); - QVERIFY(hv->visualIndexAt(hv->length()) == -1); + QCOMPARE(hv->visualIndexAt(hv->length()), -1); } void tst_QHeaderView::offsetConsistent() @@ -2307,7 +2307,7 @@ void tst_QHeaderView::offsetConsistent() hv->hideSection(sectionToHide); hv->setOffsetToSectionPosition(150); int offset2 = hv->offset(); - QVERIFY(offset1 == offset2); + QCOMPARE(offset1, offset2); // Ensure that hidden indexes (still) is considered. hv->resizeSection(sectionToHide, hv->sectionSize(200) * 2); hv->setOffsetToSectionPosition(800); @@ -2600,8 +2600,8 @@ void tst_QHeaderView::logicalIndexAtTest() //qDebug() << "logicalIndexAtTest" << check1 << check2; const int precalced_check1 = 106327; const int precalced_check2 = 29856418; - QVERIFY(precalced_check1 == check1); - QVERIFY(precalced_check2 == check2); + QCOMPARE(precalced_check1, check1); + QCOMPARE(precalced_check2, check2); const int precalced_results[] = { 1145298384, -1710423344, -650981936, 372919464, -1544372176, -426463328, 12124 }; calculateAndCheck(__LINE__, precalced_results); @@ -2628,8 +2628,8 @@ void tst_QHeaderView::visualIndexAtTest() //qDebug() << "visualIndexAtTest" << check1 << check2; const int precalced_check1 = 72665; const int precalced_check2 = 14015890; - QVERIFY(precalced_check1 == check1); - QVERIFY(precalced_check2 == check2); + QCOMPARE(precalced_check1, check1); + QCOMPARE(precalced_check2, check2); const int precalced_results[] = { 1145298384, -1710423344, -1457520212, 169223959, 557466160, -324939600, 5453 }; calculateAndCheck(__LINE__, precalced_results); diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 439eeff005..25f27cb0c7 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -804,9 +804,9 @@ void tst_QItemDelegate::dateTimeEditor() dateTimeEditor->setTime(time.addSecs(600)); widget.clearFocus(); - QVERIFY(item1->data(Qt::EditRole).userType() == QMetaType::QTime); - QVERIFY(item2->data(Qt::EditRole).userType() == QMetaType::QDate); - QVERIFY(item3->data(Qt::EditRole).userType() == QMetaType::QDateTime); + QCOMPARE(item1->data(Qt::EditRole).userType(), int(QMetaType::QTime)); + QCOMPARE(item2->data(Qt::EditRole).userType(), int(QMetaType::QDate)); + QCOMPARE(item3->data(Qt::EditRole).userType(), int(QMetaType::QDateTime)); } // A delegate where we can either enforce a certain widget or use the standard widget. @@ -901,9 +901,9 @@ void tst_QItemDelegate::dateAndTimeEditorTest2() s.setData(i1, datetime2); editor = w.fastEdit(i1); timeEdit = qobject_cast<QTimeEdit*>(editor); - QVERIFY(timeEdit == 0); + QVERIFY(!timeEdit); dateEdit = qobject_cast<QDateEdit*>(editor); - QVERIFY(dateEdit == 0); + QVERIFY(!dateEdit); dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor); QVERIFY(dateTimeEdit); QCOMPARE(dateTimeEdit->dateTime(), datetime2); @@ -1154,7 +1154,7 @@ void tst_QItemDelegate::editorEvent_data() QTest::newRow("unchecked, tristate, release") << (int)(Qt::Unchecked) - << (int)(defaultFlags | Qt::ItemIsTristate) + << (int)(defaultFlags | Qt::ItemIsAutoTristate) << true << (int)(QEvent::MouseButtonRelease) << (int)(Qt::LeftButton) @@ -1163,7 +1163,7 @@ void tst_QItemDelegate::editorEvent_data() QTest::newRow("partially checked, tristate, release") << (int)(Qt::PartiallyChecked) - << (int)(defaultFlags | Qt::ItemIsTristate) + << (int)(defaultFlags | Qt::ItemIsAutoTristate) << true << (int)(QEvent::MouseButtonRelease) << (int)(Qt::LeftButton) @@ -1172,7 +1172,7 @@ void tst_QItemDelegate::editorEvent_data() QTest::newRow("checked, tristate, release") << (int)(Qt::Checked) - << (int)(defaultFlags | Qt::ItemIsTristate) + << (int)(defaultFlags | Qt::ItemIsAutoTristate) << true << (int)(QEvent::MouseButtonRelease) << (int)(Qt::LeftButton) diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp index 3a6f1f933d..8fd86ea467 100644 --- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp +++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp @@ -483,6 +483,7 @@ void tst_QItemView::spider() view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->setModel(treeModel); view->show(); + QVERIFY(QTest::qWaitForWindowActive(view)); #if defined(Q_OS_WINCE) srandom(0); #else @@ -551,7 +552,7 @@ void tst_QItemView::visualRect() QFETCH(bool, displays); if (!displays){ - QVERIFY(view->visualRect(topIndex) == QRect()); + QCOMPARE(view->visualRect(topIndex), QRect()); return; } @@ -559,15 +560,15 @@ void tst_QItemView::visualRect() view->show(); QVERIFY(view->visualRect(topIndex) != QRect()); - QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).center())); - QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomLeft())); - QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).bottomRight())); - QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topLeft())); - QVERIFY(topIndex == view->indexAt(view->visualRect(topIndex).topRight())); + QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).center())); + QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).bottomLeft())); + QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).bottomRight())); + QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).topLeft())); + QCOMPARE(topIndex, view->indexAt(view->visualRect(topIndex).topRight())); testViews->hideIndexes(view); QModelIndex hiddenIndex = treeModel->index(1, 0); - QVERIFY(view->visualRect(hiddenIndex) == QRect()); + QCOMPARE(view->visualRect(hiddenIndex), QRect()); } void tst_QItemView::walkScreen(QAbstractItemView *view) @@ -615,7 +616,7 @@ void walkIndex(QModelIndex index, QAbstractItemView *view) if (view->indexAt(point) != index) { qDebug() << "index" << index << "visualRect" << visualRect << point << view->indexAt(point); } - QVERIFY(view->indexAt(point) == index); + QCOMPARE(view->indexAt(point), index); } } diff --git a/tests/auto/widgets/itemviews/qlistview/qlistview.pro b/tests/auto/widgets/itemviews/qlistview/qlistview.pro index 0623fc8ede..509303b62e 100644 --- a/tests/auto/widgets/itemviews/qlistview/qlistview.pro +++ b/tests/auto/widgets/itemviews/qlistview/qlistview.pro @@ -3,3 +3,4 @@ TARGET = tst_qlistview QT += widgets gui-private widgets-private core-private testlib SOURCES += tst_qlistview.cpp win32:!wince:!winrt: LIBS += -luser32 +linux*: CONFIG += insignificant_test # Crashes diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 244af1316a..fc671fdc9f 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -38,6 +38,7 @@ #include <qapplication.h> #include <qlistview.h> #include <private/qlistview_p.h> +#include <private/qcoreapplication_p.h> #include <qlistwidget.h> #include <qitemdelegate.h> #include <qstandarditemmodel.h> @@ -149,6 +150,7 @@ private slots: void testScrollToWithHidden(); void testViewOptions(); void taskQTBUG_39902_mutualScrollBars(); + void horizontalScrollingByVerticalWheelEvents(); }; // Testing get/set functions @@ -1208,7 +1210,7 @@ void tst_QListView::scrollTo() list << "Short item"; model.setStringList(list); lv.setModel(&model); - lv.setFixedSize(100, 200); + lv.setFixedSize(110, 200); topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); @@ -2423,5 +2425,52 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() QTRY_VERIFY(!view->verticalScrollBar()->isVisible()); } +void tst_QListView::horizontalScrollingByVerticalWheelEvents() +{ + QListView lv; + lv.setWrapping(true); + + TestDelegate *delegate = new TestDelegate(&lv); + delegate->m_sizeHint = QSize(100, 100); + lv.setItemDelegate(delegate); + + QtTestModel model; + model.colCount = 1; + model.rCount = 100; + + lv.setModel(&model); + + lv.resize(300, 300); + lv.show(); + QTest::qWaitForWindowExposed(&lv); + + QPoint globalPos = lv.geometry().center(); + QPoint pos = lv.viewport()->geometry().center(); + + QWheelEvent wheelDownEvent(pos, globalPos, QPoint(0, 0), QPoint(0, -120), -120, Qt::Vertical, 0, 0); + QWheelEvent wheelUpEvent(pos, globalPos, QPoint(0, 0), QPoint(0, 120), 120, Qt::Vertical, 0, 0); + QWheelEvent wheelLeftDownEvent(pos, globalPos, QPoint(0, 0), QPoint(120, -120), -120, Qt::Vertical, 0, 0); + + int hValue = lv.horizontalScrollBar()->value(); + QApplication::sendEvent(lv.viewport(), &wheelDownEvent); + QVERIFY(lv.horizontalScrollBar()->value() > hValue); + + QApplication::sendEvent(lv.viewport(), &wheelUpEvent); + QCOMPARE(lv.horizontalScrollBar()->value(), hValue); + + QApplication::sendEvent(lv.viewport(), &wheelLeftDownEvent); + QCOMPARE(lv.horizontalScrollBar()->value(), hValue); + + // ensure that vertical wheel events are not converted when vertical + // scroll bar is not visible but vertical scrolling is possible + lv.setWrapping(false); + lv.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QApplication::processEvents(); + + int vValue = lv.verticalScrollBar()->value(); + QApplication::sendEvent(lv.viewport(), &wheelDownEvent); + QVERIFY(lv.verticalScrollBar()->value() > vValue); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index dcbdbe824a..ecf72613da 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -427,9 +427,9 @@ void tst_QListWidget::currentItem() // actual test QModelIndex currentIndex = testWidget->selectionModel()->currentIndex(); if (currentIndex.isValid()) - QVERIFY(testWidget->currentItem() == testWidget->item(currentIndex.row())); + QCOMPARE(testWidget->currentItem(), testWidget->item(currentIndex.row())); else - QVERIFY(testWidget->currentItem() == (QListWidgetItem*)0); + QCOMPARE(testWidget->currentItem(), (QListWidgetItem*)0); } void tst_QListWidget::currentRow() @@ -742,7 +742,7 @@ void tst_QListWidget::selectedItems() QFETCH(IntList, selectedRows); QFETCH(IntList, expectedRows); - QVERIFY(testWidget->count() == 0); + QCOMPARE(testWidget->count(), 0); //insert items for (int i=0; i<itemCount; ++i) @@ -1159,7 +1159,7 @@ void tst_QListWidget::setData() QFETCH(int, expectedSignalCount); qRegisterMetaType<QListWidgetItem *>("QListWidgetItem*"); - QVERIFY(roles.count() == values.count()); + QCOMPARE(roles.count(), values.count()); for (int manipulateModel=0; manipulateModel<2; ++manipulateModel) { testWidget->clear(); @@ -1711,7 +1711,7 @@ void tst_QListWidget::mimeData() QVERIFY(data->hasFormat(format)); QVERIFY(data2->hasFormat(format)); - QVERIFY(data->data(format) == data2->data(format)); + QCOMPARE(data->data(format), data2->data(format)); delete data; delete data2; diff --git a/tests/auto/widgets/itemviews/qtableview/BLACKLIST b/tests/auto/widgets/itemviews/qtableview/BLACKLIST index fc231a4e30..329010a86e 100644 --- a/tests/auto/widgets/itemviews/qtableview/BLACKLIST +++ b/tests/auto/widgets/itemviews/qtableview/BLACKLIST @@ -1,2 +1,4 @@ [moveCursorBiggerJump] osx +[resizeColumnsToContents] +ubuntu-14.04 diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 75f77f8107..e5abd6bc46 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -2249,11 +2249,11 @@ void tst_QTableView::resizeColumnsToContents_data() QTest::addColumn<int>("rowHeight"); QTest::addColumn<int>("columnWidth"); - QTest::newRow("10x10 grid shown 40x40") - << 10 << 10 << false << 40 << 40 << 40 << 40; + QTest::newRow("10x10 grid not shown 60x60") + << 10 << 10 << false << 60 << 60 << 60 << 60; - QTest::newRow("10x10 grid not shown 40x40") - << 10 << 10 << true << 40 << 40 << 41 << 41; + QTest::newRow("10x10 grid shown 60x60") + << 10 << 10 << true << 60 << 60 << 61 << 61; } void tst_QTableView::resizeColumnsToContents() @@ -4051,9 +4051,9 @@ void tst_QTableView::mouseWheel() QWheelEvent verticalEvent(pos, delta, 0, 0, Qt::Vertical); QWheelEvent horizontalEvent(pos, delta, 0, 0, Qt::Horizontal); QApplication::sendEvent(view.viewport(), &horizontalEvent); - QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 10); + QVERIFY(qAbs(view.horizontalScrollBar()->value() - horizontalPositon) < 15); QApplication::sendEvent(view.viewport(), &verticalEvent); - QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 10); + QVERIFY(qAbs(view.verticalScrollBar()->value() - verticalPosition) < 15); } #endif // !QT_NO_WHEELEVENT diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index 36bc23910c..6d2b2ea964 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -196,9 +196,9 @@ void tst_QTableWidget::clearContents() { QTableWidgetItem *item = new QTableWidgetItem("test"); testWidget->setHorizontalHeaderItem(0, item); - QVERIFY(testWidget->horizontalHeaderItem(0) == item); + QCOMPARE(testWidget->horizontalHeaderItem(0), item); testWidget->clearContents(); - QVERIFY(testWidget->horizontalHeaderItem(0) == item); + QCOMPARE(testWidget->horizontalHeaderItem(0), item); } void tst_QTableWidget::clear() @@ -1559,7 +1559,7 @@ void tst_QTableWidget::mimeData() QVERIFY(data->hasFormat(format)); QVERIFY(data2->hasFormat(format)); - QVERIFY(data->data(format) == data2->data(format)); + QCOMPARE(data->data(format), data2->data(format)); delete data; delete data2; diff --git a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro index 3abd58e73d..e8406dab7b 100644 --- a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro +++ b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro @@ -4,3 +4,5 @@ QT += widgets testlib QT += widgets-private gui-private core-private SOURCES += tst_qtreeview.cpp HEADERS += ../../../../shared/fakedirmodel.h + +win32: CONFIG += insignificant_test diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 340637513c..4edf5d1a3b 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -3657,7 +3657,7 @@ void tst_QTreeView::task202039_closePersistentEditor() QVERIFY(view.indexWidget(current)); view.closePersistentEditor(current); - QVERIFY(view.indexWidget(current) == 0); + QVERIFY(!view.indexWidget(current)); //here was the bug: closing the persistent editor would not reset the state //and it was impossible to go into editinon again diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 5c881369a0..727bc41478 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -1037,7 +1037,7 @@ void tst_QTreeWidget::checkState() QCOMPARE(firstChild->checkState(0), Qt::Checked); QCOMPARE(seccondChild->checkState(0), Qt::Unchecked); - item->setFlags(item->flags()|Qt::ItemIsTristate); + item->setFlags(item->flags()|Qt::ItemIsAutoTristate); QCOMPARE(item->checkState(0), Qt::PartiallyChecked); QCOMPARE(firstChild->checkState(0), Qt::Checked); QCOMPARE(seccondChild->checkState(0), Qt::Unchecked); @@ -1586,7 +1586,7 @@ void tst_QTreeWidget::scrollToItem() testWidget->setHeaderLabels(QStringList() << "foo"); testWidget->scrollToItem(search); - QVERIFY(search->text(0) == "111"); + QCOMPARE(search->text(0), QLatin1String("111")); bar = search->parent(); QVERIFY(testWidget->isItemExpanded(bar)); @@ -2287,7 +2287,7 @@ void tst_QTreeWidget::insertExpandedItemsWithSorting() QCOMPARE(parent->childCount(), childText.count()); QVERIFY(parent->isExpanded()); } - QVERIFY(tree.model()->rowCount() == parentText.count()); + QCOMPARE(tree.model()->rowCount(), parentText.count()); // verify that the items are still expanded foreach (QTreeWidgetItem *item, items) { @@ -2659,7 +2659,7 @@ void tst_QTreeWidget::sortedIndexOfChild() tw.sortItems(0, (Qt::SortOrder)sortOrder); tw.expandAll(); - QVERIFY(itms.count() == expectedIndexes.count()); + QCOMPARE(itms.count(), expectedIndexes.count()); for (int j = 0; j < expectedIndexes.count(); ++j) QCOMPARE(top->indexOfChild(itms.at(j)), expectedIndexes.at(j)); } @@ -3155,11 +3155,11 @@ void tst_QTreeWidget::setSelectionModel() void tst_QTreeWidget::task217309() { QTreeWidgetItem item; - item.setFlags(item.flags() | Qt::ItemIsTristate); + item.setFlags(item.flags() | Qt::ItemIsAutoTristate); QTreeWidgetItem subitem1; - subitem1.setFlags(subitem1.flags() | Qt::ItemIsTristate); + subitem1.setFlags(subitem1.flags() | Qt::ItemIsAutoTristate); QTreeWidgetItem subitem2; - subitem2.setFlags(subitem2.flags() | Qt::ItemIsTristate); + subitem2.setFlags(subitem2.flags() | Qt::ItemIsAutoTristate); item.addChild(&subitem1); item.addChild(&subitem2); subitem1.setCheckState(0, Qt::Checked); @@ -3180,7 +3180,7 @@ void tst_QTreeWidget::nonEditableTristate() QTreeWidget *tree = new QTreeWidget; QTreeWidgetItem *item = new QTreeWidgetItem(); tree->insertTopLevelItem(0, item); - item->setFlags(item->flags() | Qt::ItemIsTristate); + item->setFlags(item->flags() | Qt::ItemIsAutoTristate); item->setCheckState(0, Qt::Unchecked); QTreeWidgetItem *subitem1 = new QTreeWidgetItem(item); subitem1->setCheckState(0, Qt::Unchecked); @@ -3235,7 +3235,7 @@ void tst_QTreeWidget::setCurrentItemExpandsParent() QTreeWidgetItem *i1 = new QTreeWidgetItem(&w, QStringList() << "parent"); QTreeWidgetItem *i2 = new QTreeWidgetItem(i1, QStringList() << "child"); QVERIFY(!i2->isExpanded()); - QVERIFY(w.currentItem() == 0); + QVERIFY(!w.currentItem()); w.setCurrentItem(i2); QVERIFY(!i2->isExpanded()); QCOMPARE(w.currentItem(), i2); diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp index 490f87a7ef..c52198fa2c 100644 --- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp +++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp @@ -1112,13 +1112,13 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget() delete item; item = *it; if (expecteditemIsNull) { - QVERIFY(item == 0); + QVERIFY(!item); } else { QVERIFY(item); QCOMPARE(item->text(0), expecteditemvalue); item = *itRemove; if (expectedUpdatedCurrent.isNull()) { - QVERIFY(item == 0); + QVERIFY(!item); } else { QCOMPARE(item->text(0), expectedUpdatedCurrent); } diff --git a/tests/auto/widgets/kernel/qaction/BLACKLIST b/tests/auto/widgets/kernel/qaction/BLACKLIST index f67a3c471e..1ad524fdbf 100644 --- a/tests/auto/widgets/kernel/qaction/BLACKLIST +++ b/tests/auto/widgets/kernel/qaction/BLACKLIST @@ -1,2 +1,2 @@ [setStandardKeys] -ubuntu-14.04 +linux diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 897128d40e..71b55d71ea 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -242,7 +242,7 @@ void tst_QAction::setStandardKeys() QList<QKeySequence> list; act.setShortcuts(list); act.setShortcuts(QKeySequence::Copy); - QVERIFY(act.shortcut() == act.shortcuts().first()); + QCOMPARE(act.shortcut(), act.shortcuts().first()); QList<QKeySequence> expected; const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); diff --git a/tests/auto/widgets/kernel/qactiongroup/BLACKLIST b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST new file mode 100644 index 0000000000..fdc424b6ac --- /dev/null +++ b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST @@ -0,0 +1,2 @@ +[QTBUG_14292_filesystem] +linux diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index 8ce9941238..81e5542e91 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -42,6 +42,7 @@ class tst_QActionGroup : public QObject Q_OBJECT private slots: + void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void enabledPropagation(); void visiblePropagation(); void exclusive(); @@ -223,7 +224,7 @@ void tst_QActionGroup::unCheckCurrentAction() current->setChecked(false); QVERIFY(!action1.isChecked()); QVERIFY(!action2.isChecked()); - QVERIFY(group.checkedAction() == 0); + QVERIFY(!group.checkedAction()); } diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST new file mode 100644 index 0000000000..6abb1d9988 --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST @@ -0,0 +1,4 @@ +[quitOnLastWindowClosed] +osx-10.10 +[touchEventPropagation] +xcb diff --git a/tests/auto/widgets/kernel/qapplication/qapplication.pro b/tests/auto/widgets/kernel/qapplication/qapplication.pro index 3d167827a3..5154c915cd 100644 --- a/tests/auto/widgets/kernel/qapplication/qapplication.pro +++ b/tests/auto/widgets/kernel/qapplication/qapplication.pro @@ -2,6 +2,5 @@ TEMPLATE = subdirs SUBDIRS = desktopsettingsaware modal -win32:!wince: SUBDIRS += wincmdline test.depends += $$SUBDIRS SUBDIRS += test diff --git a/tests/auto/widgets/kernel/qapplication/test/BLACKLIST b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST new file mode 100644 index 0000000000..f4a9cb6166 --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST @@ -0,0 +1,2 @@ +[quitOnLastWindowClosed] +osx-10.10 diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 84956d0a02..878136b4a0 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -62,6 +62,7 @@ #endif #include <qpa/qwindowsysteminterface.h> +#include <private/qhighdpiscaling_p.h> #include "../../../qtest-config.h" @@ -162,9 +163,6 @@ private slots: void setAttribute(); - void windowsCommandLine_data(); - void windowsCommandLine(); - void touchEventPropagation(); void qtbug_12673(); @@ -1160,7 +1158,7 @@ void tst_QApplication::sendPostedEvents() QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); QPointer<SendPostedEventsTester> p = tester; (void) app.exec(); - QVERIFY(p == 0); + QVERIFY(p.isNull()); } void tst_QApplication::thread() @@ -1178,8 +1176,8 @@ void tst_QApplication::thread() // *before* the QApplication has a thread QObject object; QObject child(&object); - QVERIFY(object.thread() == currentThread); - QVERIFY(child.thread() == currentThread); + QCOMPARE(object.thread(), currentThread); + QCOMPARE(child.thread(), currentThread); { int argc = 0; @@ -1209,8 +1207,8 @@ void tst_QApplication::thread() QVERIFY(!currentThread->isFinished()); // should still have a thread - QVERIFY(object.thread() == currentThread); - QVERIFY(child.thread() == currentThread); + QCOMPARE(object.thread(), currentThread); + QCOMPARE(child.thread(), currentThread); // do the test again, making sure that the thread is the same as // before @@ -1231,8 +1229,8 @@ void tst_QApplication::thread() QVERIFY(!currentThread->isFinished()); // should still have a thread - QVERIFY(object.thread() == currentThread); - QVERIFY(child.thread() == currentThread); + QCOMPARE(object.thread(), currentThread); + QCOMPARE(child.thread(), currentThread); QTestEventLoop::instance().enterLoop(1); } @@ -1246,8 +1244,8 @@ void tst_QApplication::thread() QVERIFY(!currentThread->isFinished()); // should still have a thread - QVERIFY(object.thread() == currentThread); - QVERIFY(child.thread() == currentThread); + QCOMPARE(object.thread(), currentThread); + QCOMPARE(child.thread(), currentThread); } class DeleteLaterWidget : public QWidget @@ -1561,9 +1559,9 @@ void tst_QApplication::focusChanged() QCOMPARE(spy.at(0).count(), 2); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &le1); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == 0); + QCOMPARE(now, &le1); + QCOMPARE(now, QApplication::focusWidget()); + QVERIFY(!old); spy.clear(); QCOMPARE(spy.count(), 0); @@ -1571,27 +1569,27 @@ void tst_QApplication::focusChanged() QCOMPARE(spy.count(), 1); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &pb1); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &le1); + QCOMPARE(now, &pb1); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &le1); spy.clear(); lb1.setFocus(); QCOMPARE(spy.count(), 1); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &lb1); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &pb1); + QCOMPARE(now, &lb1); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &pb1); spy.clear(); lb1.clearFocus(); QCOMPARE(spy.count(), 1); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == 0); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &lb1); + QVERIFY(!now); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &lb1); spy.clear(); QWidget parent2; @@ -1608,9 +1606,9 @@ void tst_QApplication::focusChanged() QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0)); now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1)); - QVERIFY(now == &le2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == 0); + QCOMPARE(now, &le2); + QCOMPARE(now, QApplication::focusWidget()); + QVERIFY(!old); spy.clear(); QTestKeyEvent tab(QTest::Press, Qt::Key_Tab, 0, 0); @@ -1632,82 +1630,82 @@ void tst_QApplication::focusChanged() tab.simulate(now); if (!tabAllControls) { - QVERIFY(spy.count() == 0); - QVERIFY(now == QApplication::focusWidget()); + QCOMPARE(spy.count(), 0); + QCOMPARE(now, QApplication::focusWidget()); } else { QVERIFY(spy.count() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &pb2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &le2); + QCOMPARE(now, &pb2); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &le2); spy.clear(); } if (!tabAllControls) { - QVERIFY(spy.count() == 0); - QVERIFY(now == QApplication::focusWidget()); + QCOMPARE(spy.count(), 0); + QCOMPARE(now, QApplication::focusWidget()); } else { tab.simulate(now); QVERIFY(spy.count() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &le2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &pb2); + QCOMPARE(now, &le2); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &pb2); spy.clear(); } if (!tabAllControls) { - QVERIFY(spy.count() == 0); - QVERIFY(now == QApplication::focusWidget()); + QCOMPARE(spy.count(), 0); + QCOMPARE(now, QApplication::focusWidget()); } else { backtab.simulate(now); QVERIFY(spy.count() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &pb2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &le2); + QCOMPARE(now, &pb2); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &le2); spy.clear(); } if (!tabAllControls) { - QVERIFY(spy.count() == 0); - QVERIFY(now == QApplication::focusWidget()); + QCOMPARE(spy.count(), 0); + QCOMPARE(now, QApplication::focusWidget()); old = &pb2; } else { backtab.simulate(now); QVERIFY(spy.count() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &le2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &pb2); + QCOMPARE(now, &le2); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &pb2); spy.clear(); } click.simulate(old); if (!(pb2.focusPolicy() & Qt::ClickFocus)) { - QVERIFY(spy.count() == 0); - QVERIFY(now == QApplication::focusWidget()); + QCOMPARE(spy.count(), 0); + QCOMPARE(now, QApplication::focusWidget()); } else { QVERIFY(spy.count() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &pb2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &le2); + QCOMPARE(now, &pb2); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &le2); spy.clear(); click.simulate(old); QVERIFY(spy.count() > 0); old = qvariant_cast<QWidget*>(spy.at(0).at(0)); now = qvariant_cast<QWidget*>(spy.at(0).at(1)); - QVERIFY(now == &le2); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &pb2); + QCOMPARE(now, &le2); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &pb2); spy.clear(); } @@ -1722,9 +1720,9 @@ void tst_QApplication::focusChanged() else old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0)); now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1)); - QVERIFY(now == &le1); - QVERIFY(now == QApplication::focusWidget()); - QVERIFY(old == &le2); + QCOMPARE(now, &le1); + QCOMPARE(now, QApplication::focusWidget()); + QCOMPARE(old, &le2); spy.clear(); } @@ -1933,39 +1931,6 @@ void tst_QApplication::setAttribute() delete w; } -void tst_QApplication::windowsCommandLine_data() -{ -#if defined(Q_OS_WIN) - QTest::addColumn<QString>("args"); - QTest::addColumn<QString>("expected"); - - QTest::newRow("hello world") - << QString("Hello \"World\"") - << QString("Hello \"World\""); - QTest::newRow("sql") - << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME") - << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME"); -#endif -} - -void tst_QApplication::windowsCommandLine() -{ -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) - QFETCH(QString, args); - QFETCH(QString, expected); - - QProcess testProcess; - const QString path = QStringLiteral("wincmdline/wincmdline"); - testProcess.start(path, QStringList(args)); - QVERIFY2(testProcess.waitForStarted(), - qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, testProcess.errorString()))); - QVERIFY(testProcess.waitForFinished(10000)); - QByteArray error = testProcess.readAllStandardError(); - QString procError(error); - QCOMPARE(procError, expected); -#endif -} - class TouchEventPropagationTestWidget : public QWidget { Q_OBJECT @@ -2038,8 +2003,10 @@ void tst_QApplication::touchEventPropagation() QVERIFY(QTest::qWaitForWindowExposed(&window)); // QPA always takes screen positions and since we map the TouchPoint back to QPA's structure first, // we must ensure there is a screen position in the TouchPoint that maps to a local 0, 0. - pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0))); - releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0))); + const QPoint deviceGlobalPos = + QHighDpi::toNativePixels(window.mapToGlobal(QPoint(0, 0)), window.windowHandle()->screen()); + pressedTouchPoints[0].setScreenPos(deviceGlobalPos); + releasedTouchPoints[0].setScreenPos(deviceGlobalPos); QWindowSystemInterface::handleTouchEvent(window.windowHandle(), 0, @@ -2092,8 +2059,10 @@ void tst_QApplication::touchEventPropagation() widget.setObjectName("2. widget"); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50))); - releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50))); + const QPoint deviceGlobalPos = + QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 50)), window.windowHandle()->screen()); + pressedTouchPoints[0].setScreenPos(deviceGlobalPos); + releasedTouchPoints[0].setScreenPos(deviceGlobalPos); QWindowSystemInterface::handleTouchEvent(window.windowHandle(), 0, diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro b/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro deleted file mode 100644 index 3e32a6798d..0000000000 --- a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += widgets -CONFIG -= app_bundle debug_and_release_target -SOURCES += main.cpp -DESTDIR = ./ - diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 35a8636f0b..aeaf1e7bf0 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -48,17 +48,8 @@ class tst_QBoxLayout : public QObject { Q_OBJECT -public: - tst_QBoxLayout(); - virtual ~tst_QBoxLayout(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - private slots: + void cleanup(); void insertSpacerItem(); void insertLayout(); void sizeHint(); @@ -120,34 +111,15 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti return QProxyStyle::pixelMetric(metric, option, widget); } - -tst_QBoxLayout::tst_QBoxLayout() -{ -} - -tst_QBoxLayout::~tst_QBoxLayout() -{ -} - -void tst_QBoxLayout::initTestCase() -{ -} - -void tst_QBoxLayout::cleanupTestCase() -{ -} - -void tst_QBoxLayout::init() -{ -} - void tst_QBoxLayout::cleanup() { + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QBoxLayout::insertSpacerItem() { - QWidget *window = new QWidget; + QWidget window; + window.setWindowTitle(QTest::currentTestFunction()); QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding); QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -157,44 +129,43 @@ void tst_QBoxLayout::insertSpacerItem() layout->addSpacerItem(spacer1); layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar")); layout->insertSpacerItem(0, spacer2); - window->setLayout(layout); + window.setLayout(layout); - QVERIFY(layout->itemAt(0) == spacer2); - QVERIFY(layout->itemAt(2) == spacer1); + QCOMPARE(layout->itemAt(0), spacer2); + QCOMPARE(layout->itemAt(2), spacer1); - window->show(); + window.show(); } void tst_QBoxLayout::insertLayout() { - QWidget *window = new QWidget; - QVBoxLayout *vbox = new QVBoxLayout(window); - QVBoxLayout *dummyParentLayout = new QVBoxLayout; + QWidget window; + QVBoxLayout *vbox = new QVBoxLayout(&window); + QScopedPointer<QVBoxLayout> dummyParentLayout(new QVBoxLayout); QHBoxLayout *subLayout = new QHBoxLayout; dummyParentLayout->addLayout(subLayout); - QCOMPARE(subLayout->parent(), dummyParentLayout); + QCOMPARE(subLayout->parent(), dummyParentLayout.data()); QCOMPARE(dummyParentLayout->count(), 1); // add subLayout to another layout QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent"); vbox->addLayout(subLayout); QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1)); - - delete dummyParentLayout; - delete window; } void tst_QBoxLayout::sizeHint() { - QWidget *window = new QWidget; + QWidget window; + window.setWindowTitle(QTest::currentTestFunction()); QHBoxLayout *lay1 = new QHBoxLayout; QHBoxLayout *lay2 = new QHBoxLayout; QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo"); lay2->addWidget(label); lay1->addLayout(lay2); - window->setLayout(lay1); - window->show(); + window.setLayout(lay1); + window.show(); + QTest::qWaitForWindowExposed(&window); label->setText("foooooooo baaaaaaar"); QSize sh = lay1->sizeHint(); QApplication::processEvents(); @@ -207,24 +178,26 @@ void tst_QBoxLayout::sizeHint() void tst_QBoxLayout::sizeConstraints() { - QWidget *window = new QWidget; + QWidget window; + window.setWindowTitle(QTest::currentTestFunction()); QHBoxLayout *lay = new QHBoxLayout; lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo")); lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar")); lay->setSizeConstraint(QLayout::SetFixedSize); - window->setLayout(lay); - window->show(); - QApplication::processEvents(); - QSize sh = window->sizeHint(); + window.setLayout(lay); + window.show(); + QTest::qWaitForWindowExposed(&window); + QSize sh = window.sizeHint(); lay->takeAt(1); - QVERIFY(sh.width() >= window->sizeHint().width() && - sh.height() >= window->sizeHint().height()); + QVERIFY(sh.width() >= window.sizeHint().width() && + sh.height() >= window.sizeHint().height()); } void tst_QBoxLayout::setGeometry() { QWidget toplevel; + toplevel.setWindowTitle(QTest::currentTestFunction()); setFrameless(&toplevel); QWidget w(&toplevel); QVBoxLayout *lay = new QVBoxLayout; @@ -247,33 +220,30 @@ void tst_QBoxLayout::setGeometry() void tst_QBoxLayout::setStyleShouldChangeSpacing() { - QWidget *window = new QWidget; - QHBoxLayout *hbox = new QHBoxLayout(window); + QWidget window; + window.setWindowTitle(QTest::currentTestFunction()); + QHBoxLayout *hbox = new QHBoxLayout(&window); QPushButton *pb1 = new QPushButton(tr("The spacing between this")); QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));; pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect); pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect); hbox->addWidget(pb1); hbox->addWidget(pb2); - CustomLayoutStyle *style1 = new CustomLayoutStyle; + QScopedPointer<CustomLayoutStyle> style1(new CustomLayoutStyle); style1->hspacing = 6; - window->setStyle(style1); - window->show(); + window.setStyle(style1.data()); + window.show(); + QTest::qWaitForWindowExposed(&window); - QTest::qWait(100); int spacing = pb2->geometry().left() - pb1->geometry().right() - 1; QCOMPARE(spacing, 6); - CustomLayoutStyle *style2 = new CustomLayoutStyle(); + QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle()); style2->hspacing = 10; - window->setStyle(style2); + window.setStyle(style2.data()); QTest::qWait(100); spacing = pb2->geometry().left() - pb1->geometry().right() - 1; QCOMPARE(spacing, 10); - - delete window; - delete style1; - delete style2; } void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected() @@ -287,6 +257,7 @@ void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected() layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding)); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); @@ -325,6 +296,7 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){ QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setObjectName("347b469225a24a0ef05150a"); QVBoxLayout layout(&widget); layout.setObjectName("ef9e2b42298e0e6420105bb"); @@ -340,6 +312,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){ void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){ QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setObjectName("fe44e5cb6c08006597126a"); QVBoxLayout layout(&widget); layout.setObjectName("cc751dd0f50f62b05a62da"); diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp index b717c1deb1..e94dfa5754 100644 --- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp +++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp @@ -73,6 +73,7 @@ void tst_QDesktopWidget::init() void tst_QDesktopWidget::cleanup() { + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QDesktopWidget::numScreens() diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 8588df7afa..e1b494c9f1 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -60,17 +60,8 @@ class tst_QFormLayout : public QObject { Q_OBJECT -public: - tst_QFormLayout(); - ~tst_QFormLayout(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - private slots: + void cleanup(); void rowCount(); void buddies(); void getItemPosition(); @@ -132,34 +123,15 @@ private slots: }; -tst_QFormLayout::tst_QFormLayout() -{ -} - -tst_QFormLayout::~tst_QFormLayout() -{ -} - -void tst_QFormLayout::initTestCase() -{ -} - -void tst_QFormLayout::cleanupTestCase() -{ -} - -void tst_QFormLayout::init() -{ -} - void tst_QFormLayout::cleanup() { + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QFormLayout::rowCount() { - QWidget *w = new QWidget; - QFormLayout *fl = new QFormLayout(w); + QWidget w; + QFormLayout *fl = new QFormLayout(&w); fl->addRow(tr("Label 1"), new QLineEdit); fl->addRow(tr("Label 2"), new QLineEdit); @@ -174,14 +146,12 @@ void tst_QFormLayout::rowCount() QCOMPARE(fl->rowCount(), 6); //TODO: remove items - - delete w; } void tst_QFormLayout::buddies() { - QWidget *w = new QWidget; - QFormLayout *fl = new QFormLayout(w); + QWidget w; + QFormLayout *fl = new QFormLayout(&w); //normal buddy case QLineEdit *le = new QLineEdit; @@ -195,23 +165,21 @@ void tst_QFormLayout::buddies() QLineEdit *le2 = new QLineEdit; fl->addRow(0, le2); QWidget *label2 = fl->labelForField(le2); - QVERIFY(label2 == 0); + QVERIFY(!label2); //no label QLineEdit *le3 = new QLineEdit; fl->addRow(le3); QWidget *label3 = fl->labelForField(le3); - QVERIFY(label3 == 0); + QVERIFY(!label3); //TODO: empty label? - - delete w; } void tst_QFormLayout::getItemPosition() { - QWidget *w = new QWidget; - QFormLayout *fl = new QFormLayout(w); + QWidget w; + QFormLayout *fl = new QFormLayout(&w); QList<QLabel*> labels; QList<QLineEdit*> fields; @@ -249,14 +217,12 @@ void tst_QFormLayout::getItemPosition() QCOMPARE(row, 2); QCOMPARE(role, QFormLayout::FieldRole); } - - delete w; } void tst_QFormLayout::wrapping() { - QWidget *w = new QWidget; - QFormLayout *fl = new QFormLayout(w); + QWidget w; + QFormLayout *fl = new QFormLayout(&w); fl->setRowWrapPolicy(QFormLayout::WrapLongRows); QLineEdit *le = new QLineEdit; @@ -264,14 +230,13 @@ void tst_QFormLayout::wrapping() le->setMinimumWidth(200); fl->addRow(lbl, le); - w->setFixedWidth(240); - w->show(); + w.setFixedWidth(240); + w.setWindowTitle(QTest::currentTestFunction()); + w.show(); QCOMPARE(le->geometry().y() > lbl->geometry().y(), true); //TODO: additional tests covering different wrapping cases - - delete w; } class CustomLayoutStyle : public QProxyStyle @@ -309,12 +274,12 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti void tst_QFormLayout::spacing() { //TODO: confirm spacing behavior - QWidget *w = new QWidget; - CustomLayoutStyle *style = new CustomLayoutStyle; + QWidget w; + QScopedPointer<CustomLayoutStyle> style(new CustomLayoutStyle); style->hspacing = 5; style->vspacing = 10; - w->setStyle(style); - QFormLayout *fl = new QFormLayout(w); + w.setStyle(style.data()); + QFormLayout *fl = new QFormLayout(&w); QCOMPARE(style->hspacing, fl->horizontalSpacing()); QCOMPARE(style->vspacing, fl->verticalSpacing()); @@ -351,12 +316,10 @@ void tst_QFormLayout::spacing() QCheckBox *checkBox = new QCheckBox(tr("Yes")); fl->setWidget(0, QFormLayout::LabelRole, label); fl->setWidget(1, QFormLayout::FieldRole, checkBox); - w->resize(200, 100); - w->show(); - QVERIFY(QTest::qWaitForWindowExposed(w)); - - delete w; - delete style; + w.resize(200, 100); + w.setWindowTitle(QTest::currentTestFunction()); + w.show(); + QVERIFY(QTest::qWaitForWindowExposed(&w)); } void tst_QFormLayout::contentsRect() @@ -366,6 +329,7 @@ void tst_QFormLayout::contentsRect() QFormLayout form; w.setLayout(&form); form.addRow("Label", new QPushButton(&w)); + w.setWindowTitle(QTest::currentTestFunction()); w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); int l, t, r, b; @@ -425,18 +389,18 @@ void tst_QFormLayout::setFormStyle() #if 0 // QT_NO_STYLE_PLASTIQUE widget.setStyle(new QPlastiqueStyle()); - QVERIFY(layout.labelAlignment() == Qt::AlignRight); + QCOMPARE(layout.labelAlignment(), Qt::AlignRight); QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop)); - QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::ExpandingFieldsGrow); - QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows); + QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::ExpandingFieldsGrow); + QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows); #endif widget.setStyle(QStyleFactory::create("windows")); - QVERIFY(layout.labelAlignment() == Qt::AlignLeft); + QCOMPARE(layout.labelAlignment(), Qt::AlignLeft); QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop)); - QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow); - QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows); + QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow); + QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows); /* can't directly create mac style or qtopia style, since this test is cross platform.. so create dummy styles that @@ -444,17 +408,17 @@ void tst_QFormLayout::setFormStyle() */ widget.setStyle(new DummyMacStyle()); - QVERIFY(layout.labelAlignment() == Qt::AlignRight); + QCOMPARE(layout.labelAlignment(), Qt::AlignRight); QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop)); - QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::FieldsStayAtSizeHint); - QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows); + QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint); + QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows); widget.setStyle(new DummyQtopiaStyle()); - QVERIFY(layout.labelAlignment() == Qt::AlignRight); + QCOMPARE(layout.labelAlignment(), Qt::AlignRight); QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop)); - QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow); - QVERIFY(layout.rowWrapPolicy() == QFormLayout::WrapLongRows); + QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow); + QCOMPARE(layout.rowWrapPolicy(), QFormLayout::WrapLongRows); } void tst_QFormLayout::setFieldGrowthPolicy() @@ -479,14 +443,14 @@ void tst_QFormLayout::setFieldGrowthPolicy() layout.activate(); if (i == 0) { - QVERIFY(fld1.width() == fld2.width()); - QVERIFY(fld2.width() == fld3.width()); + QCOMPARE(fld1.width(), fld2.width()); + QCOMPARE(fld2.width(), fld3.width()); } else if (i == 1) { - QVERIFY(fld1.width() == fld2.width()); + QCOMPARE(fld1.width(), fld2.width()); QVERIFY(fld2.width() < fld3.width()); } else { QVERIFY(fld1.width() < fld2.width()); - QVERIFY(fld2.width() == fld3.width()); + QCOMPARE(fld2.width(), fld3.width()); } } } @@ -505,33 +469,39 @@ void tst_QFormLayout::setFormAlignment() void tst_QFormLayout::addRow() { - QFormLayout layout; - QWidget w1, w2, w3; - QHBoxLayout l1, l2, l3; - QLabel lbl1, lbl2; - - QCOMPARE(layout.rowCount(), 0); - - layout.addRow(&lbl1, &w1); - layout.addRow(&lbl2, &l1); - layout.addRow("Foo:", &w2); - layout.addRow("Bar:", &l2); - layout.addRow(&w3); - layout.addRow(&l3); - - QCOMPARE(layout.rowCount(), 6); - - QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1); - QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2); - QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:"); - QVERIFY(layout.itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:"); - QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0); - QVERIFY(layout.itemAt(5, QFormLayout::LabelRole) == 0); - - QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &w1); - QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &l1); - QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &w2); - QVERIFY(layout.itemAt(3, QFormLayout::FieldRole)->layout() == &l2); + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + QWidget *w1 = new QWidget(&topLevel); + QWidget *w2 = new QWidget(&topLevel); + QWidget *w3 = new QWidget(&topLevel); + QHBoxLayout *l1 = new QHBoxLayout; + QHBoxLayout *l2 = new QHBoxLayout; + QHBoxLayout *l3 = new QHBoxLayout; + QLabel *lbl1 = new QLabel(&topLevel); + QLabel *lbl2 = new QLabel(&topLevel); + + QCOMPARE(layout->rowCount(), 0); + + layout->addRow(lbl1, w1); + layout->addRow(lbl2, l1); + layout->addRow("Foo:", w2); + layout->addRow("Bar:", l2); + layout->addRow(w3); + layout->addRow(l3); + + QCOMPARE(layout->rowCount(), 6); + + QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1); + QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2); + QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:"); + QVERIFY(layout->itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:"); + QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0); + QVERIFY(layout->itemAt(5, QFormLayout::LabelRole) == 0); + + QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == w1); + QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == l1); + QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == w2); + QVERIFY(layout->itemAt(3, QFormLayout::FieldRole)->layout() == l2); // ### should have a third role, FullRowRole? // QVERIFY(layout.itemAt(4, QFormLayout::FieldRole) == 0); // QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0); @@ -539,17 +509,24 @@ void tst_QFormLayout::addRow() void tst_QFormLayout::insertRow_QWidget_QWidget() { - QFormLayout layout; - QLabel lbl1, lbl2, lbl3, lbl4; - QLineEdit fld1, fld2, fld3, fld4; + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + QLabel *lbl1 = new QLabel(&topLevel); + QLabel *lbl2 = new QLabel(&topLevel); + QLabel *lbl3 = new QLabel(&topLevel); + QLabel *lbl4 = new QLabel(&topLevel); + QLineEdit *fld1 = new QLineEdit(&topLevel); + QLineEdit *fld2 = new QLineEdit(&topLevel); + QLineEdit *fld3 = new QLineEdit(&topLevel); + QLineEdit *fld4 = new QLineEdit(&topLevel); - layout.insertRow(0, &lbl1, &fld1); - QCOMPARE(layout.rowCount(), 1); + layout->insertRow(0, lbl1, fld1); + QCOMPARE(layout->rowCount(), 1); { int row = -1; QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); - layout.getWidgetPosition(&lbl1, &row, &role); + layout->getWidgetPosition(lbl1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::LabelRole)); } @@ -557,63 +534,68 @@ void tst_QFormLayout::insertRow_QWidget_QWidget() { int row = -1; QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); - layout.getWidgetPosition(&fld1, &row, &role); + layout->getWidgetPosition(fld1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::FieldRole)); } // check that negative values append - layout.insertRow(-2, &lbl2, &fld2); - QCOMPARE(layout.rowCount(), 2); + layout->insertRow(-2, lbl2, fld2); + QCOMPARE(layout->rowCount(), 2); - QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1); - QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2); + QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1); + QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2); // check that too large values append - layout.insertRow(100, &lbl3, &fld3); - QCOMPARE(layout.rowCount(), 3); - QCOMPARE(layout.count(), 6); + layout->insertRow(100, lbl3, fld3); + QCOMPARE(layout->rowCount(), 3); + QCOMPARE(layout->count(), 6); - layout.insertRow(3, (QWidget *)0, (QWidget *)0); - QCOMPARE(layout.rowCount(), 4); - QCOMPARE(layout.count(), 6); + layout->insertRow(3, (QWidget *)0, (QWidget *)0); + QCOMPARE(layout->rowCount(), 4); + QCOMPARE(layout->count(), 6); - layout.insertRow(4, (QWidget *)0, &fld4); - QCOMPARE(layout.rowCount(), 5); - QCOMPARE(layout.count(), 7); + layout->insertRow(4, (QWidget *)0, fld4); + QCOMPARE(layout->rowCount(), 5); + QCOMPARE(layout->count(), 7); - layout.insertRow(5, &lbl4, (QWidget *)0); - QCOMPARE(layout.rowCount(), 6); - QCOMPARE(layout.count(), 8); - - QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1); - QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2); - QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3); - QVERIFY(layout.itemAt(3, QFormLayout::LabelRole) == 0); - QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0); - QVERIFY(layout.itemAt(5, QFormLayout::LabelRole)->widget() == &lbl4); - - QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &fld1); - QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->widget() == &fld2); - QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &fld3); - QVERIFY(layout.itemAt(3, QFormLayout::FieldRole) == 0); - QVERIFY(layout.itemAt(4, QFormLayout::FieldRole)->widget() == &fld4); - QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0); + layout->insertRow(5, lbl4, (QWidget *)0); + QCOMPARE(layout->rowCount(), 6); + QCOMPARE(layout->count(), 8); + + QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1); + QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2); + QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3); + QVERIFY(layout->itemAt(3, QFormLayout::LabelRole) == 0); + QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0); + QVERIFY(layout->itemAt(5, QFormLayout::LabelRole)->widget() == lbl4); + + QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == fld1); + QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->widget() == fld2); + QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == fld3); + QVERIFY(layout->itemAt(3, QFormLayout::FieldRole) == 0); + QVERIFY(layout->itemAt(4, QFormLayout::FieldRole)->widget() == fld4); + QVERIFY(layout->itemAt(5, QFormLayout::FieldRole) == 0); } void tst_QFormLayout::insertRow_QWidget_QLayout() { - QFormLayout layout; - QLabel lbl1, lbl2, lbl3, lbl4; - QHBoxLayout fld1, fld2, fld3, fld4; + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + QLabel *lbl1 = new QLabel(&topLevel); + QLabel *lbl2 = new QLabel(&topLevel); + QLabel *lbl3 = new QLabel(&topLevel); + QHBoxLayout *fld1 = new QHBoxLayout; + QHBoxLayout *fld2 = new QHBoxLayout; + QHBoxLayout *fld3 = new QHBoxLayout; - layout.insertRow(0, &lbl1, &fld1); - QCOMPARE(layout.rowCount(), 1); + layout->insertRow(0, lbl1, fld1); + QCOMPARE(layout->rowCount(), 1); { int row = -1; QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); - layout.getWidgetPosition(&lbl1, &row, &role); + layout->getWidgetPosition(lbl1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::LabelRole)); } @@ -621,77 +603,83 @@ void tst_QFormLayout::insertRow_QWidget_QLayout() { int row = -1; QFormLayout::ItemRole role = QFormLayout::ItemRole(-123); - layout.getLayoutPosition(&fld1, &row, &role); + layout->getLayoutPosition(fld1, &row, &role); QCOMPARE(row, 0); QCOMPARE(int(role), int(QFormLayout::FieldRole)); } // check that negative values append - layout.insertRow(-2, &lbl2, &fld2); - QCOMPARE(layout.rowCount(), 2); + layout->insertRow(-2, lbl2, fld2); + QCOMPARE(layout->rowCount(), 2); - QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1); - QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2); + QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1); + QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2); // check that too large values append - layout.insertRow(100, &lbl3, &fld3); - QCOMPARE(layout.rowCount(), 3); + layout->insertRow(100, lbl3, fld3); + QCOMPARE(layout->rowCount(), 3); - QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1); - QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2); - QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3); + QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1); + QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2); + QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3); - QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->layout() == &fld1); - QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &fld2); - QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->layout() == &fld3); + QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->layout() == fld1); + QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == fld2); + QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->layout() == fld3); } void tst_QFormLayout::insertRow_QString_QWidget() { - QFormLayout layout; - QLineEdit fld1, fld2, fld3; + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + QLineEdit *fld1 = new QLineEdit(&topLevel); + QLineEdit *fld2 = new QLineEdit(&topLevel); + QLineEdit *fld3 = new QLineEdit(&topLevel); - layout.insertRow(-5, "&Name:", &fld1); - QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget()); + layout->insertRow(-5, "&Name:", fld1); + QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label1 != 0); - QVERIFY(label1->buddy() == &fld1); + QCOMPARE(label1->buddy(), fld1); - layout.insertRow(0, "&Email:", &fld2); - QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget()); + layout->insertRow(0, "&Email:", fld2); + QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label2 != 0); - QVERIFY(label2->buddy() == &fld2); + QCOMPARE(label2->buddy(), fld2); - layout.insertRow(5, "&Age:", &fld3); - QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget()); + layout->insertRow(5, "&Age:", fld3); + QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QVERIFY(label3 != 0); - QVERIFY(label3->buddy() == &fld3); + QCOMPARE(label3->buddy(), fld3); } void tst_QFormLayout::insertRow_QString_QLayout() { - QFormLayout layout; - QHBoxLayout fld1, fld2, fld3; + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); + QHBoxLayout *fld1 = new QHBoxLayout; + QHBoxLayout *fld2 = new QHBoxLayout; + QHBoxLayout *fld3 = new QHBoxLayout; - layout.insertRow(-5, "&Name:", &fld1); - QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget()); + layout->insertRow(-5, "&Name:", fld1); + QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label1 != 0); - QVERIFY(label1->buddy() == 0); + QVERIFY(!label1->buddy()); - QCOMPARE(layout.rowCount(), 1); + QCOMPARE(layout->rowCount(), 1); - layout.insertRow(0, "&Email:", &fld2); - QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget()); + layout->insertRow(0, "&Email:", fld2); + QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label2 != 0); - QVERIFY(label2->buddy() == 0); + QVERIFY(!label2->buddy()); - QCOMPARE(layout.rowCount(), 2); + QCOMPARE(layout->rowCount(), 2); - layout.insertRow(5, "&Age:", &fld3); - QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget()); + layout->insertRow(5, "&Age:", fld3); + QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QVERIFY(label3 != 0); - QVERIFY(label3->buddy() == 0); + QVERIFY(!label3->buddy()); - QCOMPARE(layout.rowCount(), 3); + QCOMPARE(layout->rowCount(), 3); } void tst_QFormLayout::insertRow_QWidget() @@ -840,39 +828,40 @@ void tst_QFormLayout::setLayout() void tst_QFormLayout::itemAt() { - QFormLayout layout; + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); - QWidget w1; - QWidget w2; - QWidget w3; - QWidget w4; - QWidget w5; - QHBoxLayout l6; + QWidget *w1 = new QWidget(&topLevel); + QWidget *w2 = new QWidget(&topLevel); + QWidget *w3 = new QWidget(&topLevel); + QWidget *w4 = new QWidget(&topLevel); + QWidget *w5 = new QWidget(&topLevel); + QHBoxLayout *l6 = new QHBoxLayout; - layout.setWidget(5, QFormLayout::LabelRole, &w1); - layout.setWidget(3, QFormLayout::FieldRole, &w2); - layout.setWidget(3, QFormLayout::LabelRole, &w3); - layout.addRow(&w4, &w5); - layout.addRow("Foo:", &l6); + layout->setWidget(5, QFormLayout::LabelRole, w1); + layout->setWidget(3, QFormLayout::FieldRole, w2); + layout->setWidget(3, QFormLayout::LabelRole, w3); + layout->addRow(w4, w5); + layout->addRow("Foo:", l6); - QCOMPARE(layout.count(), 7); + QCOMPARE(layout->count(), 7); QBitArray scoreBoard(7); for (int i = 0; i < 7; ++i) { - QLayoutItem *item = layout.itemAt(i); + QLayoutItem *item = layout->itemAt(i); QVERIFY(item != 0); - if (item->widget() == &w1) { + if (item->widget() == w1) { scoreBoard[0] = true; - } else if (item->widget() == &w2) { + } else if (item->widget() == w2) { scoreBoard[1] = true; - } else if (item->widget() == &w3) { + } else if (item->widget() == w3) { scoreBoard[2] = true; - } else if (item->widget() == &w4) { + } else if (item->widget() == w4) { scoreBoard[3] = true; - } else if (item->widget() == &w5) { + } else if (item->widget() == w5) { scoreBoard[4] = true; - } else if (item->layout() == &l6) { + } else if (item->layout() == l6) { scoreBoard[5] = true; } else if (qobject_cast<QLabel *>(item->widget())) { scoreBoard[6] = true; @@ -883,26 +872,27 @@ void tst_QFormLayout::itemAt() void tst_QFormLayout::takeAt() { - QFormLayout layout; + QWidget topLevel; + QFormLayout *layout = new QFormLayout(&topLevel); - QWidget w1; - QWidget w2; - QWidget w3; - QWidget w4; - QWidget w5; - QHBoxLayout l6; + QWidget *w1 = new QWidget(&topLevel); + QWidget *w2 = new QWidget(&topLevel); + QWidget *w3 = new QWidget(&topLevel); + QWidget *w4 = new QWidget(&topLevel); + QWidget *w5 = new QWidget(&topLevel); + QHBoxLayout *l6 = new QHBoxLayout; - layout.setWidget(5, QFormLayout::LabelRole, &w1); - layout.setWidget(3, QFormLayout::FieldRole, &w2); - layout.setWidget(3, QFormLayout::LabelRole, &w3); - layout.addRow(&w4, &w5); - layout.addRow("Foo:", &l6); + layout->setWidget(5, QFormLayout::LabelRole, w1); + layout->setWidget(3, QFormLayout::FieldRole, w2); + layout->setWidget(3, QFormLayout::LabelRole, w3); + layout->addRow(w4, w5); + layout->addRow("Foo:", l6); - QCOMPARE(layout.count(), 7); + QCOMPARE(layout->count(), 7); for (int i = 6; i >= 0; --i) { - layout.takeAt(0); - QCOMPARE(layout.count(), i); + layout->takeAt(0); + QCOMPARE(layout->count(), i); } } @@ -917,6 +907,7 @@ void tst_QFormLayout::layoutAlone() QHBoxLayout hlay; layout.setLayout(1, QFormLayout::LabelRole, &hlay); QCOMPARE(layout.count(), 2); + w.setWindowTitle(QTest::currentTestFunction()); w.show(); layout.activate(); QTest::qWait(500); diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 7f3c289fb4..1e67c675ef 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -60,18 +60,9 @@ class tst_QGridLayout : public QObject { Q_OBJECT -public: - tst_QGridLayout(); - virtual ~tst_QGridLayout(); - - -public slots: +private slots: void initTestCase(); - void cleanupTestCase(); - void init(); void cleanup(); - -private slots: void getItemPosition(); void itemAtPosition(); void badDistributionBug(); @@ -97,76 +88,72 @@ private slots: void taskQTBUG_40609_addingLayoutToItself(); void replaceWidget(); void dontCrashWhenExtendsToEnd(); - -private: - QWidget *testWidget; - QGridLayout *testLayout; - QWidget *w1; - QWidget *w2; - QWidget *w3; - QSpacerItem *sp; - - QGridLayout *m_grid; - QWidget *m_toplevel; }; - -tst_QGridLayout::tst_QGridLayout() +void tst_QGridLayout::initTestCase() { - m_grid = 0; - m_toplevel = 0; +#ifdef Q_OS_WINCE //disable magic for WindowsCE + qApp->setAutoMaximizeThreshold(-1); +#endif } -tst_QGridLayout::~tst_QGridLayout() +static inline int visibleTopLevelWidgetCount() { - delete m_toplevel; + int result= 0; + foreach (const QWidget *topLevel, QApplication::topLevelWidgets()) { + if (topLevel->isVisible()) + ++result; + } + return result; } -void tst_QGridLayout::initTestCase() +void tst_QGridLayout::cleanup() { -#ifdef Q_OS_WINCE //disable magic for WindowsCE - qApp->setAutoMaximizeThreshold(-1); -#endif - // Create the test class - testWidget = new QWidget(0); + // Verify that no visible top levels are leaked. Cannot check for + // topLevelWidgets().isEmpty() here since the data driven test layoutSpacing() + // will appear to "leak" top levels due to it creating widgets in the test data. + QCOMPARE(visibleTopLevelWidgetCount(), 0); +} - testLayout = new QGridLayout(testWidget); +class ItemTestWidget : public QWidget { +public: + ItemTestWidget(); + + QGridLayout *testLayout; + QWidget *w1; + QWidget *w2; + QWidget *w3; + QSpacerItem *sp; +}; + +ItemTestWidget::ItemTestWidget() + : testLayout(new QGridLayout(this)) + , w1(new QWidget(this)) + , w2(new QWidget(this)) + , w3(new QWidget(this)) + , sp(new QSpacerItem(4, 4)) +{ + setObjectName("testWidget"); + setWindowTitle(QTest::currentTestFunction()); - w1 = new QWidget(testWidget); w1->setPalette(QPalette(Qt::red)); testLayout->addWidget(w1, 0, 0); - w2 = new QWidget(testWidget); testLayout->addWidget(w2, 1, 1, 2, 2); w2->setPalette(QPalette(Qt::green)); - w3 = new QWidget(testWidget); testLayout->addWidget(w3, 0, 1, 1, 2); w3->setPalette(QPalette(Qt::blue)); - sp = new QSpacerItem(4, 4); testLayout->addItem(sp, 1, 3, 2, 1); - - testWidget->resize( 200, 200 ); - testWidget->show(); -} - -void tst_QGridLayout::cleanupTestCase() -{ - delete testWidget; - testWidget = 0; -} - -void tst_QGridLayout::init() -{ -} - -void tst_QGridLayout::cleanup() -{ } void tst_QGridLayout::getItemPosition() { + ItemTestWidget testWidget; + testWidget.resize(200, 200); + testWidget.show(); + QLayoutItem *item; int counter = 0; @@ -175,28 +162,28 @@ void tst_QGridLayout::getItemPosition() bool seenW3 = false; bool seenSpacer = false; - while ((item = testLayout->itemAt(counter))) { + while ((item = testWidget.testLayout->itemAt(counter))) { QWidget *w = item->widget(); int r,c,rs,cs; - testLayout->getItemPosition(counter, &r, &c, &rs, &cs); + testWidget.testLayout->getItemPosition(counter, &r, &c, &rs, &cs); // qDebug() << "item" << counter << "has" <<r << c << rs << cs; - if (w == w1) { + if (w == testWidget.w1) { QVERIFY(!seenW1); seenW1 = true; QCOMPARE(r, 0); QCOMPARE(c, 0); QCOMPARE(rs, 1); QCOMPARE(cs, 1); - } else if (w == w2) { + } else if (w == testWidget.w2) { QVERIFY(!seenW2); seenW2 = true; QCOMPARE(r, 1); QCOMPARE(c, 1); QCOMPARE(rs, 2); QCOMPARE(cs, 2); - } else if (w == w3) { + } else if (w == testWidget.w3) { QVERIFY(!seenW3); seenW3 = true; QCOMPARE(r, 0); @@ -223,16 +210,20 @@ void tst_QGridLayout::getItemPosition() void tst_QGridLayout::itemAtPosition() { + ItemTestWidget testWidget; + testWidget.resize(200, 200); + testWidget.show(); + void *table[4][5] = { - { w1, w3, w3, 0, 0 }, - { 0, w2, w2, sp, 0 }, - { 0, w2, w2, sp, 0 }, + { testWidget.w1, testWidget.w3,testWidget.w3, 0, 0 }, + { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 }, + { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 }, { 0, 0, 0, 0, 0 } }; for (int row = 0; row < 4; ++row) { for (int col = 0; col < 5; ++col) { - QLayoutItem *item = testLayout->itemAtPosition(row, col); + QLayoutItem *item = testWidget.testLayout->itemAtPosition(row, col); QVERIFY(item == table[row][col] || (item && item->widget() == table[row][col])); } @@ -860,32 +851,31 @@ void tst_QGridLayout::minMaxSize() } } QApplication::setStyle(style); - if (!m_grid) - m_grid = new QGridLayout(); - if (!m_toplevel) { - m_toplevel = new QWidget(); - setFrameless(m_toplevel); - } + QWidget toplevel; + toplevel.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); + setFrameless(&toplevel); + QGridLayout *grid = new QGridLayout; if (fixedSize.isValid()) { - m_toplevel->setFixedSize(fixedSize); + toplevel.setFixedSize(fixedSize); } else { - m_toplevel->setMinimumSize(QSize(0,0)); - m_toplevel->setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX)); + toplevel.setMinimumSize(QSize(0,0)); + toplevel.setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX)); } // Do a two-pass one using the real testdata, the other pass enables heightForWidth // on the widget, but the heightForWidth() function just return sizeHint().width() for (int pass = 0; pass < 2; ++pass) { - m_toplevel->hide(); + toplevel.hide(); QApplication::processEvents(); QTest::qWait(20); // Test if removeItem uninitializes data properly - while (m_grid->count()) { - QLayoutItem *item = m_grid->itemAt(0); - m_grid->removeItem(item); + while (grid->count()) { + QLayoutItem *item = grid->itemAt(0); + grid->removeItem(item); delete item->widget(); delete item; } - m_toplevel->setLayout(m_grid); + toplevel.setLayout(grid); // a layout with a top-level parent widget QList<QPointer<SizeHinterFrame> > sizehinters; @@ -899,29 +889,29 @@ void tst_QGridLayout::minMaxSize() QSizePolicy sp = sh->sizePolicy(); sp.setHorizontalPolicy((QSizePolicy::Policy)sizePolicy); sh->setSizePolicy(sp); - sh->setParent(m_toplevel); + sh->setParent(&toplevel); if (si.minSize.isValid()) sh->setMinimumSize(si.minSize); if (si.maxSize.isValid()) sh->setMaximumSize(si.maxSize); sizehinters.append(sh); - m_grid->addWidget(sh, i, j); + grid->addWidget(sh, i, j); } } - m_toplevel->show(); - QVERIFY(QTest::qWaitForWindowExposed(m_toplevel)); - m_toplevel->adjustSize(); + toplevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&toplevel)); + toplevel.adjustSize(); QTest::qWait(240); // wait for the implicit adjustSize // If the following fails we might have to wait longer. // If that does not help there is likely a problem with the implicit adjustSize in show() if (!fixedSize.isValid()) { // Note that this can fail if the desktop has large fonts on windows. - QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint()); + QTRY_COMPARE(toplevel.size(), toplevel.sizeHint()); } // We are relying on the order here... for (int pi = 0; pi < sizehinters.count(); ++pi) { - QPoint pt = sizehinters.at(pi)->mapTo(m_toplevel, QPoint(0, 0)); + QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0)); QCOMPARE(pt, sizeinfos.at(pi).expectedPos); } } diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index d661c074ac..4d15ac9a93 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -66,6 +66,7 @@ public: virtual ~tst_QLayout(); private slots: + void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void getSetCheck(); void geometry(); void smartMaxSize(); @@ -217,12 +218,12 @@ void tst_QLayout::setLayoutBugs() } widget.setLayout(hBoxLayout); - QVERIFY(widget.layout() == hBoxLayout); + QCOMPARE(widget.layout(), hBoxLayout); QWidget containerWidget(0); containerWidget.setLayout(widget.layout()); - QVERIFY(widget.layout() == 0); - QVERIFY(containerWidget.layout() == hBoxLayout); + QVERIFY(!widget.layout()); + QCOMPARE(containerWidget.layout(), hBoxLayout); } class MyLayout : public QLayout diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 7b9eaa418f..f206a5fe9a 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -108,6 +108,7 @@ public slots: public slots: void initTestCase(); void cleanupTestCase(); + void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); } private slots: void number_data(); diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp index 6c88f8731b..0f8c9d1c9e 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp +++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp @@ -44,6 +44,7 @@ class tst_QSizePolicy : public QObject Q_OBJECT private Q_SLOTS: + void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void qtest(); void defaultValues(); void getSetCheck_data() { data(); } @@ -51,6 +52,8 @@ private Q_SLOTS: void dataStream(); void horizontalStretch(); void verticalStretch(); + void qhash_data() { data(); } + void qhash(); private: void data() const; }; @@ -149,8 +152,6 @@ void tst_QSizePolicy::getSetCheck() QCOMPARE(sp.expandingDirections(), ed); } -#undef FETCH_TEST_DATA - static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp, int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh, Qt::Orientations orients) @@ -314,5 +315,21 @@ void tst_QSizePolicy::verticalStretch() QCOMPARE(sp.verticalStretch(), 255); } +void tst_QSizePolicy::qhash() +{ + FETCH_TEST_DATA; + Q_UNUSED(ed); + + QSizePolicy sp2(hp, vp, ct); + sp2.setVerticalStretch(vst); + sp2.setHorizontalStretch(hst); + if (hfw) sp2.setHeightForWidth(true); + if (wfh) sp2.setWidthForHeight(true); + QCOMPARE(sp, sp2); + QCOMPARE(qHash(sp), qHash(sp2)); +} + +#undef FETCH_TEST_DATA + QTEST_MAIN(tst_QSizePolicy) #include "tst_qsizepolicy.moc" diff --git a/tests/auto/widgets/kernel/qtooltip/BLACKLIST b/tests/auto/widgets/kernel/qtooltip/BLACKLIST new file mode 100644 index 0000000000..f8d062cc46 --- /dev/null +++ b/tests/auto/widgets/kernel/qtooltip/BLACKLIST @@ -0,0 +1,4 @@ +[whatsThis] +ubuntu-14.04 +[task183679] +opensuse-13.1 diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 591aa9e40f..78ccbe302a 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -12,7 +12,7 @@ osx ubuntu-14.04 osx [focusProxyAndInputMethods] -ubuntu-14.04 +linux [touchEventSynthesizedMouseEvent] ubuntu-14.04 [grabMouse] @@ -28,73 +28,17 @@ osx [stackUnder] osx [raise] -osx-10.9 +osx [widgetAt] osx [sheetOpacity] osx [resizeEvent] osx -[setWindowGeometry:100,123 200x200, flags 0] -osx-10.10 -[windowMoveResize:100,123 200x200, flags 0] -osx-10.10 -[setWindowGeometry:100,122 200x200, flags 0] -osx-10.9 -[windowMoveResize:100,122 200x200, flags 0] -osx-10.9 -[setWindowGeometry:100,100 824x564, flags 0] -osx-10.10 -[windowMoveResize:100,100 824x564, flags 0] -osx-10.10 -[setWindowGeometry:100,100 824x516, flags 0] -osx-10.10 -[windowMoveResize:100,100 824x516, flags 0] -osx-10.10 -[setWindowGeometry:100,73 200x0, flags 0] -osx-10.10 -[windowMoveResize:100,73 200x0, flags 0] -osx-10.10 -[setWindowGeometry:100,100 824x519, flags 0] -osx-10.10 -[windowMoveResize:100,100 824x519, flags 0] -osx-10.10 -[setWindowGeometry:100,100 824x518, flags 0] -osx-10.10 -[windowMoveResize:100,100 824x518, flags 0] -osx-10.10 -[setWindowGeometry:100,72 200x0, flags 0] -osx-10.9 -[windowMoveResize:100,72 200x0, flags 0] -osx-10.9 -[setWindowGeometry:100,122 952x574, flags 0] -osx-10.9 -[windowMoveResize:100,122 952x574, flags 0] -osx-10.9 -[setWindowGeometry:100,122 952x578, flags 0] -osx-10.9 -[windowMoveResize:100,122 952x578, flags 0] -osx-10.9 -[setWindowGeometry:100,122 952x576, flags 0] -osx-10.9 -[windowMoveResize:100,122 952x576, flags 0] -osx-10.9 -[setWindowGeometry:100,100 824x521, flags 0] -osx-10.10 -[windowMoveResize:100,100 824x521, flags 0] -osx-10.10 -[setWindowGeometry:100,122 952x577, flags 0] -osx-10.9 -[windowMoveResize:100,122 952x577, flags 0] -osx-10.9 -[setWindowGeometry:100,122 952x580, flags 0] -osx-10.9 -[windowMoveResize:100,122 952x580, flags 0] -osx-10.9 -[windowMoveResize:130,72 0x0, flags 0] -osx-10.9 -[windowMoveResize:130,122 0x200, flags 0] -osx-10.9 +[setWindowGeometry] +osx +[windowMoveResize] +osx [childEvents] osx [renderInvisible] @@ -114,9 +58,9 @@ osx [showMinimizedKeepsFocus] osx-10.10 [moveWindowInShowEvent:1] -osx-10.9 +osx [moveWindowInShowEvent:2] -osx-10.9 +osx [taskQTBUG_4055_sendSyntheticEnterLeave] osx [syntheticEnterLeave] @@ -128,10 +72,14 @@ osx-10.10 [hideOpaqueChildWhileHidden] osx [resizeStaticContentsChildWidget_QTBUG35282] -osx-10.9 +osx [lower] osx [setClearAndResizeMask] osx [setToolTip] osx-10.9 +[moveInResizeEvent] +ubuntu-14.04 +[moveChild:right] +osx diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index a0d94d2dc9..34bd575646 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -51,6 +51,7 @@ #include <qdesktopwidget.h> #include <private/qwidget_p.h> #include <private/qapplication_p.h> +#include <private/qhighdpiscaling_p.h> #include <qcalendarwidget.h> #include <qmainwindow.h> #include <qdockwidget.h> @@ -193,6 +194,19 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2) return s.toLocal8Bit(); } +// Compare a window position that may go through scaling in the platform plugin with fuzz. +static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz) +{ + return (p1 - p2).manhattanLength() <= fuzz; +} + +static QString msgPointMismatch(const QPoint &p1, const QPoint p2) +{ + QString result; + QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength(); + return result; +} + class tst_QWidget : public QObject { Q_OBJECT @@ -1905,8 +1919,10 @@ void tst_QWidget::windowState() widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized); QTest::qWait(100); + const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle())); QVERIFY(!(widget1.windowState() & Qt::WindowMaximized)); - QTRY_COMPARE(widget1.pos(), pos); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), + qPrintable(msgPointMismatch(widget1.pos(), pos))); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); widget1.setWindowState(Qt::WindowMinimized); @@ -1927,7 +1943,8 @@ void tst_QWidget::windowState() widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized); QTest::qWait(100); QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized))); - QTRY_COMPARE(widget1.pos(), pos); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), + qPrintable(msgPointMismatch(widget1.pos(), pos))); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); widget1.setWindowState(Qt::WindowFullScreen); @@ -1948,7 +1965,8 @@ void tst_QWidget::windowState() widget1.setWindowState(Qt::WindowNoState); QTest::qWait(100); VERIFY_STATE(Qt::WindowNoState); - QTRY_COMPARE(widget1.pos(), pos); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), + qPrintable(msgPointMismatch(widget1.pos(), pos))); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); widget1.setWindowState(Qt::WindowFullScreen); @@ -1981,7 +1999,8 @@ void tst_QWidget::windowState() QVERIFY(!(widget1.windowState() & stateMask)); QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState); - QTRY_COMPARE(widget1.pos(), pos); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz), + qPrintable(msgPointMismatch(widget1.pos(), pos))); QTRY_COMPARE(widget1.size(), size); } @@ -3079,12 +3098,12 @@ void tst_QWidget::saveRestoreGeometry() const QByteArray four("abca"); const QByteArray garbage("abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc"); - QVERIFY(widget.restoreGeometry(empty) == false); - QVERIFY(widget.restoreGeometry(one) == false); - QVERIFY(widget.restoreGeometry(two) == false); - QVERIFY(widget.restoreGeometry(three) == false); - QVERIFY(widget.restoreGeometry(four) == false); - QVERIFY(widget.restoreGeometry(garbage) == false); + QVERIFY(!widget.restoreGeometry(empty)); + QVERIFY(!widget.restoreGeometry(one)); + QVERIFY(!widget.restoreGeometry(two)); + QVERIFY(!widget.restoreGeometry(three)); + QVERIFY(!widget.restoreGeometry(four)); + QVERIFY(!widget.restoreGeometry(garbage)); QVERIFY(widget.restoreGeometry(savedGeometry)); widget.showNormal(); @@ -3354,7 +3373,7 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif - QTRY_VERIFY(QApplication::widgetAt(testPos) == w1.data()); + QTRY_COMPARE(QApplication::widgetAt(testPos), w1.data()); QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data()); } @@ -3401,24 +3420,24 @@ void tst_QWidget::testDeletionInEventHandlers() QPointer<Widget> w = new Widget; w->deleteThis = true; w->close(); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; // focusOut (crashes) //w = new Widget; //w->show(); //w->setFocus(); - //QVERIFY(qApp->focusWidget() == w); + //QCOMPARE(qApp->focusWidget(), w); //w->deleteThis = true; //w->clearFocus(); - //QVERIFY(w == 0); + //QVERIFY(w.isNull()); // key press w = new Widget; w->show(); w->deleteThis = true; QTest::keyPress(w, Qt::Key_A); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; // key release @@ -3426,7 +3445,7 @@ void tst_QWidget::testDeletionInEventHandlers() w->show(); w->deleteThis = true; QTest::keyRelease(w, Qt::Key_A); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; // mouse press @@ -3434,15 +3453,16 @@ void tst_QWidget::testDeletionInEventHandlers() w->show(); w->deleteThis = true; QTest::mousePress(w, Qt::LeftButton); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; // mouse release w = new Widget; w->show(); w->deleteThis = true; - QTest::mouseRelease(w, Qt::LeftButton); - QVERIFY(w == 0); + QMouseEvent me(QEvent::MouseButtonRelease, QPoint(1, 1), Qt::LeftButton, Qt::LeftButton, 0); + qApp->notify(w, &me); + QVERIFY(w.isNull()); delete w; // mouse double click @@ -3450,7 +3470,7 @@ void tst_QWidget::testDeletionInEventHandlers() w->show(); w->deleteThis = true; QTest::mouseDClick(w, Qt::LeftButton); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; // hide event (crashes) @@ -3458,13 +3478,13 @@ void tst_QWidget::testDeletionInEventHandlers() //w->show(); //w->deleteThis = true; //w->hide(); - //QVERIFY(w == 0); + //QVERIFY(w.isNull()); // action event w = new Widget; w->deleteThis = true; w->addAction(new QAction(w)); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; // change event @@ -3472,16 +3492,16 @@ void tst_QWidget::testDeletionInEventHandlers() w->show(); w->deleteThis = true; w->setMouseTracking(true); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; w = new Widget; w->setMouseTracking(true); w->show(); w->deleteThis = true; - QMouseEvent me(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + me = QMouseEvent(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier); QApplication::sendEvent(w, &me); - QVERIFY(w == 0); + QVERIFY(w.isNull()); delete w; } @@ -3675,6 +3695,8 @@ void tst_QWidget::optimizedResizeMove() void tst_QWidget::optimizedResize_topLevel() { + if (QHighDpiScaling::isActive()) + QSKIP("Skip due to rounding errors in the regions."); StaticWidget topLevel; topLevel.gotPaintEvent = false; topLevel.show(); @@ -3909,7 +3931,7 @@ void tst_QWidget::winIdChangeEvent() QCOMPARE(winIdBefore, winIdAfter); QCOMPARE(child.winIdChangeEventCount(), 3); // winId is set to zero during reparenting - QVERIFY(0 == child.m_winIdList[1]); + QCOMPARE(WId(0), child.m_winIdList[1]); } { @@ -3949,7 +3971,7 @@ void tst_QWidget::winIdChangeEvent() QCOMPARE(winIdBefore, winIdAfter); QCOMPARE(child.winIdChangeEventCount(), 3); // winId is set to zero during reparenting - QVERIFY(0 == child.m_winIdList[1]); + QCOMPARE(WId(0), child.m_winIdList[1]); } } @@ -4495,7 +4517,7 @@ void tst_QWidget::qobject_castInDestroyedSlot() QObject::connect(widget, SIGNAL(destroyed(QObject*)), &checker, SLOT(destroyedSlot(QObject*))); delete widget; - QVERIFY(checker.wasQWidget == true); + QVERIFY(checker.wasQWidget); } // Since X11 WindowManager operations are all async, and we have no way to know if the window @@ -6007,10 +6029,13 @@ void tst_QWidget::childEvents() expected = EventRecorder::EventList() << qMakePair(&widget, QEvent::Polish) + << qMakePair(&widget, QEvent::PlatformSurface) << qMakePair(&widget, QEvent::WinIdChange) + << qMakePair(&widget, QEvent::WindowIconChange) << qMakePair(&widget, QEvent::Move) << qMakePair(&widget, QEvent::Resize) << qMakePair(&widget, QEvent::Show) + << qMakePair(&widget, QEvent::CursorChange) << qMakePair(&widget, QEvent::ShowToParent); QVERIFY2(spy.eventList() == expected, @@ -6022,13 +6047,9 @@ void tst_QWidget::childEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) -#if defined(Q_OS_OSX) || defined(Q_OS_QNX) << qMakePair(&widget, QEvent::UpdateLater) -#endif << qMakePair(&widget, QEvent::UpdateRequest); - if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb")) - QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue); QVERIFY2(spy.eventList() == expected, EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData()); } @@ -6097,10 +6118,13 @@ void tst_QWidget::childEvents() << qMakePair(&widget, QEvent::Polish) << qMakePair(&widget, QEvent::ChildPolished) << qMakePair(&widget, QEvent::ChildPolished) + << qMakePair(&widget, QEvent::PlatformSurface) << qMakePair(&widget, QEvent::WinIdChange) + << qMakePair(&widget, QEvent::WindowIconChange) << qMakePair(&widget, QEvent::Move) << qMakePair(&widget, QEvent::Resize) << qMakePair(&widget, QEvent::Show) + << qMakePair(&widget, QEvent::CursorChange) << qMakePair(&widget, QEvent::ShowToParent); QVERIFY2(spy.eventList() == expected, @@ -6113,13 +6137,9 @@ void tst_QWidget::childEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_OS_OSX) || defined(Q_OS_QNX) << qMakePair(&widget, QEvent::UpdateLater) -#endif << qMakePair(&widget, QEvent::UpdateRequest); - if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb")) - QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue); QVERIFY2(spy.eventList() == expected, EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData()); } @@ -6190,10 +6210,13 @@ void tst_QWidget::childEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::Polish) << qMakePair(&widget, QEvent::ChildPolished) + << qMakePair(&widget, QEvent::PlatformSurface) << qMakePair(&widget, QEvent::WinIdChange) + << qMakePair(&widget, QEvent::WindowIconChange) << qMakePair(&widget, QEvent::Move) << qMakePair(&widget, QEvent::Resize) << qMakePair(&widget, QEvent::Show) + << qMakePair(&widget, QEvent::CursorChange) << qMakePair(&widget, QEvent::ShowToParent); QVERIFY2(spy.eventList() == expected, @@ -6206,13 +6229,9 @@ void tst_QWidget::childEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_OS_OSX) || defined(Q_OS_QNX) << qMakePair(&widget, QEvent::UpdateLater) -#endif << qMakePair(&widget, QEvent::UpdateRequest); - if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb")) - QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue); QVERIFY2(spy.eventList() == expected, EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData()); } @@ -8957,7 +8976,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() int numEnterEvents, numMouseMoveEvents; }; - QCursor::setPos(QPoint(0,0)); + QCursor::setPos(QPoint(0,0)); SELParent parent; parent.move(200, 200); @@ -8965,8 +8984,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() SELChild child(&parent); child.resize(200, 200); parent.show(); - QVERIFY(QTest::qWaitForWindowExposed(&parent)); - QTest::qWait(150); + QVERIFY(QTest::qWaitForWindowActive(&parent)); QCursor::setPos(child.mapToGlobal(QPoint(100, 100))); // Make sure the cursor has entered the child. @@ -9714,8 +9732,9 @@ void tst_QWidget::grabMouse() QVERIFY(QTest::qWaitForWindowActive(&w)); QStringList expectedLog; - grabber->grabMouse(); QPoint mousePos = QPoint(w.width() / 2, 10); + QTest::mouseMove(w.windowHandle(), mousePos); + grabber->grabMouse(); const int step = w.height() / 5; for ( ; mousePos.y() < w.height() ; mousePos.ry() += step) { QTest::mouseClick(w.windowHandle(), Qt::LeftButton, 0, mousePos); @@ -10385,6 +10404,9 @@ public: void tst_QWidget::keyboardModifiers() { KeyboardWidget w; + w.resize(300, 300); + w.show(); + QVERIFY(QTest::qWaitForWindowActive(&w)); QTest::mouseClick(&w, Qt::LeftButton, Qt::ControlModifier); QCOMPARE(w.m_eventCounter, 1); QCOMPARE(int(w.m_modifiers), int(Qt::ControlModifier)); @@ -10462,7 +10484,7 @@ void tst_QWidget::qmlSetParentHelper() QWidget child; QVERIFY(QAbstractDeclarativeData::setWidgetParent); QAbstractDeclarativeData::setWidgetParent(&child, &parent); - QVERIFY(child.parentWidget() == &parent); + QCOMPARE(child.parentWidget(), &parent); QAbstractDeclarativeData::setWidgetParent(&child, 0); QVERIFY(!child.parentWidget()); #else diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 148c2352a5..4bdb299213 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -97,6 +97,8 @@ private slots: void tst_resize_count(); void tst_move_count(); + + void tst_eventfilter_on_toplevel(); }; void tst_QWidget_window::initTestCase() @@ -762,5 +764,48 @@ void tst_QWidget_window::tst_move_count() QTRY_VERIFY(move.moveCount >= 1); } +class EventFilter : public QObject +{ +public: + int eventCount; + + EventFilter() + : QObject(), + eventCount(0) + { + } + + static QEvent::Type filterEventType() + { + static int type = QEvent::registerEventType(); + return static_cast<QEvent::Type>(type); + } + +protected: + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE + { + if (e->type() == filterEventType()) + ++eventCount; + + return QObject::eventFilter(o, e); + } +}; + +void tst_QWidget_window::tst_eventfilter_on_toplevel() +{ + QWidget w; + EventFilter filter; + w.installEventFilter(&filter); + w.show(); + QVERIFY(QTest::qWaitForWindowActive(&w)); + QVERIFY(w.isWindow()); + QCOMPARE(filter.eventCount, 0); + + // send an event not handled in a special way by QWidgetWindow::event, + // and check that it's received by the event filter + QCoreApplication::postEvent(w.windowHandle(), new QEvent(EventFilter::filterEventType())); + QTRY_COMPARE(filter.eventCount, 1); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp index df54d22a2f..207ce00dbf 100644 --- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp @@ -55,6 +55,8 @@ class tst_QWidgetAction : public QObject { Q_OBJECT private slots: + void initTestCase(); + void cleanup(); void defaultWidget(); void visibilityUpdate(); void customWidget(); @@ -65,6 +67,19 @@ private slots: void releaseWidgetCrash(); }; +void tst_QWidgetAction::initTestCase() +{ + // Disable menu/combo animations to prevent the alpha widgets from getting in the + // way in popup(), failing the top level leak check in cleanup(). + QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false); + QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); +} + +void tst_QWidgetAction::cleanup() +{ + QVERIFY(QApplication::topLevelWidgets().isEmpty()); +} + void tst_QWidgetAction::defaultWidget() { { @@ -123,14 +138,14 @@ void tst_QWidgetAction::defaultWidget() action->setDefaultWidget(combo); tb1.addAction(action); - QVERIFY(combo->parent() == &tb1); + QCOMPARE(combo->parent(), &tb1); qApp->processEvents(); qApp->processEvents(); QVERIFY(combo->isVisible()); // not supported, not supposed to work, hence the parent() check tb2.addAction(action); - QVERIFY(combo->parent() == &tb1); + QCOMPARE(combo->parent(), &tb1); tb2.removeAction(action); tb1.removeAction(action); @@ -141,11 +156,11 @@ void tst_QWidgetAction::defaultWidget() tb2.addAction(action); qApp->processEvents(); //the call to hide is delayd by the toolbar layout qApp->processEvents(); - QVERIFY(combo->parent() == &tb2); + QCOMPARE(combo->parent(), &tb2); QVERIFY(combo->isVisible()); tb1.addAction(action); - QVERIFY(combo->parent() == &tb2); + QCOMPARE(combo->parent(), &tb2); delete action; QVERIFY(!combo); @@ -156,17 +171,17 @@ void tst_QWidgetAction::defaultWidget() QPointer<QComboBox> combo1 = new QComboBox; a->setDefaultWidget(combo1); - QVERIFY(a->defaultWidget() == combo1); + QCOMPARE(a->defaultWidget(), combo1.data()); a->setDefaultWidget(combo1); QVERIFY(combo1); - QVERIFY(a->defaultWidget() == combo1); + QCOMPARE(a->defaultWidget(), combo1.data()); QPointer<QComboBox> combo2 = new QComboBox; QVERIFY(combo1 != combo2); a->setDefaultWidget(combo2); QVERIFY(!combo1); - QVERIFY(a->defaultWidget() == combo2); + QCOMPARE(a->defaultWidget(), combo2.data()); delete a; QVERIFY(!combo2); @@ -238,7 +253,7 @@ void tst_QWidgetAction::customWidget() combos = action->createdWidgets(); QCOMPARE(combos.count(), 2); - QVERIFY(combos.at(0) == combo1); + QCOMPARE(combos.at(0), combo1.data()); QPointer<QComboBox> combo2 = qobject_cast<QComboBox *>(combos.at(1)); QVERIFY(combo2); @@ -262,7 +277,7 @@ void tst_QWidgetAction::keepOwnership() { QToolBar *tb = new QToolBar; tb->addAction(action); - QVERIFY(combo->parent() == tb); + QCOMPARE(combo->parent(), tb); delete tb; } diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp index 8b566713f9..690ef30f71 100644 --- a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp +++ b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp @@ -84,13 +84,13 @@ void tst_QWidgetsVariant::constructor_invalid() QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:")); QVariant variant(static_cast<QVariant::Type>(typeId)); QVERIFY(!variant.isValid()); - QVERIFY(variant.userType() == QMetaType::UnknownType); + QCOMPARE(variant.userType(), int(QMetaType::UnknownType)); } { QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:")); QVariant variant(typeId, /* copy */ 0); QVERIFY(!variant.isValid()); - QVERIFY(variant.userType() == QMetaType::UnknownType); + QCOMPARE(variant.userType(), int(QMetaType::UnknownType)); } } @@ -208,7 +208,7 @@ void tst_QWidgetsVariant::qvariant_cast_QObject_derived() CustomQWidget customWidget; QWidget *widget = &customWidget; QVariant data = QVariant::fromValue(widget); - QVERIFY(data.userType() == qMetaTypeId<QWidget*>()); + QCOMPARE(data.userType(), qMetaTypeId<QWidget*>()); QCOMPARE(data.value<QObject*>(), widget); QCOMPARE(data.value<QWidget*>(), widget); diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 33427788f6..7d48ab760d 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -327,7 +327,7 @@ void tst_QWindowContainer::testDockWidget() QTest::qWait(1000); dock->setFloating(false); - QTRY_VERIFY(window->parent() == mainWindow.window()->windowHandle()); + QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle()); } QTEST_MAIN(tst_QWindowContainer) diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 7aa529d5ee..21369d4520 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -214,12 +214,12 @@ void tst_QStyle::testProxyStyle() QProxyStyle *proxyStyle = new QProxyStyle(); QVERIFY(proxyStyle->baseStyle()); QStyle *style = QStyleFactory::create("Windows"); - QVERIFY(style->proxy() == style); + QCOMPARE(style->proxy(), style); proxyStyle->setBaseStyle(style); - QVERIFY(style->proxy() == proxyStyle); - QVERIFY(style->parent() == proxyStyle); - QVERIFY(proxyStyle->baseStyle() == style); + QCOMPARE(style->proxy(), proxyStyle); + QCOMPARE(style->parent(), proxyStyle); + QCOMPARE(proxyStyle->baseStyle(), style); QVERIFY(testAllFunctions(proxyStyle)); proxyStyle->setBaseStyle(0); @@ -236,7 +236,7 @@ void tst_QStyle::testProxyStyle() QLineEdit edit; edit.setStyle(&customStyle); QVERIFY(!customStyle.parent()); - QVERIFY(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize) == 13); + QCOMPARE(edit.style()->pixelMetric(QStyle::PM_ButtonIconSize), 13); } void tst_QStyle::drawItemPixmap() diff --git a/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST new file mode 100644 index 0000000000..cf78fb47c2 --- /dev/null +++ b/tests/auto/widgets/styles/qstylesheetstyle/BLACKLIST @@ -0,0 +1,2 @@ +[hoverColors] +ubuntu-14.04 diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 25f7715e3b..a511e91e2c 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -178,45 +178,49 @@ void tst_QStyleSheetStyle::numinstances() void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet() { QPushButton w1; // widget with no stylesheet + const QColor red(Qt::red); + const QColor white(Qt::white); qApp->setStyleSheet("* { color: red; }"); - QVERIFY(COLOR(w1) == QColor("red")); + QCOMPARE(COLOR(w1), red); w1.setStyleSheet("color: white"); - QVERIFY(COLOR(w1) == QColor("white")); + QCOMPARE(COLOR(w1), white); qApp->setStyleSheet(""); - QVERIFY(COLOR(w1) == QColor("white")); + QCOMPARE(COLOR(w1), white); w1.setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); } class FriendlySpinBox : public QSpinBox { friend class tst_QStyleSheetStyle; }; void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet() { + const QColor red(Qt::red); + const QColor white(Qt::white); qApp->setStyleSheet("* { color: red; font-size: 32pt; }"); QPushButton w1; FriendlySpinBox spin; - QVERIFY(COLOR(w1) == QColor("red")); - QVERIFY(COLOR(spin) == QColor("red")); - QVERIFY(COLOR(*spin.lineEdit()) == QColor("red")); + QCOMPARE(COLOR(w1), red); + QCOMPARE(COLOR(spin), red); + QCOMPARE(COLOR(*spin.lineEdit()), red); QCOMPARE(FONTSIZE(w1), 32); QCOMPARE(FONTSIZE(spin), 32); QCOMPARE(FONTSIZE(*spin.lineEdit()), 32); w1.setStyleSheet("color: white"); - QVERIFY(COLOR(w1) == QColor("white")); - QVERIFY(COLOR(spin) == QColor("red")); - QVERIFY(COLOR(*spin.lineEdit()) == QColor("red")); + QCOMPARE(COLOR(w1), white); + QCOMPARE(COLOR(spin), red); + QCOMPARE(COLOR(*spin.lineEdit()), red); w1.setStyleSheet(""); - QVERIFY(COLOR(w1) == QColor("red")); - QVERIFY(COLOR(spin) == QColor("red")); - QVERIFY(COLOR(*spin.lineEdit()) == QColor("red")); + QCOMPARE(COLOR(w1), red); + QCOMPARE(COLOR(spin), red); + QCOMPARE(COLOR(*spin.lineEdit()), red); w1.setStyleSheet("color: white"); - QVERIFY(COLOR(w1) == QColor("white")); + QCOMPARE(COLOR(w1), white); qApp->setStyleSheet(""); - QVERIFY(COLOR(w1) == QColor("white")); - QVERIFY(COLOR(spin) == APPCOLOR(spin)); - QVERIFY(COLOR(*spin.lineEdit()) == APPCOLOR(*spin.lineEdit())); + QCOMPARE(COLOR(w1), white); + QCOMPARE(COLOR(spin), APPCOLOR(spin)); + QCOMPARE(COLOR(*spin.lineEdit()), APPCOLOR(*spin.lineEdit())); w1.setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); // QCOMPARE(FONTSIZE(w1), APPFONTSIZE(w1)); //### task 244261 QCOMPARE(FONTSIZE(spin), APPFONTSIZE(spin)); //QCOMPARE(FONTSIZE(*spin.lineEdit()), APPFONTSIZE(*spin.lineEdit())); //### task 244261 @@ -224,121 +228,135 @@ void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet() void tst_QStyleSheetStyle::applicationStyleSheet() { + const QColor red(Qt::red); + const QColor white(Qt::white); QPushButton w1; qApp->setStyleSheet("* { color: red; }"); - QVERIFY(COLOR(w1) == QColor("red")); + QCOMPARE(COLOR(w1), red); qApp->setStyleSheet("* { color: white; }"); - QVERIFY(COLOR(w1) == QColor("white")); + QCOMPARE(COLOR(w1), white); qApp->setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); qApp->setStyleSheet("* { color: red }"); - QVERIFY(COLOR(w1) == QColor("red")); + QCOMPARE(COLOR(w1), red); } void tst_QStyleSheetStyle::windowStyleSheet() { + const QColor red(Qt::red); + const QColor white(Qt::white); QPushButton w1; qApp->setStyleSheet(""); w1.setStyleSheet("* { color: red; }"); - QVERIFY(COLOR(w1) == QColor("red")); + QCOMPARE(COLOR(w1), red); w1.setStyleSheet("* { color: white; }"); - QVERIFY(COLOR(w1) == QColor("white")); + QCOMPARE(COLOR(w1), white); w1.setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); w1.setStyleSheet("* { color: red }"); - QVERIFY(COLOR(w1) == QColor("red")); + QCOMPARE(COLOR(w1), red); qApp->setStyleSheet("* { color: green }"); - QVERIFY(COLOR(w1) == QColor("red")); + QCOMPARE(COLOR(w1), red); w1.setStyleSheet(""); - QVERIFY(COLOR(w1) == QColor("green")); + QCOMPARE(COLOR(w1), QColor("green")); qApp->setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); } void tst_QStyleSheetStyle::widgetStyleSheet() { + const QColor blue(Qt::blue); + const QColor red(Qt::red); + const QColor white(Qt::white); QPushButton w1; QPushButton *pb = new QPushButton(&w1); QPushButton &w2 = *pb; qApp->setStyleSheet(""); w1.setStyleSheet("* { color: red }"); - QVERIFY(COLOR(w1) == QColor("red")); - QVERIFY(COLOR(w2) == QColor("red")); + QCOMPARE(COLOR(w1), red); + QCOMPARE(COLOR(w2), red); w2.setStyleSheet("* { color: white }"); - QVERIFY(COLOR(w2) == QColor("white")); + QCOMPARE(COLOR(w2), white); w1.setStyleSheet("* { color: blue }"); - QVERIFY(COLOR(w1) == QColor("blue")); - QVERIFY(COLOR(w2) == QColor("white")); + QCOMPARE(COLOR(w1), blue); + QCOMPARE(COLOR(w2), white); w1.setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); - QVERIFY(COLOR(w2) == QColor("white")); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); + QCOMPARE(COLOR(w2), white); w2.setStyleSheet(""); - QVERIFY(COLOR(w1) == APPCOLOR(w1)); - QVERIFY(COLOR(w2) == APPCOLOR(w2)); + QCOMPARE(COLOR(w1), APPCOLOR(w1)); + QCOMPARE(COLOR(w2), APPCOLOR(w2)); } void tst_QStyleSheetStyle::reparentWithNoChildStyleSheet() { + const QColor blue(Qt::blue); + const QColor red(Qt::red); + const QColor white(Qt::white); QPushButton p1, p2; QPushButton *pb = new QPushButton(&p1); QPushButton &c1 = *pb; // child with no stylesheet qApp->setStyleSheet(""); p1.setStyleSheet("* { color: red }"); - QVERIFY(COLOR(c1) == QColor("red")); + QCOMPARE(COLOR(c1), red); c1.setParent(&p2); - QVERIFY(COLOR(c1) == APPCOLOR(c1)); + QCOMPARE(COLOR(c1), APPCOLOR(c1)); p2.setStyleSheet("* { color: white }"); - QVERIFY(COLOR(c1) == QColor("white")); + QCOMPARE(COLOR(c1), white); c1.setParent(&p1); - QVERIFY(COLOR(c1) == QColor("red")); + QCOMPARE(COLOR(c1), red); qApp->setStyleSheet("* { color: blue }"); c1.setParent(0); - QVERIFY(COLOR(c1) == QColor("blue")); + QCOMPARE(COLOR(c1), blue); delete pb; } void tst_QStyleSheetStyle::reparentWithChildStyleSheet() { + const QColor gray("gray"); + const QColor white(Qt::white); qApp->setStyleSheet(""); QPushButton p1, p2; QPushButton *pb = new QPushButton(&p1); QPushButton &c1 = *pb; c1.setStyleSheet("background: gray"); - QVERIFY(BACKGROUND(c1) == QColor("gray")); + QCOMPARE(BACKGROUND(c1), gray); c1.setParent(&p2); - QVERIFY(BACKGROUND(c1) == QColor("gray")); + QCOMPARE(BACKGROUND(c1), gray); qApp->setStyleSheet("* { color: white }"); c1.setParent(&p1); - QVERIFY(BACKGROUND(c1) == QColor("gray")); - QVERIFY(COLOR(c1) == QColor("white")); + QCOMPARE(BACKGROUND(c1), gray); + QCOMPARE(COLOR(c1), white); } void tst_QStyleSheetStyle::repolish() { + const QColor red(Qt::red); + const QColor white(Qt::white); qApp->setStyleSheet(""); QPushButton p1; p1.setStyleSheet("color: red; background: white"); - QVERIFY(BACKGROUND(p1) == QColor("white")); + QCOMPARE(BACKGROUND(p1), white); p1.setStyleSheet("background: white"); - QVERIFY(COLOR(p1) == APPCOLOR(p1)); + QCOMPARE(COLOR(p1), APPCOLOR(p1)); p1.setStyleSheet("color: red"); - QVERIFY(COLOR(p1) == QColor("red")); - QVERIFY(BACKGROUND(p1) == APPBACKGROUND(p1)); + QCOMPARE(COLOR(p1), red); + QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1)); p1.setStyleSheet(""); - QVERIFY(COLOR(p1) == APPCOLOR(p1)); - QVERIFY(BACKGROUND(p1) == APPBACKGROUND(p1)); + QCOMPARE(COLOR(p1), APPCOLOR(p1)); + QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1)); } void tst_QStyleSheetStyle::widgetStyle() @@ -492,12 +510,12 @@ void tst_QStyleSheetStyle::appStyle() QPointer<QStyle> style2 = QStyleFactory::create("Windows"); qApp->setStyle(style1); // Basic sanity - QVERIFY(qApp->style() == style1); + QCOMPARE(QApplication::style(), style1.data()); qApp->setStyle(style2); QVERIFY(style1.isNull()); // qApp must have taken ownership and deleted it // Setting null should not crash qApp->setStyle(0); - QVERIFY(qApp->style() == style2); + QCOMPARE(QApplication::style(), style2.data()); // Set the stylesheet qApp->setStyleSheet("whatever"); @@ -505,7 +523,7 @@ void tst_QStyleSheetStyle::appStyle() QVERIFY(!sss.isNull()); QCOMPARE(sss->metaObject()->className(), "QStyleSheetStyle"); // must be our proxy now QVERIFY(!style2.isNull()); // this should exist as it is the base of the proxy - QVERIFY(sss->baseStyle() == style2); + QCOMPARE(sss->baseStyle(), style2.data()); style1 = QStyleFactory::create("Windows"); qApp->setStyle(style1); QVERIFY(style2.isNull()); // should disappear automatically @@ -514,16 +532,16 @@ void tst_QStyleSheetStyle::appStyle() // Update the stylesheet and check nothing changes sss = (QStyleSheetStyle *)qApp->style(); qApp->setStyleSheet("whatever2"); - QVERIFY(qApp->style() == sss); - QVERIFY(sss->baseStyle() == style1); + QCOMPARE(QApplication::style(), sss.data()); + QCOMPARE(sss->baseStyle(), style1.data()); // Revert the stylesheet qApp->setStyleSheet(""); QVERIFY(sss.isNull()); // should have disappeared - QVERIFY(qApp->style() == style1); + QCOMPARE(QApplication::style(), style1.data()); qApp->setStyleSheet(""); - QVERIFY(qApp->style() == style1); + QCOMPARE(QApplication::style(), style1.data()); } void tst_QStyleSheetStyle::dynamicProperty() @@ -589,21 +607,24 @@ namespace ns { void tst_QStyleSheetStyle::namespaces() { + const QColor blue(Qt::blue); + const QColor red(Qt::red); + const QColor white(Qt::white); ns::PushButton1 pb1; qApp->setStyleSheet("ns--PushButton1 { background: white }"); - QVERIFY(BACKGROUND(pb1) == QColor("white")); + QCOMPARE(BACKGROUND(pb1), white); qApp->setStyleSheet(".ns--PushButton1 { background: red }"); - QVERIFY(BACKGROUND(pb1) == QColor("red")); + QCOMPARE(BACKGROUND(pb1), red); ns::PushButton2 pb2; qApp->setStyleSheet("ns--PushButton1 { background: blue}"); - QVERIFY(BACKGROUND(pb2) == QColor("blue")); + QCOMPARE(BACKGROUND(pb2), blue); qApp->setStyleSheet("ns--PushButton2 { background: magenta }"); - QVERIFY(BACKGROUND(pb2) == QColor("magenta")); + QCOMPARE(BACKGROUND(pb2), QColor(Qt::magenta)); qApp->setStyleSheet(".PushButtonTwo { background: white; }"); - QVERIFY(BACKGROUND(pb2) == QColor("white")); + QCOMPARE(BACKGROUND(pb2), white); qApp->setStyleSheet(".PushButtonDuo { background: red; }"); - QVERIFY(BACKGROUND(pb2) == QColor("red")); + QCOMPARE(BACKGROUND(pb2), red); } void tst_QStyleSheetStyle::palettePropagation() @@ -639,8 +660,8 @@ void tst_QStyleSheetStyle::fontPropagation() int viewFontSize = FONTSIZE(*popup); cb.setStyleSheet("QComboBox { font-size: 20pt; }"); - QVERIFY(FONTSIZE(cb) == 20); - QVERIFY(FONTSIZE(*popup) == viewFontSize); + QCOMPARE(FONTSIZE(cb), 20); + QCOMPARE(FONTSIZE(*popup), viewFontSize); QGroupBox gb; QPushButton *push = new QPushButton(&gb); QPushButton &pb = *push; @@ -648,25 +669,25 @@ void tst_QStyleSheetStyle::fontPropagation() int gbFontSize = FONTSIZE(gb); gb.setStyleSheet("QGroupBox { font-size: 20pt }"); - QVERIFY(FONTSIZE(gb) == 20); + QCOMPARE(FONTSIZE(gb), 20); QVERIFY(FONTSIZE(pb) == buttonFontSize); // font does not propagate gb.setStyleSheet("QGroupBox * { font-size: 20pt; }"); - QVERIFY(FONTSIZE(gb) == gbFontSize); - QVERIFY(FONTSIZE(pb) == 20); + QCOMPARE(FONTSIZE(gb), gbFontSize); + QCOMPARE(FONTSIZE(pb), 20); QWidget window; window.setStyleSheet("* { font-size: 10pt }"); pb.setParent(&window); QCOMPARE(FONTSIZE(pb), 10); window.setStyleSheet(""); - QVERIFY(FONTSIZE(pb) == buttonFontSize); + QCOMPARE(FONTSIZE(pb), buttonFontSize); QTabWidget tw; tw.setStyleSheet("QTabWidget { font-size: 20pt; }"); - QVERIFY(FONTSIZE(tw) == 20); + QCOMPARE(FONTSIZE(tw), 20); QWidget *child = tw.findChild<QWidget *>("qt_tabwidget_tabbar"); QVERIFY2(child, "QTabWidget did not contain a widget named \"qt_tabwidget_tabbar\""); - QVERIFY(FONTSIZE(*child) == 20); + QCOMPARE(FONTSIZE(*child), 20); } void tst_QStyleSheetStyle::onWidgetDestroyed() @@ -1009,6 +1030,8 @@ void tst_QStyleSheetStyle::tabAlignement() void tst_QStyleSheetStyle::attributesList() { + const QColor blue(Qt::blue); + const QColor red(Qt::red); QWidget w; QPushButton *p1=new QPushButton(&w); QPushButton *p2=new QPushButton(&w); @@ -1019,10 +1042,10 @@ void tst_QStyleSheetStyle::attributesList() p3->setProperty("prop", QStringList() << "foo" << "bar"); w.setStyleSheet(" QPushButton{ background-color:blue; } QPushButton[prop~=red] { background-color:red; }"); - QCOMPARE(BACKGROUND(*p1) , QColor("red")); - QCOMPARE(BACKGROUND(*p2) , QColor("red")); - QCOMPARE(BACKGROUND(*p3) , QColor("blue")); - QCOMPARE(BACKGROUND(*p4) , QColor("blue")); + QCOMPARE(BACKGROUND(*p1) , red); + QCOMPARE(BACKGROUND(*p2) , red); + QCOMPARE(BACKGROUND(*p3) , blue); + QCOMPARE(BACKGROUND(*p4) , blue); } void tst_QStyleSheetStyle::minmaxSizes() @@ -1065,6 +1088,7 @@ void tst_QStyleSheetStyle::minmaxSizes() void tst_QStyleSheetStyle::task206238_twice() { + const QColor red(Qt::red); QMainWindow w; QTabWidget* tw = new QTabWidget; tw->addTab(new QLabel("foo"), "test"); @@ -1073,12 +1097,12 @@ void tst_QStyleSheetStyle::task206238_twice() centerOnScreen(&w); w.show(); QTest::qWait(20); - QCOMPARE(BACKGROUND(w) , QColor("red")); - QCOMPARE(BACKGROUND(*tw), QColor("red")); + QCOMPARE(BACKGROUND(w) , red); + QCOMPARE(BACKGROUND(*tw), red); w.setStyleSheet("background: red;"); QTest::qWait(20); - QCOMPARE(BACKGROUND(w) , QColor("red")); - QCOMPARE(BACKGROUND(*tw), QColor("red")); + QCOMPARE(BACKGROUND(w) , red); + QCOMPARE(BACKGROUND(*tw), red); } void tst_QStyleSheetStyle::transparent() diff --git a/tests/auto/widgets/util/qcompleter/BLACKLIST b/tests/auto/widgets/util/qcompleter/BLACKLIST index ffbcc94a1f..fdc424b6ac 100644 --- a/tests/auto/widgets/util/qcompleter/BLACKLIST +++ b/tests/auto/widgets/util/qcompleter/BLACKLIST @@ -1,2 +1,2 @@ [QTBUG_14292_filesystem] -ubuntu-14.04 +linux diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index dbfeda8104..e8ac9aa5d2 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1043,9 +1043,9 @@ void tst_QCompleter::setters() QAbstractItemModel *oldModel = completer->model(); completer->setModel(dirModel); QVERIFY(completer->popup()->model() != oldModel); - QVERIFY(completer->popup()->model() == completer->completionModel()); + QCOMPARE(completer->popup()->model(), completer->completionModel()); completer->setPopup(new QListView); - QVERIFY(completer->popup()->model() == completer->completionModel()); + QCOMPARE(completer->popup()->model(), completer->completionModel()); completer->setModel(new QStringListModel(completer)); QVERIFY(dirModel == 0); // must have been deleted @@ -1062,7 +1062,7 @@ void tst_QCompleter::modelDeletion() QStringListModel *listModel = new QStringListModel(list); completer->setCompletionPrefix("i"); completer->setModel(listModel); - QVERIFY(completer->completionCount() == 3); + QCOMPARE(completer->completionCount(), 3); QScopedPointer<QListView> view(new QListView); view->setModel(completer->completionModel()); delete listModel; @@ -1070,8 +1070,8 @@ void tst_QCompleter::modelDeletion() view->show(); qApp->processEvents(); view.reset(); - QVERIFY(completer->completionCount() == 0); - QVERIFY(completer->currentRow() == -1); + QCOMPARE(completer->completionCount(), 0); + QCOMPARE(completer->currentRow(), -1); } void tst_QCompleter::multipleWidgets() @@ -1098,7 +1098,7 @@ void tst_QCompleter::multipleWidgets() window.activateWindow(); QApplication::setActiveWindow(&window); QTest::qWait(50); - QTRY_VERIFY(qApp->focusWidget() == comboBox); + QTRY_COMPARE(QApplication::focusWidget(), comboBox); comboBox->lineEdit()->setText("it"); QCOMPARE(comboBox->currentText(), QString("it")); // should not complete with setText QTest::keyPress(comboBox, 'e'); @@ -1111,7 +1111,7 @@ void tst_QCompleter::multipleWidgets() lineEdit->show(); lineEdit->setFocus(); QTest::qWait(50); - QTRY_VERIFY(qApp->focusWidget() == lineEdit); + QTRY_COMPARE(QApplication::focusWidget(), lineEdit); lineEdit->setText("it"); QCOMPARE(lineEdit->text(), QString("it")); // should not completer with setText QCOMPARE(comboBox->currentText(), QString("")); // combo box text must not change! @@ -1148,13 +1148,13 @@ void tst_QCompleter::focusIn() lineEdit2->show(); comboBox->setFocus(); - QTRY_VERIFY(completer.widget() == comboBox); + QTRY_COMPARE(completer.widget(), comboBox); lineEdit->setFocus(); - QTRY_VERIFY(completer.widget() == lineEdit); + QTRY_COMPARE(completer.widget(), lineEdit); comboBox->setFocus(); - QTRY_VERIFY(completer.widget() == comboBox); + QTRY_COMPARE(completer.widget(), comboBox); lineEdit2->setFocus(); - QTRY_VERIFY(completer.widget() == comboBox); + QTRY_COMPARE(completer.widget(), comboBox); } void tst_QCompleter::dynamicSortOrder() diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index d2e88a1656..58a655321c 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -297,7 +297,7 @@ void tst_QScroller::staticScrollers() QScrollerProperties sp2 = QScroller::scroller(o2)->scrollerProperties(); // default properties should be the same - QVERIFY(sp1 == sp2); + QCOMPARE(sp1, sp2); QCOMPARE(QScroller::scroller(o1)->scrollerProperties(), sp1); diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp index 7ea63911ae..05511a17a1 100644 --- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp +++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp @@ -136,7 +136,7 @@ void tst_QSystemTrayIcon::lastWindowClosed() QTimer::singleShot(2500, &window, SLOT(close())); QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails qApp->exec(); - QVERIFY(spy.count() == 1); + QCOMPARE(spy.count(), 1); } QTEST_MAIN(tst_QSystemTrayIcon) diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp index a633ba0cf0..43d6912c6e 100644 --- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp @@ -283,9 +283,9 @@ void tst_QAbstractButton::setAutoRepeat() QTest::qWait(REPEAT_DELAY); QVERIFY(testWidget->isDown()); QTest::keyRelease(testWidget, Qt::Key_Space); - QVERIFY(release_count == press_count); - QVERIFY(toggle_count == 0); - QVERIFY(press_count == click_count); + QCOMPARE(release_count, press_count); + QCOMPARE(toggle_count, uint(0)); + QCOMPARE(press_count, click_count); QVERIFY(click_count > 1); break; case 4: diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index df69063540..5dec6224ca 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -324,13 +324,13 @@ void tst_QButtonGroup::testSignals() int expectedId = -2; - QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId); + QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId); QCOMPARE(pressedSpy.count(), 1); QCOMPARE(pressedIdSpy.count(), 1); - QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == expectedId); + QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId); QCOMPARE(releasedSpy.count(), 1); QCOMPARE(releasedIdSpy.count(), 1); - QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == expectedId); + QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId); clickedSpy.clear(); clickedIdSpy.clear(); @@ -344,13 +344,13 @@ void tst_QButtonGroup::testSignals() QCOMPARE(clickedSpy.count(), 1); QCOMPARE(clickedIdSpy.count(), 1); - QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == 23); + QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23); QCOMPARE(pressedSpy.count(), 1); QCOMPARE(pressedIdSpy.count(), 1); - QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == 23); + QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23); QCOMPARE(releasedSpy.count(), 1); QCOMPARE(releasedIdSpy.count(), 1); - QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == 23); + QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23); QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool))); @@ -427,25 +427,25 @@ void tst_QButtonGroup::checkedButton() buttons.addButton(&pb1); buttons.addButton(&pb2, 23); - QVERIFY(buttons.checkedButton() == 0); + QVERIFY(!buttons.checkedButton()); pb1.setChecked(true); - QVERIFY(buttons.checkedButton() == &pb1); + QCOMPARE(buttons.checkedButton(), &pb1); pb2.setChecked(true); - QVERIFY(buttons.checkedButton() == &pb2); + QCOMPARE(buttons.checkedButton(), &pb2); pb2.setChecked(false); - QVERIFY(buttons.checkedButton() == &pb1); + QCOMPARE(buttons.checkedButton(), &pb1); pb1.setChecked(false); - QVERIFY(buttons.checkedButton() == 0); + QVERIFY(!buttons.checkedButton()); buttons.setExclusive(true); - QVERIFY(buttons.checkedButton() == 0); + QVERIFY(!buttons.checkedButton()); pb1.setChecked(true); - QVERIFY(buttons.checkedButton() == &pb1); + QCOMPARE(buttons.checkedButton(), &pb1); pb2.setChecked(true); - QVERIFY(buttons.checkedButton() == &pb2); + QCOMPARE(buttons.checkedButton(), &pb2); // checked button cannot be unchecked pb2.setChecked(false); - QVERIFY(buttons.checkedButton() == &pb2); + QCOMPARE(buttons.checkedButton(), &pb2); } class task209485_ButtonDeleter : public QObject @@ -523,9 +523,9 @@ void tst_QButtonGroup::autoIncrementId() radio1->setChecked(true); - QVERIFY(buttons->id(radio1) == -2); - QVERIFY(buttons->id(radio2) == -3); - QVERIFY(buttons->id(radio3) == -4); + QCOMPARE(buttons->id(radio1), -2); + QCOMPARE(buttons->id(radio2), -3); + QCOMPARE(buttons->id(radio3), -4); dlg.show(); } diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp index e76e11fc67..5696382fab 100644 --- a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp +++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp @@ -83,9 +83,7 @@ private: uint press_count; uint release_count; int cur_state; - uint tmp; QCheckBox *testWidget; - uint tmp2; }; tst_QCheckBox::tst_QCheckBox() @@ -326,7 +324,7 @@ void tst_QCheckBox::isToggleButton() void tst_QCheckBox::foregroundRole() { - QVERIFY(testWidget->foregroundRole() == QPalette::WindowText); + QCOMPARE(testWidget->foregroundRole(), QPalette::WindowText); } void tst_QCheckBox::minimumSizeHint() diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 7824172812..09129f0676 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -164,6 +164,7 @@ private slots: void keyboardSelection(); void setCustomModelAndView(); void updateDelegateOnEditableChange(); + void respectChangedOwnershipOfItemView(); void task_QTBUG_39088_inputMethodHints(); }; @@ -453,7 +454,7 @@ void tst_QComboBox::setPalette() for (int i = 0; i < comboChildren.size(); ++i) { QObject *o = comboChildren.at(i); if (o->isWidgetType()) { - QVERIFY(((QWidget*)o)->palette() == pal); + QCOMPARE(((QWidget*)o)->palette(), pal); } } @@ -462,12 +463,12 @@ void tst_QComboBox::setPalette() //Setting it on the lineedit should be separate form the combo testWidget->lineEdit()->setPalette(pal); QVERIFY(testWidget->palette() != pal); - QVERIFY(testWidget->lineEdit()->palette() == pal); + QCOMPARE(testWidget->lineEdit()->palette(), pal); pal.setColor(QPalette::Base, Qt::green); //Setting it on the combo directly should override lineedit testWidget->setPalette(pal); - QVERIFY(testWidget->palette() == pal); - QVERIFY(testWidget->lineEdit()->palette() == pal); + QCOMPARE(testWidget->palette(), pal); + QCOMPARE(testWidget->lineEdit()->palette(), pal); } void tst_QComboBox::sizeAdjustPolicy() @@ -478,7 +479,7 @@ void tst_QComboBox::sizeAdjustPolicy() QComboBox *testWidget = topLevel.comboBox(); // test that adding new items will not change the sizehint for AdjustToContentsOnFirstShow QVERIFY(!testWidget->count()); - QVERIFY(testWidget->sizeAdjustPolicy() == QComboBox::AdjustToContentsOnFirstShow); + QCOMPARE(testWidget->sizeAdjustPolicy(), QComboBox::AdjustToContentsOnFirstShow); QVERIFY(testWidget->isVisible()); QSize firstShow = testWidget->sizeHint(); testWidget->addItem("normal item"); @@ -751,7 +752,7 @@ void tst_QComboBox::insertPolicy() // First check that there is the right number of entries, or // we may unwittingly pass - QVERIFY((int)result.count() == testWidget->count()); + QCOMPARE((int)result.count(), testWidget->count()); // No need to compare if there are no strings to compare if (result.count() > 0) { @@ -796,7 +797,7 @@ void tst_QComboBox::virtualAutocompletion() QApplication::sendEvent(testWidget, &kr1); qApp->processEvents(); // Process events to trigger autocompletion - QTRY_VERIFY(testWidget->currentIndex() == 1); + QTRY_COMPARE(testWidget->currentIndex(), 1); QKeyEvent kp2(QEvent::KeyPress, Qt::Key_O, 0, "o"); QKeyEvent kr2(QEvent::KeyRelease, Qt::Key_O, 0, "o"); @@ -845,7 +846,7 @@ void tst_QComboBox::autoCompletionCaseSensitivity() testWidget->clearEditText(); QSignalSpy spyReturn(testWidget, SIGNAL(activated(int))); testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive); - QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive); + QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseInsensitive); QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); @@ -879,7 +880,7 @@ void tst_QComboBox::autoCompletionCaseSensitivity() // case sensitive testWidget->clearEditText(); testWidget->setAutoCompletionCaseSensitivity(Qt::CaseSensitive); - QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseSensitive); + QCOMPARE(testWidget->autoCompletionCaseSensitivity(), Qt::CaseSensitive); QTest::keyClick(testWidget->lineEdit(), Qt::Key_A); qApp->processEvents(); QCOMPARE(testWidget->currentText(), QString("aww")); @@ -1377,7 +1378,7 @@ void tst_QComboBox::textpixmapdata() QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey()); QPixmap original = icons.at(i).pixmap(1024); QPixmap pixmap = icon.pixmap(1024); - QVERIFY(pixmap.toImage() == original.toImage()); + QCOMPARE(pixmap.toImage(), original.toImage()); } for (int i = 0; i<text.count(); ++i) { @@ -1611,7 +1612,7 @@ void tst_QComboBox::setModel() QCOMPARE(box.currentIndex(), 0); QVERIFY(box.model() != oldModel); QVERIFY(box.rootModelIndex() != rootModelIndex); - QVERIFY(box.rootModelIndex() == QModelIndex()); + QCOMPARE(box.rootModelIndex(), QModelIndex()); // check that setting the very same model doesn't move the current item box.setCurrentIndex(1); @@ -3178,5 +3179,27 @@ void tst_QComboBox::task_QTBUG_39088_inputMethodHints() QCOMPARE(box.lineEdit()->inputMethodHints(), Qt::ImhNoPredictiveText); } +void tst_QComboBox::respectChangedOwnershipOfItemView() +{ + QComboBox box1; + QComboBox box2; + QTableView *v1 = new QTableView; + box1.setView(v1); + + QSignalSpy spy1(v1, SIGNAL(destroyed())); + box2.setView(v1); // Ownership should now be transferred to box2 + + + QTableView *v2 = new QTableView(&box1); + box1.setView(v2); // Here we do not expect v1 to be deleted + QApplication::processEvents(); + QCOMPARE(spy1.count(), 0); + + QSignalSpy spy2(v2, SIGNAL(destroyed())); + box1.setView(v1); + QCOMPARE(spy2.count(), 1); +} + + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index d8cb7c01ad..a57553097a 100644 --- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -98,11 +98,11 @@ void tst_QCommandLinkButton::getSetCheck() QString text("mytext"); QVERIFY(obj1.description().isEmpty()); obj1.setDescription(text); - QVERIFY(obj1.description() == text); + QCOMPARE(obj1.description(), text); QVERIFY(obj1.text().isEmpty()); obj1.setText(text); - QVERIFY(obj1.text() == text); + QCOMPARE(obj1.text(), text); QMenu *var1 = new QMenu; obj1.setMenu(var1); @@ -236,8 +236,8 @@ void tst_QCommandLinkButton::setAutoRepeat() QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QTest::keyRelease( testWidget, Qt::Key_Space ); - QVERIFY(press_count == release_count); - QVERIFY(release_count == click_count); + QCOMPARE(press_count, release_count); + QCOMPARE(release_count, click_count); QVERIFY(press_count > 1); // #### shouldn't I check here to see if multiple signals have been fired??? diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index c9ae60dd76..e8a0916dc5 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -2416,7 +2416,7 @@ void tst_QDateTimeEdit::displayedSections() QFETCH(uint, section); testWidget->setDisplayFormat(format); - QVERIFY((QDateTimeEdit::Section)section == testWidget->displayedSections()); + QCOMPARE(QDateTimeEdit::Sections(section), testWidget->displayedSections()); } void tst_QDateTimeEdit::currentSection_data() @@ -2460,7 +2460,7 @@ void tst_QDateTimeEdit::currentSection() if ((QDateTimeEdit::Section)section == QDateTimeEdit::NoSection) testWidget->setCurrentSection(QDateTimeEdit::YearSection); // Ensure it's not reset (see above) testWidget->setCurrentSection((QDateTimeEdit::Section)section); - QVERIFY((QDateTimeEdit::Section)currentSection == testWidget->currentSection()); + QCOMPARE((QDateTimeEdit::Section)currentSection, testWidget->currentSection()); } void tst_QDateTimeEdit::readOnly() @@ -2825,7 +2825,7 @@ void tst_QDateTimeEdit::calendarPopup() rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &timeEdit); QTest::mouseClick(&timeEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2)); QWidget *wid2 = timeEdit.findChild<QWidget *>("qt_datetimedit_calendar"); - QVERIFY(wid2 == 0); + QVERIFY(!wid2); timeEdit.hide(); @@ -2839,7 +2839,7 @@ void tst_QDateTimeEdit::calendarPopup() rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &dateEdit); QTest::mouseClick(&dateEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2)); QWidget *wid3 = dateEdit.findChild<QWidget *>("qt_datetimedit_calendar"); - QVERIFY(wid3 == 0); + QVERIFY(!wid3); dateEdit.hide(); } diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index 38b473e5ae..32412afcd5 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -132,12 +132,12 @@ void tst_QDialogButtonBox::layoutReuse() QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok); QPointer<QLayout> layout = box->layout(); box->setCenterButtons(!box->centerButtons()); - QVERIFY(layout == box->layout()); + QCOMPARE(layout.data(), box->layout()); QEvent event(QEvent::StyleChange); QApplication::sendEvent(box, &event); - QVERIFY(layout == box->layout()); + QCOMPARE(layout.data(), box->layout()); box->setOrientation(box->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal); - QVERIFY(layout == 0); + QVERIFY(layout.isNull()); QVERIFY(layout != box->layout()); delete box; } diff --git a/tests/auto/widgets/widgets/qdockwidget/BLACKLIST b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST new file mode 100644 index 0000000000..60adfb9f4b --- /dev/null +++ b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST @@ -0,0 +1,2 @@ +[restoreDockWidget] +ubuntu-14.04 diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 2bbc2e05b7..82832bced1 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -120,7 +120,7 @@ void tst_QDockWidget::widget() { { QDockWidget dw; - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); } { @@ -130,32 +130,32 @@ void tst_QDockWidget::widget() dw.setWidget(w1); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w1); + QCOMPARE(dw.widget(), w1); QCOMPARE(w1->parentWidget(), (QWidget*)&dw); dw.setWidget(0); - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); dw.setWidget(w2); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w2); + QCOMPARE(dw.widget(), w2); QCOMPARE(w2->parentWidget(), (QWidget*)&dw); dw.setWidget(0); - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); dw.setWidget(w1); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w1); + QCOMPARE(dw.widget(), w1); QCOMPARE(w1->parentWidget(), (QWidget*)&dw); dw.setWidget(w2); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w2); + QCOMPARE(dw.widget(), w2); QCOMPARE(w2->parentWidget(), (QWidget*)&dw); dw.setWidget(0); - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); } { @@ -165,37 +165,37 @@ void tst_QDockWidget::widget() dw.setWidget(w1); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w1); + QCOMPARE(dw.widget(), w1); QCOMPARE(w1->parentWidget(), (QWidget*)&dw); w1->setParent(0); - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); dw.setWidget(w2); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w2); + QCOMPARE(dw.widget(), w2); QCOMPARE(w2->parentWidget(), (QWidget*)&dw); w2->setParent(0); - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); dw.setWidget(w1); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w1); + QCOMPARE(dw.widget(), w1); QCOMPARE(w1->parentWidget(), (QWidget*)&dw); dw.setWidget(w2); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w2); + QCOMPARE(dw.widget(), w2); QCOMPARE(w2->parentWidget(), (QWidget*)&dw); w1->setParent(0); QVERIFY(dw.widget() != 0); - QVERIFY(dw.widget() == w2); + QCOMPARE(dw.widget(), w2); QCOMPARE(w2->parentWidget(), (QWidget*)&dw); w2->setParent(0); - QVERIFY(dw.widget() == 0); + QVERIFY(!dw.widget()); delete w1; delete w2; } diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png Binary files differindex a75833c89c..00447760ec 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_raised_2_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_0_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_1_2.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_0.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_1.png diff --git a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png Binary files differindex d656ac56f0..4c809a2c80 100644 --- a/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png +++ b/tests/auto/widgets/widgets/qframe/images/winpanel_sunken_2_2.png diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index 1d995b5eea..789a280e80 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -111,7 +111,6 @@ private: QLabel *testWidget; QPointer<Widget> test_box; QPointer<QLabel> test_label; - QLineEdit *test_edit; }; // Testing get/set functions @@ -196,7 +195,7 @@ void tst_QLabel::setBuddy() test_box = new Widget; test_label= new QLabel( test_box ); test_label->setText( "&Test with a buddy" ); - test_edit = new QLineEdit( test_box ); + QWidget *test_edit = new QLineEdit( test_box ); QVBoxLayout *layout = new QVBoxLayout(test_box); layout->addWidget(test_label); layout->addWidget(test_edit); @@ -322,7 +321,7 @@ void tst_QLabel::eventPropagation() test_label->setText(text); test_box->events.clear(); test_label->setTextInteractionFlags(Qt::TextInteractionFlags(textInteractionFlags)); - QVERIFY(int(test_label->focusPolicy()) == focusPolicy); + QCOMPARE(int(test_label->focusPolicy()), focusPolicy); QTest::mousePress(test_label, Qt::LeftButton); QVERIFY(test_box->events.contains(QEvent::MouseButtonPress) == propagation); // should have propagated! } diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index e6d63ee4d9..a41d80d7dd 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -1669,7 +1669,7 @@ void tst_QLineEdit::displayText() testWidget->setEchoMode(mode); testWidget->setText(insertString); QCOMPARE(testWidget->displayText(), expectedString); - QVERIFY(testWidget->echoMode() == mode); + QCOMPARE(testWidget->echoMode(), mode); } void tst_QLineEdit::passwordEchoOnEdit() @@ -1839,9 +1839,9 @@ void tst_QLineEdit::maxLength() // Make sure that the textChanged is not emitted unless the text is actually changed if (insertString == expectedString) { - QVERIFY(changed_count == 0); + QCOMPARE(changed_count, 0); } else { - QVERIFY(changed_count == 1); + QCOMPARE(changed_count, 1); } } @@ -1962,7 +1962,7 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo void tst_QLineEdit::cursorPosition() { QLineEdit *testWidget = ensureTestWidget(); - QVERIFY(testWidget->cursorPosition() == 0); + QCOMPARE(testWidget->cursorPosition(), 0); // start with a basic text QTest::keyClicks(testWidget, "The"); @@ -2208,7 +2208,7 @@ void tst_QLineEdit::selectedText() testWidget->cursorForward(true, 9); QVERIFY(testWidget->hasSelectedText()); QCOMPARE(testWidget->selectedText(), QString("Abc defg ")); - QVERIFY(selection_count == 1); + QCOMPARE(selection_count, 1); // reset selection testWidget->home(false); @@ -2264,19 +2264,19 @@ void tst_QLineEdit::textChangedAndTextEdited() QLineEdit *testWidget = ensureTestWidget(); QTest::keyClick(testWidget, Qt::Key_A); QCOMPARE(changed_count, 1); - QVERIFY(edited_count == changed_count); + QCOMPARE(edited_count, changed_count); QTest::keyClick(testWidget, 'b'); QCOMPARE(changed_count, 2); - QVERIFY(edited_count == changed_count); + QCOMPARE(edited_count, changed_count); QTest::keyClick(testWidget, 'c'); QCOMPARE(changed_count, 3); - QVERIFY(edited_count == changed_count); + QCOMPARE(edited_count, changed_count); QTest::keyClick(testWidget, ' '); QCOMPARE(changed_count, 4); - QVERIFY(edited_count == changed_count); + QCOMPARE(edited_count, changed_count); QTest::keyClick(testWidget, 'd'); QCOMPARE(changed_count, 5); - QVERIFY(edited_count == changed_count); + QCOMPARE(edited_count, changed_count); changed_count = 0; edited_count = 0; @@ -2322,27 +2322,27 @@ void tst_QLineEdit::returnPressed() QLineEdit *testWidget = ensureTestWidget(); QTest::keyClick(testWidget, Qt::Key_Return); - QVERIFY(return_count == 1); + QCOMPARE(return_count, 1); return_count = 0; QTest::keyClick(testWidget, 'A'); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); QTest::keyClick(testWidget, 'b'); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); QTest::keyClick(testWidget, 'c'); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); QTest::keyClick(testWidget, ' '); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); QTest::keyClick(testWidget, 'd'); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); psKeyClick(testWidget, Qt::Key_Home); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); psKeyClick(testWidget, Qt::Key_End); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); QTest::keyClick(testWidget, Qt::Key_Escape); - QVERIFY(return_count == 0); + QCOMPARE(return_count, 0); QTest::keyClick(testWidget, Qt::Key_Return); - QVERIFY(return_count == 1); + QCOMPARE(return_count, 1); } // int validator that fixes all !isNumber to '0' @@ -2498,14 +2498,14 @@ void tst_QLineEdit::setValidator() QCOMPARE(testWidget->validator(), static_cast<const QValidator*>(&iv1)); testWidget->setValidator(0); - QVERIFY(testWidget->validator() == 0); + QVERIFY(!testWidget->validator()); QIntValidator iv2(0, 99, 0); testWidget->setValidator(&iv2); QCOMPARE(testWidget->validator(), static_cast<const QValidator *>(&iv2)); testWidget->setValidator(0); - QVERIFY(testWidget->validator() == 0); + QVERIFY(!testWidget->validator()); } void tst_QLineEdit::setValidator_QIntValidator_data() @@ -2747,7 +2747,7 @@ void tst_QLineEdit::setAlignment() QTEST(testWidget, "left"); #endif #endif - QVERIFY(testWidget->alignment() == Qt::AlignLeft); + QCOMPARE(testWidget->alignment(), Qt::AlignLeft); testWidget->setText("hcenter"); testWidget->setAlignment(Qt::AlignHCenter); @@ -2756,7 +2756,7 @@ void tst_QLineEdit::setAlignment() QTEST(testWidget, "hcenter"); #endif #endif - QVERIFY(testWidget->alignment() == Qt::AlignHCenter); + QCOMPARE(testWidget->alignment(), Qt::AlignHCenter); testWidget->setText("right"); testWidget->setAlignment(Qt::AlignRight); @@ -2765,16 +2765,16 @@ void tst_QLineEdit::setAlignment() QTEST(testWidget, "right"); #endif #endif - QVERIFY(testWidget->alignment() == Qt::AlignRight); + QCOMPARE(testWidget->alignment(), Qt::AlignRight); testWidget->setAlignment(Qt::AlignTop); - QVERIFY(testWidget->alignment() == Qt::AlignTop); + QCOMPARE(testWidget->alignment(), Qt::AlignTop); testWidget->setAlignment(Qt::AlignBottom); - QVERIFY(testWidget->alignment() == Qt::AlignBottom); + QCOMPARE(testWidget->alignment(), Qt::AlignBottom); testWidget->setAlignment(Qt::AlignCenter); - QVERIFY(testWidget->alignment() == Qt::AlignCenter); + QCOMPARE(testWidget->alignment(), Qt::AlignCenter); } void tst_QLineEdit::isModified() @@ -3082,10 +3082,10 @@ void tst_QLineEdit::maxLengthAndInputMask() QLineEdit *testWidget = ensureTestWidget(); QVERIFY(testWidget->inputMask().isNull()); testWidget->setMaxLength(10); - QVERIFY(testWidget->maxLength() == 10); + QCOMPARE(testWidget->maxLength(), 10); testWidget->setInputMask(QString::null); QVERIFY(testWidget->inputMask().isNull()); - QVERIFY(testWidget->maxLength() == 10); + QCOMPARE(testWidget->maxLength(), 10); } @@ -4453,7 +4453,7 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited() QSignalSpy spy(&lineEdit, SIGNAL(textEdited(QString))); lineEdit.setInputMask("AAAA"); lineEdit.setInputMask(QString()); - QVERIFY(spy.count() == 0); + QCOMPARE(spy.count(), 0); } QTEST_MAIN(tst_QLineEdit) diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 270e5168f7..6282028746 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -149,6 +149,8 @@ private slots: void toggleUnifiedTitleAndToolBarOnMac(); #endif void QTBUG21378_animationFinished(); + void resizeDocks(); + void resizeDocks_data(); }; @@ -211,15 +213,15 @@ tst_QMainWindow::tst_QMainWindow() void tst_QMainWindow::constructor() { QMainWindow mw; - QVERIFY(mw.parentWidget() == 0); + QVERIFY(!mw.parentWidget()); QVERIFY(mw.isWindow()); QMainWindow mw2(&mw); - QVERIFY(mw2.parentWidget() == &mw); + QCOMPARE(mw2.parentWidget(), &mw); QVERIFY(mw2.isWindow()); QMainWindow mw3(&mw, Qt::FramelessWindowHint); - QVERIFY(mw3.parentWidget() == &mw); + QCOMPARE(mw3.parentWidget(), &mw); QVERIFY(mw3.isWindow()); } @@ -607,7 +609,7 @@ void tst_QMainWindow::menuBar() QVERIFY(mw.menuBar() != 0); //we now call deleteLater on the previous menubar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mb1 == 0); + QVERIFY(mb1.isNull()); mw.setMenuBar(mb2); QVERIFY(mw.menuBar() != 0); @@ -618,7 +620,7 @@ void tst_QMainWindow::menuBar() QVERIFY(mw.menuBar() != 0); //we now call deleteLater on the previous menubar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mb2 == 0); + QVERIFY(mb2.isNull()); mb1 = new QMenuBar; mw.setMenuBar(mb1); @@ -631,7 +633,7 @@ void tst_QMainWindow::menuBar() QCOMPARE(mw.menuBar(), (QMenuBar *)mb2); //we now call deleteLater on the previous menubar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mb1 == 0); + QVERIFY(mb1.isNull()); mb1 = new QMenuBar; mw.setMenuBar(mb1); @@ -639,7 +641,7 @@ void tst_QMainWindow::menuBar() QCOMPARE(mw.menuBar(), (QMenuBar *)mb1); //we now call deleteLater on the previous menubar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mb2 == 0); + QVERIFY(mb2.isNull()); QPointer<QWidget> topLeftCornerWidget = new QWidget; mb1->setCornerWidget(topLeftCornerWidget, Qt::TopLeftCorner); @@ -652,7 +654,7 @@ void tst_QMainWindow::menuBar() QCOMPARE(mw.menuBar(), (QMenuBar *)mb2); //we now call deleteLater on the previous menubar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mb1 == 0); + QVERIFY(mb1.isNull()); QVERIFY(topLeftCornerWidget); QCOMPARE(mb2->cornerWidget(Qt::TopLeftCorner), static_cast<QWidget *>(topLeftCornerWidget)); @@ -663,8 +665,8 @@ void tst_QMainWindow::menuBar() QVERIFY(mw.menuBar() != 0); //we now call deleteLater on the previous menubar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mb2 == 0); + QVERIFY(mb2.isNull()); QVERIFY(!topLeftCornerWidget); QVERIFY(!topRightCornerWidget); } @@ -692,7 +694,7 @@ void tst_QMainWindow::statusBar() QVERIFY(mw.statusBar() != 0); //we now call deleteLater on the previous statusbar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(sb1 == 0); + QVERIFY(sb1.isNull()); mw.setStatusBar(sb2); QVERIFY(mw.statusBar() != 0); @@ -703,7 +705,7 @@ void tst_QMainWindow::statusBar() QVERIFY(mw.statusBar() != 0); //we now call deleteLater on the previous statusbar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(sb2 == 0); + QVERIFY(sb2.isNull()); sb1 = new QStatusBar; mw.setStatusBar(sb1); @@ -718,7 +720,7 @@ void tst_QMainWindow::statusBar() QCOMPARE(sb2->parentWidget(), (QWidget *)&mw); //we now call deleteLater on the previous statusbar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(sb1 == 0); + QVERIFY(sb1.isNull()); sb1 = new QStatusBar; mw.setStatusBar(sb1); @@ -727,7 +729,7 @@ void tst_QMainWindow::statusBar() QCOMPARE(sb1->parentWidget(), (QWidget *)&mw); //we now call deleteLater on the previous statusbar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(sb2 == 0); + QVERIFY(sb2.isNull()); sb2 = new QStatusBar; mw.setStatusBar(sb2); @@ -736,7 +738,7 @@ void tst_QMainWindow::statusBar() QCOMPARE(sb2->parentWidget(), (QWidget *)&mw); //we now call deleteLater on the previous statusbar QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(sb1 == 0); + QVERIFY(sb1.isNull()); } { @@ -749,7 +751,7 @@ void tst_QMainWindow::statusBar() QVERIFY(indexOfSb != -1); delete sb; indexOfSb = l->indexOf(sb); - QVERIFY(indexOfSb == -1); + QCOMPARE(indexOfSb, -1); } } @@ -791,7 +793,7 @@ void tst_QMainWindow::centralWidget() { { QMainWindow mw; - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); } { @@ -799,7 +801,7 @@ void tst_QMainWindow::centralWidget() QPointer<QWidget> w1 = new QWidget; QPointer<QWidget> w2 = new QWidget; - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); mw.setCentralWidget(w1); QVERIFY(mw.centralWidget() != 0); @@ -812,12 +814,12 @@ void tst_QMainWindow::centralWidget() QCOMPARE(w2->parentWidget(), (QWidget *)&mw); mw.setCentralWidget(0); - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); //we now call deleteLater on the previous central widgets QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(w1 == 0); - QVERIFY(w2 == 0); + QVERIFY(w1.isNull()); + QVERIFY(w2.isNull()); } { @@ -831,7 +833,7 @@ void tst_QMainWindow::centralWidget() QPointer<QWidget> w1 = new QWidget; QPointer<QWidget> w2 = new QWidget; - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); mw.setCentralWidget(w1); QVERIFY(mw.centralWidget() != 0); @@ -844,12 +846,12 @@ void tst_QMainWindow::centralWidget() QCOMPARE(w2->parentWidget(), (QWidget *)&mw); mw.setCentralWidget(0); - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); //we now call deleteLater on the previous central widgets QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(w1 == 0); - QVERIFY(w2 == 0); + QVERIFY(w1.isNull()); + QVERIFY(w2.isNull()); } } @@ -860,25 +862,25 @@ void tst_QMainWindow::takeCentralWidget() { QPointer<QWidget> w1 = new QWidget; - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); mw.setCentralWidget(w1); QWidget *oldCentralWidget = mw.takeCentralWidget(); - QVERIFY(oldCentralWidget == w1.data()); + QCOMPARE(oldCentralWidget, w1.data()); // ensure that takeCentralWidget doesn't end up calling deleteLater // on the central widget QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); QVERIFY(!w1.isNull()); - QVERIFY(w1->parent() == 0); + QVERIFY(!w1->parent()); mw.setCentralWidget(w1); // ensure that the deleteLater called by setCentralWidget // gets executed QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(mw.centralWidget() == w1.data()); + QCOMPARE(mw.centralWidget(), w1.data()); QPointer<QWidget> w2 = new QWidget; @@ -887,10 +889,10 @@ void tst_QMainWindow::takeCentralWidget() { QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QVERIFY(w1.isNull()); - QVERIFY(mw.centralWidget() == w2.data()); + QCOMPARE(mw.centralWidget(), w2.data()); QWidget *hopefullyW2 = mw.takeCentralWidget(); - QVERIFY(mw.centralWidget() == 0); + QVERIFY(!mw.centralWidget()); // ensure that takeCentralWidget doesn't end up calling deleteLater // on the central widget QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); @@ -1928,9 +1930,9 @@ void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac() mw.show(); QRect frameGeometry = mw.frameGeometry(); mw.setUnifiedTitleAndToolBarOnMac(false); - QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft()); + QCOMPARE(frameGeometry.topLeft(), mw.frameGeometry().topLeft()); mw.setUnifiedTitleAndToolBarOnMac(true); - QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft()); + QCOMPARE(frameGeometry.topLeft(), mw.frameGeometry().topLeft()); } #endif @@ -1950,5 +1952,96 @@ void tst_QMainWindow::QTBUG21378_animationFinished() delete mwClickTimer; QVERIFY(true); } + +Q_DECLARE_METATYPE(Qt::Orientation) + +void tst_QMainWindow::resizeDocks_data() +{ + QTest::addColumn<Qt::Orientation>("orientation"); + QTest::addColumn<QStringList>("docks"); + QTest::addColumn<QList<int> >("sizes"); + + QTest::newRow("1") << Qt::Horizontal + << (QStringList() << "blue" << "orange" << "green" << "gray") + << (QList<int>() << 190 << 190 << 320 << 160); + + QTest::newRow("2") << Qt::Vertical + << (QStringList() << "yellow" << "orange") + << (QList<int>() << 147 << 133 ); + + + QTest::newRow("3") << Qt::Horizontal + << (QStringList() << "blue" << "yellow") + << (QList<int>() << 190 << 600); +} + +void tst_QMainWindow::resizeDocks() +{ + AddList addList; + addList + << AddDockWidget("blue", Qt::LeftDockWidgetArea) + << AddDockWidget("red", Qt::TopDockWidgetArea) + << AddDockWidget("pink", "red") + << AddDockWidget("yellow", Qt::RightDockWidgetArea) + << AddDockWidget("orange", Qt::RightDockWidgetArea) + << AddDockWidget("green", "orange", Qt::Horizontal) + << AddDockWidget("gray", "orange", Qt::Horizontal); + /* + +--------------------------------+ + | red/pink | + +------+-+-----------------------+ + | | | yellow | + | blue + +--------+------+-------+ + | | | orange | gray | green | + +------+-+--------+------+-------+ + + */ + + QMainWindow mw(0, Qt::BypassWindowManagerHint); + mw.setDockNestingEnabled(true); + mw.resize(1800, 600); + + foreach (const AddDockWidget &i, addList) + i.apply(&mw); + + foreach (QDockWidget *dw, mw.findChildren<QDockWidget *>()) + dw->setStyleSheet( "* { background-color: " + dw->objectName() +" }"); + + mw.setCentralWidget(new QTextEdit); + + mw.show(); + QTest::qWaitForWindowExposed(&mw); + + QFETCH(Qt::Orientation, orientation); + QFETCH(QStringList, docks); + QFETCH(QList<int>, sizes); + + QList<QDockWidget *> list; + foreach (const QString &name, docks) { + QDockWidget *d = mw.findChild<QDockWidget *>(name); + QVERIFY(d); + list << d; + } + + mw.resizeDocks(list, sizes, orientation); + + qApp->processEvents(); + + int totalFromList = 0; + int actualTotal = 0; + for (int i = 0; i < docks.count(); ++i) { + totalFromList += sizes[i]; + QSize s = list[i]->size(); + actualTotal += (orientation == Qt::Horizontal) ? s.width() : s.height(); +// qDebug() << list[i] << list[i]->size() << sizes[i]; + } + + for (int i = 0; i < docks.count(); ++i) { + QSize s = list[i]->size(); + int value = (orientation == Qt::Horizontal) ? s.width() : s.height(); + QCOMPARE(value, qRound(sizes[i]*actualTotal/double(totalFromList))); + } +} + QTEST_MAIN(tst_QMainWindow) #include "tst_qmainwindow.moc" diff --git a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST index b8640e9ac3..63da2e3ae3 100644 --- a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST +++ b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST @@ -1,2 +1,5 @@ [updateScrollBars] osx +[tileSubWindows] +osx +xcb diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 53defce423..e7de027b22 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -377,13 +377,13 @@ void tst_QMdiArea::subWindowActivated() while (workspace->activeSubWindow() ) { workspace->activeSubWindow()->close(); qApp->processEvents(); - QVERIFY(activeWindow == workspace->activeSubWindow()); + QCOMPARE(activeWindow, workspace->activeSubWindow()); QCOMPARE(spy.count(), 1); spy.clear(); } - QVERIFY(activeWindow == 0); - QVERIFY(workspace->activeSubWindow() == 0); + QVERIFY(!activeWindow); + QVERIFY(!workspace->activeSubWindow()); QCOMPARE(workspace->subWindowList().count(), 0); { @@ -432,13 +432,13 @@ void tst_QMdiArea::subWindowActivated() QCOMPARE(spy.count(), 1); spy.clear(); QVERIFY( activeWindow == window ); - QVERIFY(workspace->activeSubWindow() == window); + QCOMPARE(workspace->activeSubWindow(), window); window->close(); qApp->processEvents(); QCOMPARE(spy.count(), 1); spy.clear(); - QVERIFY(workspace->activeSubWindow() == 0); - QVERIFY( activeWindow == 0 ); + QVERIFY(!workspace->activeSubWindow()); + QVERIFY(!activeWindow); } } @@ -564,8 +564,8 @@ void tst_QMdiArea::subWindowActivatedWithMinimize() window1->close(); qApp->processEvents(); - QVERIFY(workspace->activeSubWindow() == 0); - QVERIFY( activeWindow == 0 ); + QVERIFY(!workspace->activeSubWindow()); + QVERIFY(!activeWindow); QVERIFY( workspace->subWindowList().count() == 0 ); } @@ -1104,7 +1104,7 @@ void tst_QMdiArea::addAndRemoveWindows() QVERIFY(window); qApp->processEvents(); QCOMPARE(workspace.subWindowList().count(), 1); - QVERIFY(window->windowFlags() == DefaultWindowFlags); + QCOMPARE(window->windowFlags(), DefaultWindowFlags); QCOMPARE(window->size(), workspace.viewport()->size()); } @@ -1115,7 +1115,7 @@ void tst_QMdiArea::addAndRemoveWindows() QVERIFY(window); qApp->processEvents(); QCOMPARE(workspace.subWindowList().count(), 2); - QVERIFY(window->windowFlags() == DefaultWindowFlags); + QCOMPARE(window->windowFlags(), DefaultWindowFlags); QCOMPARE(window->size(), window->minimumSize()); } @@ -1127,7 +1127,7 @@ void tst_QMdiArea::addAndRemoveWindows() QVERIFY(window); qApp->processEvents(); QCOMPARE(workspace.subWindowList().count(), 3); - QVERIFY(window->windowFlags() == DefaultWindowFlags); + QCOMPARE(window->windowFlags(), DefaultWindowFlags); QCOMPARE(window->size(), QSize(1500, 1500)); } @@ -1142,7 +1142,7 @@ void tst_QMdiArea::addAndRemoveWindows() QMdiSubWindow *window = new QMdiSubWindow; workspace.addSubWindow(window); qApp->processEvents(); - QVERIFY(window->windowFlags() == DefaultWindowFlags); + QCOMPARE(window->windowFlags(), DefaultWindowFlags); window->setWidget(new QWidget); QCOMPARE(workspace.subWindowList().count(), 4); QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added"); @@ -1206,7 +1206,7 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting() { QMdiArea workspace; QMdiSubWindow window(&workspace); - QVERIFY(window.windowFlags() == DefaultWindowFlags); + QCOMPARE(window.windowFlags(), DefaultWindowFlags); // 0 because the window list contains widgets and not actual // windows. Silly, but that's the behavior. @@ -1219,7 +1219,7 @@ void tst_QMdiArea::addAndRemoveWindowsWithReparenting() QCOMPARE(workspace.subWindowList().count(), 0); window.setParent(&workspace); QCOMPARE(workspace.subWindowList().count(), 1); - QVERIFY(window.windowFlags() == DefaultWindowFlags); + QCOMPARE(window.windowFlags(), DefaultWindowFlags); QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added"); workspace.addSubWindow(&window); diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 46d3177a56..843bb3437c 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -78,6 +78,7 @@ public slots: private slots: void getSetCheck(); void addActionsAndClear(); + void addActionsConnect(); void keyboardNavigation_data(); void keyboardNavigation(); @@ -264,6 +265,34 @@ void tst_QMenu::addActionsAndClear() QCOMPARE(menus[0]->actions().count(), 0); } +static void testFunction() { } + +void tst_QMenu::addActionsConnect() +{ + QMenu menu; + const QString text = QLatin1String("bla"); + const QIcon icon; + menu.addAction(text, &menu, SLOT(deleteLater())); + menu.addAction(text, &menu, &QMenu::deleteLater); + menu.addAction(text, testFunction); + menu.addAction(text, &menu, testFunction); + menu.addAction(icon, text, &menu, SLOT(deleteLater())); + menu.addAction(icon, text, &menu, &QMenu::deleteLater); + menu.addAction(icon, text, testFunction); + menu.addAction(icon, text, &menu, testFunction); +#ifndef QT_NO_SHORTCUT + const QKeySequence keySequence(Qt::CTRL + Qt::Key_C); + menu.addAction(text, &menu, SLOT(deleteLater()), keySequence); + menu.addAction(text, &menu, &QMenu::deleteLater, keySequence); + menu.addAction(text, testFunction, keySequence); + menu.addAction(text, &menu, testFunction, keySequence); + menu.addAction(icon, text, &menu, SLOT(deleteLater()), keySequence); + menu.addAction(icon, text, &menu, &QMenu::deleteLater, keySequence); + menu.addAction(icon, text, testFunction, keySequence); + menu.addAction(icon, text, &menu, testFunction, keySequence); +#endif // !QT_NO_SHORTCUT +} + // We have a separate mouseActivation test for Windows mobile #ifndef Q_OS_WINCE void tst_QMenu::mouseActivation() @@ -334,8 +363,10 @@ void tst_QMenu::keyboardNavigation_data() QTest::newRow("data9") << Qt::Key(Qt::Key_Down) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << false<< true; QTest::newRow("data10") << Qt::Key(Qt::Key_Return) << Qt::KeyboardModifiers(Qt::NoModifier) << 3 << 0 << false << true << false; - // Test shortcuts. - QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false; + if (qApp->platformName().toLower() != QStringLiteral("xcb")) { + // Test shortcuts. + QTest::newRow("shortcut0") << Qt::Key(Qt::Key_V) << Qt::KeyboardModifiers(Qt::AltModifier) << 5 << 0 << true << true << false; + } } void tst_QMenu::keyboardNavigation() @@ -513,7 +544,7 @@ void tst_QMenu::onStatusTipTimer() menu->close(); //goes out of the menu QCOMPARE(st, QString("sub action")); - QVERIFY(menu->isVisible() == false); + QVERIFY(!menu->isVisible()); m_onStatusTipTimerExecuted = true; } diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 31e9c737e2..baf60551c4 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -146,7 +146,7 @@ private: QAction* m_lastSimpleAcceleratorId; int m_simpleActivatedCount; - int m_complexTriggerCount['k']; + int m_complexTriggerCount[int('k')]; }; // Testing get/set functions @@ -534,60 +534,60 @@ void tst_QMenuBar::check_accelKeys() QCOMPARE(m_complexTriggerCount[2], 0); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); - QCOMPARE(m_complexTriggerCount['b'], 0); - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 0); + QCOMPARE(m_complexTriggerCount[int('b')], 0); + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier); QCOMPARE(m_complexTriggerCount[1], 0); QCOMPARE(m_complexTriggerCount[2], 0); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 1); - QCOMPARE(m_complexTriggerCount['b'], 0); - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 1); + QCOMPARE(m_complexTriggerCount[int('b')], 0); + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_C, Qt::ControlModifier); QCOMPARE(m_complexTriggerCount[1], 0); QCOMPARE(m_complexTriggerCount[2], 0); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 1); - QCOMPARE(m_complexTriggerCount['b'], 0); - QCOMPARE(m_complexTriggerCount['c'], 1); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 1); + QCOMPARE(m_complexTriggerCount[int('b')], 0); + QCOMPARE(m_complexTriggerCount[int('c')], 1); + QCOMPARE(m_complexTriggerCount[int('d')], 0); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_B, Qt::ControlModifier); QCOMPARE(m_complexTriggerCount[1], 0); QCOMPARE(m_complexTriggerCount[2], 0); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 1); - QCOMPARE(m_complexTriggerCount['b'], 1); - QCOMPARE(m_complexTriggerCount['c'], 1); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 1); + QCOMPARE(m_complexTriggerCount[int('b')], 1); + QCOMPARE(m_complexTriggerCount[int('c')], 1); + QCOMPARE(m_complexTriggerCount[int('d')], 0); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_D, Qt::ControlModifier); QCOMPARE(m_complexTriggerCount[1], 0); QCOMPARE(m_complexTriggerCount[2], 0); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 1); - QCOMPARE(m_complexTriggerCount['b'], 1); - QCOMPARE(m_complexTriggerCount['c'], 1); - QCOMPARE(m_complexTriggerCount['d'], 1); + QCOMPARE(m_complexTriggerCount[int('a')], 1); + QCOMPARE(m_complexTriggerCount[int('b')], 1); + QCOMPARE(m_complexTriggerCount[int('c')], 1); + QCOMPARE(m_complexTriggerCount[int('d')], 1); QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_J, Qt::AltModifier); QCOMPARE(m_complexTriggerCount[1], 0); QCOMPARE(m_complexTriggerCount[2], 0); QCOMPARE(m_complexTriggerCount[3], 1); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 1); - QCOMPARE(m_complexTriggerCount['b'], 1); - QCOMPARE(m_complexTriggerCount['c'], 1); - QCOMPARE(m_complexTriggerCount['d'], 1); + QCOMPARE(m_complexTriggerCount[int('a')], 1); + QCOMPARE(m_complexTriggerCount[int('b')], 1); + QCOMPARE(m_complexTriggerCount[int('c')], 1); + QCOMPARE(m_complexTriggerCount[int('d')], 1); } #endif @@ -606,10 +606,10 @@ void tst_QMenuBar::check_cursorKeys1() // the Popupmenu should be visible now QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); - QCOMPARE(m_complexTriggerCount['b'], 0); - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 0); + QCOMPARE(m_complexTriggerCount[int('b')], 0); + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); // Simulate a cursor key down click QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down ); @@ -618,10 +618,10 @@ void tst_QMenuBar::check_cursorKeys1() // Let's see if the correct slot is called... QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been called - QCOMPARE(m_complexTriggerCount['b'], 1); // and this should have been called by a signal now - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been called + QCOMPARE(m_complexTriggerCount[int('b')], 1); // and this should have been called by a signal now + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); } #endif @@ -648,10 +648,10 @@ void tst_QMenuBar::check_cursorKeys2() // Let's see if the correct slot is called... QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been caled - QCOMPARE(m_complexTriggerCount['b'], 0); // and this should have been called by a signal ow - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 1); + QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been caled + QCOMPARE(m_complexTriggerCount[int('b')], 0); // and this should have been called by a signal ow + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 1); } #endif @@ -679,10 +679,10 @@ void tst_QMenuBar::check_cursorKeys3() // Let's see if the correct slot is called... QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); // this shouldn't have been called - QCOMPARE(m_complexTriggerCount['b'], 1); // and this should have been called by a signal now - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 0); // this shouldn't have been called + QCOMPARE(m_complexTriggerCount[int('b')], 1); // and this should have been called by a signal now + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); } #endif @@ -715,17 +715,17 @@ void tst_QMenuBar::check_homeKey() // and press ENTER QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter ); // Let's see if the correct slot is called... -// QVERIFY2( m_complexActionTriggerCount['c'] == 1, "Popupmenu should respond to a Home key" ); - QCOMPARE(m_complexTriggerCount['c'], 1); +// QVERIFY2( m_complexActionTriggerCount[int('c')] == 1, "Popupmenu should respond to a Home key" ); + QCOMPARE(m_complexTriggerCount[int('c')], 1); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); - QCOMPARE(m_complexTriggerCount['b'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); - QCOMPARE(m_complexTriggerCount['e'], 0); - QCOMPARE(m_complexTriggerCount['f'], 0); - QCOMPARE(m_complexTriggerCount['g'], 0); - QCOMPARE(m_complexTriggerCount['h'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 0); + QCOMPARE(m_complexTriggerCount[int('b')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); + QCOMPARE(m_complexTriggerCount[int('e')], 0); + QCOMPARE(m_complexTriggerCount[int('f')], 0); + QCOMPARE(m_complexTriggerCount[int('g')], 0); + QCOMPARE(m_complexTriggerCount[int('h')], 0); } /*! @@ -754,17 +754,17 @@ void tst_QMenuBar::check_endKey() // and press ENTER QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter ); // Let's see if the correct slot is called... -// QVERIFY2( m_complexActionTriggerCount['h'] == 1, "Popupmenu should respond to an End key" ); - QCOMPARE(m_complexTriggerCount['h'], 1);//, "Popupmenu should respond to an End key"); +// QVERIFY2( m_complexActionTriggerCount[int('h')] == 1, "Popupmenu should respond to an End key" ); + QCOMPARE(m_complexTriggerCount[int('h')], 1);//, "Popupmenu should respond to an End key"); QCOMPARE(m_complexTriggerCount[3], 0); QCOMPARE(m_complexTriggerCount[4], 0); - QCOMPARE(m_complexTriggerCount['a'], 0); - QCOMPARE(m_complexTriggerCount['b'], 0); - QCOMPARE(m_complexTriggerCount['c'], 0); - QCOMPARE(m_complexTriggerCount['d'], 0); - QCOMPARE(m_complexTriggerCount['e'], 0); - QCOMPARE(m_complexTriggerCount['f'], 0); - QCOMPARE(m_complexTriggerCount['g'], 0); + QCOMPARE(m_complexTriggerCount[int('a')], 0); + QCOMPARE(m_complexTriggerCount[int('b')], 0); + QCOMPARE(m_complexTriggerCount[int('c')], 0); + QCOMPARE(m_complexTriggerCount[int('d')], 0); + QCOMPARE(m_complexTriggerCount[int('e')], 0); + QCOMPARE(m_complexTriggerCount[int('f')], 0); + QCOMPARE(m_complexTriggerCount[int('g')], 0); } /*! @@ -808,7 +808,7 @@ void tst_QMenuBar::check_escKey() // and press ENTER QTest::keyClick( menu.menus.at(1), Qt::Key_Enter ); // Let's see if the correct slot is called... - QVERIFY2( m_complexTriggerCount['c'] == 1, "Expected item 2C to be selected" ); + QVERIFY2(m_complexTriggerCount[int('c')] == 1, "Expected item 2C to be selected"); } #endif diff --git a/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST new file mode 100644 index 0000000000..725b8e93b4 --- /dev/null +++ b/tests/auto/widgets/widgets/qopenglwidget/BLACKLIST @@ -0,0 +1,2 @@ +[clearAndGrab] +opensuse-13.1 diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index e9f9c67856..638fad6206 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -70,7 +70,7 @@ void tst_QOpenGLWidget::create() QVERIFY(w->isValid()); QVERIFY(w->context()); - QVERIFY(w->context()->format() == w->format()); + QCOMPARE(w->context()->format(), w->format()); QVERIFY(w->defaultFramebufferObject() != 0); } @@ -304,7 +304,7 @@ void tst_QOpenGLWidget::asViewport() // the widget stack. btn->update(); qApp->processEvents(); - QVERIFY(view->paintCount() == 0); + QCOMPARE(view->paintCount(), 0); } class PaintCountWidget : public QOpenGLWidget diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index e7de6b0b75..2145260013 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -333,7 +333,7 @@ void tst_QPlainTextEdit::selectAllSetsNotSelection() QSKIP("Test only relevant for systems with selection"); QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection); - QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar")); + QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString("foobar")); ed->insertPlainText("Hello World"); ed->selectAll(); @@ -905,13 +905,13 @@ void tst_QPlainTextEdit::mouseCursorShape() { // always show an IBeamCursor, see change 170146 QVERIFY(!ed->isReadOnly()); - QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor); + QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor); ed->setReadOnly(true); - QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor); + QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor); ed->setPlainText("Foo"); - QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor); + QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor); } #endif @@ -1324,7 +1324,7 @@ void tst_QPlainTextEdit::preserveCharFormatAfterSetPlainText() QTextBlock block = ed->document()->begin(); block = block.next(); QCOMPARE(block.text(), QString("This should still be blue")); - QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue)); + QCOMPARE(block.begin().fragment().charFormat().foreground().color(), QColor(Qt::blue)); } void tst_QPlainTextEdit::extraSelections() @@ -1444,7 +1444,7 @@ void tst_QPlainTextEdit::wordWrapProperty() doc->setDocumentLayout(new QPlainTextDocumentLayout(doc)); edit.setDocument(doc); edit.setWordWrapMode(QTextOption::NoWrap); - QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap); + QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap); } { QPlainTextEdit edit; @@ -1452,18 +1452,18 @@ void tst_QPlainTextEdit::wordWrapProperty() doc->setDocumentLayout(new QPlainTextDocumentLayout(doc)); edit.setWordWrapMode(QTextOption::NoWrap); edit.setDocument(doc); - QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap); + QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap); } } void tst_QPlainTextEdit::lineWrapProperty() { - QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere); - QVERIFY(ed->lineWrapMode() == QPlainTextEdit::WidgetWidth); + QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere); + QCOMPARE(ed->lineWrapMode(), QPlainTextEdit::WidgetWidth); ed->setLineWrapMode(QPlainTextEdit::NoWrap); - QVERIFY(ed->lineWrapMode() == QPlainTextEdit::NoWrap); - QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere); - QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap); + QCOMPARE(ed->lineWrapMode(), QPlainTextEdit::NoWrap); + QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere); + QCOMPARE(ed->document()->defaultTextOption().wrapMode(), QTextOption::NoWrap); } void tst_QPlainTextEdit::selectionChanged() @@ -1560,7 +1560,7 @@ void tst_QPlainTextEdit::findWithRegExp() bool found = ed->find(rx); - QVERIFY(found == true); + QVERIFY(found); QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); } @@ -1574,7 +1574,7 @@ void tst_QPlainTextEdit::findBackwardWithRegExp() bool found = ed->find(rx, QTextDocument::FindBackward); - QVERIFY(found == true); + QVERIFY(found); QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); } @@ -1586,7 +1586,7 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() bool found = ed->find(rx); - QVERIFY(found == false); + QVERIFY(!found); QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); } #endif diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 4fd8b99acf..44a554ad82 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -227,8 +227,8 @@ void tst_QPushButton::autoRepeat() QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QTest::keyRelease( testWidget, Qt::Key_Space ); - QVERIFY(press_count == release_count); - QVERIFY(release_count == click_count); + QCOMPARE(press_count, release_count); + QCOMPARE(release_count, click_count); QVERIFY(press_count > 1); // #### shouldn't I check here to see if multiple signals have been fired??? diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp index 40e13c8e8d..ce6afc0a57 100644 --- a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp +++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp @@ -166,8 +166,8 @@ void tst_QScrollArea::checkHFW_Task_197736() scrollArea.setWidgetResizable(false); scrollArea.resize(QSize(100,100)); w->resize(QSize(200,200)); - QVERIFY(w->width() == 200); - QVERIFY(w->height() == 200); + QCOMPARE(w->width(), 200); + QCOMPARE(w->height(), 200); } QTEST_MAIN(tst_QScrollArea) diff --git a/tests/auto/widgets/widgets/qsizegrip/BLACKLIST b/tests/auto/widgets/widgets/qsizegrip/BLACKLIST new file mode 100644 index 0000000000..2c874bcb57 --- /dev/null +++ b/tests/auto/widgets/widgets/qsizegrip/BLACKLIST @@ -0,0 +1,2 @@ +[hideAndShowOnWindowStateChange:Qt::Window] +xcb diff --git a/tests/auto/widgets/widgets/qspinbox/BLACKLIST b/tests/auto/widgets/widgets/qspinbox/BLACKLIST new file mode 100644 index 0000000000..5bf6c3beed --- /dev/null +++ b/tests/auto/widgets/widgets/qspinbox/BLACKLIST @@ -0,0 +1,3 @@ +[editingFinished] +osx-10.8 +osx-10.9 diff --git a/tests/auto/widgets/widgets/qtabbar/BLACKLIST b/tests/auto/widgets/widgets/qtabbar/BLACKLIST new file mode 100644 index 0000000000..b000b08444 --- /dev/null +++ b/tests/auto/widgets/widgets/qtabbar/BLACKLIST @@ -0,0 +1,2 @@ +[sizeHints] +ubuntu-14.04 diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index fffbbc2ec7..a991f18110 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -165,7 +165,7 @@ void tst_QTabWidget::init() tw = new QTabWidget(0); QCOMPARE(tw->count(), 0); QCOMPARE(tw->currentIndex(), -1); - QVERIFY(tw->currentWidget() == NULL); + QVERIFY(!tw->currentWidget()); } void tst_QTabWidget::cleanup() @@ -208,7 +208,7 @@ void tst_QTabWidget::addRemoveTab() QCOMPARE(tw->count(), 0); tw->removeTab(-1); QCOMPARE(tw->count(), 0); - QVERIFY(tw->widget(-1) == 0); + QVERIFY(!tw->widget(-1)); QWidget *w = new QWidget(); int index = tw->addTab(w, LABEL); @@ -216,7 +216,7 @@ void tst_QTabWidget::addRemoveTab() QCOMPARE(tw->indexOf(w), index); QCOMPARE(tw->count(), 1); - QVERIFY(tw->widget(index) == w); + QCOMPARE(tw->widget(index), w); QCOMPARE(tw->tabText(index), QString(LABEL)); removePage(index); @@ -238,7 +238,7 @@ void tst_QTabWidget::tabPosition() void tst_QTabWidget::tabEnabled() { // Test bad arguments - QVERIFY(tw->isTabEnabled(-1) == false); + QVERIFY(!tw->isTabEnabled(-1)); tw->setTabEnabled(-1, false); int index = addPage(); @@ -333,21 +333,21 @@ void tst_QTabWidget::currentWidget() { // Test bad arguments tw->setCurrentWidget(NULL); - QVERIFY(tw->currentWidget() == NULL); + QVERIFY(!tw->currentWidget()); int index = addPage(); QWidget *w = tw->widget(index); - QVERIFY(tw->currentWidget() == w); + QCOMPARE(tw->currentWidget(), w); QCOMPARE(tw->currentIndex(), index); tw->setCurrentWidget(NULL); - QVERIFY(tw->currentWidget() == w); + QCOMPARE(tw->currentWidget(), w); QCOMPARE(tw->currentIndex(), index); int index2 = addPage(); QWidget *w2 = tw->widget(index2); Q_UNUSED(w2); - QVERIFY(tw->currentWidget() == w); + QCOMPARE(tw->currentWidget(), w); QCOMPARE(tw->currentIndex(), index); removePage(index2); @@ -372,7 +372,7 @@ void tst_QTabWidget::currentIndex() QCOMPARE(tw->currentIndex(), firstIndex); QCOMPARE(spy.count(), 1); QList<QVariant> arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toInt() == firstIndex); + QCOMPARE(arguments.at(0).toInt(), firstIndex); int index = addPage(); QCOMPARE(tw->currentIndex(), firstIndex); @@ -380,19 +380,19 @@ void tst_QTabWidget::currentIndex() QCOMPARE(tw->currentIndex(), index); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toInt() == index); + QCOMPARE(arguments.at(0).toInt(), index); removePage(index); QCOMPARE(tw->currentIndex(), firstIndex); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toInt() == firstIndex); + QCOMPARE(arguments.at(0).toInt(), firstIndex); removePage(firstIndex); QCOMPARE(tw->currentIndex(), -1); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); - QVERIFY(arguments.at(0).toInt() == -1); + QCOMPARE(arguments.at(0).toInt(), -1); } void tst_QTabWidget::cornerWidget() @@ -400,24 +400,24 @@ void tst_QTabWidget::cornerWidget() // Test bad arguments tw->setCornerWidget(NULL, Qt::TopRightCorner); - QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == 0); - QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0); - QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == 0); - QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == 0); + QVERIFY(!tw->cornerWidget(Qt::TopLeftCorner)); + QVERIFY(!tw->cornerWidget(Qt::TopRightCorner)); + QVERIFY(!tw->cornerWidget(Qt::BottomLeftCorner)); + QVERIFY(!tw->cornerWidget(Qt::BottomRightCorner)); QWidget *w = new QWidget(0); tw->setCornerWidget(w, Qt::TopLeftCorner); QCOMPARE(w->parent(), (QObject *)tw); - QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == w); + QCOMPARE(tw->cornerWidget(Qt::TopLeftCorner), w); tw->setCornerWidget(w, Qt::TopRightCorner); - QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == w); + QCOMPARE(tw->cornerWidget(Qt::TopRightCorner), w); tw->setCornerWidget(w, Qt::BottomLeftCorner); - QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == w); + QCOMPARE(tw->cornerWidget(Qt::BottomLeftCorner), w); tw->setCornerWidget(w, Qt::BottomRightCorner); - QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == w); + QCOMPARE(tw->cornerWidget(Qt::BottomRightCorner), w); tw->setCornerWidget(0, Qt::TopRightCorner); - QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0); + QVERIFY(!tw->cornerWidget(Qt::TopRightCorner)); QCOMPARE(w->isHidden(), true); } diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp index aaa7348bdf..adc768f828 100644 --- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp @@ -141,14 +141,14 @@ void tst_QTextBrowser::noReloadOnAnchorJump() browser->setSource(url); QCOMPARE(browser->htmlLoadAttempts, 1); QVERIFY(!browser->toPlainText().isEmpty()); - QVERIFY(browser->source() == url); + QCOMPARE(browser->source(), url); } void tst_QTextBrowser::bgColorOnSourceChange() { browser->setSource(QUrl::fromLocalFile("pagewithbg.html")); QVERIFY(browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush)); - QVERIFY(browser->document()->rootFrame()->frameFormat().background().color() == Qt::blue); + QCOMPARE(browser->document()->rootFrame()->frameFormat().background().color(), QColor(Qt::blue)); browser->setSource(QUrl::fromLocalFile("pagewithoutbg.html")); QVERIFY(!browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush)); @@ -167,13 +167,13 @@ void tst_QTextBrowser::forwardButton() QVERIFY(!forwardEmissions.isEmpty()); QVariant val = forwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == false); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(!val.toBool()); QVERIFY(!backwardEmissions.isEmpty()); val = backwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == false); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(!val.toBool()); QVERIFY(browser->historyTitle(-1).isEmpty()); QCOMPARE(browser->historyUrl(0), QUrl::fromLocalFile("pagewithbg.html")); @@ -185,13 +185,13 @@ void tst_QTextBrowser::forwardButton() QVERIFY(!forwardEmissions.isEmpty()); val = forwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == false); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(!val.toBool()); QVERIFY(!backwardEmissions.isEmpty()); val = backwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == true); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(val.toBool()); QCOMPARE(browser->historyTitle(-1), QString("Page With BG")); QCOMPARE(browser->historyTitle(0), QString("Sample Anchor")); @@ -201,13 +201,13 @@ void tst_QTextBrowser::forwardButton() QVERIFY(!forwardEmissions.isEmpty()); val = forwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == true); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(val.toBool()); QVERIFY(!backwardEmissions.isEmpty()); val = backwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == false); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(!val.toBool()); QVERIFY(browser->historyTitle(-1).isEmpty()); QCOMPARE(browser->historyTitle(0), QString("Page With BG")); @@ -217,13 +217,13 @@ void tst_QTextBrowser::forwardButton() QVERIFY(!forwardEmissions.isEmpty()); val = forwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == false); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(!val.toBool()); QVERIFY(!backwardEmissions.isEmpty()); val = backwardEmissions.takeLast()[0]; - QVERIFY(val.type() == QVariant::Bool); - QVERIFY(val.toBool() == true); + QCOMPARE(val.type(), QVariant::Bool); + QVERIFY(val.toBool()); } void tst_QTextBrowser::viewportPositionInHistory() @@ -244,29 +244,29 @@ void tst_QTextBrowser::relativeLinks() QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(QUrl))); browser->setSource(QUrl("subdir/../qtextbrowser.html")); QVERIFY(!browser->document()->isEmpty()); - QVERIFY(sourceChangedSpy.count() == 1); + QCOMPARE(sourceChangedSpy.count(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html")); browser->setSource(QUrl("subdir/index.html")); QVERIFY(!browser->document()->isEmpty()); - QVERIFY(sourceChangedSpy.count() == 1); + QCOMPARE(sourceChangedSpy.count(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html")); browser->setSource(QUrl("anchor.html")); QVERIFY(!browser->document()->isEmpty()); - QVERIFY(sourceChangedSpy.count() == 1); + QCOMPARE(sourceChangedSpy.count(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("anchor.html")); browser->setSource(QUrl("subdir/index.html")); QVERIFY(!browser->document()->isEmpty()); - QVERIFY(sourceChangedSpy.count() == 1); + QCOMPARE(sourceChangedSpy.count(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html")); // using QUrl::fromLocalFile() browser->setSource(QUrl::fromLocalFile("anchor.html")); QVERIFY(!browser->document()->isEmpty()); - QVERIFY(sourceChangedSpy.count() == 1); + QCOMPARE(sourceChangedSpy.count(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html")); browser->setSource(QUrl("subdir/../qtextbrowser.html")); QVERIFY(!browser->document()->isEmpty()); - QVERIFY(sourceChangedSpy.count() == 1); + QCOMPARE(sourceChangedSpy.count(), 1); QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html")); } @@ -446,13 +446,13 @@ void tst_QTextBrowser::sourceInsideLoadResource() void tst_QTextBrowser::textInteractionFlags_vs_readOnly() { QVERIFY(browser->isReadOnly()); - QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction); + QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction); browser->setReadOnly(true); - QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction); + QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction); browser->setReadOnly(false); - QVERIFY(browser->textInteractionFlags() == Qt::TextEditorInteraction); + QCOMPARE(browser->textInteractionFlags(), Qt::TextEditorInteraction); browser->setReadOnly(true); - QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction); + QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction); } void tst_QTextBrowser::anchorsWithSelfBuiltHtml() @@ -525,7 +525,7 @@ void tst_QTextBrowser::loadResourceOnRelativeLocalFiles() QVERIFY(!browser->toPlainText().isEmpty()); QVariant v = browser->loadResource(QTextDocument::HtmlResource, QUrl("../anchor.html")); QVERIFY(v.isValid()); - QVERIFY(v.type() == QVariant::ByteArray); + QCOMPARE(v.type(), QVariant::ByteArray); QVERIFY(!v.toByteArray().isEmpty()); } @@ -658,7 +658,7 @@ void tst_QTextBrowser::urlEncoding() QCOMPARE(spy.count(), 1); QUrl url = spy.at(0).at(0).toUrl(); - QVERIFY(url.toEncoded() == QByteArray("http://www.google.com/q=%22")); + QCOMPARE(url.toEncoded(), QByteArray("http://www.google.com/q=%22")); delete browser; } diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 35a6a8e4e0..0cc812cbca 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -398,12 +398,13 @@ void tst_QTextEdit::cleanup() void tst_QTextEdit::inlineAttributesOnInsert() { - QVERIFY(ed->textCursor().charFormat().foreground().color() != Qt::blue); + const QColor blue(Qt::blue); + QVERIFY(ed->textCursor().charFormat().foreground().color() != blue); - ed->setTextColor(Qt::blue); + ed->setTextColor(blue); QTest::keyClick(ed, Qt::Key_A); - QVERIFY(ed->textCursor().charFormat().foreground().color() == Qt::blue); + QCOMPARE(ed->textCursor().charFormat().foreground().color(), blue); } void tst_QTextEdit::inlineAttributesOnSelection() @@ -457,7 +458,7 @@ void tst_QTextEdit::autoBulletList1() QTest::keyClicks(ed, "*This should become a list"); QVERIFY(ed->textCursor().currentList()); - QVERIFY(ed->textCursor().currentList()->format().style() == QTextListFormat::ListDisc); + QCOMPARE(ed->textCursor().currentList()->format().style(), QTextListFormat::ListDisc); } void tst_QTextEdit::autoBulletList2() @@ -582,7 +583,7 @@ void tst_QTextEdit::selectAllSetsNotSelection() } QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection); - QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar")); + QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString("foobar")); ed->insertPlainText("Hello World"); ed->selectAll(); @@ -867,11 +868,12 @@ void tst_QTextEdit::appendShouldUseCurrentFormat() fmt.setFontItalic(true); ed->setCurrentCharFormat(fmt); ed->append("Hello"); + const QColor blue(Qt::blue); QTextCursor cursor(ed->document()); QVERIFY(cursor.movePosition(QTextCursor::NextCharacter)); - QVERIFY(cursor.charFormat().foreground().color() != Qt::blue); + QVERIFY(cursor.charFormat().foreground().color() != blue); QVERIFY(!cursor.charFormat().fontItalic()); QVERIFY(cursor.movePosition(QTextCursor::NextBlock)); @@ -883,7 +885,7 @@ void tst_QTextEdit::appendShouldUseCurrentFormat() } QVERIFY(cursor.movePosition(QTextCursor::NextCharacter)); - QVERIFY(cursor.charFormat().foreground().color() == Qt::blue); + QCOMPARE(cursor.charFormat().foreground().color(), blue); QVERIFY(cursor.charFormat().fontItalic()); } @@ -1211,7 +1213,7 @@ void tst_QTextEdit::lineWrapModes() { ed->setLineWrapMode(QTextEdit::NoWrap); // NoWrap at the same time as having all lines that are all left aligned means we optimize to only layout once. The effect is that the width is always 0 - QVERIFY(ed->document()->pageSize().width() == qreal(0)); + QCOMPARE(ed->document()->pageSize().width(), qreal(0)); QTextCursor cursor = QTextCursor(ed->document()); cursor.insertText(QString("A simple line")); @@ -1237,13 +1239,13 @@ void tst_QTextEdit::mouseCursorShape() { // always show an IBeamCursor, see change 170146 QVERIFY(!ed->isReadOnly()); - QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor); + QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor); ed->setReadOnly(true); - QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor); + QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor); ed->setPlainText("Foo"); - QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor); + QCOMPARE(ed->viewport()->cursor().shape(), Qt::IBeamCursor); } #endif @@ -1661,7 +1663,7 @@ void tst_QTextEdit::preserveCharFormatAfterSetPlainText() QTextBlock block = ed->document()->begin(); block = block.next(); QCOMPARE(block.text(), QString("This should still be blue")); - QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue)); + QCOMPARE(block.begin().fragment().charFormat().foreground().color(), QColor(Qt::blue)); } void tst_QTextEdit::extraSelections() @@ -1796,25 +1798,25 @@ void tst_QTextEdit::wordWrapProperty() QTextDocument *doc = new QTextDocument(&edit); edit.setDocument(doc); edit.setWordWrapMode(QTextOption::NoWrap); - QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap); + QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap); } { QTextEdit edit; QTextDocument *doc = new QTextDocument(&edit); edit.setWordWrapMode(QTextOption::NoWrap); edit.setDocument(doc); - QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap); + QCOMPARE(doc->defaultTextOption().wrapMode(), QTextOption::NoWrap); } } void tst_QTextEdit::lineWrapProperty() { - QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere); - QVERIFY(ed->lineWrapMode() == QTextEdit::WidgetWidth); + QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere); + QCOMPARE(ed->lineWrapMode(), QTextEdit::WidgetWidth); ed->setLineWrapMode(QTextEdit::NoWrap); - QVERIFY(ed->lineWrapMode() == QTextEdit::NoWrap); - QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere); - QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap); + QCOMPARE(ed->lineWrapMode(), QTextEdit::NoWrap); + QCOMPARE(ed->wordWrapMode(), QTextOption::WrapAtWordBoundaryOrAnywhere); + QCOMPARE(ed->document()->defaultTextOption().wrapMode(), QTextOption::NoWrap); } void tst_QTextEdit::selectionChanged() @@ -2122,7 +2124,7 @@ void tst_QTextEdit::setDocumentPreservesPalette() QTextDocument *newDoc = new QTextDocument(ed); ed->setDocument(newDoc); - QVERIFY(control->document() == newDoc); + QCOMPARE(control->document(), newDoc); QVERIFY(whitePal.color(QPalette::Active, QPalette::Text) == control->palette().color(QPalette::Active, QPalette::Text)); } @@ -2525,7 +2527,7 @@ void tst_QTextEdit::findWithRegExp() bool found = ed->find(rx); - QVERIFY(found == true); + QVERIFY(found); QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); } @@ -2539,7 +2541,7 @@ void tst_QTextEdit::findBackwardWithRegExp() bool found = ed->find(rx, QTextDocument::FindBackward); - QVERIFY(found == true); + QVERIFY(found); QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); } @@ -2551,7 +2553,7 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() bool found = ed->find(rx); - QVERIFY(found == false); + QVERIFY(!found); QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); } #endif diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp index 24de35ce89..e653a85d96 100644 --- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp @@ -67,6 +67,7 @@ private slots: void allowedAreas(); void orientation(); void addAction(); + void addActionConnect(); void insertAction(); void addSeparator(); void insertSeparator(); @@ -361,6 +362,23 @@ void tst_QToolBar::addAction() } } +static void testFunction() { } + +void tst_QToolBar::addActionConnect() +{ + QToolBar tb; + const QString text = QLatin1String("bla"); + const QIcon icon; + tb.addAction(text, &tb, SLOT(deleteLater())); + tb.addAction(text, &tb, &QMenu::deleteLater); + tb.addAction(text, testFunction); + tb.addAction(text, &tb, testFunction); + tb.addAction(icon, text, &tb, SLOT(deleteLater())); + tb.addAction(icon, text, &tb, &QMenu::deleteLater); + tb.addAction(icon, text, testFunction); + tb.addAction(icon, text, &tb, testFunction); +} + void tst_QToolBar::insertAction() { QToolBar tb; @@ -495,13 +513,13 @@ void tst_QToolBar::insertWidget() QToolBar tb; QPointer<QWidget> widget = new QWidget; QAction *action = tb.addWidget(widget); - QVERIFY(action->parent() == &tb); + QCOMPARE(action->parent(), &tb); QToolBar tb2; tb.removeAction(action); tb2.addAction(action); QVERIFY(widget && widget->parent() == &tb2); - QVERIFY(action->parent() == &tb2); + QCOMPARE(action->parent(), &tb2); } } @@ -960,10 +978,10 @@ void tst_QToolBar::actionOwnership() QToolBar *tb2 = new QToolBar; QPointer<QAction> action = tb1->addAction("test"); - QVERIFY(action->parent() == tb1); + QCOMPARE(action->parent(), tb1); tb2->addAction(action); - QVERIFY(action->parent() == tb1); + QCOMPARE(action->parent(), tb1); delete tb1; QVERIFY(!action); @@ -974,13 +992,13 @@ void tst_QToolBar::actionOwnership() QToolBar *tb2 = new QToolBar; QPointer<QAction> action = tb1->addAction("test"); - QVERIFY(action->parent() == tb1); + QCOMPARE(action->parent(), tb1); tb1->removeAction(action); - QVERIFY(action->parent() == tb1); + QCOMPARE(action->parent(), tb1); tb2->addAction(action); - QVERIFY(action->parent() == tb1); + QCOMPARE(action->parent(), tb1); delete tb1; QVERIFY(!action); diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp index 03fbae2e57..0d1abe5032 100644 --- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp @@ -170,10 +170,10 @@ void tst_QToolButton::collapseTextOnPriority() QStyleOptionToolButton option; button.initStyleOption(&option); - QVERIFY(option.toolButtonStyle == Qt::ToolButtonTextBesideIcon); + QCOMPARE(option.toolButtonStyle, Qt::ToolButtonTextBesideIcon); action.setPriority(QAction::LowPriority); button.initStyleOption(&option); - QVERIFY(option.toolButtonStyle == Qt::ToolButtonIconOnly); + QCOMPARE(option.toolButtonStyle, Qt::ToolButtonIconOnly); } diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index 2ce32c7cf2..a4a3f1f6b3 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1043,15 +1043,15 @@ void tst_QDom::browseElements() QVERIFY(!bar.isNull()); QVERIFY(bar.previousSiblingElement("bar").isNull()); QVERIFY(bar.previousSiblingElement().isNull()); - QVERIFY(bar.nextSiblingElement("bar").tagName() == "bar"); + QCOMPARE(bar.nextSiblingElement("bar").tagName(), QLatin1String("bar")); QVERIFY(bar.nextSiblingElement("bar").nextSiblingElement("bar").isNull()); QDomElement bop = foo.firstChildElement("bop"); QVERIFY(!bop.isNull()); - QVERIFY(bar.nextSiblingElement() == bop); - QVERIFY(bop.nextSiblingElement("bop") == foo.lastChildElement("bop")); - QVERIFY(bop.previousSiblingElement("bar") == foo.firstChildElement("bar")); - QVERIFY(bop.previousSiblingElement("bar") == foo.firstChildElement()); + QCOMPARE(bar.nextSiblingElement(), bop); + QCOMPARE(bop.nextSiblingElement("bop"), foo.lastChildElement("bop")); + QCOMPARE(bop.previousSiblingElement("bar"), foo.firstChildElement("bar")); + QCOMPARE(bop.previousSiblingElement("bar"), foo.firstChildElement()); } void tst_QDom::domNodeMapAndList() diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp index 04f19f6a2b..a5ac58878e 100644 --- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp +++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp @@ -147,7 +147,7 @@ public slots: void requestFinished(QNetworkReply *reply) { - QVERIFY(reply->error() == QNetworkReply::NoError); + QCOMPARE(reply->error(), QNetworkReply::NoError); reply->deleteLater(); } diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent index 1cff3fd44f..1cff3fd44f 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/001.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent index 45f6d8e74e..45f6d8e74e 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/002.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent index 3436f20001..3436f20001 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/004.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent index c6e97f821f..c6e97f821f 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/005.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent index 4df2f0c2ac..4df2f0c2ac 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/006.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent Binary files differindex ab1d696dd7..ab1d696dd7 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/007.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent Binary files differindex c6ca61f9c8..c6ca61f9c8 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/008.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent index 67c3297611..67c3297611 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/009.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent index b19be3a497..b19be3a497 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/011.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent index 8eb1fb9c41..8eb1fb9c41 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/012.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent index 7f25c502dd..7f25c502dd 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/013.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent Binary files differindex 470fd6fe44..470fd6fe44 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/ext-sa/014.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent index 67c3297611..67c3297611 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/002.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent index 931f3ad6d8..931f3ad6d8 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/003-1.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent index 40f7ff58a2..40f7ff58a2 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-1.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent index 61def75cb7..61def75cb7 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/004-2.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent index ade9599032..ade9599032 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-1.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent index bef50b1f38..bef50b1f38 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/005-2.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent index 8f305a82bd..8f305a82bd 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/006.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent index fbf4ca4947..fbf4ca4947 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/007.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent index fbf4ca4947..fbf4ca4947 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/008.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent index fbf4ca4947..fbf4ca4947 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/009.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent index 52a28f5deb..52a28f5deb 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/010.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent index fbf4ca4947..fbf4ca4947 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/011.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent index 7e372e65e9..7e372e65e9 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/012.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent index a3691d9f08..a3691d9f08 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/013.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent index 6eaf779329..6eaf779329 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/014.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent index 00d2f30e1d..00d2f30e1d 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/015.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent index bf77ef8336..bf77ef8336 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/016.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent index ffd9adde61..ffd9adde61 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/017.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent index 2d46f76fc3..2d46f76fc3 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/018.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent index d18201a98b..d18201a98b 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/019.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent index 815291c6d2..815291c6d2 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/020.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent index 9f8f2afd2b..9f8f2afd2b 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/021.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent index 26f2d8beb2..26f2d8beb2 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/022.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent index e3268819f7..e3268819f7 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/023.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent index aa6d0eccac..aa6d0eccac 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/024.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent index 389d259eb1..389d259eb1 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/025.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent index bdc93af639..bdc93af639 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/026.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent index 712cce3700..712cce3700 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/027.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent index ac249d7b2c..ac249d7b2c 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/028.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent index df94df5560..df94df5560 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/029.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent index e3864460df..e3864460df 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/030.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent index f7f94ab152..f7f94ab152 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-1.ent diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent index bef50b1f38..bef50b1f38 100755..100644 --- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent +++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/not-sa/031-2.ent |