summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-01-28 15:52:30 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-04 22:10:17 +0000
commit57469a8e10f11ee04964ed9f8f8d00de0d6d45c1 (patch)
tree875b8ca4bcbafedad54ff0483fc5a19b07660254 /tests/auto
parenta29374fc8ecb9fc17ac125d730eed9c8ec98badb (diff)
Avoid creating a QPixmap on QBrush comparisons
We shouldn't create QPixmaps when comparing QBrushes that do not contain a QPixmap. This patch extends the comparison logic to comparing QImage cachekeys if the brushes are QImage based. Note the comparison still produces false negatives on equal content on different pixmaps and images, but this is preserving existing behavior. Task-number: QTBUG-43766 Change-Id: I001b4032172c1e568aad311f7df2eaae6aee8dc6 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/painting/qbrush/qbrush.pro2
-rw-r--r--tests/auto/gui/painting/qbrush/tst_qbrush.cpp19
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/auto/gui/painting/qbrush/qbrush.pro b/tests/auto/gui/painting/qbrush/qbrush.pro
index 526de12815..0cb11398dc 100644
--- a/tests/auto/gui/painting/qbrush/qbrush.pro
+++ b/tests/auto/gui/painting/qbrush/qbrush.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qbrush
-QT += testlib
+QT += testlib gui-private
SOURCES += tst_qbrush.cpp
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
index 8be9973c64..5ffba431ff 100644
--- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
+++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
@@ -37,6 +37,7 @@
#include "qbrush.h"
#include <QPainter>
#include <QBitmap>
+#include <private/qpixmap_raster_p.h>
#include <qdebug.h>
@@ -71,6 +72,7 @@ private slots:
void debug();
void textureBrushStream();
+ void textureBrushComparison();
};
@@ -446,5 +448,22 @@ void tst_QBrush::textureBrushStream()
QCOMPARE(loadedBrush2.textureImage(), image_source);
}
+void tst_QBrush::textureBrushComparison()
+{
+ QImage image1(10, 10, QImage::Format_RGB32);
+ QRasterPlatformPixmap* ppixmap = new QRasterPlatformPixmap(QPlatformPixmap::PixmapType);
+ ppixmap->fromImage(image1, Qt::NoFormatConversion);
+ QPixmap pixmap(ppixmap);
+ QImage image2(image1);
+
+ QBrush pixmapBrush, imageBrush1, imageBrush2;
+ pixmapBrush.setTexture(pixmap);
+ imageBrush1.setTextureImage(image1);
+ imageBrush2.setTextureImage(image2);
+
+ QVERIFY(imageBrush1 == imageBrush2);
+ QVERIFY(pixmapBrush == imageBrush1);
+}
+
QTEST_MAIN(tst_QBrush)
#include "tst_qbrush.moc"