summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/gui.pro7
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp4
-rw-r--r--tests/auto/gui/image/qimage/qimage.pro1
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp364
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp6
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp6
-rw-r--r--tests/auto/gui/image/qpixmap/qpixmap.pro2
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp6
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/qstandarditem.pro2
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp2
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro1
-rw-r--r--tests/auto/gui/kernel/qguiapplication/qguiapplication.pro2
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp12
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/black.pngbin0 -> 697 bytes
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/black2.pngbin0 -> 697 bytes
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/test.pro1
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp41
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.qrc6
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp30
-rw-r--r--tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp24
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp8
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp63
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp162
-rw-r--r--tests/auto/gui/painting/qpainter/utils/createImages/main.cpp100
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp24
-rw-r--r--tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp10
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp186
-rw-r--r--tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp218
-rw-r--r--tests/auto/gui/qopengl/qopengl.pro2
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp279
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp160
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp10
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp8
-rw-r--r--tests/auto/gui/text/qstatictext/qstatictext.pro2
-rw-r--r--tests/auto/gui/text/qtextdocument/common.h10
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp50
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp205
-rw-r--r--tests/auto/gui/text/qtextformat/qtextformat.pro2
-rw-r--r--tests/auto/gui/text/qtextformat/tst_qtextformat.cpp243
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp110
-rw-r--r--tests/auto/gui/text/qtextlist/tst_qtextlist.cpp2
-rw-r--r--tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp180
-rw-r--r--tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp7
43 files changed, 1835 insertions, 723 deletions
diff --git a/tests/auto/gui/gui.pro b/tests/auto/gui/gui.pro
index b6c55c5eaa..d250e45a4e 100644
--- a/tests/auto/gui/gui.pro
+++ b/tests/auto/gui/gui.pro
@@ -1,7 +1,10 @@
TEMPLATE=subdirs
-SUBDIRS=\
+
+SUBDIRS = \
+ kernel
+
+!ios: SUBDIRS += \
image \
- kernel \
math3d \
painting \
qopengl \
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index bfe2fbc9f7..0f642bcc10 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.cpp
@@ -45,6 +45,8 @@
#include <qicon.h>
#include <qiconengine.h>
+#include <algorithm>
+
class tst_QIcon : public QObject
{
@@ -421,7 +423,7 @@ void tst_QIcon::availableSizes()
QList<QSize> availableSizes = icon.availableSizes();
QCOMPARE(availableSizes.size(), 3);
- qSort(availableSizes.begin(), availableSizes.end(), sizeLess);
+ std::sort(availableSizes.begin(), availableSizes.end(), sizeLess);
QCOMPARE(availableSizes.at(0), QSize(32,32));
QCOMPARE(availableSizes.at(1), QSize(64,64));
QCOMPARE(availableSizes.at(2), QSize(128,128));
diff --git a/tests/auto/gui/image/qimage/qimage.pro b/tests/auto/gui/image/qimage/qimage.pro
index 467a59ec9f..117e34653d 100644
--- a/tests/auto/gui/image/qimage/qimage.pro
+++ b/tests/auto/gui/image/qimage/qimage.pro
@@ -4,5 +4,6 @@ TARGET = tst_qimage
SOURCES += tst_qimage.cpp
QT += core-private gui-private testlib
+contains(QT_CONFIG, c++11): CONFIG += c++11
TESTDATA += images/*
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 7fdb2f4cba..01a56883bf 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -149,9 +149,25 @@ private slots:
void rgbSwapped_data();
void rgbSwapped();
+ void mirrored_data();
+ void mirrored();
+
+ void inplaceRgbSwapped_data();
+ void inplaceRgbSwapped();
+
+ void inplaceMirrored_data();
+ void inplaceMirrored();
+
+ void inplaceRgbMirrored();
+
+ void inplaceConversion_data();
+ void inplaceConversion();
+
void deepCopyWhenPaintingActive();
void scaled_QTBUG19157();
+ void convertOverUnPreMul();
+
void cleanupFunctions();
};
@@ -183,9 +199,9 @@ void tst_QImage::create()
#if !defined(Q_OS_WINCE)
QT_TRY {
#endif
- //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian);
- QImage image(7000000, 7000000, QImage::Format_Indexed8);
- image.setColorCount(256);
+ //QImage image(7000000, 7000000, 8, 256, QImage::IgnoreEndian);
+ QImage image(7000000, 7000000, QImage::Format_Indexed8);
+ image.setColorCount(256);
cr = !image.isNull();
#if !defined(Q_OS_WINCE)
} QT_CATCH (...) {
@@ -204,15 +220,10 @@ void tst_QImage::createInvalidXPM()
void tst_QImage::createFromUChar()
{
- uchar data[] = {
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- 0xFF,
-#endif
- 1,1,1, 0xFF, 2,2,2, 0xFF, 3,3,3, 0xFF, 4,4,4,
-#if Q_BYTE_ORDER != Q_BIG_ENDIAN
- 0xFF,
-#endif
- };
+ uint data[] = { 0xff010101U,
+ 0xff020202U,
+ 0xff030303U,
+ 0xff040404U };
// When the data is const, nothing you do to the image will change the source data.
QImage i1((const uchar*)data, 2, 2, 8, QImage::Format_RGB32);
@@ -226,8 +237,8 @@ void tst_QImage::createFromUChar()
}
QCOMPARE(i1.pixel(0,0), 0xFF010101U);
QCOMPARE(*(QRgb*)data, 0xFF010101U);
- *((QRgb*)i1.bits()) = 7U;
- QCOMPARE(i1.pixel(0,0), 7U);
+ *((QRgb*)i1.bits()) = 0xFF070707U;
+ QCOMPARE(i1.pixel(0,0), 0xFF070707U);
QCOMPARE(*(QRgb*)data, 0xFF010101U);
// Changing copies should not change the original image or data.
@@ -254,16 +265,16 @@ void tst_QImage::createFromUChar()
}
QCOMPARE(i2.pixel(0,0), 0xFF010101U);
QCOMPARE(*(QRgb*)data, 0xFF010101U);
- *((QRgb*)i2.bits()) = 7U;
- QCOMPARE(i2.pixel(0,0), 7U);
- QCOMPARE(*(QRgb*)data, 7U);
+ *((QRgb*)i2.bits()) = 0xFF070707U;
+ QCOMPARE(i2.pixel(0,0), 0xFF070707U);
+ QCOMPARE(*(QRgb*)data, 0xFF070707U);
// Changing the data will change the image in either case.
QImage i3((uchar*)data, 2, 2, 8, QImage::Format_RGB32);
QImage i4((const uchar*)data, 2, 2, 8, QImage::Format_RGB32);
- *(QRgb*)data = 6U;
- QCOMPARE(i3.pixel(0,0), 6U);
- QCOMPARE(i4.pixel(0,0), 6U);
+ *(QRgb*)data = 0xFF060606U;
+ QCOMPARE(i3.pixel(0,0), 0xFF060606U);
+ QCOMPARE(i4.pixel(0,0), 0xFF060606U);
}
void tst_QImage::formatHandlersInput_data()
@@ -298,16 +309,16 @@ void tst_QImage::formatHandlersInput()
bool formatSupported = false;
for (QList<QByteArray>::Iterator it = formats.begin(); it != formats.end(); ++it) {
if (*it == testFormat.toLower()) {
- formatSupported = true;
- break;
- }
+ formatSupported = true;
+ break;
+ }
}
if (formatSupported) {
// qDebug(QImage::imageFormat(testFile));
- QCOMPARE(testFormat.toLatin1().toLower(), QImageReader::imageFormat(testFile));
+ QCOMPARE(testFormat.toLatin1().toLower(), QImageReader::imageFormat(testFile));
} else {
- QString msg = "Format not supported : ";
- QSKIP(QString(msg + testFormat).toLatin1());
+ QString msg = "Format not supported : ";
+ QSKIP(QString(msg + testFormat).toLatin1());
}
}
@@ -2106,6 +2117,287 @@ void tst_QImage::rgbSwapped()
QCOMPARE(memcmp(image.constBits(), imageSwappedTwice.constBits(), image.byteCount()), 0);
}
+void tst_QImage::mirrored_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<bool>("swap_vertical");
+ QTest::addColumn<bool>("swap_horizontal");
+
+ QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false;
+ QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false;
+ QTest::newRow("Format_ARGB32_Premultiplied, vertical") << QImage::Format_ARGB32_Premultiplied << true << false;
+ QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false;
+ QTest::newRow("Format_ARGB8565_Premultiplied, vertical") << QImage::Format_ARGB8565_Premultiplied << true << false;
+ QTest::newRow("Format_ARGB6666_Premultiplied, vertical") << QImage::Format_ARGB6666_Premultiplied << true << false;
+ QTest::newRow("Format_ARGB4444_Premultiplied, vertical") << QImage::Format_ARGB4444_Premultiplied << true << false;
+ QTest::newRow("Format_RGB666, vertical") << QImage::Format_RGB666 << true << false;
+ QTest::newRow("Format_RGB555, vertical") << QImage::Format_RGB555 << true << false;
+ QTest::newRow("Format_ARGB8555_Premultiplied, vertical") << QImage::Format_ARGB8555_Premultiplied << true << false;
+ QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false;
+ QTest::newRow("Format_RGB444, vertical") << QImage::Format_RGB444 << true << false;
+ QTest::newRow("Format_RGBX8888, vertical") << QImage::Format_RGBX8888 << true << false;
+ QTest::newRow("Format_RGBA8888_Premultiplied, vertical") << QImage::Format_RGBA8888_Premultiplied << true << false;
+ QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false;
+ QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false;
+
+ QTest::newRow("Format_ARGB32_Premultiplied, horizontal") << QImage::Format_ARGB32_Premultiplied << false << true;
+ QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true;
+ QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true;
+ QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true;
+ QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true;
+
+ QTest::newRow("Format_ARGB32_Premultiplied, horizontal+vertical") << QImage::Format_ARGB32_Premultiplied << true << true;
+ QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
+ QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
+ QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true;
+ QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true;
+}
+
+void tst_QImage::mirrored()
+{
+ QFETCH(QImage::Format, format);
+ QFETCH(bool, swap_vertical);
+ QFETCH(bool, swap_horizontal);
+
+ QImage image(16, 16, format);
+
+ switch (format) {
+ case QImage::Format_Mono:
+ for (int i = 0; i < image.height(); ++i) {
+ ushort* scanLine = (ushort*)image.scanLine(i);
+ *scanLine = (i % 2) ? 0x5555U : 0xCCCCU;
+ }
+ break;
+ case QImage::Format_Indexed8:
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ image.setColor(i*16+j, qRgb(j*16, i*16, 0));
+ image.setPixel(j, i, i*16+j);
+ }
+ }
+ break;
+ default:
+ for (int i = 0; i < image.height(); ++i)
+ for (int j = 0; j < image.width(); ++j)
+ image.setPixel(j, i, qRgb(j*16, i*16, 0));
+ break;
+ }
+
+ QImage imageMirrored = image.mirrored(swap_horizontal, swap_vertical);
+
+ for (int i = 0; i < image.height(); ++i) {
+ int mirroredI = swap_vertical ? (image.height() - i - 1) : i;
+ for (int j = 0; j < image.width(); ++j) {
+ QRgb referenceColor = image.pixel(j, i);
+ int mirroredJ = swap_horizontal ? (image.width() - j - 1) : j;
+ QRgb mirroredColor = imageMirrored.pixel(mirroredJ, mirroredI);
+ QCOMPARE(mirroredColor, referenceColor);
+ }
+ }
+
+ QImage imageMirroredTwice = imageMirrored.mirrored(swap_horizontal, swap_vertical);
+
+ QCOMPARE(image, imageMirroredTwice);
+
+ if (format != QImage::Format_Mono)
+ QCOMPARE(memcmp(image.constBits(), imageMirroredTwice.constBits(), image.byteCount()), 0);
+ else {
+ for (int i = 0; i < image.height(); ++i)
+ for (int j = 0; j < image.width(); ++j)
+ QCOMPARE(image.pixel(j,i), imageMirroredTwice.pixel(j,i));
+ }
+}
+
+void tst_QImage::inplaceRgbSwapped_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGBA8888") << QImage::Format_RGBA8888;
+ QTest::newRow("Format_RGB888") << QImage::Format_RGB888;
+ QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
+ QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
+}
+
+void tst_QImage::inplaceRgbSwapped()
+{
+#if defined(Q_COMPILER_REF_QUALIFIERS)
+ QFETCH(QImage::Format, format);
+
+ QImage image(64, 1, format);
+ image.fill(0);
+
+ QVector<QRgb> testColor(image.width());
+ for (int i = 0; i < image.width(); ++i)
+ testColor[i] = qRgb(i * 2, i * 3, 255 - i * 4);
+
+ if (format == QImage::Format_Indexed8) {
+ for (int i = 0; i < image.width(); ++i) {
+ image.setColor(i, testColor[i]);
+ image.setPixel(i, 0, i);
+ }
+ } else {
+ for (int i = 0; i < image.width(); ++i)
+ image.setPixel(i, 0, testColor[i]);
+ }
+
+ const uchar* orginalPtr = image.constScanLine(0);
+ QImage imageSwapped = std::move(image).rgbSwapped();
+
+ for (int i = 0; i < imageSwapped.width(); ++i) {
+ QRgb referenceColor = testColor[i];
+ QRgb swappedColor = imageSwapped.pixel(i, 0);
+ QCOMPARE(qRed(swappedColor) & 0xf8, qBlue(referenceColor) & 0xf8);
+ QCOMPARE(qGreen(swappedColor) & 0xf8, qGreen(referenceColor) & 0xf8);
+ QCOMPARE(qBlue(swappedColor) & 0xf8, qRed(referenceColor) & 0xf8);
+ }
+
+ QCOMPARE(imageSwapped.constScanLine(0), orginalPtr);
+#endif
+}
+
+
+void tst_QImage::inplaceMirrored_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<bool>("swap_vertical");
+ QTest::addColumn<bool>("swap_horizontal");
+
+ QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false;
+ QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false;
+ QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false;
+ QTest::newRow("Format_Indexed8, vertical") << QImage::Format_Indexed8 << true << false;
+ QTest::newRow("Format_Mono, vertical") << QImage::Format_Mono << true << false;
+
+ QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << false << true;
+ QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true;
+ QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true;
+ QTest::newRow("Format_Indexed8, horizontal") << QImage::Format_Indexed8 << false << true;
+ QTest::newRow("Format_Mono, horizontal") << QImage::Format_Mono << false << true;
+
+ QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << true << true;
+ QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
+ QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
+ QTest::newRow("Format_Indexed8, horizontal+vertical") << QImage::Format_Indexed8 << true << true;
+ QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true;
+}
+
+void tst_QImage::inplaceMirrored()
+{
+#if defined(Q_COMPILER_REF_QUALIFIERS)
+ QFETCH(QImage::Format, format);
+ QFETCH(bool, swap_vertical);
+ QFETCH(bool, swap_horizontal);
+
+ QImage image(16, 16, format);
+
+ switch (format) {
+ case QImage::Format_Mono:
+ for (int i = 0; i < image.height(); ++i) {
+ ushort* scanLine = (ushort*)image.scanLine(i);
+ *scanLine = (i % 2) ? 0x0fffU : 0xf000U;
+ }
+ break;
+ case QImage::Format_Indexed8:
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ image.setColor(i*16+j, qRgb(j*16, i*16, 0));
+ image.setPixel(j, i, i*16+j);
+ }
+ }
+ break;
+ default:
+ for (int i = 0; i < image.height(); ++i)
+ for (int j = 0; j < image.width(); ++j)
+ image.setPixel(j, i, qRgb(j*16, i*16, 0));
+ }
+
+ const uchar* originalPtr = image.constScanLine(0);
+
+ QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical);
+ if (format != QImage::Format_Mono) {
+ for (int i = 0; i < imageMirrored.height(); ++i) {
+ int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
+ for (int j = 0; j < imageMirrored.width(); ++j) {
+ int mirroredJ = swap_horizontal ? (imageMirrored.width() - j - 1) : j;
+ QRgb mirroredColor = imageMirrored.pixel(mirroredJ, mirroredI);
+ QCOMPARE(qRed(mirroredColor) & 0xF8, j * 16);
+ QCOMPARE(qGreen(mirroredColor) & 0xF8, i * 16);
+ }
+ }
+ } else {
+ for (int i = 0; i < imageMirrored.height(); ++i) {
+ ushort* scanLine = (ushort*)imageMirrored.scanLine(i);
+ ushort expect;
+ if (swap_vertical && swap_horizontal)
+ expect = (i % 2) ? 0x000fU : 0xfff0U;
+ else if (swap_vertical)
+ expect = (i % 2) ? 0xf000U : 0x0fffU;
+ else
+ expect = (i % 2) ? 0xfff0U : 0x000fU;
+ QCOMPARE(*scanLine, expect);
+ }
+ }
+ QCOMPARE(imageMirrored.constScanLine(0), originalPtr);
+#endif
+}
+
+void tst_QImage::inplaceRgbMirrored()
+{
+#if defined(Q_COMPILER_REF_QUALIFIERS)
+ QImage image1(32, 32, QImage::Format_ARGB32);
+ QImage image2(32, 32, QImage::Format_ARGB32);
+ image1.fill(0);
+ image2.fill(0);
+ const uchar* originalPtr1 = image1.constScanLine(0);
+ const uchar* originalPtr2 = image2.constScanLine(0);
+
+ QCOMPARE(std::move(image1).rgbSwapped().mirrored().constScanLine(0), originalPtr1);
+ QCOMPARE(std::move(image2).mirrored().rgbSwapped().constScanLine(0), originalPtr2);
+#endif
+}
+
+void tst_QImage::inplaceConversion_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<QImage::Format>("dest_format");
+
+ QTest::newRow("Format_ARGB32 -> Format_RGBA8888") << QImage::Format_ARGB32 << QImage::Format_RGBA8888;
+ QTest::newRow("Format_RGB888 -> Format_ARGB6666_Premultiplied") << QImage::Format_RGB888 << QImage::Format_ARGB6666_Premultiplied;
+ QTest::newRow("Format_RGB16 -> Format_RGB555") << QImage::Format_RGB16 << QImage::Format_RGB555;
+ QTest::newRow("Format_RGB666 -> Format_RGB888") << QImage::Format_RGB666 << QImage::Format_RGB888;
+ QTest::newRow("Format_ARGB8565_Premultiplied, Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8565_Premultiplied << QImage::Format_ARGB8555_Premultiplied;
+ QTest::newRow("Format_ARGB4444_Premultiplied, Format_RGB444") << QImage::Format_ARGB4444_Premultiplied << QImage::Format_RGB444;
+}
+
+void tst_QImage::inplaceConversion()
+{
+ // Test that conversions between RGB formats of the same bitwidth can be done inplace.
+#if defined(Q_COMPILER_REF_QUALIFIERS)
+ QFETCH(QImage::Format, format);
+ QFETCH(QImage::Format, dest_format);
+
+ QImage image(16, 16, format);
+
+ for (int i = 0; i < image.height(); ++i)
+ for (int j = 0; j < image.width(); ++j)
+ image.setPixel(j, i, qRgb(j*16, i*16, 0));
+
+ const uchar* originalPtr = image.constScanLine(0);
+
+ QImage imageConverted = std::move(image).convertToFormat(dest_format);
+ for (int i = 0; i < imageConverted.height(); ++i) {
+ for (int j = 0; j < imageConverted.width(); ++j) {
+ QRgb convertedColor = imageConverted.pixel(j,i);
+ QCOMPARE(qRed(convertedColor) & 0xF0, j * 16);
+ QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16);
+ }
+ }
+
+ QCOMPARE(imageConverted.constScanLine(0), originalPtr);
+#endif
+}
+
void tst_QImage::deepCopyWhenPaintingActive()
{
QImage image(64, 64, QImage::Format_ARGB32_Premultiplied);
@@ -2127,6 +2419,26 @@ void tst_QImage::scaled_QTBUG19157()
QVERIFY(!foo.isNull());
}
+void tst_QImage::convertOverUnPreMul()
+{
+ QImage image(256, 256, QImage::Format_ARGB32_Premultiplied);
+
+ for (int j = 0; j < 256; j++) {
+ for (int i = 0; i <= j; i++) {
+ image.setPixel(i, j, qRgba(i, i, i, j));
+ }
+ }
+
+ QImage image2 = image.convertToFormat(QImage::Format_ARGB32).convertToFormat(QImage::Format_ARGB32_Premultiplied);
+
+ for (int j = 0; j < 256; j++) {
+ for (int i = 0; i <= j; i++) {
+ QCOMPARE(qAlpha(image2.pixel(i, j)), qAlpha(image.pixel(i, j)));
+ QCOMPARE(qGray(image2.pixel(i, j)), qGray(image.pixel(i, j)));
+ }
+ }
+}
+
static void cleanupFunction(void* info)
{
bool *called = static_cast<bool*>(info);
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index b684231e10..5decbc86fc 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -55,6 +55,8 @@
#include <QTimer>
#include <QTemporaryDir>
+#include <algorithm>
+
typedef QMap<QString, QString> QStringMap;
typedef QList<int> QIntList;
Q_DECLARE_METATYPE(QImage::Format)
@@ -559,7 +561,7 @@ void tst_QImageReader::supportedFormats()
{
QList<QByteArray> formats = QImageReader::supportedImageFormats();
QList<QByteArray> sortedFormats = formats;
- qSort(sortedFormats);
+ std::sort(sortedFormats.begin(), sortedFormats.end());
// check that the list is sorted
QCOMPARE(formats, sortedFormats);
@@ -576,7 +578,7 @@ void tst_QImageReader::supportedMimeTypes()
{
QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes();
QList<QByteArray> sortedMimeTypes = mimeTypes;
- qSort(sortedMimeTypes);
+ std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end());
// check that the list is sorted
QCOMPARE(mimeTypes, sortedMimeTypes);
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index b10b5704c3..c9f8a1f681 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -57,6 +57,8 @@
# include <unistd.h>
#endif
+#include <algorithm>
+
typedef QMap<QString, QString> QStringMap;
typedef QList<int> QIntList;
Q_DECLARE_METATYPE(QImageWriter::ImageWriterError)
@@ -342,7 +344,7 @@ void tst_QImageWriter::supportedFormats()
{
QList<QByteArray> formats = QImageWriter::supportedImageFormats();
QList<QByteArray> sortedFormats = formats;
- qSort(sortedFormats);
+ std::sort(sortedFormats.begin(), sortedFormats.end());
// check that the list is sorted
QCOMPARE(formats, sortedFormats);
@@ -359,7 +361,7 @@ void tst_QImageWriter::supportedMimeTypes()
{
QList<QByteArray> mimeTypes = QImageWriter::supportedMimeTypes();
QList<QByteArray> sortedMimeTypes = mimeTypes;
- qSort(sortedMimeTypes);
+ std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end());
// check that the list is sorted
QCOMPARE(mimeTypes, sortedMimeTypes);
diff --git a/tests/auto/gui/image/qpixmap/qpixmap.pro b/tests/auto/gui/image/qpixmap/qpixmap.pro
index bdd0c15788..33c301a500 100644
--- a/tests/auto/gui/image/qpixmap/qpixmap.pro
+++ b/tests/auto/gui/image/qpixmap/qpixmap.pro
@@ -5,7 +5,7 @@ QT += core-private gui-private testlib
qtHaveModule(widgets): QT += widgets widgets-private
SOURCES += tst_qpixmap.cpp
-!wince* {
+!wince*:!winrt {
win32:LIBS += -lgdi32 -luser32
}
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index cb5d836291..79dc3f311a 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -116,7 +116,7 @@ private slots:
void convertFromImageDetach();
void convertFromImageCacheKey();
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void toWinHBITMAP_data();
void toWinHBITMAP();
void fromWinHBITMAP_data();
@@ -805,7 +805,7 @@ void tst_QPixmap::convertFromImageCacheKey()
QCOMPARE(copy.cacheKey(), pix.cacheKey());
}
-#if defined(Q_OS_WIN)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap);
@@ -1024,7 +1024,7 @@ void tst_QPixmap::fromWinHICON()
#endif // Q_OS_WINCE
}
-#endif // Q_OS_WIN
+#endif // Q_OS_WIN && !Q_OS_WINRT
void tst_QPixmap::onlyNullPixmapsOutsideGuiThread()
{
diff --git a/tests/auto/gui/itemmodels/qstandarditem/qstandarditem.pro b/tests/auto/gui/itemmodels/qstandarditem/qstandarditem.pro
index 282737ed7d..b85d475e97 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/qstandarditem.pro
+++ b/tests/auto/gui/itemmodels/qstandarditem/qstandarditem.pro
@@ -1,7 +1,7 @@
CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qstandarditem
-QT += gui testlib
+QT += testlib
SOURCES += tst_qstandarditem.cpp
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index 085dfd0461..761f6371db 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -1468,7 +1468,7 @@ static QModelIndex indexFromText(QStandardItemModel *model, const QString &text)
struct FriendlyTreeView : public QTreeView
{
friend class tst_QStandardItemModel;
- Q_DECLARE_PRIVATE(QTreeView)
+ Q_DECLARE_PRIVATE(QTreeView)
};
#endif
diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro
index b84ff760ca..a4abaeedc6 100644
--- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro
+++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro
@@ -1,4 +1,3 @@
TEMPLATE = app
TARGET = qfileopeneventexternal
-QT += core gui
SOURCES += qfileopeneventexternal.cpp
diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
index 79acb9e5f1..cd363bab31 100644
--- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
+++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
@@ -5,5 +5,5 @@ include($${CORE_TEST_PATH}/qcoreapplication.pro)
INCLUDEPATH += $$CORE_TEST_PATH
TARGET = tst_qguiapplication
-QT += gui gui-private
+QT += gui-private
SOURCES += tst_qguiapplication.cpp
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index d4237b135f..6ef9957fa1 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -60,6 +60,7 @@ class tst_QGuiApplication: public tst_QCoreApplication
private slots:
void displayName();
+ void firstWindowTitle();
void focusObject();
void allWindows();
void topLevelWindows();
@@ -83,6 +84,17 @@ void tst_QGuiApplication::displayName()
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
}
+void tst_QGuiApplication::firstWindowTitle()
+{
+ int argc = 3;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication"), const_cast<char*>("-qwindowtitle"), const_cast<char*>("User Title") };
+ QGuiApplication app(argc, argv);
+ QWindow window;
+ window.setTitle("Application Title");
+ window.show();
+ QCOMPARE(window.title(), QString("User Title"));
+}
+
class DummyWindow : public QWindow
{
public:
diff --git a/tests/auto/gui/kernel/qguivariant/test/black.png b/tests/auto/gui/kernel/qguivariant/test/black.png
new file mode 100644
index 0000000000..6c94085ed5
--- /dev/null
+++ b/tests/auto/gui/kernel/qguivariant/test/black.png
Binary files differ
diff --git a/tests/auto/gui/kernel/qguivariant/test/black2.png b/tests/auto/gui/kernel/qguivariant/test/black2.png
new file mode 100644
index 0000000000..6c94085ed5
--- /dev/null
+++ b/tests/auto/gui/kernel/qguivariant/test/black2.png
Binary files differ
diff --git a/tests/auto/gui/kernel/qguivariant/test/test.pro b/tests/auto/gui/kernel/qguivariant/test/test.pro
index e3b4a350ca..c4123797d2 100644
--- a/tests/auto/gui/kernel/qguivariant/test/test.pro
+++ b/tests/auto/gui/kernel/qguivariant/test/test.pro
@@ -2,6 +2,7 @@ CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qguivariant
SOURCES += tst_qguivariant.cpp
+RESOURCES = tst_qguivariant.qrc
INCLUDEPATH += $$PWD/../../../../other/qvariant_common
QT += testlib
RESOURCES += qguivariant.qrc
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
index 7512829e09..431db86330 100644
--- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
@@ -126,6 +126,8 @@ private slots:
void implicitConstruction();
void guiVariantAtExit();
+
+ void iconEquality();
};
void tst_QGuiVariant::constructor_invalid_data()
@@ -466,8 +468,8 @@ void tst_QGuiVariant::vector3D()
QVariant variant;
QVector3D vector = qvariant_cast<QVector3D>(variant);
QVERIFY(vector.isNull());
- variant.setValue(QVector3D(0.1, 0.2, 0.3));
- QCOMPARE(QVector3D(0.1, 0.2, 0.3), qvariant_cast<QVector3D>(variant));
+ variant.setValue(QVector3D(0.1f, 0.2f, 0.3f));
+ QCOMPARE(QVector3D(0.1f, 0.2f, 0.3f), qvariant_cast<QVector3D>(variant));
void *pvector = QMetaType::create(QVariant::Vector3D, 0);
QVERIFY(pvector);
@@ -479,8 +481,8 @@ void tst_QGuiVariant::vector4D()
QVariant variant;
QVector4D vector = qvariant_cast<QVector4D>(variant);
QVERIFY(vector.isNull());
- variant.setValue(QVector4D(0.1, 0.2, 0.3, 0.4));
- QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qvariant_cast<QVector4D>(variant));
+ variant.setValue(QVector4D(0.1f, 0.2f, 0.3f, 0.4f));
+ QCOMPARE(QVector4D(0.1f, 0.2f, 0.3f, 0.4f), qvariant_cast<QVector4D>(variant));
void *pvector = QMetaType::create(QVariant::Vector4D, 0);
QVERIFY(pvector);
@@ -492,8 +494,8 @@ void tst_QGuiVariant::quaternion()
QVariant variant;
QQuaternion quaternion = qvariant_cast<QQuaternion>(variant);
QVERIFY(quaternion.isIdentity());
- variant.setValue(QQuaternion(0.1, 0.2, 0.3, 0.4));
- QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qvariant_cast<QQuaternion>(variant));
+ variant.setValue(QQuaternion(0.1f, 0.2f, 0.3f, 0.4f));
+ QCOMPARE(QQuaternion(0.1f, 0.2f, 0.3f, 0.4f), qvariant_cast<QQuaternion>(variant));
void *pquaternion = QMetaType::create(QVariant::Quaternion, 0);
QVERIFY(pquaternion);
@@ -761,5 +763,32 @@ void tst_QGuiVariant::guiVariantAtExit()
QVERIFY(true);
}
+void tst_QGuiVariant::iconEquality()
+{
+ QIcon i;
+ QVariant a = i;
+ QVariant b = i;
+ QCOMPARE(a, b);
+
+ i = QIcon(":/black.png");
+ a = i;
+ QVERIFY(a != b);
+
+ b = a;
+ QCOMPARE(a, b);
+
+ i = QIcon(":/black2.png");
+ a = i;
+ QVERIFY(a != b);
+
+ b = i;
+ QCOMPARE(a, b);
+
+ // This is a "different" QIcon
+ // even if the contents are the same
+ b = QIcon(":/black2.png");
+ QVERIFY(a != b);
+}
+
QTEST_MAIN(tst_QGuiVariant)
#include "tst_qguivariant.moc"
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.qrc b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.qrc
new file mode 100644
index 0000000000..15cfde5788
--- /dev/null
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+<file>black.png</file>
+<file>black2.png</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index 493d7e20c5..94353703dc 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -50,7 +50,9 @@
#include <QLibraryInfo>
#ifdef Q_OS_MAC
+#ifdef Q_OS_OSX
#include <Carbon/Carbon.h>
+#endif
struct MacSpecialKey {
int key;
ushort macSymbol;
@@ -73,10 +75,12 @@ static const MacSpecialKey entries[NumEntries] = {
{ Qt::Key_Down, 0x2193 },
{ Qt::Key_PageUp, 0x21DE },
{ Qt::Key_PageDown, 0x21DF },
+#ifdef Q_OS_OSX
{ Qt::Key_Shift, kShiftUnicode },
{ Qt::Key_Control, kCommandUnicode },
{ Qt::Key_Meta, kControlUnicode },
{ Qt::Key_Alt, kOptionUnicode },
+#endif
{ Qt::Key_CapsLock, 0x21EA },
};
@@ -527,7 +531,7 @@ void tst_QKeySequence::toStringFromKeycode()
void tst_QKeySequence::streamOperators_data()
{
- operatorQString_data();
+ operatorQString_data();
}
void tst_QKeySequence::streamOperators()
@@ -535,21 +539,21 @@ void tst_QKeySequence::streamOperators()
QFETCH( int, modifiers );
QFETCH( int, keycode );
- QByteArray data;
- QKeySequence refK( modifiers | keycode );
- QKeySequence orgK( "Ctrl+A" );
- QKeySequence copyOrgK = orgK;
- QVERIFY( copyOrgK == orgK );
+ QByteArray data;
+ QKeySequence refK( modifiers | keycode );
+ QKeySequence orgK( "Ctrl+A" );
+ QKeySequence copyOrgK = orgK;
+ QVERIFY( copyOrgK == orgK );
- QDataStream in(&data, QIODevice::WriteOnly);
- in << refK;
- QDataStream out(&data, QIODevice::ReadOnly);
- out >> orgK;
+ QDataStream in(&data, QIODevice::WriteOnly);
+ in << refK;
+ QDataStream out(&data, QIODevice::ReadOnly);
+ out >> orgK;
- QVERIFY( orgK == refK );
+ QVERIFY( orgK == refK );
- // check if detached
- QVERIFY( orgK != copyOrgK );
+ // check if detached
+ QVERIFY( orgK != copyOrgK );
}
diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
index 424b5fea3a..828c1fc41f 100644
--- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
@@ -61,21 +61,21 @@ public:
protected:
void mousePressEvent(QMouseEvent *e)
{
- QWindow::mousePressEvent(e);
- mousePressButton = e->button();
- mousePressButtons = e->buttons();
- mousePressModifiers = e->modifiers();
- mousePressEventRecieved = true;
- e->accept();
+ QWindow::mousePressEvent(e);
+ mousePressButton = e->button();
+ mousePressButtons = e->buttons();
+ mousePressModifiers = e->modifiers();
+ mousePressEventRecieved = true;
+ e->accept();
}
void mouseReleaseEvent(QMouseEvent *e)
{
- QWindow::mouseReleaseEvent(e);
- mouseReleaseButton = e->button();
- mouseReleaseButtons = e->buttons();
- mouseReleaseModifiers = e->modifiers();
- mouseReleaseEventRecieved = true;
- e->accept();
+ QWindow::mouseReleaseEvent(e);
+ mouseReleaseButton = e->button();
+ mouseReleaseButtons = e->buttons();
+ mouseReleaseModifiers = e->modifiers();
+ mouseReleaseEventRecieved = true;
+ e->accept();
}
};
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
index ef800bd995..48f079a24e 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
+++ b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
@@ -183,9 +183,9 @@ TstWidget::TstWidget()
connect( pb, SIGNAL(pressed()), this, SLOT(buttonPressed()) );
-// QScrollBar *sb = new QScrollBar( Qt::Horizontal, this );
+// QScrollBar *sb = new QScrollBar( Qt::Horizontal, this );
-// sb->setGeometry( 5, pb->geometry().bottom() + 5, 100, sb->sizeHint().height() );
+// sb->setGeometry( 5, pb->geometry().bottom() + 5, 100, sb->sizeHint().height() );
d = new TstDialog( pb, this , 0 );
}
@@ -218,8 +218,8 @@ void TstDialog::releaseMouse()
void TstDialog::closeDialog()
{
if ( isVisible() ) {
- c++;
- accept();
+ c++;
+ accept();
}
}
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 259c840ae7..7e6313295b 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -61,6 +61,7 @@ private slots:
void eventOrderOnShow();
void resizeEventAfterResize();
void mapGlobal();
+ void positioning_data();
void positioning();
void isExposed();
void isActive();
@@ -81,6 +82,7 @@ private slots:
void windowModality_QTBUG27039();
void visibility();
void mask();
+ void initialSize();
void initTestCase()
{
@@ -93,7 +95,6 @@ private:
QTouchDevice *touchDevice;
};
-
void tst_QWindow::mapGlobal()
{
QWindow a;
@@ -116,10 +117,10 @@ void tst_QWindow::mapGlobal()
class Window : public QWindow
{
public:
- Window()
+ Window(const Qt::WindowFlags flags = Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
{
reset();
- setFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
+ setFlags(flags);
}
void reset()
@@ -188,6 +189,23 @@ void tst_QWindow::resizeEventAfterResize()
QTRY_COMPARE(window.received(QEvent::Resize), 2);
}
+void tst_QWindow::positioning_data()
+{
+ QTest::addColumn<int>("windowflags");
+ QTest::addColumn<int>("resizecount");
+
+ QTest::newRow("default") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint)
+#if defined(Q_OS_OSX) && MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+ << 4;
+#else
+ << 3;
+#endif
+
+#ifdef Q_OS_OSX
+ QTest::newRow("fake") << int(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) << 4;
+#endif
+}
+
void tst_QWindow::positioning()
{
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(
@@ -200,7 +218,9 @@ void tst_QWindow::positioning()
const QSize size = QSize(300, 40);
const QRect geometry(QPoint(80, 80), size);
- Window window;
+ QFETCH(int, windowflags);
+ QFETCH(int, resizecount);
+ Window window((Qt::WindowFlags)windowflags);
window.setGeometry(QRect(QPoint(20, 20), size));
window.setFramePosition(QPoint(40, 40)); // Move window around before show, size must not change.
QCOMPARE(window.geometry().size(), size);
@@ -223,14 +243,13 @@ void tst_QWindow::positioning()
window.setWindowState(Qt::WindowFullScreen);
QCoreApplication::processEvents();
-#ifdef Q_OS_OSX
- QEXPECT_FAIL("", "Multiple failures in this test on Mac OS X, see QTBUG-23059", Abort);
-#endif
QTRY_COMPARE(window.received(QEvent::Resize), 2);
+ QTest::qWait(2000);
+
window.setWindowState(Qt::WindowNoState);
QCoreApplication::processEvents();
- QTRY_COMPARE(window.received(QEvent::Resize), 3);
+ QTRY_COMPARE(window.received(QEvent::Resize), resizecount);
QTRY_COMPARE(originalPos, window.position());
QTRY_COMPARE(originalFramePos, window.framePosition());
@@ -239,7 +258,7 @@ 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 = QGuiApplication::primaryScreen()->availableVirtualGeometry().topLeft() + QPoint(40, 40);
+ QPoint framePos = QPlatformScreen::platformScreenForWindow(&window)->availableGeometry().topLeft() + QPoint(40, 40);
window.reset();
window.setFramePosition(framePos);
@@ -1168,6 +1187,32 @@ void tst_QWindow::mask()
QCOMPARE(window.mask(), mask);
}
+void tst_QWindow::initialSize()
+{
+ QSize defaultSize(0,0);
+ {
+ Window w;
+ w.show();
+ QTRY_VERIFY(w.width() > 0);
+ QTRY_VERIFY(w.height() > 0);
+ defaultSize = QSize(w.width(), w.height());
+ }
+ {
+ Window w;
+ w.setWidth(200);
+ w.show();
+ QTRY_COMPARE(w.width(), 200);
+ QTRY_VERIFY(w.height() > 0);
+ }
+ {
+ Window w;
+ w.resize(200, 42);
+ w.show();
+ QTRY_COMPARE(w.width(), 200);
+ QTRY_COMPARE(w.height(), 42);
+ }
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow)
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 4c4e46de05..e4340451ce 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -80,6 +80,7 @@
Q_DECLARE_METATYPE(QGradientStops)
Q_DECLARE_METATYPE(QPainterPath)
Q_DECLARE_METATYPE(QImage::Format)
+Q_DECLARE_METATYPE(QPainter::CompositionMode)
class tst_QPainter : public QObject
{
@@ -290,6 +291,9 @@ private slots:
void cosmeticStrokerClipping_data();
void cosmeticStrokerClipping();
+ void blendARGBonRGB_data();
+ void blendARGBonRGB();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -514,7 +518,7 @@ void tst_QPainter::drawPixmap_comp()
bool different = false;
for (int y=0; y<result.height(); ++y)
for (int x=0; x<result.width(); ++x) {
- bool diff;
+ bool diff;
if (qAlpha(expected) == 0) {
diff = qAlpha(result.pixel(x, y)) != 0;
} else {
@@ -526,12 +530,12 @@ void tst_QPainter::drawPixmap_comp()
|| (qAbs(qBlue(pix) - qBlue(expected)) > off)
|| (qAbs(qAlpha(pix) - qAlpha(expected)) > off);
}
- if (diff && !different)
- qDebug( "Different at %d,%d pixel [%d,%d,%d,%d] expected [%d,%d,%d,%d]", x, y,
+ if (diff && !different)
+ qDebug( "Different at %d,%d pixel [%d,%d,%d,%d] expected [%d,%d,%d,%d]", x, y,
qRed(result.pixel(x, y)), qGreen(result.pixel(x, y)),
qBlue(result.pixel(x, y)), qAlpha(result.pixel(x, y)),
qRed(expected), qGreen(expected), qBlue(expected), qAlpha(expected));
- different |= diff;
+ different |= diff;
}
QVERIFY(!different);
@@ -563,24 +567,24 @@ void tst_QPainter::saveAndRestore_data()
QRect viewport = p.viewport();
QTest::newRow("Original") << font << pen << brush << backgroundColor << int(backgroundMode)
- << brushOrigin << clipRegion << window << viewport;
+ << brushOrigin << clipRegion << window << viewport;
QFont font2 = font;
font2.setPointSize( 24 );
QTest::newRow("Modified font.pointSize, brush, backgroundColor, backgroundMode")
<< font2 << pen << QBrush(Qt::red) << QColor(Qt::blue) << int(Qt::TransparentMode)
- << brushOrigin << clipRegion << window << viewport;
+ << brushOrigin << clipRegion << window << viewport;
font2 = font;
font2.setPixelSize( 20 );
QTest::newRow("Modified font.pixelSize, brushOrigin, pos")
<< font2 << pen << brush << backgroundColor << int(backgroundMode)
- << QPoint( 50, 32 ) << clipRegion << window << viewport;
+ << QPoint( 50, 32 ) << clipRegion << window << viewport;
QTest::newRow("Modified clipRegion, window, viewport")
<< font << pen << brush << backgroundColor << int(backgroundMode)
- << brushOrigin << clipRegion.subtracted(QRect(10,10,50,30))
- << QRect(-500, -500, 500, 500 ) << QRect( 0, 0, 50, 50 );
+ << brushOrigin << clipRegion.subtracted(QRect(10,10,50,30))
+ << QRect(-500, -500, 500, 500 ) << QRect( 0, 0, 50, 50 );
}
void tst_QPainter::saveAndRestore()
@@ -665,13 +669,13 @@ QBitmap tst_QPainter::getBitmap( const QString &dir, const QString &filename, bo
return QBitmap();
}
if ( mask ) {
- QBitmap mask;
- QString maskFilename = dir + QString( "/%1-mask.xbm" ).arg( filename );
- if ( !mask.load( maskFilename ) ) {
- QWARN(QString("Could not load mask '%1'").arg(maskFilename).toLatin1());
- return QBitmap();
- }
- bm.setMask( mask );
+ QBitmap mask;
+ QString maskFilename = dir + QString( "/%1-mask.xbm" ).arg( filename );
+ if (!mask.load(maskFilename)) {
+ QWARN(QString("Could not load mask '%1'").arg(maskFilename).toLatin1());
+ return QBitmap();
+ }
+ bm.setMask( mask );
}
return bm;
}
@@ -701,17 +705,17 @@ static QRect getPaintedSize(const QImage &image, const QColor &background)
uint color = background.rgba();
for ( int y = 0; y < image.height(); ++y ) {
- for ( int x = 0; x < image.width(); ++x ) {
+ for (int x = 0; x < image.width(); ++x) {
QRgb pixel = image.pixel( x, y );
- if ( pixel != color && x < xmin )
- xmin = x;
- if ( pixel != color && x > xmax )
- xmax = x;
- if ( pixel != color && y < ymin )
- ymin = y;
- if ( pixel != color && y > ymax )
- ymax = y;
- }
+ if (pixel != color && x < xmin)
+ xmin = x;
+ if (pixel != color && x > xmax)
+ xmax = x;
+ if (pixel != color && y < ymin)
+ ymin = y;
+ if (pixel != color && y > ymax)
+ ymax = y;
+ }
}
return QRect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1);
@@ -4574,6 +4578,112 @@ void tst_QPainter::QTBUG25153_drawLine()
}
}
+void tst_QPainter::blendARGBonRGB_data()
+{
+ QTest::addColumn<QImage::Format>("dst_format");
+ QTest::addColumn<QImage::Format>("src_format");
+ QTest::addColumn<QPainter::CompositionMode>("compositionMode");
+ QTest::addColumn<QRgb>("color");
+ QTest::addColumn<int>("expected_red");
+
+ QTest::newRow("ARGB over ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127 ;
+ QTest::newRow("ARGB_PM over ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver<< qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 255;
+ QTest::newRow("ARGB_PM source ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 255;
+ QTest::newRow("ARGB source-in ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 255 ;
+ QTest::newRow("ARGB_PM source-in ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 255;
+ // Only ARGB does inverse premultiply, on the rest over and source gives similar results:
+ QTest::newRow("ARGB over RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM over RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM source RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source-in RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM source-in RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB over RGB888") << QImage::Format_RGB888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM over RGB888") << QImage::Format_RGB888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source RGB888") << QImage::Format_RGB888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM source RGB888") << QImage::Format_RGB888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source-in RGB888") << QImage::Format_RGB888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM source-in RGB888") << QImage::Format_RGB888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB over RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM over RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM source RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source-in RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM source-in RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 123;
+ QTest::newRow("ARGB_PM over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 123;
+ QTest::newRow("ARGB source RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 123;
+ QTest::newRow("ARGB_PM source RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 123;
+ QTest::newRow("ARGB source-in RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 123;
+ QTest::newRow("ARGB_PM source-in RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 123;
+ QTest::newRow("ARGB over RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 125;
+ QTest::newRow("ARGB_PM over RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 125;
+ QTest::newRow("ARGB source RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 125;
+ QTest::newRow("ARGB_PM source RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 125;
+ QTest::newRow("ARGB source-in RGB666") << QImage::Format_RGB666 << QImage::Format_ARGB32
+ << 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;
+}
+
+void tst_QPainter::blendARGBonRGB()
+{
+ QFETCH(QImage::Format, dst_format);
+ QFETCH(QImage::Format, src_format);
+ QFETCH(QPainter::CompositionMode, compositionMode);
+ QFETCH(QRgb, color);
+ QFETCH(int, expected_red);
+
+ QImage imageRgb(16,16, dst_format);
+ QImage imageArgb(16,16, src_format);
+ QPainter painter;
+
+ imageArgb.fill(color);
+
+ imageRgb.fill(Qt::black);
+ painter.begin(&imageRgb);
+ painter.setCompositionMode(compositionMode);
+ painter.drawImage(0, 0, imageArgb);
+ painter.end();
+
+ QCOMPARE(qRed(imageRgb.pixel(0,0)), expected_red);
+}
+
enum CosmeticStrokerPaint
{
Antialiasing,
diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
index 11ce8b947b..a6bf4eca8b 100644
--- a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
+++ b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
@@ -61,15 +61,15 @@ static QPixmap createDestPixmap()
QPainter painter;
painter.begin( &pm );
for ( int i=0; i<colorbands; i++ ) {
- for ( int j=0; j<intensities; j++ ) {
- int intensity = 255 * (j+1) / intensities; // 25%, 50%, 75% and 100%
- for ( int k=0; k<8; k++ ) {
- QColor col = baseColor( k, intensity );
- painter.setPen( QPen( col, 1 ) );
- painter.setBrush( col );
- painter.drawRect( k*4, j*4 + i*intensities*4, 4, 4 );
- }
- }
+ for (int j = 0; j < intensities; j++) {
+ int intensity = 255 * (j+1) / intensities; // 25%, 50%, 75% and 100%
+ for (int k = 0; k < 8; k++) {
+ QColor col = baseColor(k, intensity);
+ painter.setPen(QPen(col, 1));
+ painter.setBrush(col);
+ painter.drawRect(k*4, j*4 + i*intensities*4, 4, 4);
+ }
+ }
}
painter.end();
return pm;
@@ -127,14 +127,14 @@ static QBitmap createSrcBitmap( int size, int border )
painter.drawRect( border, border, size, size2 );
painter.end();
if ( border > 0 ) {
- QBitmap mask( totalSize, totalSize, true );
- QPainter painter;
- painter.begin( &mask );
- painter.setPen( QPen( Qt::color1, 1 ) );
- painter.setBrush( Qt::color1 );
- painter.drawRect( border, border, size, size );
- painter.end();
- bm.setMask( mask );
+ QBitmap mask(totalSize, totalSize, true);
+ QPainter painter;
+ painter.begin(&mask);
+ painter.setPen(QPen(Qt::color1, 1));
+ painter.setBrush(Qt::color1);
+ painter.drawRect(border, border, size, size);
+ painter.end();
+ bm.setMask(mask);
}
return bm;
}
@@ -146,49 +146,49 @@ int main( int argc, char **argv )
// input for tst_QPainter::drawLine_rop_bitmap()
{
- QBitmap dst = createDestBitmap();
- dst.save( "../../drawLine_rop_bitmap/dst.xbm", "XBM" );
+ QBitmap dst = createDestBitmap();
+ dst.save("../../drawLine_rop_bitmap/dst.xbm", "XBM");
}
// input for tst_QPainter::drawPixmap_rop_bitmap()
{
- QBitmap dst = createDestBitmap();
- QBitmap src1 = createSrcBitmap( 4, 2 );
- QBitmap src2 = createSrcBitmap( 4, 0 );
- dst.save( "../../drawPixmap_rop_bitmap/dst.xbm", "XBM" );
- src1.save( "../../drawPixmap_rop_bitmap/src1.xbm", "XBM" );
- src1.mask()->save( "../../drawPixmap_rop_bitmap/src1-mask.xbm", "XBM" );
- src2.save( "../../drawPixmap_rop_bitmap/src2.xbm", "XBM" );
+ QBitmap dst = createDestBitmap();
+ QBitmap src1 = createSrcBitmap(4, 2);
+ QBitmap src2 = createSrcBitmap(4, 0);
+ dst.save("../../drawPixmap_rop_bitmap/dst.xbm", "XBM");
+ src1.save("../../drawPixmap_rop_bitmap/src1.xbm", "XBM");
+ src1.mask()->save("../../drawPixmap_rop_bitmap/src1-mask.xbm", "XBM");
+ src2.save("../../drawPixmap_rop_bitmap/src2.xbm", "XBM");
}
// input for tst_QPainter::drawPixmap_rop()
{
- QPixmap dst1 = createDestPixmap();
- QPixmap dst2 = createDestPixmap();
- dst2.resize( 32, 32 );
- QBitmap src1 = createSrcBitmap( 32, 0 );
+ QPixmap dst1 = createDestPixmap();
+ QPixmap dst2 = createDestPixmap();
+ dst2.resize(32, 32);
+ QBitmap src1 = createSrcBitmap(32, 0);
- QBitmap src_tmp = createSrcBitmap( 32, 0 ).xForm( QWMatrix( 1, 0, 0, -1, 0, 0 ) );
- src_tmp.resize( 32, 48 );
- QBitmap src2 = src_tmp.xForm( QWMatrix( 1, 0, 0, -1, 0, 0 ) );
- QBitmap mask( 32, 48, true );
- {
- QPainter painter;
- painter.begin( &mask );
- painter.setPen( QPen( Qt::color1, 1 ) );
- painter.setBrush( Qt::color1 );
- painter.drawRect( 0, 16, 32, 32 );
- painter.end();
- }
- src2.setMask( mask );
+ QBitmap src_tmp = createSrcBitmap(32, 0).xForm(QWMatrix(1, 0, 0, -1, 0, 0));
+ src_tmp.resize(32, 48);
+ QBitmap src2 = src_tmp.xForm(QWMatrix(1, 0, 0, -1, 0, 0));
+ QBitmap mask(32, 48, true);
+ {
+ QPainter painter;
+ painter.begin(&mask);
+ painter.setPen(QPen(Qt::color1, 1));
+ painter.setBrush(Qt::color1);
+ painter.drawRect(0, 16, 32, 32);
+ painter.end();
+ }
+ src2.setMask(mask);
- QBitmap src3 = createSrcBitmap( 32, 0 ).xForm( QWMatrix( 1, 0, 0, -1, 0, 0 ) );
+ QBitmap src3 = createSrcBitmap(32, 0).xForm(QWMatrix(1, 0, 0, -1, 0, 0));
- dst1.save( "../../drawPixmap_rop/dst1.png", "PNG" );
- dst2.save( "../../drawPixmap_rop/dst2.png", "PNG" );
- src1.save( "../../drawPixmap_rop/src1.xbm", "XBM" );
- src2.save( "../../drawPixmap_rop/src2.xbm", "XBM" );
- src2.mask()->save( "../../drawPixmap_rop/src2-mask.xbm", "XBM" );
- src3.save( "../../drawPixmap_rop/src3.xbm", "XBM" );
+ dst1.save("../../drawPixmap_rop/dst1.png", "PNG");
+ dst2.save("../../drawPixmap_rop/dst2.png", "PNG");
+ src1.save("../../drawPixmap_rop/src1.xbm", "XBM");
+ src2.save("../../drawPixmap_rop/src2.xbm", "XBM");
+ src2.mask()->save("../../drawPixmap_rop/src2-mask.xbm", "XBM");
+ src3.save("../../drawPixmap_rop/src3.xbm", "XBM");
}
}
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index 1444c4fc16..07c996d026 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -114,23 +114,23 @@ void tst_QPen::operator_eq_eq_data()
QTest::addColumn<bool>("isEqual");
QTest::newRow("differentColor") << QPen(Qt::red)
- << QPen(Qt::blue)
- << false;
+ << QPen(Qt::blue)
+ << false;
QTest::newRow("differentWidth") << QPen(Qt::red, 2)
- << QPen(Qt::red, 3)
- << false;
+ << QPen(Qt::red, 3)
+ << false;
QTest::newRow("differentPenStyle") << QPen(Qt::red, 2, Qt::DashLine)
- << QPen(Qt::red, 2, Qt::DotLine)
- << false;
+ << QPen(Qt::red, 2, Qt::DotLine)
+ << false;
QTest::newRow("differentCapStyle") << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin)
- << QPen(Qt::red, 2, Qt::DashLine, Qt::SquareCap, Qt::BevelJoin)
- << false;
+ << QPen(Qt::red, 2, Qt::DashLine, Qt::SquareCap, Qt::BevelJoin)
+ << false;
QTest::newRow("differentJoinStyle") << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin)
- << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin)
- << false;
+ << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin)
+ << false;
QTest::newRow("same") << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin)
- << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin)
- << true;
+ << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin)
+ << true;
}
diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
index 4a659a3159..07670b2ae2 100644
--- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
+++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
@@ -77,11 +77,11 @@ void tst_QPolygon::makeEllipse()
// make sure that all points are R+-1 away from the center
bool err = false;
for (i = 1; i < pa.size(); i++) {
- QPoint p = pa.at( i );
- double r = sqrt( pow( double(p.x() - R), 2.0 ) + pow( double(p.y() - R), 2.0 ) );
- // ### too strict ? at least from visual inspection it looks
- // quite odd around the main axes. 2.0 passes easily.
- err |= ( qAbs( r - double(R) ) > 2.0 );
+ QPoint p = pa.at(i);
+ double r = sqrt(pow(double(p.x() - R), 2.0) + pow(double(p.y() - R), 2.0));
+ // ### too strict ? at least from visual inspection it looks
+ // quite odd around the main axes. 2.0 passes easily.
+ err |= (qAbs(r - double(R)) > 2.0);
}
QVERIFY( !err );
}
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index c099611755..121d98e653 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -109,19 +109,19 @@ tst_QRegion::tst_QRegion()
void tst_QRegion::boundingRect()
{
{
- QRect rect;
- QRegion region( rect );
- QCOMPARE( region.boundingRect(), rect );
+ QRect rect;
+ QRegion region(rect);
+ QCOMPARE(region.boundingRect(), rect);
}
{
- QRect rect( 10, -20, 30, 40 );
- QRegion region( rect );
- QCOMPARE( region.boundingRect(), rect );
+ QRect rect(10, -20, 30, 40);
+ QRegion region(rect);
+ QCOMPARE(region.boundingRect(), rect);
}
{
- QRect rect(15,25,10,10);
- QRegion region( rect );
- QCOMPARE( region.boundingRect(), rect );
+ QRect rect(15,25,10,10);
+ QRegion region(rect);
+ QCOMPARE(region.boundingRect(), rect);
}
}
@@ -129,75 +129,75 @@ void tst_QRegion::boundingRect()
void tst_QRegion::rects()
{
{
- QRect rect;
- QRegion region( rect );
- QVERIFY( region.isEmpty() );
- QVERIFY( region.rects().isEmpty() );
+ QRect rect;
+ QRegion region(rect);
+ QVERIFY(region.isEmpty());
+ QVERIFY(region.rects().isEmpty());
}
{
- QRect rect( 10, -20, 30, 40 );
- QRegion region( rect );
- QCOMPARE( region.rects().count(), 1 );
- QCOMPARE( region.rects()[0], rect );
+ QRect rect(10, -20, 30, 40);
+ QRegion region(rect);
+ QCOMPARE(region.rects().count(), 1);
+ QCOMPARE(region.rects()[0], rect);
}
{
- QRect r( QPoint(10, 10), QPoint(40, 40) );
- QRegion region( r );
- QVERIFY( region.contains( QPoint(10,10) ) );
- QVERIFY( region.contains( QPoint(20,40) ) );
- QVERIFY( region.contains( QPoint(40,20) ) );
- QVERIFY( !region.contains( QPoint(20,41) ) );
- QVERIFY( !region.contains( QPoint(41,20) ) );
+ QRect r(QPoint(10, 10), QPoint(40, 40));
+ QRegion region(r);
+ QVERIFY(region.contains(QPoint(10,10)));
+ QVERIFY(region.contains(QPoint(20,40)));
+ QVERIFY(region.contains(QPoint(40,20)));
+ QVERIFY(!region.contains(QPoint(20,41)));
+ QVERIFY(!region.contains(QPoint(41,20)));
}
{
- QRect r( 10, 10, 30, 30 );
- QRegion region( r );
- QVERIFY( region.contains( QPoint(10,10) ) );
- QVERIFY( region.contains( QPoint(20,39) ) );
- QVERIFY( region.contains( QPoint(39,20) ) );
- QVERIFY( !region.contains( QPoint(20,40) ) );
- QVERIFY( !region.contains( QPoint(40,20) ) );
+ QRect r(10, 10, 30, 30);
+ QRegion region(r);
+ QVERIFY(region.contains(QPoint(10,10)));
+ QVERIFY(region.contains(QPoint(20,39)));
+ QVERIFY(region.contains(QPoint(39,20)));
+ QVERIFY(!region.contains(QPoint(20,40)));
+ QVERIFY(!region.contains(QPoint(40,20)));
}
}
void tst_QRegion::swap()
{
- QRegion r1(QRect( 0, 0,10,10));
+ QRegion r1(QRect(0, 0,10,10));
QRegion r2(QRect(10,10,10,10));
r1.swap(r2);
QCOMPARE(r1.rects().front(), QRect(10,10,10,10));
- QCOMPARE(r2.rects().front(), QRect( 0, 0,10,10));
+ QCOMPARE(r2.rects().front(), QRect(0, 0,10,10));
}
void tst_QRegion::setRects()
{
{
- QRegion region;
- region.setRects( 0, 0 );
- QVERIFY( region.rects().isEmpty() );
+ QRegion region;
+ region.setRects(0, 0);
+ QVERIFY(region.rects().isEmpty());
}
{
- QRegion region;
- QRect rect;
- region.setRects( &rect, 0 );
+ QRegion region;
+ QRect rect;
+ region.setRects(&rect, 0);
QVERIFY(region.isEmpty());
QVERIFY(region == QRegion());
- QVERIFY(!region.boundingRect().isValid());
- QVERIFY(region.rects().isEmpty());
+ QVERIFY(!region.boundingRect().isValid());
+ QVERIFY(region.rects().isEmpty());
}
{
- QRegion region;
- QRect rect;
- region.setRects( &rect, 1 );
- QVERIFY( !region.boundingRect().isValid() );
- QVERIFY( region.rects().isEmpty() );
+ QRegion region;
+ QRect rect;
+ region.setRects(&rect, 1);
+ QVERIFY(!region.boundingRect().isValid());
+ QVERIFY(region.rects().isEmpty());
}
{
- QRegion region;
- QRect rect( 10, -20, 30, 40 );
- region.setRects( &rect, 1 );
- QCOMPARE( region.rects().count(), 1 );
- QCOMPARE( region.rects()[0], rect );
+ QRegion region;
+ QRect rect(10, -20, 30, 40);
+ region.setRects(&rect, 1);
+ QCOMPARE(region.rects().count(), 1);
+ QCOMPARE(region.rects()[0], rect);
}
}
@@ -242,30 +242,30 @@ void tst_QRegion::polygonRegion()
{
QPolygon pa;
{
- QRegion region ( pa );
- QVERIFY( region.isEmpty() );
+ QRegion region (pa);
+ QVERIFY(region.isEmpty());
}
{
- pa.setPoints( 8, 10, 10, // a____________b
- 40, 10, // | |
- 40, 20, // |___ ___|
- 30, 20, // | |
- 30, 40, // | |
- 20, 40, // | |
- 20, 20, // |____c
- 10, 20 );
+ pa.setPoints(8, 10, 10, // a____________b
+ 40, 10, // | |
+ 40, 20, // |___ ___|
+ 30, 20, // | |
+ 30, 40, // | |
+ 20, 40, // | |
+ 20, 20, // |____c
+ 10, 20);
- QRegion region ( pa );
- QVERIFY( !region.isEmpty() );
+ QRegion region (pa);
+ QVERIFY(!region.isEmpty());
- // These should not be inside the circle
- QVERIFY( !region.contains( QPoint( 9, 9 ) ) );
- QVERIFY( !region.contains( QPoint( 30, 41 ) ) );
- QVERIFY( !region.contains( QPoint( 41, 10 ) ) );
- QVERIFY( !region.contains( QPoint( 31, 21 ) ) );
+ // These should not be inside the circle
+ QVERIFY(!region.contains(QPoint( 9, 9)));
+ QVERIFY(!region.contains(QPoint(30, 41)));
+ QVERIFY(!region.contains(QPoint(41, 10)));
+ QVERIFY(!region.contains(QPoint(31, 21)));
- // These should be inside
- QVERIFY( region.contains( QPoint( 10, 10 ) ) ); // Upper-left (a)
+ // These should be inside
+ QVERIFY(region.contains(QPoint(10, 10))); // Upper-left (a)
}
}
@@ -317,8 +317,8 @@ void tst_QRegion::emptyPolygonRegion()
static const char *circle_xpm[] = {
"20 20 2 1",
- " c #FFFFFF",
- ". c #000000",
+ " c #FFFFFF",
+ ". c #000000",
" ...... ",
" .......... ",
" .............. ",
@@ -345,29 +345,29 @@ void tst_QRegion::bitmapRegion()
{
QBitmap circle;
{
- QRegion region( circle );
- QVERIFY( region.isEmpty() );
+ QRegion region(circle);
+ QVERIFY(region.isEmpty());
}
{
- circle = QPixmap( circle_xpm );
- QRegion region( circle );
-
- //// These should not be inside the circe
- QVERIFY( !region.contains( QPoint( 2, 2 ) ) );
- QVERIFY( !region.contains( QPoint( 2, 17 ) ) );
- QVERIFY( !region.contains( QPoint( 17, 2 ) ) );
- QVERIFY( !region.contains( QPoint( 17, 17 ) ) );
-
- //// These should be inside
- QVERIFY( region.contains( QPoint( 3, 3 ) ) );
- QVERIFY( region.contains( QPoint( 3, 16 ) ) );
- QVERIFY( region.contains( QPoint( 16, 3 ) ) );
- QVERIFY( region.contains( QPoint( 16, 16 ) ) );
-
- QVERIFY( region.contains( QPoint( 0, 10 ) ) ); // Mid-left
- QVERIFY( region.contains( QPoint( 10, 0 ) ) ); // Mid-top
- QVERIFY( region.contains( QPoint( 19, 10 ) ) ); // Mid-right
- QVERIFY( region.contains( QPoint( 10, 19 ) ) ); // Mid-bottom
+ circle = QPixmap(circle_xpm);
+ QRegion region(circle);
+
+ //// These should not be inside the circe
+ QVERIFY(!region.contains(QPoint(2, 2)));
+ QVERIFY(!region.contains(QPoint(2, 17)));
+ QVERIFY(!region.contains(QPoint(17, 2)));
+ QVERIFY(!region.contains(QPoint(17, 17)));
+
+ //// These should be inside
+ QVERIFY(region.contains(QPoint(3, 3)));
+ QVERIFY(region.contains(QPoint(3, 16)));
+ QVERIFY(region.contains(QPoint(16, 3)));
+ QVERIFY(region.contains(QPoint(16, 16)));
+
+ QVERIFY(region.contains(QPoint(0, 10))); // Mid-left
+ QVERIFY(region.contains(QPoint(10, 0))); // Mid-top
+ QVERIFY(region.contains(QPoint(19, 10))); // Mid-right
+ QVERIFY(region.contains(QPoint(10, 19))); // Mid-bottom
}
}
diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp
index 4c73676329..c62ca3fa38 100644
--- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp
+++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp
@@ -112,47 +112,47 @@ void tst_QWMatrix::mapping_data()
//next we fill it with data
// identity
- QTest::newRow( "identity" ) << QMatrix( 1, 0, 0, 1, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 10, 20, 30, 40 ) );
+ QTest::newRow( "identity" ) << QMatrix( 1, 0, 0, 1, 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 10, 20, 30, 40 ) );
// scaling
QTest::newRow( "scale 0" ) << QMatrix( 2, 0, 0, 2, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 20, 40, 60, 80 ) );
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 20, 40, 60, 80 ) );
QTest::newRow( "scale 1" ) << QMatrix( 10, 0, 0, 10, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 100, 200, 300, 400 ) );
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 100, 200, 300, 400 ) );
// mirroring
- QTest::newRow( "mirror 0" ) << QMatrix( -1, 0, 0, 1, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -40, 20, 30, 40 ) );
- QTest::newRow( "mirror 1" ) << QMatrix( 1, 0, 0, -1, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 10, -60, 30, 40 ) );
- QTest::newRow( "mirror 2" ) << QMatrix( -1, 0, 0, -1, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -40, -60, 30, 40 ) );
- QTest::newRow( "mirror 3" ) << QMatrix( -2, 0, 0, -2, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -80, -120, 60, 80 ) );
- QTest::newRow( "mirror 4" ) << QMatrix( -10, 0, 0, -10, 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -400, -600, 300, 400 ) );
- QTest::newRow( "mirror 5" ) << QMatrix( -1, 0, 0, 1, 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -30, 0, 30, 40 ) );
- QTest::newRow( "mirror 6" ) << QMatrix( 1, 0, 0, -1, 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( 0, -40, 30, 40 ) );
- QTest::newRow( "mirror 7" ) << QMatrix( -1, 0, 0, -1, 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -30, -40, 30, 40 ) );
- QTest::newRow( "mirror 8" ) << QMatrix( -2, 0, 0, -2, 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -60, -80, 60, 80 ) );
- QTest::newRow( "mirror 9" ) << QMatrix( -10, 0, 0, -10, 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -300, -400, 300, 400 ) );
+ QTest::newRow( "mirror 0" ) << QMatrix( -1, 0, 0, 1, 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -40, 20, 30, 40 ) );
+ QTest::newRow( "mirror 1" ) << QMatrix( 1, 0, 0, -1, 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 10, -60, 30, 40 ) );
+ QTest::newRow( "mirror 2" ) << QMatrix( -1, 0, 0, -1, 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -40, -60, 30, 40 ) );
+ QTest::newRow( "mirror 3" ) << QMatrix( -2, 0, 0, -2, 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -80, -120, 60, 80 ) );
+ QTest::newRow( "mirror 4" ) << QMatrix( -10, 0, 0, -10, 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -400, -600, 300, 400 ) );
+ QTest::newRow( "mirror 5" ) << QMatrix( -1, 0, 0, 1, 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -30, 0, 30, 40 ) );
+ QTest::newRow( "mirror 6" ) << QMatrix( 1, 0, 0, -1, 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( 0, -40, 30, 40 ) );
+ QTest::newRow( "mirror 7" ) << QMatrix( -1, 0, 0, -1, 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -30, -40, 30, 40 ) );
+ QTest::newRow( "mirror 8" ) << QMatrix( -2, 0, 0, -2, 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -60, -80, 60, 80 ) );
+ QTest::newRow( "mirror 9" ) << QMatrix( -10, 0, 0, -10, 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -300, -400, 300, 400 ) );
#if (defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(M_PI)
#define M_PI 3.14159265897932384626433832795f
@@ -161,126 +161,126 @@ void tst_QWMatrix::mapping_data()
// rotations
float deg = 0.;
QTest::newRow( "rot 0 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon ( QRect( 0, 0, 30, 40 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon ( QRect( 0, 0, 30, 40 ) );
deg = 0.00001f;
QTest::newRow( "rot 0 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon ( QRect( 0, 0, 30, 40 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon ( QRect( 0, 0, 30, 40 ) );
deg = 0.;
QTest::newRow( "rot 0 c" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon ( QRect( 10, 20, 30, 40 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon ( QRect( 10, 20, 30, 40 ) );
deg = 0.00001f;
QTest::newRow( "rot 0 d" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon ( QRect( 10, 20, 30, 40 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon ( QRect( 10, 20, 30, 40 ) );
#if 0
// rotations
deg = 90.;
QTest::newRow( "rotscale 90 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( 0, -299, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( 0, -299, 400, 300 ) );
deg = 90.00001;
QTest::newRow( "rotscale 90 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( 0, -299, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( 0, -299, 400, 300 ) );
deg = 90.;
QTest::newRow( "rotscale 90 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 200, -399, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 200, -399, 400, 300 ) );
deg = 90.00001;
QTest::newRow( "rotscale 90 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 200, -399, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 200, -399, 400, 300 ) );
deg = 180.;
QTest::newRow( "rotscale 180 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -299, -399, 300, 400 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -299, -399, 300, 400 ) );
deg = 180.000001;
QTest::newRow( "rotscale 180 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -299, -399, 300, 400 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -299, -399, 300, 400 ) );
deg = 180.;
QTest::newRow( "rotscale 180 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -399, -599, 300, 400 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -399, -599, 300, 400 ) );
deg = 180.000001;
QTest::newRow( "rotscale 180 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -399, -599, 300, 400 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -399, -599, 300, 400 ) );
deg = 270.;
QTest::newRow( "rotscale 270 a" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -399, 00, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -399, 00, 400, 300 ) );
deg = 270.0000001;
QTest::newRow( "rotscale 270 b" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 30, 40 )
- << QPolygon( QRect( -399, 00, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 30, 40 )
+ << QPolygon( QRect( -399, 00, 400, 300 ) );
deg = 270.;
QTest::newRow( "rotscale 270 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -599, 100, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -599, 100, 400, 300 ) );
deg = 270.000001;
QTest::newRow( "rotscale 270 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -599, 100, 400, 300 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -599, 100, 400, 300 ) );
// rotations that are not multiples of 90 degrees. mapRect returns the bounding rect here.
deg = 45;
QTest::newRow( "rot 45 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 10, 10 )
- << QPolygon( QRect( 0, -7, 14, 14 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 10, 10 )
+ << QPolygon( QRect( 0, -7, 14, 14 ) );
QTest::newRow( "rot 45 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 21, -14, 49, 49 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 21, -14, 49, 49 ) );
QTest::newRow( "rot 45 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 10, 10 )
- << QPolygon( QRect( 0, -70, 141, 141 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 10, 10 )
+ << QPolygon( QRect( 0, -70, 141, 141 ) );
QTest::newRow( "rot 45 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( 212, -141, 495, 495 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( 212, -141, 495, 495 ) );
deg = -45;
QTest::newRow( "rot -45 a" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 10, 10 )
- << QPolygon( QRect( -7, 0, 14, 14 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 10, 10 )
+ << QPolygon( QRect( -7, 0, 14, 14 ) );
QTest::newRow( "rot -45 b" ) << QMatrix( cos( M_PI*deg/180. ), -sin( M_PI*deg/180. ),
- sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -35, 21, 49, 49 ) );
+ sin( M_PI*deg/180. ), cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -35, 21, 49, 49 ) );
QTest::newRow( "rot -45 c" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 0, 0, 10, 10 )
- << QPolygon( QRect( -70, 0, 141, 141 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 0, 0, 10, 10 )
+ << QPolygon( QRect( -70, 0, 141, 141 ) );
QTest::newRow( "rot -45 d" ) << QMatrix( 10*cos( M_PI*deg/180. ), -10*sin( M_PI*deg/180. ),
- 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
- << QRect( 10, 20, 30, 40 )
- << QPolygon( QRect( -353, 212, 495, 495 ) );
+ 10*sin( M_PI*deg/180. ), 10*cos( M_PI*deg/180. ), 0, 0 )
+ << QRect( 10, 20, 30, 40 )
+ << QPolygon( QRect( -353, 212, 495, 495 ) );
#endif
}
diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro
index 34af962d36..12429bbeed 100644
--- a/tests/auto/gui/qopengl/qopengl.pro
+++ b/tests/auto/gui/qopengl/qopengl.pro
@@ -5,7 +5,7 @@
CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qopengl
-QT += gui gui-private core-private testlib
+QT += gui-private core-private testlib
SOURCES += tst_qopengl.cpp
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 4defbe181f..4018c00a38 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -48,6 +48,10 @@
#include <QtGui/QScreen>
#include <QtGui/QWindow>
#include <QtGui/QOffscreenSurface>
+#include <QtGui/QGenericMatrix>
+#include <QtGui/QMatrix4x4>
+#include <QtGui/private/qopengltextureblitter_p.h>
+
#include <QtTest/QtTest>
@@ -66,13 +70,21 @@ private slots:
void multiGroupSharedResourceCleanupCustom();
void fboSimpleRendering_data();
void fboSimpleRendering();
+ void fboTextureOwnership_data();
+ void fboTextureOwnership();
void fboRendering_data();
void fboRendering();
void fboHandleNulledAfterContextDestroyed();
void openGLPaintDevice_data();
void openGLPaintDevice();
void aboutToBeDestroyed();
+ void sizeLessWindow();
void QTBUG15621_triangulatingStrokerDivZero();
+ void textureblitterFullSourceRectTransform();
+ void textureblitterPartOriginBottomLeftSourceRectTransform();
+ void textureblitterPartOriginTopLeftSourceRectTransform();
+ void textureblitterFullTargetRectTransform();
+ void textureblitterPartTargetRectTransform();
};
struct SharedResourceTracker
@@ -429,6 +441,54 @@ void tst_QOpenGL::fboSimpleRendering()
delete fbo;
}
+void tst_QOpenGL::fboTextureOwnership_data()
+{
+ common_data();
+}
+
+void tst_QOpenGL::fboTextureOwnership()
+{
+ QFETCH(int, surfaceClass);
+ QScopedPointer<QSurface> surface(createSurface(surfaceClass));
+
+ QOpenGLContext ctx;
+ QVERIFY(ctx.create());
+
+ ctx.makeCurrent(surface.data());
+
+ if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QOpenGLFramebufferObject not supported on this platform");
+
+ QOpenGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment);
+
+ QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat);
+ QVERIFY(fbo->texture() != 0);
+ fbo->bind();
+
+ // pull out the texture
+ GLuint texture = fbo->takeTexture();
+ QVERIFY(texture != 0);
+ QVERIFY(fbo->texture() == 0);
+
+ // verify that the next bind() creates a new texture
+ fbo->bind();
+ QVERIFY(fbo->texture() != 0 && fbo->texture() != texture);
+
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFinish();
+
+ QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
+ QImage reference(fb.size(), QImage::Format_RGB32);
+ reference.fill(0xffff0000);
+
+ QFUZZY_COMPARE_IMAGES(fb, reference);
+
+ glDeleteTextures(1, &texture);
+ delete fbo;
+}
+
void tst_QOpenGL::fboRendering_data()
{
common_data();
@@ -586,6 +646,43 @@ void tst_QOpenGL::aboutToBeDestroyed()
QCOMPARE(spy.size(), 1);
}
+// Verify that QOpenGLContext works with QWindows that do
+// not have an explicit size set.
+void tst_QOpenGL::sizeLessWindow()
+{
+ // top-level window
+ {
+ QWindow window;
+ window.setSurfaceType(QWindow::OpenGLSurface);
+
+ QOpenGLContext context;
+ QVERIFY(context.create());
+
+ window.show();
+ QVERIFY(context.makeCurrent(&window));
+ QVERIFY(QOpenGLContext::currentContext());
+ }
+
+ QVERIFY(!QOpenGLContext::currentContext());
+
+ // child window
+ {
+ QWindow parent;
+ QWindow window(&parent);
+ window.setSurfaceType(QWindow::OpenGLSurface);
+
+ QOpenGLContext context;
+ QVERIFY(context.create());
+
+ parent.show();
+ window.show();
+ QVERIFY(context.makeCurrent(&window));
+ QVERIFY(QOpenGLContext::currentContext());
+ }
+
+ QVERIFY(!QOpenGLContext::currentContext());
+}
+
void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
@@ -658,6 +755,188 @@ void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
QCOMPARE(image.pixel(95, 95), blue);
}
+typedef QGenericMatrix<1, 3, float> TestVertex3D;
+static const float uv_top_left[] = {0.f, 1.f, 1.f};
+static const float uv_bottom_left[] = {0.f, 0.f, 1.f};
+static const float uv_top_right[] = {1.f, 1.f, 1.f};
+static const float uv_bottom_right[] = {1.f, 0.f, 1.f};
+
+bool q_fuzzy_compare(const TestVertex3D &left, const TestVertex3D &right) {
+ return qFuzzyCompare(left(0,0), right(0,0)) &&
+ qFuzzyCompare(left(1,0), right(1,0)) &&
+ qFuzzyCompare(left(2,0), right(2,0));
+}
+
+void tst_QOpenGL::textureblitterFullSourceRectTransform()
+{
+ TestVertex3D topLeft(uv_top_left);
+ TestVertex3D bottomLeft(uv_bottom_left);
+ TestVertex3D topRight(uv_top_right);
+ TestVertex3D bottomRight(uv_bottom_right);
+
+ QRectF rect(0,0,1,1);
+ QMatrix3x3 flippedMatrix = QOpenGLTextureBlitter::sourceTransform(rect, rect.size().toSize(), QOpenGLTextureBlitter::OriginTopLeft);
+
+ TestVertex3D flippedTopLeft = flippedMatrix * topLeft;
+ QCOMPARE(flippedTopLeft, bottomLeft);
+
+ TestVertex3D flippedBottomLeft = flippedMatrix * bottomLeft;
+ QCOMPARE(flippedBottomLeft, topLeft);
+
+ TestVertex3D flippedTopRight = flippedMatrix * topRight;
+ QCOMPARE(flippedTopRight, bottomRight);
+
+ TestVertex3D flippedBottomRight = flippedMatrix * bottomRight;
+ QCOMPARE(flippedBottomRight, topRight);
+
+ QMatrix3x3 identityMatrix = QOpenGLTextureBlitter::sourceTransform(rect, rect.size().toSize(), QOpenGLTextureBlitter::OriginBottomLeft);
+
+ TestVertex3D notFlippedTopLeft = identityMatrix * topLeft;
+ QCOMPARE(notFlippedTopLeft, topLeft);
+
+ TestVertex3D notFlippedBottomLeft = identityMatrix * bottomLeft;
+ QCOMPARE(notFlippedBottomLeft, bottomLeft);
+
+ TestVertex3D notFlippedTopRight = identityMatrix * topRight;
+ QCOMPARE(notFlippedTopRight, topRight);
+
+ TestVertex3D notFlippedBottomRight = identityMatrix * bottomRight;
+ QCOMPARE(notFlippedBottomRight, bottomRight);
+}
+
+void tst_QOpenGL::textureblitterPartOriginBottomLeftSourceRectTransform()
+{
+ TestVertex3D topLeft(uv_top_left);
+ TestVertex3D bottomLeft(uv_bottom_left);
+ TestVertex3D topRight(uv_top_right);
+ TestVertex3D bottomRight(uv_bottom_right);
+
+ QRectF sourceRect(50,200,200,200);
+ QSize textureSize(400,400);
+
+ QMatrix3x3 sourceMatrix = QOpenGLTextureBlitter::sourceTransform(sourceRect, textureSize, QOpenGLTextureBlitter::OriginBottomLeft);
+
+ const float x_point_ratio = sourceRect.topLeft().x() / textureSize.width();
+ const float y_point_ratio = sourceRect.topLeft().y() / textureSize.height();
+ const float width_ratio = sourceRect.width() / textureSize.width();
+ const float height_ratio = sourceRect.height() / textureSize.height();
+
+ TestVertex3D uvTopLeft = sourceMatrix * topLeft;
+ const float expected_top_left[] = { x_point_ratio, y_point_ratio + height_ratio, 1 };
+ TestVertex3D expectedTopLeft(expected_top_left);
+ QCOMPARE(uvTopLeft, expectedTopLeft);
+
+ TestVertex3D uvBottomLeft = sourceMatrix * bottomLeft;
+ const float expected_bottom_left[] = { x_point_ratio, y_point_ratio, 1 };
+ TestVertex3D expectedBottomLeft(expected_bottom_left);
+ QCOMPARE(uvBottomLeft, expectedBottomLeft);
+
+ TestVertex3D uvTopRight = sourceMatrix * topRight;
+ const float expected_top_right[] = { x_point_ratio + width_ratio, y_point_ratio + height_ratio, 1 };
+ TestVertex3D expectedTopRight(expected_top_right);
+ QCOMPARE(uvTopRight, expectedTopRight);
+
+ TestVertex3D uvBottomRight = sourceMatrix * bottomRight;
+ const float expected_bottom_right[] = { x_point_ratio + width_ratio, y_point_ratio, 1 };
+ TestVertex3D expectedBottomRight(expected_bottom_right);
+ QCOMPARE(uvBottomRight, expectedBottomRight);
+}
+
+void tst_QOpenGL::textureblitterPartOriginTopLeftSourceRectTransform()
+{
+ TestVertex3D topLeft(uv_top_left);
+ TestVertex3D bottomLeft(uv_bottom_left);
+ TestVertex3D topRight(uv_top_right);
+ TestVertex3D bottomRight(uv_bottom_right);
+
+ QRectF sourceRect(50,190,170,170);
+ QSize textureSize(400,400);
+
+ QMatrix3x3 sourceMatrix = QOpenGLTextureBlitter::sourceTransform(sourceRect, textureSize, QOpenGLTextureBlitter::OriginTopLeft);
+
+ const float x_point_ratio = sourceRect.topLeft().x() / textureSize.width();
+ const float y_point_ratio = sourceRect.topLeft().y() / textureSize.height();
+ const float width_ratio = sourceRect.width() / textureSize.width();
+ const float height_ratio = sourceRect.height() / textureSize.height();
+
+ TestVertex3D uvTopLeft = sourceMatrix * topLeft;
+ const float expected_top_left[] = { x_point_ratio, 1 - y_point_ratio - height_ratio, 1 };
+ TestVertex3D expectedTopLeft(expected_top_left);
+ QVERIFY(q_fuzzy_compare(uvTopLeft, expectedTopLeft));
+
+ TestVertex3D uvBottomLeft = sourceMatrix * bottomLeft;
+ const float expected_bottom_left[] = { x_point_ratio, 1 - y_point_ratio, 1 };
+ TestVertex3D expectedBottomLeft(expected_bottom_left);
+ QVERIFY(q_fuzzy_compare(uvBottomLeft, expectedBottomLeft));
+
+ TestVertex3D uvTopRight = sourceMatrix * topRight;
+ const float expected_top_right[] = { x_point_ratio + width_ratio, 1 - y_point_ratio - height_ratio, 1 };
+ TestVertex3D expectedTopRight(expected_top_right);
+ QVERIFY(q_fuzzy_compare(uvTopRight, expectedTopRight));
+
+ TestVertex3D uvBottomRight = sourceMatrix * bottomRight;
+ const float expected_bottom_right[] = { x_point_ratio + width_ratio, 1 - y_point_ratio, 1 };
+ TestVertex3D expectedBottomRight(expected_bottom_right);
+ QVERIFY(q_fuzzy_compare(uvBottomRight, expectedBottomRight));
+}
+
+void tst_QOpenGL::textureblitterFullTargetRectTransform()
+{
+ QVector4D topLeft(-1.f, 1.f, 0.f, 1.f);
+ QVector4D bottomLeft(-1.f, -1.f, 0.f, 1.f);
+ QVector4D topRight(1.f, 1.f, 0.f, 1.f);
+ QVector4D bottomRight(1.f, -1.f, 0.f, 1.f);
+
+ QRectF rect(0,0,200,200);
+ QMatrix4x4 targetMatrix = QOpenGLTextureBlitter::targetTransform(rect,rect.toRect());
+
+ QVector4D translatedTopLeft = targetMatrix * topLeft;
+ QCOMPARE(translatedTopLeft, topLeft);
+
+ QVector4D translatedBottomLeft = targetMatrix * bottomLeft;
+ QCOMPARE(translatedBottomLeft, bottomLeft);
+
+ QVector4D translatedTopRight = targetMatrix * topRight;
+ QCOMPARE(translatedTopRight, topRight);
+
+ QVector4D translatedBottomRight = targetMatrix * bottomRight;
+ QCOMPARE(translatedBottomRight, bottomRight);
+}
+
+void tst_QOpenGL::textureblitterPartTargetRectTransform()
+{
+ QVector4D topLeft(-1.f, 1.f, 0.f, 1.f);
+ QVector4D bottomLeft(-1.f, -1.f, 0.f, 1.f);
+ QVector4D topRight(1.f, 1.f, 0.f, 1.f);
+ QVector4D bottomRight(1.f, -1.f, 0.f, 1.f);
+
+ QRectF targetRect(50,50,200,200);
+ QRect viewport(0,0,400,400);
+
+ //multiply by 2 since coordinate system goes from -1 -> 1;
+ qreal x_point_ratio = (50. / 400.) * 2;
+ qreal y_point_ratio = (50. / 400.) * 2;
+ qreal width_ratio = (200. / 400.) * 2;
+ qreal height_ratio = (200. / 400.) * 2;
+
+ QMatrix4x4 targetMatrix = QOpenGLTextureBlitter::targetTransform(targetRect, viewport);
+
+ QVector4D targetTopLeft = targetMatrix * topLeft;
+ QVector4D expectedTopLeft(-1 + x_point_ratio, 1 - y_point_ratio, .0, 1.0);
+ QCOMPARE(targetTopLeft, expectedTopLeft);
+
+ QVector4D targetBottomLeft = targetMatrix * bottomLeft;
+ QVector4D expectedBottomLeft(-1 + x_point_ratio, 1 - y_point_ratio - height_ratio, 0.0, 1.0);
+ QCOMPARE(targetBottomLeft, expectedBottomLeft);
+
+ QVector4D targetTopRight = targetMatrix * topRight;
+ QVector4D expectedTopRight(-1 + x_point_ratio + width_ratio, 1 - y_point_ratio, 0.0, 1.0);
+ QCOMPARE(targetTopRight, expectedTopRight);
+
+ QVector4D targetBottomRight = targetMatrix * bottomRight;
+ QVector4D expectedBottomRight(-1 + x_point_ratio + width_ratio, 1 - y_point_ratio - height_ratio, 0.0, 1.0);
+ QCOMPARE(targetBottomRight, expectedBottomRight);
+}
QTEST_MAIN(tst_QOpenGL)
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index aa5fa10a33..dde4e54a8e 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -316,25 +316,25 @@ void tst_QFont::italicOblique()
QStringList::ConstIterator f_it, f_end = families.end();
for (f_it = families.begin(); f_it != f_end; ++f_it) {
- QString family = *f_it;
- QStringList styles = fdb.styles(family);
- QVERIFY(!styles.isEmpty());
- QStringList::ConstIterator s_it, s_end = styles.end();
- for (s_it = styles.begin(); s_it != s_end; ++s_it) {
- QString style = *s_it;
-
- if (fdb.isSmoothlyScalable(family, style)) {
- if (style.contains("Oblique")) {
- style.replace("Oblique", "Italic");
- } else if (style.contains("Italic")) {
- style.replace("Italic", "Oblique");
- } else {
- continue;
- }
- QFont f = fdb.font(family, style, 12);
- QVERIFY(f.italic());
- }
- }
+ QString family = *f_it;
+ QStringList styles = fdb.styles(family);
+ QVERIFY(!styles.isEmpty());
+ QStringList::ConstIterator s_it, s_end = styles.end();
+ for (s_it = styles.begin(); s_it != s_end; ++s_it) {
+ QString style = *s_it;
+
+ if (fdb.isSmoothlyScalable(family, style)) {
+ if (style.contains("Oblique")) {
+ style.replace("Oblique", "Italic");
+ } else if (style.contains("Italic")) {
+ style.replace("Italic", "Oblique");
+ } else {
+ continue;
+ }
+ QFont f = fdb.font(family, style, 12);
+ QVERIFY(f.italic());
+ }
+ }
}
}
@@ -342,16 +342,16 @@ void tst_QFont::compare()
{
QFont font;
{
- QFont font2 = font;
- font2.setPointSize( 24 );
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
+ QFont font2 = font;
+ font2.setPointSize(24);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
}
{
- QFont font2 = font;
- font2.setPixelSize( 24 );
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
+ QFont font2 = font;
+ font2.setPixelSize(24);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
}
font.setPointSize(12);
@@ -361,69 +361,69 @@ void tst_QFont::compare()
font.setStrikeOut(false);
font.setOverline(false);
{
- QFont font2 = font;
- font2.setPointSize( 24 );
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
+ QFont font2 = font;
+ font2.setPointSize(24);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
}
{
- QFont font2 = font;
- font2.setPixelSize( 24 );
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
+ QFont font2 = font;
+ font2.setPixelSize(24);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
}
{
- QFont font2 = font;
-
- font2.setItalic(true);
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
- font2.setItalic(false);
- QVERIFY( font == font2 );
- QVERIFY(!(font < font2));
-
- font2.setWeight(QFont::Bold);
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
- font2.setWeight(QFont::Normal);
- QVERIFY( font == font2 );
- QVERIFY(!(font < font2));
-
- font.setUnderline(true);
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
- font.setUnderline(false);
- QVERIFY( font == font2 );
- QVERIFY(!(font < font2));
-
- font.setStrikeOut(true);
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
- font.setStrikeOut(false);
- QVERIFY( font == font2 );
- QVERIFY(!(font < font2));
-
- font.setOverline(true);
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
- font.setOverline(false);
- QVERIFY( font == font2 );
- QVERIFY(!(font < font2));
+ QFont font2 = font;
+
+ font2.setItalic(true);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
+ font2.setItalic(false);
+ QVERIFY(font == font2);
+ QVERIFY(!(font < font2));
+
+ font2.setWeight(QFont::Bold);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
+ font2.setWeight(QFont::Normal);
+ QVERIFY(font == font2);
+ QVERIFY(!(font < font2));
+
+ font.setUnderline(true);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
+ font.setUnderline(false);
+ QVERIFY(font == font2);
+ QVERIFY(!(font < font2));
+
+ font.setStrikeOut(true);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
+ font.setStrikeOut(false);
+ QVERIFY(font == font2);
+ QVERIFY(!(font < font2));
+
+ font.setOverline(true);
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
+ font.setOverline(false);
+ QVERIFY(font == font2);
+ QVERIFY(!(font < font2));
font.setCapitalization(QFont::SmallCaps);
- QVERIFY( font != font2 );
- QCOMPARE(font < font2,!(font2 < font));
+ QVERIFY(font != font2);
+ QCOMPARE(font < font2,!(font2 < font));
font.setCapitalization(QFont::MixedCase);
- QVERIFY( font == font2 );
- QVERIFY(!(font < font2));
+ QVERIFY(font == font2);
+ QVERIFY(!(font < font2));
}
#if defined(Q_WS_X11)
{
- QFont font1, font2;
- font1.setRawName("-Adobe-Helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1");
- font2.setRawName("-Adobe-Helvetica-medium-r-normal--24-240-75-75-p-130-iso8859-1");
- QVERIFY(font1 != font2);
+ QFont font1, font2;
+ font1.setRawName("-Adobe-Helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1");
+ font2.setRawName("-Adobe-Helvetica-medium-r-normal--24-240-75-75-p-130-iso8859-1");
+ QVERIFY(font1 != font2);
}
#endif
}
@@ -646,7 +646,7 @@ QString getPlatformGenericFont(const char* genericName)
static inline QByteArray msgNotAcceptableFont(const QString &defaultFamily, const QStringList &acceptableFamilies)
{
- QString res = QString::fromLatin1("Font family '%1' is not one of the following accaptable results: ").arg(defaultFamily);
+ QString res = QString::fromLatin1("Font family '%1' is not one of the following acceptable results: ").arg(defaultFamily);
Q_FOREACH (const QString &family, acceptableFamilies)
res += QString::fromLatin1("\n %1").arg(family);
return res.toLocal8Bit();
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 104d3465f2..fa5c81a2f0 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -124,11 +124,11 @@ void tst_QFontDatabase::styles()
QStringList styles = fdb.styles( font );
QStringList::Iterator it = styles.begin();
while ( it != styles.end() ) {
- QString style = *it;
- QString trimmed = style.trimmed();
- ++it;
+ QString style = *it;
+ QString trimmed = style.trimmed();
+ ++it;
- QCOMPARE( style, trimmed );
+ QCOMPARE(style, trimmed);
}
}
@@ -160,7 +160,7 @@ void tst_QFontDatabase::fixedPitch()
QFontDatabase fdb;
if (!fdb.families().contains(font))
- QSKIP( "Font not installed");
+ QSKIP("Font not installed");
QCOMPARE(fdb.isFixedPitch(font), fixedPitch);
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
index cddec5b6e7..d3f5ce4a7d 100644
--- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
@@ -100,6 +100,12 @@ void tst_QFontMetrics::same()
const QString text = QLatin1String("Some stupid STRING");
QCOMPARE(fm.size(0, text), fm.size(0, text)) ;
+ for (int i = 10; i <= 32; ++i) {
+ font.setPixelSize(i);
+ QFontMetrics fm1(font);
+ QCOMPARE(fm1.size(0, text), fm1.size(0, text));
+ }
+
{
QImage image;
QFontMetrics fm2(font, &image);
@@ -163,7 +169,7 @@ void tst_QFontMetrics::metrics()
fontmetrics.lineSpacing());
}
}
- }
+ }
}
}
diff --git a/tests/auto/gui/text/qstatictext/qstatictext.pro b/tests/auto/gui/text/qstatictext/qstatictext.pro
index 55b218deb7..435b132ffd 100644
--- a/tests/auto/gui/text/qstatictext/qstatictext.pro
+++ b/tests/auto/gui/text/qstatictext/qstatictext.pro
@@ -3,5 +3,5 @@ CONFIG += parallel_test
linux: CONFIG += insignificant_test
TARGET = tst_qstatictext
QT += testlib
-QT += core core-private gui gui-private
+QT += core-private gui-private
SOURCES += tst_qstatictext.cpp
diff --git a/tests/auto/gui/text/qtextdocument/common.h b/tests/auto/gui/text/qtextdocument/common.h
index 8fb5fe2499..184b2f7ec7 100644
--- a/tests/auto/gui/text/qtextdocument/common.h
+++ b/tests/auto/gui/text/qtextdocument/common.h
@@ -79,11 +79,11 @@ public:
int l;
void expect(int from, int oldLength, int length) {
- f = from;
- o = oldLength;
- l = length;
- error = false;
- called = false;
+ f = from;
+ o = oldLength;
+ l = length;
+ error = false;
+ called = false;
}
bool error;
bool called;
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index d5ddf8fbec..53aef40df0 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -187,6 +187,9 @@ private slots:
void htmlExportImportBlockCount();
void QTBUG27354_spaceAndSoftSpace();
+ void baseUrl_data();
+ void baseUrl();
+
void QTBUG28998_linkColor();
private:
@@ -2947,6 +2950,53 @@ void tst_QTextDocument::QTBUG27354_spaceAndSoftSpace()
}
}
+class BaseDocument : public QTextDocument
+{
+public:
+ QUrl loadedResource() const { return resourceUrl; }
+
+ QVariant loadResource(int type, const QUrl &name)
+ {
+ resourceUrl = name;
+ return QTextDocument::loadResource(type, name);
+ }
+
+private:
+ QUrl resourceUrl;
+};
+
+void tst_QTextDocument::baseUrl_data()
+{
+ QTest::addColumn<QUrl>("base");
+ QTest::addColumn<QUrl>("resource");
+ QTest::addColumn<QUrl>("loaded");
+
+ QTest::newRow("1") << QUrl() << QUrl("images/logo.png") << QUrl("images/logo.png");
+ QTest::newRow("2") << QUrl("file:///path/to/content") << QUrl("images/logo.png") << QUrl("file:///path/to/images/logo.png");
+ QTest::newRow("3") << QUrl("file:///path/to/content/") << QUrl("images/logo.png") << QUrl("file:///path/to/content/images/logo.png");
+ QTest::newRow("4") << QUrl("file:///path/to/content/images") << QUrl("images/logo.png") << QUrl("file:///path/to/content/images/logo.png");
+ QTest::newRow("5") << QUrl("file:///path/to/content/images/") << QUrl("images/logo.png") << QUrl("file:///path/to/content/images/images/logo.png");
+ QTest::newRow("6") << QUrl("file:///path/to/content/images") << QUrl("../images/logo.png") << QUrl("file:///path/to/images/logo.png");
+ QTest::newRow("7") << QUrl("file:///path/to/content/images/") << QUrl("../images/logo.png") << QUrl("file:///path/to/content/images/logo.png");
+ QTest::newRow("8") << QUrl("file:///path/to/content/index.html") << QUrl("images/logo.png") << QUrl("file:///path/to/content/images/logo.png");
+}
+
+void tst_QTextDocument::baseUrl()
+{
+ QFETCH(QUrl, base);
+ QFETCH(QUrl, resource);
+ QFETCH(QUrl, loaded);
+
+ BaseDocument document;
+ QVERIFY(!document.baseUrl().isValid());
+ document.setBaseUrl(base);
+ QCOMPARE(document.baseUrl(), base);
+
+ document.setHtml(QString("<img src='%1'/>").arg(resource.toString()));
+ document.resource(QTextDocument::ImageResource, resource);
+ QCOMPARE(document.loadedResource(), loaded);
+}
+
void tst_QTextDocument::QTBUG28998_linkColor()
{
QPalette pal;
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index 9f9b6acb02..4274753c37 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -266,6 +266,7 @@ private slots:
void html_metaInBody();
void html_importImageWithoutAspectRatio();
void html_fromFirefox();
+ void html_emptyInlineInsideBlock();
private:
inline void setHtml(const QString &html)
@@ -360,8 +361,8 @@ void tst_QTextDocumentFragment::listCopying2()
cursor.movePosition(QTextCursor::Start);
int listItemCount = 0;
do {
- if (cursor.currentList())
- listItemCount++;
+ if (cursor.currentList())
+ listItemCount++;
} while (cursor.movePosition(QTextCursor::NextBlock));
QCOMPARE(listItemCount, 4);
@@ -378,35 +379,35 @@ void tst_QTextDocumentFragment::tableCopying()
// as the pasiveness of the tablemanager.
QTextDocumentFragment fragment;
{
- QTextDocument doc;
- QTextCursor cursor(&doc);
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
- QTextTableFormat fmt;
- QTextTable *table = cursor.insertTable(2, 2, fmt);
+ QTextTableFormat fmt;
+ QTextTable *table = cursor.insertTable(2, 2, fmt);
- table->cellAt(0, 0).firstCursorPosition().insertText("First Cell");
- table->cellAt(0, 1).firstCursorPosition().insertText("Second Cell");
- table->cellAt(1, 0).firstCursorPosition().insertText("Third Cell");
- table->cellAt(1, 1).firstCursorPosition().insertText("Fourth Cell");
+ table->cellAt(0, 0).firstCursorPosition().insertText("First Cell");
+ table->cellAt(0, 1).firstCursorPosition().insertText("Second Cell");
+ table->cellAt(1, 0).firstCursorPosition().insertText("Third Cell");
+ table->cellAt(1, 1).firstCursorPosition().insertText("Fourth Cell");
- fragment = QTextDocumentFragment(&doc);
+ fragment = QTextDocumentFragment(&doc);
}
{
- QTextDocument doc;
- QTextCursor cursor(&doc);
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
- cursor.insertText("FooBar");
- cursor.insertBlock();
- cursor.movePosition(QTextCursor::Left);
+ cursor.insertText("FooBar");
+ cursor.insertBlock();
+ cursor.movePosition(QTextCursor::Left);
- cursor.insertFragment(fragment);
- cursor.movePosition(QTextCursor::Start);
- cursor.movePosition(QTextCursor::NextBlock);
+ cursor.insertFragment(fragment);
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextBlock);
- QTextTable *table = cursor.currentTable();
- QVERIFY(table);
- QCOMPARE(table->rows(), 2);
- QCOMPARE(table->columns(), 2);
+ QTextTable *table = cursor.currentTable();
+ QVERIFY(table);
+ QCOMPARE(table->rows(), 2);
+ QCOMPARE(table->columns(), 2);
}
}
@@ -488,91 +489,91 @@ void tst_QTextDocumentFragment::tableImport()
void tst_QTextDocumentFragment::tableImport2()
{
{
- const char html[] = ""
- "<table>"
- "<tr><td>First Cell</td><td>Second Cell</td></tr>"
- "<tr><td>Third Cell</td><td>Fourth Cell</td></tr>"
- "</table>";
-
- QTextDocument doc;
- QTextCursor cursor(&doc);
- cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0]))));
-
- cursor.movePosition(QTextCursor::Start);
- cursor.movePosition(QTextCursor::NextBlock);
- QTextTable *table = cursor.currentTable();
- QVERIFY(table);
- QCOMPARE(table->columns(), 2);
- QCOMPARE(table->rows(), 2);
+ const char html[] = ""
+ "<table>"
+ "<tr><td>First Cell</td><td>Second Cell</td></tr>"
+ "<tr><td>Third Cell</td><td>Fourth Cell</td></tr>"
+ "</table>";
+
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
+ cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0]))));
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextBlock);
+ QTextTable *table = cursor.currentTable();
+ QVERIFY(table);
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(table->rows(), 2);
}
{
- const char html[] = ""
- "<table>"
- "<tr><td>First Cell</td><td>Second Cell</td></tr>"
- "<tr><td>Third Cell</td><td>"
- " <table>"
- " <tr><td>First Nested Cell</td><td>Second Nested Cell</td></tr>"
- " <tr><td>Third Nested Cell</td><td>Fourth Nested Cell</td></tr>"
- " <tr><td>Fifth Nested Cell</td><td>Sixth Nested Cell</td></tr>"
- " </table></td></tr>"
- "</table>";
-
- QTextDocument doc;
- QTextCursor cursor(&doc);
- cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0]))));
-
- cursor.movePosition(QTextCursor::Start);
- cursor.movePosition(QTextCursor::NextBlock);
- QTextTable *table = cursor.currentTable();
- QVERIFY(table);
- QCOMPARE(table->columns(), 2);
- QCOMPARE(table->rows(), 2);
+ const char html[] = ""
+ "<table>"
+ "<tr><td>First Cell</td><td>Second Cell</td></tr>"
+ "<tr><td>Third Cell</td><td>"
+ " <table>"
+ " <tr><td>First Nested Cell</td><td>Second Nested Cell</td></tr>"
+ " <tr><td>Third Nested Cell</td><td>Fourth Nested Cell</td></tr>"
+ " <tr><td>Fifth Nested Cell</td><td>Sixth Nested Cell</td></tr>"
+ " </table></td></tr>"
+ "</table>";
+
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
+ cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(html, sizeof(html) / sizeof(html[0]))));
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextBlock);
+ QTextTable *table = cursor.currentTable();
+ QVERIFY(table);
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(table->rows(), 2);
/*
- QTextCursor fourthCell = table->cellAt(1, 1).firstCursorPosition();
- fourthCell.movePosition(QTextCursor::NextBlock);
- table = fourthCell.currentTable();
- QVERIFY(table);
- QVERIFY(table != cursor.currentTable());
- QCOMPARE(table->columns(), 2);
- QCOMPARE(table->rows(), 3);
+ QTextCursor fourthCell = table->cellAt(1, 1).firstCursorPosition();
+ fourthCell.movePosition(QTextCursor::NextBlock);
+ table = fourthCell.currentTable();
+ QVERIFY(table);
+ QVERIFY(table != cursor.currentTable());
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(table->rows(), 3);
*/
}
{
- const char buggyHtml[] = ""
- "<table>"
- "<tr><td>First Cell<td>Second Cell"
- "<tr><td>Third Cell<td>Fourth Cell"
- "</table>";
-
- QTextDocument doc;
- QTextCursor cursor(&doc);
- cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(buggyHtml, sizeof(buggyHtml) / sizeof(buggyHtml[0]))));
-
- cursor.movePosition(QTextCursor::Start);
- cursor.movePosition(QTextCursor::NextBlock);
- QTextTable *table = cursor.currentTable();
- QVERIFY(table);
- QCOMPARE(table->columns(), 2);
- QCOMPARE(table->rows(), 2);
+ const char buggyHtml[] = ""
+ "<table>"
+ "<tr><td>First Cell<td>Second Cell"
+ "<tr><td>Third Cell<td>Fourth Cell"
+ "</table>";
+
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
+ cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(buggyHtml, sizeof(buggyHtml) / sizeof(buggyHtml[0]))));
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextBlock);
+ QTextTable *table = cursor.currentTable();
+ QVERIFY(table);
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(table->rows(), 2);
}
{
- const char buggyHtml[] = ""
- "<table>"
- "<tr><th>First Cell<th>Second Cell"
- "<tr><td>Third Cell<td>Fourth Cell"
- "</table>";
-
- QTextDocument doc;
- QTextCursor cursor(&doc);
- cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(buggyHtml, sizeof(buggyHtml) / sizeof(buggyHtml[0]))));
-
- cursor.movePosition(QTextCursor::Start);
- cursor.movePosition(QTextCursor::NextBlock);
- QTextTable *table = cursor.currentTable();
- QVERIFY(table);
- QCOMPARE(table->columns(), 2);
- QCOMPARE(table->rows(), 2);
+ const char buggyHtml[] = ""
+ "<table>"
+ "<tr><th>First Cell<th>Second Cell"
+ "<tr><td>Third Cell<td>Fourth Cell"
+ "</table>";
+
+ QTextDocument doc;
+ QTextCursor cursor(&doc);
+ cursor.insertFragment(QTextDocumentFragment::fromHtml(QByteArray::fromRawData(buggyHtml, sizeof(buggyHtml) / sizeof(buggyHtml[0]))));
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextBlock);
+ QTextTable *table = cursor.currentTable();
+ QVERIFY(table);
+ QCOMPARE(table->columns(), 2);
+ QCOMPARE(table->rows(), 2);
}
}
@@ -4004,5 +4005,11 @@ void tst_QTextDocumentFragment::html_fromFirefox()
QCOMPARE(doc->toPlainText(), QString::fromLatin1("Test Text "));
}
+void tst_QTextDocumentFragment::html_emptyInlineInsideBlock()
+{
+ doc->setHtml(QString::fromLatin1("<!--StartFragment--><blockquote><span/>Foobar</blockquote><!--EndFragment-->"));
+ QVERIFY(doc->firstBlock().blockFormat().leftMargin() > 0);
+}
+
QTEST_MAIN(tst_QTextDocumentFragment)
#include "tst_qtextdocumentfragment.moc"
diff --git a/tests/auto/gui/text/qtextformat/qtextformat.pro b/tests/auto/gui/text/qtextformat/qtextformat.pro
index b137dac9eb..c64d266916 100644
--- a/tests/auto/gui/text/qtextformat/qtextformat.pro
+++ b/tests/auto/gui/text/qtextformat/qtextformat.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qtextformat
-QT += testlib
+QT += testlib core-private gui-private
SOURCES += tst_qtextformat.cpp
diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
index 1eb073d3b4..beb5069f06 100644
--- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
@@ -46,6 +46,7 @@
#include <qdebug.h>
#include <qsettings.h>
#include <qtextformat.h>
+#include <private/qtextformat_p.h>
#include <qtextdocument.h>
#include <qtextcursor.h>
#include <qtextobject.h>
@@ -68,6 +69,10 @@ private slots:
void getSetTabs();
void testTabsUsed();
void testFontStyleSetters();
+ void setFont_data();
+ void setFont();
+ void setFont_collection_data();
+ void setFont_collection();
};
/*! \internal
@@ -410,5 +415,243 @@ void tst_QTextFormat::testFontStyleSetters()
QCOMPARE(format.font().kerning(), false);
}
+Q_DECLARE_METATYPE(QTextCharFormat)
+
+void tst_QTextFormat::setFont_data()
+{
+ QTest::addColumn<QTextCharFormat>("format1");
+ QTest::addColumn<QTextCharFormat>("format2");
+ QTest::addColumn<bool>("overrideAll");
+
+ QTextCharFormat format1;
+ format1.setFontStyleHint(QFont::Serif);
+ format1.setFontStyleStrategy(QFont::PreferOutline);
+ format1.setFontCapitalization(QFont::AllUppercase);
+ format1.setFontKerning(true);
+
+ {
+ QTest::newRow("noop|override") << format1 << format1 << true;
+ QTest::newRow("noop|inherit") << format1 << format1 << false;
+ }
+
+ {
+ QTextCharFormat format2;
+ format2.setFontStyleHint(QFont::SansSerif);
+ format2.setFontStyleStrategy(QFont::PreferAntialias);
+ format2.setFontCapitalization(QFont::MixedCase);
+ format2.setFontKerning(false);
+
+ QTest::newRow("coverage|override") << format1 << format2 << true;
+ QTest::newRow("coverage|inherit") << format1 << format2 << false;
+ }
+
+ {
+ QTextCharFormat format2;
+ format2.setFontStyleHint(QFont::SansSerif);
+ format2.setFontStyleStrategy(QFont::PreferAntialias);
+
+ QTest::newRow("partial|override") << format1 << format2 << true;
+ QTest::newRow("partial|inherit") << format1 << format2 << false;
+ }
+}
+
+void tst_QTextFormat::setFont()
+{
+ QFETCH(QTextCharFormat, format1);
+ QFETCH(QTextCharFormat, format2);
+ QFETCH(bool, overrideAll);
+
+ QTextCharFormat f;
+
+ f.merge(format1);
+ QCOMPARE((int)f.fontStyleHint(), (int)format1.fontStyleHint());
+ QCOMPARE((int)f.fontStyleStrategy(), (int)format1.fontStyleStrategy());
+ QCOMPARE((int)f.fontCapitalization(), (int)format1.fontCapitalization());
+ QCOMPARE(f.fontKerning(), format1.fontKerning());
+
+ QCOMPARE((int)f.font().styleHint(), (int)f.fontStyleHint());
+ QCOMPARE((int)f.font().styleStrategy(), (int)f.fontStyleStrategy());
+ QCOMPARE((int)f.font().capitalization(), (int)f.fontCapitalization());
+ QCOMPARE(f.font().kerning(), f.fontKerning());
+
+ f.merge(format2);
+ QCOMPARE((int)f.font().styleHint(), (int)f.fontStyleHint());
+ QCOMPARE((int)f.font().styleStrategy(), (int)f.fontStyleStrategy());
+ QCOMPARE((int)f.font().capitalization(), (int)f.fontCapitalization());
+ QCOMPARE(f.font().kerning(), f.fontKerning());
+
+ if (format2.hasProperty(QTextFormat::FontStyleHint))
+ QCOMPARE((int)f.font().styleHint(), (int)format2.fontStyleHint());
+ else
+ QCOMPARE((int)f.font().styleHint(), (int)format1.fontStyleHint());
+ if (format2.hasProperty(QTextFormat::FontStyleStrategy))
+ QCOMPARE((int)f.font().styleStrategy(), (int)format2.fontStyleStrategy());
+ else
+ QCOMPARE((int)f.font().styleStrategy(), (int)format1.fontStyleStrategy());
+ if (format2.hasProperty(QTextFormat::FontCapitalization))
+ QCOMPARE((int)f.font().capitalization(), (int)format2.fontCapitalization());
+ else
+ QCOMPARE((int)f.font().capitalization(), (int)format1.fontCapitalization());
+ if (format2.hasProperty(QTextFormat::FontKerning))
+ QCOMPARE(f.font().kerning(), format2.fontKerning());
+ else
+ QCOMPARE(f.font().kerning(), format1.fontKerning());
+
+
+ QFont font1 = format1.font();
+ QFont font2 = format2.font();
+
+ f = QTextCharFormat();
+
+ {
+ QTextCharFormat tmp;
+ tmp.setFont(font1, overrideAll ? QTextCharFormat::FontPropertiesAll
+ : QTextCharFormat::FontPropertiesSpecifiedOnly);
+ f.merge(tmp);
+ }
+ QCOMPARE((int)f.fontStyleHint(), (int)format1.fontStyleHint());
+ QCOMPARE((int)f.fontStyleStrategy(), (int)format1.fontStyleStrategy());
+ QCOMPARE((int)f.fontCapitalization(), (int)format1.fontCapitalization());
+ QCOMPARE(f.fontKerning(), format1.fontKerning());
+
+ QCOMPARE((int)f.font().styleHint(), (int)f.fontStyleHint());
+ QCOMPARE((int)f.font().styleStrategy(), (int)f.fontStyleStrategy());
+ QCOMPARE((int)f.font().capitalization(), (int)f.fontCapitalization());
+ QCOMPARE(f.font().kerning(), f.fontKerning());
+
+ {
+ QTextCharFormat tmp;
+ tmp.setFont(font2, overrideAll ? QTextCharFormat::FontPropertiesAll
+ : QTextCharFormat::FontPropertiesSpecifiedOnly);
+ f.merge(tmp);
+ }
+ QCOMPARE((int)f.font().styleHint(), (int)f.fontStyleHint());
+ QCOMPARE((int)f.font().styleStrategy(), (int)f.fontStyleStrategy());
+ QCOMPARE((int)f.font().capitalization(), (int)f.fontCapitalization());
+ QCOMPARE(f.font().kerning(), f.fontKerning());
+
+ if (overrideAll || (font2.resolve() & QFont::StyleHintResolved))
+ QCOMPARE((int)f.font().styleHint(), (int)font2.styleHint());
+ else
+ QCOMPARE((int)f.font().styleHint(), (int)font1.styleHint());
+ if (overrideAll || (font2.resolve() & QFont::StyleStrategyResolved))
+ QCOMPARE((int)f.font().styleStrategy(), (int)font2.styleStrategy());
+ else
+ QCOMPARE((int)f.font().styleStrategy(), (int)font1.styleStrategy());
+ if (overrideAll || (font2.resolve() & QFont::CapitalizationResolved))
+ QCOMPARE((int)f.font().capitalization(), (int)font2.capitalization());
+ else
+ QCOMPARE((int)f.font().capitalization(), (int)font1.capitalization());
+ if (overrideAll || (font2.resolve() & QFont::KerningResolved))
+ QCOMPARE(f.font().kerning(), font2.kerning());
+ else
+ QCOMPARE(f.font().kerning(), font1.kerning());
+}
+
+void tst_QTextFormat::setFont_collection_data()
+{
+ setFont_data();
+}
+
+void tst_QTextFormat::setFont_collection()
+{
+ QFETCH(QTextCharFormat, format1);
+ QFETCH(QTextCharFormat, format2);
+ QFETCH(bool, overrideAll);
+
+ QFont font1 = format1.font();
+ QFont font2 = format2.font();
+
+ {
+ QTextFormatCollection collection;
+ collection.setDefaultFont(font1);
+
+ int formatIndex = collection.indexForFormat(format1);
+ QTextCharFormat f = collection.charFormat(formatIndex);
+
+ QCOMPARE((int)f.fontStyleHint(), (int)format1.fontStyleHint());
+ QCOMPARE((int)f.fontStyleStrategy(), (int)format1.fontStyleStrategy());
+ QCOMPARE((int)f.fontCapitalization(), (int)format1.fontCapitalization());
+ QCOMPARE(f.fontKerning(), format1.fontKerning());
+
+ QCOMPARE((int)f.font().styleHint(), (int)f.fontStyleHint());
+ QCOMPARE((int)f.font().styleStrategy(), (int)f.fontStyleStrategy());
+ QCOMPARE((int)f.font().capitalization(), (int)f.fontCapitalization());
+ QCOMPARE(f.font().kerning(), f.fontKerning());
+ }
+ {
+ QTextFormatCollection collection;
+ collection.setDefaultFont(font1);
+
+ int formatIndex = collection.indexForFormat(format2);
+ QTextCharFormat f = collection.charFormat(formatIndex);
+
+ if (format2.hasProperty(QTextFormat::FontStyleHint))
+ QCOMPARE((int)f.font().styleHint(), (int)format2.fontStyleHint());
+ else
+ QCOMPARE((int)f.font().styleHint(), (int)format1.fontStyleHint());
+ if (format2.hasProperty(QTextFormat::FontStyleStrategy))
+ QCOMPARE((int)f.font().styleStrategy(), (int)format2.fontStyleStrategy());
+ else
+ QCOMPARE((int)f.font().styleStrategy(), (int)format1.fontStyleStrategy());
+ if (format2.hasProperty(QTextFormat::FontCapitalization))
+ QCOMPARE((int)f.font().capitalization(), (int)format2.fontCapitalization());
+ else
+ QCOMPARE((int)f.font().capitalization(), (int)format1.fontCapitalization());
+ if (format2.hasProperty(QTextFormat::FontKerning))
+ QCOMPARE(f.font().kerning(), format2.fontKerning());
+ else
+ QCOMPARE(f.font().kerning(), format1.fontKerning());
+ }
+
+ {
+ QTextFormatCollection collection;
+ collection.setDefaultFont(font1);
+
+ QTextCharFormat tmp;
+ tmp.setFont(font1, overrideAll ? QTextCharFormat::FontPropertiesAll
+ : QTextCharFormat::FontPropertiesSpecifiedOnly);
+ int formatIndex = collection.indexForFormat(tmp);
+ QTextCharFormat f = collection.charFormat(formatIndex);
+
+ QCOMPARE((int)f.fontStyleHint(), (int)format1.fontStyleHint());
+ QCOMPARE((int)f.fontStyleStrategy(), (int)format1.fontStyleStrategy());
+ QCOMPARE((int)f.fontCapitalization(), (int)format1.fontCapitalization());
+ QCOMPARE(f.fontKerning(), format1.fontKerning());
+
+ QCOMPARE((int)f.font().styleHint(), (int)f.fontStyleHint());
+ QCOMPARE((int)f.font().styleStrategy(), (int)f.fontStyleStrategy());
+ QCOMPARE((int)f.font().capitalization(), (int)f.fontCapitalization());
+ QCOMPARE(f.font().kerning(), f.fontKerning());
+ }
+ {
+ QTextFormatCollection collection;
+ collection.setDefaultFont(font1);
+
+ QTextCharFormat tmp;
+ tmp.setFont(font2, overrideAll ? QTextCharFormat::FontPropertiesAll
+ : QTextCharFormat::FontPropertiesSpecifiedOnly);
+ int formatIndex = collection.indexForFormat(tmp);
+ QTextCharFormat f = collection.charFormat(formatIndex);
+
+ if (overrideAll || (font2.resolve() & QFont::StyleHintResolved))
+ QCOMPARE((int)f.font().styleHint(), (int)font2.styleHint());
+ else
+ QCOMPARE((int)f.font().styleHint(), (int)font1.styleHint());
+ if (overrideAll || (font2.resolve() & QFont::StyleStrategyResolved))
+ QCOMPARE((int)f.font().styleStrategy(), (int)font2.styleStrategy());
+ else
+ QCOMPARE((int)f.font().styleStrategy(), (int)font1.styleStrategy());
+ if (overrideAll || (font2.resolve() & QFont::CapitalizationResolved))
+ QCOMPARE((int)f.font().capitalization(), (int)font2.capitalization());
+ else
+ QCOMPARE((int)f.font().capitalization(), (int)font1.capitalization());
+ if (overrideAll || (font2.resolve() & QFont::KerningResolved))
+ QCOMPARE(f.font().kerning(), font2.kerning());
+ else
+ QCOMPARE(f.font().kerning(), font1.kerning());
+ }
+}
+
QTEST_MAIN(tst_QTextFormat)
#include "tst_qtextformat.moc"
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 90137079f3..56d6711dc6 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -212,63 +212,63 @@ void tst_QTextLayout::lineBreaking()
{
#if 0
struct Breaks {
- const char *utf8;
- uchar breaks[32];
+ const char *utf8;
+ uchar breaks[32];
};
Breaks brks[] = {
- { "11", { false, 0xff } },
- { "aa", { false, 0xff } },
- { "++", { false, 0xff } },
- { "--", { false, 0xff } },
- { "((", { false, 0xff } },
- { "))", { false, 0xff } },
- { "..", { false, 0xff } },
- { "\"\"", { false, 0xff } },
- { "$$", { false, 0xff } },
- { "!!", { false, 0xff } },
- { "??", { false, 0xff } },
- { ",,", { false, 0xff } },
-
- { ")()", { true, false, 0xff } },
- { "?!?", { false, false, 0xff } },
- { ".,.", { false, false, 0xff } },
- { "+-+", { false, false, 0xff } },
- { "+=+", { false, false, 0xff } },
- { "+(+", { false, false, 0xff } },
- { "+)+", { false, false, 0xff } },
-
- { "a b", { false, true, 0xff } },
- { "a(b", { false, false, 0xff } },
- { "a)b", { false, false, 0xff } },
- { "a-b", { false, true, 0xff } },
- { "a.b", { false, false, 0xff } },
- { "a+b", { false, false, 0xff } },
- { "a?b", { false, false, 0xff } },
- { "a!b", { false, false, 0xff } },
- { "a$b", { false, false, 0xff } },
- { "a,b", { false, false, 0xff } },
- { "a/b", { false, false, 0xff } },
- { "1/2", { false, false, 0xff } },
- { "./.", { false, false, 0xff } },
- { ",/,", { false, false, 0xff } },
- { "!/!", { false, false, 0xff } },
- { "\\/\\", { false, false, 0xff } },
- { "1 2", { false, true, 0xff } },
- { "1(2", { false, false, 0xff } },
- { "1)2", { false, false, 0xff } },
- { "1-2", { false, false, 0xff } },
- { "1.2", { false, false, 0xff } },
- { "1+2", { false, false, 0xff } },
- { "1?2", { false, true, 0xff } },
- { "1!2", { false, true, 0xff } },
- { "1$2", { false, false, 0xff } },
- { "1,2", { false, false, 0xff } },
- { "1/2", { false, false, 0xff } },
- { "\330\260\331\216\331\204\331\220\331\203\331\216", { false, false, false, false, false, 0xff } },
- { "\330\247\331\204\331\205 \330\247\331\204\331\205", { false, false, false, true, false, false, 0xff } },
- { "1#2", { false, false, 0xff } },
- { "!#!", { false, false, 0xff } },
- { 0, {} }
+ { "11", { false, 0xff } },
+ { "aa", { false, 0xff } },
+ { "++", { false, 0xff } },
+ { "--", { false, 0xff } },
+ { "((", { false, 0xff } },
+ { "))", { false, 0xff } },
+ { "..", { false, 0xff } },
+ { "\"\"", { false, 0xff } },
+ { "$$", { false, 0xff } },
+ { "!!", { false, 0xff } },
+ { "??", { false, 0xff } },
+ { ",,", { false, 0xff } },
+
+ { ")()", { true, false, 0xff } },
+ { "?!?", { false, false, 0xff } },
+ { ".,.", { false, false, 0xff } },
+ { "+-+", { false, false, 0xff } },
+ { "+=+", { false, false, 0xff } },
+ { "+(+", { false, false, 0xff } },
+ { "+)+", { false, false, 0xff } },
+
+ { "a b", { false, true, 0xff } },
+ { "a(b", { false, false, 0xff } },
+ { "a)b", { false, false, 0xff } },
+ { "a-b", { false, true, 0xff } },
+ { "a.b", { false, false, 0xff } },
+ { "a+b", { false, false, 0xff } },
+ { "a?b", { false, false, 0xff } },
+ { "a!b", { false, false, 0xff } },
+ { "a$b", { false, false, 0xff } },
+ { "a,b", { false, false, 0xff } },
+ { "a/b", { false, false, 0xff } },
+ { "1/2", { false, false, 0xff } },
+ { "./.", { false, false, 0xff } },
+ { ",/,", { false, false, 0xff } },
+ { "!/!", { false, false, 0xff } },
+ { "\\/\\", { false, false, 0xff } },
+ { "1 2", { false, true, 0xff } },
+ { "1(2", { false, false, 0xff } },
+ { "1)2", { false, false, 0xff } },
+ { "1-2", { false, false, 0xff } },
+ { "1.2", { false, false, 0xff } },
+ { "1+2", { false, false, 0xff } },
+ { "1?2", { false, true, 0xff } },
+ { "1!2", { false, true, 0xff } },
+ { "1$2", { false, false, 0xff } },
+ { "1,2", { false, false, 0xff } },
+ { "1/2", { false, false, 0xff } },
+ { "\330\260\331\216\331\204\331\220\331\203\331\216", { false, false, false, false, false, 0xff } },
+ { "\330\247\331\204\331\205 \330\247\331\204\331\205", { false, false, false, true, false, false, 0xff } },
+ { "1#2", { false, false, 0xff } },
+ { "!#!", { false, false, 0xff } },
+ { 0, {} }
};
Breaks *b = brks;
while (b->utf8) {
diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
index 10a25ba437..0628cc66d1 100644
--- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
@@ -119,7 +119,7 @@ void tst_QTextList::autoNumbering()
QVERIFY(list);
for (int i = 0; i < 27; ++i)
- cursor.insertBlock();
+ cursor.insertBlock();
QVERIFY(list->count() == 28);
diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
index 3359cc8d32..5efb532233 100644
--- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
+++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
@@ -158,12 +158,12 @@ void tst_QTextPieceTable::insertion3()
{
QString compare;
for (int i = 0; i < 20000; ++i) {
- int pos = rand() % (i+1);
- QChar c((unsigned short)(i & 0xff) + 1);
- QString str;
- str += c;
- table->insert(pos, str, charFormatIndex);
- compare.insert(pos, str);
+ int pos = rand() % (i+1);
+ QChar c((unsigned short)(i & 0xff) + 1);
+ QString str;
+ str += c;
+ table->insert(pos, str, charFormatIndex);
+ compare.insert(pos, str);
}
QVERIFY(table->plainText() == compare);
}
@@ -172,17 +172,17 @@ void tst_QTextPieceTable::insertion4()
{
QString compare;
for (int i = 0; i < 20000; ++i) {
- int pos = rand() % (i+1);
- QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
- QString str;
- str += c;
- str += c;
- table->insert(pos, str, charFormatIndex);
- compare.insert(pos, str);
- // if (table->text() != compare) {
- // qDebug("compare failed: i=%d (current char=%c) insert at %d\nexpected '%s'\ngot '%s'", i, (i % 26) + (i>25?'A':'a'), pos, compare.latin1(), table->text().latin1());
- // exit(12);
- // }
+ int pos = rand() % (i+1);
+ QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
+ QString str;
+ str += c;
+ str += c;
+ table->insert(pos, str, charFormatIndex);
+ compare.insert(pos, str);
+// if (table->text() != compare) {
+// qDebug("compare failed: i=%d (current char=%c) insert at %d\nexpected '%s'\ngot '%s'", i, (i % 26) + (i>25?'A':'a'), pos, compare.latin1(), table->text().latin1());
+// exit(12);
+// }
}
QVERIFY(table->plainText() == compare);
}
@@ -191,23 +191,23 @@ void tst_QTextPieceTable::insertion5()
{
QString compare;
for (int i = 0; i < 20000; ++i) {
- int pos = rand() % (i+1);
- QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
- QString str;
- str += c;
- str += c;
- if (c == 'a') {
- table->insertBlock(pos, blockFormatIndex, charFormatIndex);
- str = QChar(QChar::ParagraphSeparator);
- } else {
- table->insert(pos, str, charFormatIndex);
- }
- compare.insert(pos, str);
+ int pos = rand() % (i+1);
+ QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
+ QString str;
+ str += c;
+ str += c;
+ if (c == 'a') {
+ table->insertBlock(pos, blockFormatIndex, charFormatIndex);
+ str = QChar(QChar::ParagraphSeparator);
+ } else {
+ table->insert(pos, str, charFormatIndex);
+ }
+ compare.insert(pos, str);
}
QVERIFY(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());
+ QTextDocumentPrivate::FragmentIterator fit = table->find(it.position());
+ QVERIFY(fit.position() == it.position());
}
}
@@ -249,24 +249,24 @@ void tst_QTextPieceTable::removal3()
QString compare;
int l = 0;
for (int i = 0; i < 20000; ++i) {
- bool remove = l && (rand() % 2);
- int pos = rand() % (remove ? l : (l+1));
- QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
- QString str;
- str += c;
- str += c;
- if (remove && pos < table->length()) {
- compare.remove(pos, 1);
- table->remove(pos, 1);
- } else {
- compare.insert(pos, str);
- table->insert(pos, str, charFormatIndex);
- }
- l += remove ? -1 : 2;
- // if (table->text() != compare) {
- // qDebug("compare failed: i=%d (current char=%c) insert at %d\nexpected '%s'\ngot '%s'", i, (i % 26) + (i>25?'A':'a'), pos, compare.latin1(), table->text().latin1());
- // exit(12);
- // }
+ bool remove = l && (rand() % 2);
+ int pos = rand() % (remove ? l : (l+1));
+ QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
+ QString str;
+ str += c;
+ str += c;
+ if (remove && pos < table->length()) {
+ compare.remove(pos, 1);
+ table->remove(pos, 1);
+ } else {
+ compare.insert(pos, str);
+ table->insert(pos, str, charFormatIndex);
+ }
+ l += remove ? -1 : 2;
+// if (table->text() != compare) {
+// qDebug("compare failed: i=%d (current char=%c) insert at %d\nexpected '%s'\ngot '%s'", i, (i % 26) + (i>25?'A':'a'), pos, compare.latin1(), table->text().latin1());
+// exit(12);
+// }
}
QVERIFY(table->plainText() == compare);
}
@@ -276,31 +276,31 @@ void tst_QTextPieceTable::removal4()
QString compare;
int l = 0;
for (int i = 0; i < 20000; ++i) {
- bool remove = l && (rand() % 2);
- int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0;
- QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
- QString str;
- if (c != 'a') {
- str += c;
- str += c;
- } else {
- str = QChar(QChar::ParagraphSeparator);
- }
- if (remove && pos < table->length() - 1) {
- compare.remove(pos, 1);
- table->remove(pos, 1);
- } else {
- if (str[0] == QChar(QChar::ParagraphSeparator))
- table->insertBlock(pos, blockFormatIndex, charFormatIndex);
- else
- table->insert(pos, str, charFormatIndex);
- compare.insert(pos, str);
- }
- l += remove ? -1 : 2;
-// if (table->plainText() != compare) {
-// qDebug("compare failed: i=%d (current char=%c) insert at %d\nexpected '%s'\ngot '%s'", i, (i % 26) + (i>25?'A':'a'), pos, compare.latin1(), table->plainText().latin1());
-// exit(12);
-// }
+ bool remove = l && (rand() % 2);
+ int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0;
+ QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
+ QString str;
+ if (c != 'a') {
+ str += c;
+ str += c;
+ } else {
+ str = QChar(QChar::ParagraphSeparator);
+ }
+ if (remove && pos < table->length() - 1) {
+ compare.remove(pos, 1);
+ table->remove(pos, 1);
+ } else {
+ if (str[0] == QChar(QChar::ParagraphSeparator))
+ table->insertBlock(pos, blockFormatIndex, charFormatIndex);
+ else
+ table->insert(pos, str, charFormatIndex);
+ compare.insert(pos, str);
+ }
+ l += remove ? -1 : 2;
+// if (table->plainText() != compare) {
+// qDebug("compare failed: i=%d (current char=%c) insert at %d\nexpected '%s'\ngot '%s'", i, (i % 26) + (i>25?'A':'a'), pos, compare.latin1(), table->plainText().latin1());
+// exit(12);
+// }
}
QVERIFY(table->plainText() == compare);
}
@@ -490,27 +490,27 @@ void tst_QTextPieceTable::undoRedo11()
QString compare;
int l = 0;
for (int i = 0; i < loops; ++i) {
- bool remove = l && (rand() % 2);
- int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0;
- QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
- QString str;
- str += c;
- str += c;
- if (remove) {
- compare.remove(pos, 1);
- table->remove(pos, 1);
- } else {
- compare.insert(pos, str);
- table->insert(pos, str, charFormatIndex);
- }
- l += remove ? -1 : 2;
+ bool remove = l && (rand() % 2);
+ int pos = (l > 1) ? rand() % (remove ? l-1 : l) : 0;
+ QChar c((unsigned short)((i % 26) + (i>25?'A':'a')));
+ QString str;
+ str += c;
+ str += c;
+ if (remove) {
+ compare.remove(pos, 1);
+ table->remove(pos, 1);
+ } else {
+ compare.insert(pos, str);
+ table->insert(pos, str, charFormatIndex);
+ }
+ l += remove ? -1 : 2;
}
QVERIFY(table->plainText() == compare);
for (int i = 0; i < loops; ++i)
- table->undo();
+ table->undo();
QVERIFY(table->plainText() == QString(""));
for (int i = 0; i < loops; ++i)
- table->redo();
+ table->redo();
QVERIFY(table->plainText() == compare);
}
diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
index eebac28323..74802c3217 100644
--- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -1067,7 +1067,7 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204()
e->shape(0);
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(2));
- QVERIFY(e->layoutData->glyphLayout.advances_x[1] != 0);
+ QVERIFY(e->layoutData->glyphLayout.advances[1].toInt() != 0);
#endif
}
@@ -1087,8 +1087,7 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675()
e->shape(0);
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(4));
- QEXPECT_FAIL("", "QTBUG-23064", Abort);
- QVERIFY(e->layoutData->glyphLayout.advances_y[2] > 0);
+ QCOMPARE(e->layoutData->glyphLayout.advances[2].toInt(), 0);
#else
QFontDatabase db;
@@ -1106,7 +1105,7 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675()
e->shape(0);
QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(3));
- QVERIFY(e->layoutData->glyphLayout.advances_x[1] == 0);
+ QCOMPARE(e->layoutData->glyphLayout.advances[1].toInt(), 0);
#endif
}