summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmap
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qpixmap')
-rw-r--r--tests/auto/qpixmap/images/designer.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.pngbin0 -> 4385 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.pngbin0 -> 4104 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.pngbin0 -> 4243 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.pngbin0 -> 4116 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.pngbin0 -> 4367 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.pngbin0 -> 4157 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_0_null.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.pngbin0 -> 4271 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.pngbin0 -> 4188 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_0_dy_1_null.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.pngbin0 -> 4248 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.pngbin0 -> 4196 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.pngbin0 -> 4243 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.pngbin0 -> 4220 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/images/dx_1_dy_0_null.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/qpixmap.pro3
-rw-r--r--tests/auto/qpixmap/qpixmap.qrc29
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp96
28 files changed, 126 insertions, 2 deletions
diff --git a/tests/auto/qpixmap/images/designer.png b/tests/auto/qpixmap/images/designer.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/designer.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.png
new file mode 100644
index 0000000..a4a1924
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_-10_dy_-10_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.png
new file mode 100644
index 0000000..1506af5
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_-10_dy_-10_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.png b/tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.png
new file mode 100644
index 0000000..8500ab1
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_-10_dy_0_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.png
new file mode 100644
index 0000000..2145c61
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_-10_dy_0_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_-128_dy_-128_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_-128_dy_0_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.png
new file mode 100644
index 0000000..728ee79
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_-10_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.png
new file mode 100644
index 0000000..e9d5850
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_-10_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_-128_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.png b/tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_0_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_0_null.png b/tests/auto/qpixmap/images/dx_0_dy_0_null.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_0_null.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_0_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.png
new file mode 100644
index 0000000..7c09b17
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_10_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.png
new file mode 100644
index 0000000..70a6340
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_10_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_128_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_0_dy_1_null.png b/tests/auto/qpixmap/images/dx_0_dy_1_null.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_0_dy_1_null.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.png b/tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.png
new file mode 100644
index 0000000..85abada
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_10_dy_0_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.png
new file mode 100644
index 0000000..3e03450
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_10_dy_0_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.png b/tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.png
new file mode 100644
index 0000000..315fbe0
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_10_dy_10_50_50_100_100.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.png b/tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.png
new file mode 100644
index 0000000..d91dc71
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_10_dy_10_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.png b/tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_128_dy_0_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.png b/tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_128_dy_128_64_64_128_128.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.png b/tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_128_dy_128_x_y_w_h.png
Binary files differ
diff --git a/tests/auto/qpixmap/images/dx_1_dy_0_null.png b/tests/auto/qpixmap/images/dx_1_dy_0_null.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/images/dx_1_dy_0_null.png
Binary files differ
diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro
index e5dace4..70be4be 100644
--- a/tests/auto/qpixmap/qpixmap.pro
+++ b/tests/auto/qpixmap/qpixmap.pro
@@ -13,5 +13,4 @@ wince*: {
win32:LIBS += -lgdi32 -luser32
}
-
-
+RESOURCES += qpixmap.qrc
diff --git a/tests/auto/qpixmap/qpixmap.qrc b/tests/auto/qpixmap/qpixmap.qrc
new file mode 100644
index 0000000..99fde61
--- /dev/null
+++ b/tests/auto/qpixmap/qpixmap.qrc
@@ -0,0 +1,29 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>images/designer.png</file>
+ <file>images/dx_0_dy_0_50_50_100_100.png</file>
+ <file>images/dx_0_dy_0_null.png</file>
+ <file>images/dx_0_dy_0_x_y_w_h.png</file>
+ <file>images/dx_0_dy_-10_50_50_100_100.png</file>
+ <file>images/dx_0_dy_10_50_50_100_100.png</file>
+ <file>images/dx_0_dy_-10_x_y_w_h.png</file>
+ <file>images/dx_0_dy_10_x_y_w_h.png</file>
+ <file>images/dx_0_dy_-128_x_y_w_h.png</file>
+ <file>images/dx_0_dy_128_x_y_w_h.png</file>
+ <file>images/dx_0_dy_1_null.png</file>
+ <file>images/dx_-10_dy_0_50_50_100_100.png</file>
+ <file>images/dx_10_dy_0_50_50_100_100.png</file>
+ <file>images/dx_-10_dy_0_x_y_w_h.png</file>
+ <file>images/dx_10_dy_0_x_y_w_h.png</file>
+ <file>images/dx_-10_dy_-10_50_50_100_100.png</file>
+ <file>images/dx_10_dy_10_50_50_100_100.png</file>
+ <file>images/dx_-10_dy_-10_x_y_w_h.png</file>
+ <file>images/dx_10_dy_10_x_y_w_h.png</file>
+ <file>images/dx_-128_dy_0_x_y_w_h.png</file>
+ <file>images/dx_128_dy_0_x_y_w_h.png</file>
+ <file>images/dx_128_dy_128_64_64_128_128.png</file>
+ <file>images/dx_-128_dy_-128_x_y_w_h.png</file>
+ <file>images/dx_128_dy_128_x_y_w_h.png</file>
+ <file>images/dx_1_dy_0_null.png</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index ba117d8..8a6b63b 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -88,6 +88,9 @@ private slots:
void testMetrics();
+ void scroll_data();
+ void scroll();
+
void fill_data();
void fill();
void fill_transparent();
@@ -302,6 +305,99 @@ void tst_QPixmap::convertFromImage()
QVERIFY( pixmapsAreEqual(&pix, &res) );
}
+void tst_QPixmap::scroll_data()
+{
+ QTest::addColumn<QImage>("input");
+ QTest::addColumn<int>("dx");
+ QTest::addColumn<int>("dy");
+ QTest::addColumn<QRect>("rect");
+ QTest::addColumn<QRegion>("exposed");
+ QTest::addColumn<bool>("newPix");
+
+ QImage input(":/images/designer.png");
+
+ // Noop tests
+ QTest::newRow("null") << QImage() << 0 << 0 << QRect() << QRegion() << false;
+ QTest::newRow("dx_0_dy_0_null") << input << 0 << 0 << QRect() << QRegion() << false;
+ QTest::newRow("dx_1_dy_0_null") << input << 1 << 0 << QRect() << QRegion() << false;
+ QTest::newRow("dx_0_dy_1_null") << input << 0 << 1 << QRect() << QRegion() << false;
+ QTest::newRow("dx_0_dy_0_x_y_w_h") << input << 0 << 0 << input.rect() << QRegion() << false;
+
+ QRegion r;
+ // Scroll whole pixmap
+ r = QRegion(); r += QRect(0, 0, 128, 10);
+ QTest::newRow("dx_0_dy_10_x_y_w_h") << input << 0 << 10 << input.rect() << r << true;
+ r = QRegion(); r += QRect(0, 0, 10, 128);
+ QTest::newRow("dx_10_dy_0_x_y_w_h") << input << 10 << 0 << input.rect() << r << true;
+ r = QRegion(); r += QRect(0, 0, 128, 10); r += QRect(0, 10, 10, 118);
+ QTest::newRow("dx_10_dy_10_x_y_w_h") << input << 10 << 10 << input.rect() << r << true;
+ r = QRegion(); r += QRect(118, 0, 10, 128);
+ QTest::newRow("dx_-10_dy_0_x_y_w_h") << input << -10 << 0 << input.rect() << r << true;
+ r = QRegion(); r += QRect(0, 118, 128, 10);
+ QTest::newRow("dx_0_dy_-10_x_y_w_h") << input << 0 << -10 << input.rect() << r << true;
+ r = QRegion(); r += QRect(118, 0, 10, 118); r += QRect(0, 118, 128, 10);
+ QTest::newRow("dx_-10_dy_-10_x_y_w_h") << input << -10 << -10 << input.rect() << r << true;
+
+ // Scroll part of pixmap
+ QTest::newRow("dx_0_dy_0_50_50_100_100") << input << 0 << 0 << QRect(50, 50, 100, 100) << QRegion() << false;
+ r = QRegion(); r += QRect(50, 50, 10, 78);
+ QTest::newRow("dx_10_dy_0_50_50_100_100") << input << 10 << 0 << QRect(50, 50, 100, 100) << r << true;
+ r = QRegion(); r += QRect(50, 50, 78, 10);
+ QTest::newRow("dx_0_dy_10_50_50_100_100") << input << 0 << 10 << QRect(50, 50, 100, 100) << r << true;
+ r = QRegion(); r += QRect(50, 50, 78, 10); r += QRect(50, 60, 10, 68);
+ QTest::newRow("dx_10_dy_10_50_50_100_100") << input << 10 << 10 << QRect(50, 50, 100, 100) << r << true;
+ r = QRegion(); r += QRect(118, 50, 10, 78);
+ QTest::newRow("dx_-10_dy_0_50_50_100_100") << input << -10 << 0 << QRect(50, 50, 100, 100) << r << true;
+ r = QRegion(); r += QRect(50, 118, 78, 10);
+ QTest::newRow("dx_0_dy_-10_50_50_100_100") << input << 0 << -10 << QRect(50, 50, 100, 100) << r << true;
+ r = QRegion(); r += QRect(118, 50, 10, 68); r += QRect(50, 118, 78, 10);
+ QTest::newRow("dx_-10_dy_-10_50_50_100_100") << input << -10 << -10 << QRect(50, 50, 100, 100) << r << true;
+
+ // Scroll away the whole pixmap
+ r = input.rect();
+ QTest::newRow("dx_128_dy_0_x_y_w_h") << input << 128 << 0 << input.rect() << r << false;
+ QTest::newRow("dx_0_dy_128_x_y_w_h") << input << 0 << 128 << input.rect() << r << false;
+ QTest::newRow("dx_128_dy_128_x_y_w_h") << input << 128 << 128 << input.rect() << r << false;
+ QTest::newRow("dx_-128_dy_0_x_y_w_h") << input << -128 << 0 << input.rect() << r << false;
+ QTest::newRow("dx_0_dy_-128_x_y_w_h") << input << 0 << -128 << input.rect() << r << false;
+ QTest::newRow("dx_-128_dy_-128_x_y_w_h") << input << -128 << -128 << input.rect() << r << false;
+
+ // Scroll away part of the pixmap
+ r = QRegion(); r += QRect(64, 64, 64, 64);
+ QTest::newRow("dx_128_dy_128_64_64_128_128") << input << 128 << 128 << QRect(64, 64, 128, 128) << r << false;
+}
+
+void tst_QPixmap::scroll()
+{
+ QFETCH(QImage, input);
+ QFETCH(int, dx);
+ QFETCH(int, dy);
+ QFETCH(QRect, rect);
+ QFETCH(QRegion, exposed);
+ QFETCH(bool, newPix);
+
+ QPixmap pixmap(input);
+ QRegion exp;
+ qint64 oldKey = pixmap.cacheKey();
+ pixmap.scroll(dx, dy, rect, &exp);
+ if (!newPix)
+ QCOMPARE(pixmap.cacheKey(), oldKey);
+ else
+ QVERIFY(pixmap.cacheKey() != oldKey);
+
+#if 0
+ // Remember to add to resources.
+ QString fileName = QString("images/%1.png").arg(QTest::currentDataTag());
+ pixmap.toImage().save(fileName);
+#else
+ QString fileName = QString(":/images/%1.png").arg(QTest::currentDataTag());
+#endif
+ QImage output(fileName);
+ QVERIFY(input.isNull() == output.isNull());
+ QCOMPARE(pixmap.toImage(), output);
+ QCOMPARE(exp, exposed);
+}
+
void tst_QPixmap::fill_data()
{
QTest::addColumn<uint>("pixel");