diff options
Diffstat (limited to 'tests/auto/gui')
56 files changed, 1714 insertions, 1066 deletions
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index d2fae0e5e3..bff762fd04 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -324,6 +324,11 @@ void tst_QIcoImageFormat::pngCompression() QImage image; reader.jumpToImage(index); + + QSize size = reader.size(); + QCOMPARE(size.width(), width); + QCOMPARE(size.height(), height); + reader.read(&image); QCOMPARE(image.width(), width); diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 20a08e10a2..7333dd739f 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -53,6 +53,7 @@ private slots: void actualSize2_data(); // test with 2 pixmaps with different aspect ratio void actualSize2(); void isNull(); + void isMask(); void swap(); void bestMatch(); void cacheKey(); @@ -75,14 +76,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); @@ -224,6 +219,20 @@ void tst_QIcon::isNull() { QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid()); } +void tst_QIcon::isMask() +{ + QIcon icon; + icon.setIsMask(true); + icon.addPixmap(QPixmap()); + QVERIFY(icon.isMask()); + + QIcon icon2; + icon2.setIsMask(true); + QVERIFY(icon2.isMask()); + icon2.setIsMask(false); + QVERIFY(!icon2.isMask()); +} + void tst_QIcon::swap() { QPixmap p1(1, 1), p2(2, 2); @@ -354,10 +363,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 +383,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 +571,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 +608,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 939226e2b0..23ddfbdd58 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -196,6 +196,8 @@ private slots: void metadataPassthrough(); + void pixelColor(); + private: const QString m_prefix; }; @@ -478,7 +480,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 +1567,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 +1583,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() @@ -3020,5 +3022,21 @@ void tst_QImage::metadataPassthrough() QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio()); } +void tst_QImage::pixelColor() +{ + QImage argb32(1, 1, QImage::Format_ARGB32); + QImage argb32pm(1, 1, QImage::Format_ARGB32_Premultiplied); + + QColor c(Qt::red); + c.setAlpha(128); + argb32.setPixelColor(QPoint(0, 0), c); + argb32pm.setPixelColor(QPoint(0, 0), c); + QCOMPARE(argb32.pixelColor(QPoint(0, 0)), c); + QCOMPARE(argb32pm.pixelColor(QPoint(0, 0)), c); + + QImage t = argb32.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QCOMPARE(t.pixel(0,0), argb32pm.pixel(0,0)); +} + QTEST_GUILESS_MAIN(tst_QImage) #include "tst_qimage.moc" diff --git a/tests/auto/gui/image/qimagereader/images/longcomment.pgm b/tests/auto/gui/image/qimagereader/images/longcomment.pgm new file mode 100644 index 0000000000..a5624b6c73 --- /dev/null +++ b/tests/auto/gui/image/qimagereader/images/longcomment.pgm @@ -0,0 +1,12 @@ +P2 +# A short comment +# A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment A very long comment +24 7 +15 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 +0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 +0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 +0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 +0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 4b3e2606fd..86dd8c4daf 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -36,7 +36,6 @@ #include <QBuffer> #include <QDebug> -#include <QFile> #include <QImage> #include <QImageReader> #include <QImageWriter> @@ -46,6 +45,7 @@ #include <QTcpServer> #include <QTimer> #include <QTemporaryDir> +#include <QTemporaryFile> #include <algorithm> @@ -53,6 +53,22 @@ typedef QMap<QString, QString> QStringMap; typedef QList<int> QIntList; Q_DECLARE_METATYPE(QImage::Format) +static QByteArray msgFileOpenWriteFailed(const QFile &file) +{ + const QString result = QLatin1String("Cannot open \"") + + QDir::toNativeSeparators(file.fileName()) + + QLatin1String("\" for writing: ") + file.errorString(); + return result.toLocal8Bit(); +} + +static QByteArray msgFileOpenReadFailed(const QFile &file) +{ + const QString result = QLatin1String("Cannot open \"") + + QDir::toNativeSeparators(file.fileName()) + + QLatin1String("\" for reading: ") + file.errorString(); + return result.toLocal8Bit(); +} + class tst_QImageReader : public QObject { Q_OBJECT @@ -194,7 +210,7 @@ void tst_QImageReader::initTestCase() prefix = QFINDTESTDATA("images/"); if (prefix.isEmpty()) QFAIL("Can't find images directory!"); - QVERIFY(m_temporaryDir.isValid()); + QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString())); } void tst_QImageReader::cleanupTestCase() @@ -224,6 +240,7 @@ void tst_QImageReader::readImage_data() QTest::newRow("PPM: runners") << QString("runners.ppm") << true << QByteArray("ppm"); QTest::newRow("PPM: test") << QString("test.ppm") << true << QByteArray("ppm"); QTest::newRow("XBM: gnus") << QString("gnus.xbm") << true << QByteArray("xbm"); + QTest::newRow("PGM: longcomment") << QString("longcomment.pgm") << true << QByteArray("pgm"); QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg"); QTest::newRow("JPEG: qtbug13653") << QString("qtbug13653-no_eoi.jpg") << true << QByteArray("jpeg"); @@ -733,7 +750,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 +827,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 +942,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)); } } @@ -1050,7 +1067,7 @@ void tst_QImageReader::readFromDevice() const QString imageFileName = prefix + fileName; QImage expectedImage(imageFileName, format); QFile file(imageFileName); - QVERIFY(file.open(QFile::ReadOnly)); + QVERIFY2(file.open(QFile::ReadOnly), msgFileOpenReadFailed(file).constData()); QByteArray imageData = file.readAll(); QVERIFY(!imageData.isEmpty()); { @@ -1128,12 +1145,11 @@ void tst_QImageReader::readFromFileAfterJunk() SKIP_IF_UNSUPPORTED(format); - QFile::remove("junk"); - QFile junkFile("junk"); - QVERIFY(junkFile.open(QFile::WriteOnly)); + QTemporaryFile junkFile(m_temporaryDir.path() + QLatin1String("/junkXXXXXX")); + QVERIFY2(junkFile.open(), msgFileOpenWriteFailed(junkFile).constData()); QFile imageFile(prefix + fileName); - QVERIFY(imageFile.open(QFile::ReadOnly)); + QVERIFY2(imageFile.open(QFile::ReadOnly), msgFileOpenReadFailed(imageFile).constData()); QByteArray imageData = imageFile.readAll(); QVERIFY(!imageData.isNull()); @@ -1154,7 +1170,7 @@ void tst_QImageReader::readFromFileAfterJunk() } } junkFile.close(); - junkFile.open(QFile::ReadOnly); + QVERIFY2(junkFile.open(), msgFileOpenReadFailed(junkFile).constData()); for (int i = 0; i < iterations; ++i) { QByteArray ole = junkFile.read(9); @@ -1204,7 +1220,7 @@ void tst_QImageReader::devicePosition() QVERIFY(!expected.isNull()); QFile imageFile(prefix + fileName); - QVERIFY(imageFile.open(QFile::ReadOnly)); + QVERIFY2(imageFile.open(QFile::ReadOnly), msgFileOpenReadFailed(imageFile).constData()); QByteArray imageData = imageFile.readAll(); QVERIFY(!imageData.isNull()); int imageDataSize = imageData.size(); diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index 4f04e50294..1dd4d69ea8 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -89,6 +89,7 @@ private slots: void saveToTemporaryFile(); private: + QTemporaryDir m_temporaryDir; QString prefix; QString writePrefix; }; @@ -112,14 +113,11 @@ static void initializePadding(QImage *image) void tst_QImageWriter::initTestCase() { + QVERIFY(m_temporaryDir.isValid()); prefix = QFINDTESTDATA("images/"); if (prefix.isEmpty()) QFAIL("Can't find images directory!"); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) - writePrefix = QDir::homePath(); -#else - writePrefix = prefix; -#endif + writePrefix = m_temporaryDir.path(); } // Testing get/set functions @@ -416,7 +414,7 @@ void tst_QImageWriter::testCanWrite() { // check if canWrite won't leave an empty file QTemporaryDir dir; - QVERIFY(dir.isValid()); + QVERIFY2(dir.isValid(), qPrintable(dir.errorString())); QString fileName(dir.path() + QLatin1String("/001.garble")); QVERIFY(!QFileInfo(fileName).exists()); QImageWriter writer(fileName); @@ -524,7 +522,7 @@ void tst_QImageWriter::saveToTemporaryFile() { // 1) Via QImageWriter's API, with a standard temp file name QTemporaryFile file; - QVERIFY(file.open()); + QVERIFY2(file.open(), qPrintable(file.errorString())); QImageWriter writer(&file, "PNG"); if (writer.canWrite()) QVERIFY(writer.write(image)); @@ -538,7 +536,7 @@ void tst_QImageWriter::saveToTemporaryFile() { // 2) Via QImage's API, with a standard temp file name QTemporaryFile file; - QVERIFY(file.open()); + QVERIFY2(file.open(), qPrintable(file.errorString())); QVERIFY(image.save(&file, "PNG")); file.reset(); QImage tmp; @@ -548,7 +546,7 @@ void tst_QImageWriter::saveToTemporaryFile() { // 3) Via QImageWriter's API, with a named temp file QTemporaryFile file("tempXXXXXX"); - QVERIFY(file.open()); + QVERIFY2(file.open(), qPrintable(file.errorString())); QImageWriter writer(&file, "PNG"); QVERIFY(writer.write(image)); #if defined(Q_OS_WINCE) @@ -559,7 +557,7 @@ void tst_QImageWriter::saveToTemporaryFile() { // 4) Via QImage's API, with a named temp file QTemporaryFile file("tempXXXXXX"); - QVERIFY(file.open()); + QVERIFY2(file.open(), qPrintable(file.errorString())); QVERIFY(image.save(&file, "PNG")); file.reset(); QImage tmp; 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/qclipboard/qclipboard.pro b/tests/auto/gui/kernel/qclipboard/qclipboard.pro index d97c58dea0..b9fd2080e7 100644 --- a/tests/auto/gui/kernel/qclipboard/qclipboard.pro +++ b/tests/auto/gui/kernel/qclipboard/qclipboard.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = copier paster +!winrt: SUBDIRS = copier paster test.depends += $$SUBDIRS SUBDIRS += test diff --git a/tests/auto/gui/kernel/qclipboard/test/test.pro b/tests/auto/gui/kernel/qclipboard/test/test.pro index 586404871f..40bf9c8d8e 100644 --- a/tests/auto/gui/kernel/qclipboard/test/test.pro +++ b/tests/auto/gui/kernel/qclipboard/test/test.pro @@ -3,6 +3,8 @@ SOURCES += ../tst_qclipboard.cpp TARGET = ../tst_qclipboard QT += testlib +osx: LIBS += -framework AppKit + win32 { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qclipboard @@ -15,6 +17,6 @@ wince* { DEPLOYMENT += rsc reg_resource } -TEST_HELPER_INSTALLS = \ +!winrt: TEST_HELPER_INSTALLS = \ ../copier/copier \ ../paster/paster diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index d573d97495..d18f9664fc 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -171,7 +171,7 @@ void tst_QGuiApplication::focusObject() int argc = 0; QGuiApplication app(argc, 0); - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QObject obj1, obj2, obj3; @@ -342,7 +342,7 @@ void tst_QGuiApplication::changeFocusWindow() int argc = 0; QGuiApplication app(argc, 0); - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); @@ -416,11 +416,11 @@ void tst_QGuiApplication::keyboardModifiers() QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); // shortcut events - QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_5, Qt::MetaModifier); + QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_5, Qt::MetaModifier); QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::MetaModifier); - QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_Period, Qt::NoModifier); + QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_Period, Qt::NoModifier); QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier); - QWindowSystemInterface::tryHandleShortcutEvent(window.data(), Qt::Key_0, Qt::ControlModifier); + QTest::keyEvent(QTest::Shortcut, window.data(), Qt::Key_0, Qt::ControlModifier); QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier); // key events @@ -928,7 +928,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/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..0a704b9f64 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)); } } @@ -250,6 +250,14 @@ void tst_QGuiVariant::toColor_data() QColor c("red"); QTest::newRow( "string" ) << QVariant( QString( "red" ) ) << c; QTest::newRow( "solid brush" ) << QVariant( QBrush(c) ) << c; + QTest::newRow("qbytearray") << QVariant(QByteArray("red")) << c; + QTest::newRow("same color") << QVariant(c) << c; + QTest::newRow("qstring(#ff0000)") << QVariant(QString::fromUtf8("#ff0000")) << c; + QTest::newRow("qbytearray(#ff0000)") << QVariant(QByteArray("#ff0000")) << c; + + c.setNamedColor("#88112233"); + QTest::newRow("qstring(#88112233)") << QVariant(QString::fromUtf8("#88112233")) << c; + QTest::newRow("qbytearray(#88112233)") << QVariant(QByteArray("#88112233")) << c; } void tst_QGuiVariant::toColor() @@ -260,6 +268,8 @@ void tst_QGuiVariant::toColor() QVERIFY( value.canConvert( QVariant::Color ) ); QColor d = qvariant_cast<QColor>(value); QCOMPARE( d, result ); + QVERIFY(value.convert(QMetaType::QColor)); + QCOMPARE(d, QColor(value.toString())); } void tst_QGuiVariant::toPixmap_data() @@ -611,9 +621,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 +642,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 +666,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..e3b71e40d1 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -191,7 +191,7 @@ void tst_qinputmethod::cursorRectangle() { QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF()); - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); DummyWindow window; @@ -289,9 +289,12 @@ void tst_qinputmethod::inputDirection() void tst_qinputmethod::inputMethodAccepted() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); + if (!QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive)) + 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..a89f0da4d2 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> @@ -94,6 +95,8 @@ private slots: void windowsTransientChildren(); void requestUpdate(); void initTestCase(); + void stateChange_data(); + void stateChange(); void cleanup(); private: @@ -265,6 +268,38 @@ 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 inline bool qFuzzyCompareWindowSize(const QSize &s1, const QSize &s2, int fuzz) +{ + const int manhattanLength = qAbs(s1.width() - s2.width()) + qAbs(s1.height() - s2.height()); + return manhattanLength <= fuzz; +} + +static inline bool qFuzzyCompareWindowGeometry(const QRect &r1, const QRect &r2, int fuzz) +{ + return qFuzzyCompareWindowPosition(r1.topLeft(), r2.topLeft(), fuzz) + && qFuzzyCompareWindowSize(r1.size(), r2.size(), fuzz); +} + +static QString msgPointMismatch(const QPoint &p1, const QPoint p2) +{ + QString result; + QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength(); + return result; +} + +static QString msgRectMismatch(const QRect &r1, const QRect &r2) +{ + QString result; + QDebug(&result) << r1 << "!=" << r2; + return result; +} + void tst_QWindow::positioning() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability( @@ -272,7 +307,7 @@ void tst_QWindow::positioning() QSKIP("This platform does not support non-fullscreen windows"); } - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); // Some platforms enforce minimum widths for windows, which can cause extra resize @@ -327,21 +362,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 +396,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")); @@ -375,6 +415,52 @@ void tst_QWindow::positioningDuringMinimized() QTRY_COMPARE(window.geometry(), newGeometry); } +// QTBUG-49709: Verify that the normal geometry is correctly restored +// when executing a sequence of window state changes. So far, Windows +// only where state changes have immediate effect. + +typedef QList<Qt::WindowState> WindowStateList; + +Q_DECLARE_METATYPE(WindowStateList) + +void tst_QWindow::stateChange_data() +{ + QTest::addColumn<WindowStateList>("stateSequence"); + + QTest::newRow("normal->min->normal") << + (WindowStateList() << Qt::WindowMinimized << Qt::WindowNoState); + QTest::newRow("normal->maximized->normal") << + (WindowStateList() << Qt::WindowMaximized << Qt::WindowNoState); + QTest::newRow("normal->fullscreen->normal") << + (WindowStateList() << Qt::WindowFullScreen << Qt::WindowNoState); + QTest::newRow("normal->maximized->fullscreen->normal") << + (WindowStateList() << Qt::WindowMaximized << Qt::WindowFullScreen << Qt::WindowNoState); +} + +void tst_QWindow::stateChange() +{ + QFETCH(WindowStateList, stateSequence); + + if (QGuiApplication::platformName().compare(QLatin1String("windows"), Qt::CaseInsensitive)) + QSKIP("Windows-only test"); + + Window window; + window.setTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); + const QRect normalGeometry(m_availableTopLeft + QPoint(40, 40), m_testWindowSize); + window.setGeometry(normalGeometry); + // explicitly use non-fullscreen show. show() can be fullscreen on some platforms + window.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + foreach (Qt::WindowState state, stateSequence) { + window.setWindowState(state); + QCoreApplication::processEvents(); + } + const QRect geometry = window.geometry(); + const int fuzz = int(QHighDpiScaling::factor(&window)); + QVERIFY2(qFuzzyCompareWindowGeometry(geometry, normalGeometry, fuzz), + qPrintable(msgRectMismatch(geometry, normalGeometry))); +} + class PlatformWindowFilter : public QObject { Q_OBJECT @@ -418,14 +504,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 @@ -457,7 +543,7 @@ void tst_QWindow::isExposed() window.hide(); - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This is flaky. Figure out why."); QCoreApplication::processEvents(); @@ -468,7 +554,7 @@ void tst_QWindow::isExposed() void tst_QWindow::isActive() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); Window window; @@ -487,7 +573,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 +585,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 +608,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 +619,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 +740,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 +772,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 +804,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 +815,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 +1032,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. @@ -1112,7 +1201,7 @@ void tst_QWindow::close() void tst_QWindow::activateAndClose() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); for (int i = 0; i < 10; ++i) { @@ -1149,8 +1238,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 +1398,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 +1427,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 @@ -1363,7 +1455,7 @@ void tst_QWindow::tabletEvents() void tst_QWindow::windowModality_QTBUG27039() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QWindow parent; @@ -1458,7 +1550,7 @@ void tst_QWindow::mask() void tst_QWindow::initialSize() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QSize defaultSize(0,0); @@ -1499,7 +1591,7 @@ void tst_QWindow::initialSize() void tst_QWindow::modalDialog() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QWindow normalWindow; @@ -1525,7 +1617,7 @@ void tst_QWindow::modalDialog() void tst_QWindow::modalDialogClosingOneOfTwoModal() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QWindow normalWindow; @@ -1563,7 +1655,7 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal() void tst_QWindow::modalWithChildWindow() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QWindow normalWindow; @@ -1597,7 +1689,7 @@ void tst_QWindow::modalWithChildWindow() void tst_QWindow::modalWindowModallity() { - if (qApp->platformName().toLower() == QLatin1String("wayland")) + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) QSKIP("Wayland: This fails. Figure out why."); QWindow normal_window; @@ -1703,13 +1795,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 752ab0fd8c..1ed78fa0ef 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/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp index 4bc31baba8..5eaee1192a 100644 --- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp +++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp @@ -50,8 +50,7 @@ private slots: void tst_QPdfWriter::basics() { QTemporaryFile file; - if (!file.open()) - QSKIP("Couldn't open temp file!"); + QVERIFY2(file.open(), qPrintable(file.errorString())); QPdfWriter writer(file.fileName()); QCOMPARE(writer.title(), QString()); @@ -150,8 +149,7 @@ void tst_QPdfWriter::testPageMetrics() QSizeF sizeMMf = QSizeF(widthMMf, heightMMf); QTemporaryFile file; - if (!file.open()) - QSKIP("Couldn't open temp file!"); + QVERIFY2(file.open(), qPrintable(file.errorString())); QPdfWriter writer(file.fileName()); QCOMPARE(writer.pageLayout().orientation(), QPageLayout::Portrait); 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 3e66bcbf70..e2ad502a52 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -87,6 +87,8 @@ private slots: void fboRenderingRGB30_data(); void fboRenderingRGB30(); void fboHandleNulledAfterContextDestroyed(); + void fboMRT(); + void fboMRT_differentFormats(); void openGLPaintDevice_data(); void openGLPaintDevice(); void aboutToBeDestroyed(); @@ -515,7 +517,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(); @@ -595,6 +597,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 @@ -607,6 +617,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__) @@ -624,24 +652,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); @@ -721,6 +734,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)); @@ -1175,18 +1332,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 @@ -1215,7 +1372,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..1cb7972cc6 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 (QGuiApplication::platformName().compare(QLatin1String("windows"), Qt::CaseInsensitive)) + 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..93e308b96a 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -149,7 +149,7 @@ void tst_QFont::exactMatch() #endif - if (QGuiApplication::platformName() == QLatin1String("xcb")) { + if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) { QVERIFY(QFont("sans").exactMatch()); QVERIFY(QFont("sans-serif").exactMatch()); QVERIFY(QFont("serif").exactMatch()); @@ -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 @@ -608,6 +608,11 @@ void tst_QFont::serialize_data() font.setStyleName("Regular Black Condensed"); // This wasn't read until 5.4. QTest::newRow("styleName") << font << QDataStream::Qt_5_4; + + font = basicFont; + font.setCapitalization(QFont::AllUppercase); + // This wasn't read until 5.6. + QTest::newRow("capitalization") << font << QDataStream::Qt_5_6; } void tst_QFont::serialize() @@ -728,24 +733,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/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index d8e9836112..ec62bafd6c 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -65,6 +65,7 @@ private slots: void inFontUcs4(); void lineWidth(); void mnemonicTextWidth(); + void leadingBelowLine(); }; tst_QFontMetrics::tst_QFontMetrics() @@ -343,5 +344,16 @@ void tst_QFontMetrics::mnemonicTextWidth() QCOMPARE(fm.size(Qt::TextShowMnemonic, f1), fm.size(Qt::TextShowMnemonic, f2)); QCOMPARE(fm.size(Qt::TextHideMnemonic, f1), fm.size(Qt::TextHideMnemonic, f2)); } + +void tst_QFontMetrics::leadingBelowLine() +{ + QScriptLine line; + line.leading = 10; + line.leadingIncluded = true; + line.ascent = 5; + QCOMPARE(line.height(), line.ascent + line.descent + line.leading); + QCOMPARE(line.base(), line.ascent); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" 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..de0c2d6dbe 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() @@ -1984,7 +1985,12 @@ void tst_QTextLayout::textWidthVsWIdth() "./libs -I/home/ettrich/dev/creator/tools -I../../plugins -I../../shared/scriptwrapper -I../../libs/3rdparty/botan/build -Idialogs -Iactionmanager -Ieditorma" "nager -Iprogressmanager -Iscriptmanager -I.moc/debug-shared -I.uic -o .obj/debug-shared/sidebar.o sidebar.cpp")); - // textWidth includes right bearing, but it should never be LARGER than width if there is space for at least one character + // The naturalTextWidth includes right bearing, but should never be LARGER than line width if + // there is space for at least one character. Unfortunately that assumption may not hold if the + // font engine fails to report an accurate minimum right bearing for the font, eg. when the + // minimum right bearing reported by the font engine doesn't cover all the glyphs in the font. + // The result is that this test may fail in some cases. We should fix this by running the test + // with a font that we know have no suprising right bearings. See qtextlayout.cpp for details. for (int width = 100; width < 1000; ++width) { layout.beginLayout(); QTextLine line = layout.createLine(); @@ -2096,8 +2102,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/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp index c8964eb02c..db4b15530c 100644 --- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp @@ -35,6 +35,7 @@ #include <QtTest/QtTest> #include <qdebug.h> #include <qdesktopservices.h> +#include <qregularexpression.h> class tst_qdesktopservices : public QObject { @@ -74,7 +75,9 @@ void tst_qdesktopservices::openUrl() QCOMPARE(QDesktopServices::openUrl(QUrl()), false); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // this test is only valid on windows on other systems it might mean open a new document in the application handling .file - QTest::ignoreMessage(QtWarningMsg, "ShellExecute 'file://invalid.file' failed (error 3)."); + const QRegularExpression messagePattern("ShellExecute 'file://invalid\\.file' failed \\(error \\d+\\)\\."); + QVERIFY(messagePattern.isValid()); + QTest::ignoreMessage(QtWarningMsg, messagePattern); QCOMPARE(QDesktopServices::openUrl(QUrl("file://invalid.file")), false); #endif } 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); |