summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-02-29 12:28:03 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-29 17:39:01 +0100
commitd87edf4e3e850d36c9d091b7bb62d9d0a481ad9f (patch)
treef8feebf61286c8e6c3f1c0328eec380a340413af /tests/auto/gui
parent3b80f1c4d582953da925e9f690a87a3af3158546 (diff)
Remove internal class QVolatileImage.
This made sense only for Symbian where there was a special CFbsBitmap-based backend present and it was used from the Symbian-specific VG and GL pixmap implementations. The generic version is merely a useless wrapper over QImage and is not in use anywhere in the codebase. Change-Id: I1dabe22dfb8cbbc35dce8e22703a3aff810fb5f9 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/image.pro1
-rw-r--r--tests/auto/gui/image/qvolatileimage/qvolatileimage.pro6
-rw-r--r--tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp206
3 files changed, 0 insertions, 213 deletions
diff --git a/tests/auto/gui/image/image.pro b/tests/auto/gui/image/image.pro
index fe089f5e75..fa8f8df29d 100644
--- a/tests/auto/gui/image/image.pro
+++ b/tests/auto/gui/image/image.pro
@@ -9,7 +9,6 @@ SUBDIRS=\
qimageiohandler \
qimagewriter \
qmovie \
- qvolatileimage \
qicon \
qpicture \
diff --git a/tests/auto/gui/image/qvolatileimage/qvolatileimage.pro b/tests/auto/gui/image/qvolatileimage/qvolatileimage.pro
deleted file mode 100644
index 3d982d7951..0000000000
--- a/tests/auto/gui/image/qvolatileimage/qvolatileimage.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qvolatileimage
-
-QT += gui-private widgets testlib
-
-SOURCES += tst_qvolatileimage.cpp
diff --git a/tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp b/tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp
deleted file mode 100644
index f203cfec0f..0000000000
--- a/tests/auto/gui/image/qvolatileimage/tst_qvolatileimage.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include <QtGui/qpainter.h>
-#include <QtGui/qpaintengine.h>
-#include <QtGui/private/qvolatileimage_p.h>
-
-class tst_QVolatileImage : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QVolatileImage() { }
-
-private slots:
- void create();
- void ensureFormat();
- void dataAccess();
- void sharing();
- void fill();
- void copy();
-};
-
-void tst_QVolatileImage::create()
-{
- QVolatileImage nullImg;
- QVERIFY(nullImg.isNull());
-
- QVolatileImage img(100, 200, QImage::Format_ARGB32);
- QVERIFY(!img.isNull());
- QCOMPARE(img.width(), 100);
- QCOMPARE(img.height(), 200);
- QCOMPARE(img.format(), QImage::Format_ARGB32);
- QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height());
- QCOMPARE(img.hasAlphaChannel(), true);
- QCOMPARE(img.depth(), 32);
-
- QImage source(12, 23, QImage::Format_ARGB32_Premultiplied);
- img = QVolatileImage(source);
- QVERIFY(!img.isNull());
- QCOMPARE(img.width(), 12);
- QCOMPARE(img.height(), 23);
- QCOMPARE(img.format(), source.format());
- QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height());
- QVERIFY(img.imageRef() == source);
- QVERIFY(img.toImage() == source);
- QCOMPARE(img.hasAlphaChannel(), true);
- QCOMPARE(img.hasAlphaChannel(), img.imageRef().hasAlphaChannel());
- QCOMPARE(img.hasAlphaChannel(), img.toImage().hasAlphaChannel());
- QCOMPARE(img.depth(), 32);
-}
-
-void tst_QVolatileImage::ensureFormat()
-{
- QImage source(12, 23, QImage::Format_ARGB32_Premultiplied);
- QVolatileImage img(source);
- QVERIFY(!img.isNull());
- QVERIFY(img.imageRef() == source);
- QVERIFY(img.toImage() == source);
-
- QVERIFY(img.ensureFormat(QImage::Format_ARGB32_Premultiplied)); // no-op
- QVERIFY(img.imageRef() == source);
- QVERIFY(img.toImage() == source);
- QVERIFY(img.format() == QImage::Format_ARGB32_Premultiplied);
-
- QVERIFY(img.ensureFormat(QImage::Format_RGB32)); // new data under-the-hood
- QVERIFY(img.imageRef() != source);
- QVERIFY(img.toImage() != source);
- QVERIFY(img.format() == QImage::Format_RGB32);
-}
-
-void tst_QVolatileImage::dataAccess()
-{
- QImage source(12, 23, QImage::Format_ARGB32_Premultiplied);
- QVolatileImage img(source);
- QVERIFY(!img.isNull());
- img.beginDataAccess();
- QVERIFY(img.constBits());
- QVERIFY(img.imageRef().constBits());
- QVERIFY(img.bits());
- QVERIFY(img.imageRef().bits());
- img.endDataAccess();
-
- img = QVolatileImage(12, 23, QImage::Format_ARGB32);
- img.beginDataAccess();
- QVERIFY(img.constBits() && img.bits());
- img.endDataAccess();
-}
-
-void tst_QVolatileImage::sharing()
-{
- QVolatileImage img1(100, 100, QImage::Format_ARGB32);
- QVolatileImage img2 = img1;
- img1.beginDataAccess();
- img2.beginDataAccess();
- QVERIFY(img1.constBits() == img2.constBits());
- img2.endDataAccess();
- img1.endDataAccess();
- img1.imageRef(); // non-const call, should detach
- img1.beginDataAccess();
- img2.beginDataAccess();
- QVERIFY(img1.constBits() != img2.constBits());
- img2.endDataAccess();
- img1.endDataAccess();
-
- // toImage() should return a copy of the internal QImage.
- // imageRef() is a reference to the internal QImage.
- QVERIFY(img1.imageRef().constBits() != img1.toImage().constBits());
-}
-
-bool fuzzyCompareImages(const QImage &image1, const QImage &image2, int tolerance)
-{
- if (image1.bytesPerLine() != image2.bytesPerLine()
- || image1.width() != image2.width()
- || image1.height() != image2.height()) {
- return false;
- }
- for (int i = 0; i < image1.height(); i++) {
- const uchar *line1 = image1.scanLine(i);
- const uchar *line2 = image2.scanLine(i);
- int bytes = image1.bytesPerLine();
- for (int j = 0; j < bytes; j++) {
- int delta = line1[j] - line2[j];
- if (qAbs(delta) > tolerance)
- return false;
- }
- }
- return true;
-}
-
-void tst_QVolatileImage::fill()
-{
- QVolatileImage img(100, 100, QImage::Format_ARGB32_Premultiplied);
- QColor col = QColor(10, 20, 30);
- img.fill(col.rgba());
- QVERIFY(img.imageRef().pixel(1, 1) == col.rgba());
- QVERIFY(img.toImage().pixel(1, 1) == col.rgba());
-}
-
-void tst_QVolatileImage::copy()
-{
- QVolatileImage img(100, 100, QImage::Format_RGB32);
- img.beginDataAccess();
- img.imageRef().fill(QColor(Qt::green).rgba());
- QPainter p(&img.imageRef());
- p.drawRect(10, 10, 50, 50);
- p.end();
- img.endDataAccess();
-
- QVolatileImage img2(100, 100, QImage::Format_RGB32);
- img2.copyFrom(&img, QRect());
- QImage imgA = img.toImage();
- QImage imgB = img2.toImage();
- QCOMPARE(imgA.size(), imgB.size());
- QVERIFY(fuzzyCompareImages(imgA, imgB, 0));
-
- img2 = QVolatileImage(20, 20, QImage::Format_RGB32);
- img2.copyFrom(&img, QRect(5, 5, 20, 20));
- imgA = img.toImage().copy(5, 5, 20, 20);
- imgB = img2.toImage();
- QCOMPARE(imgA.size(), imgB.size());
- QVERIFY(fuzzyCompareImages(imgA, imgB, 0));
-}
-
-QTEST_MAIN(tst_QVolatileImage)
-#include "tst_qvolatileimage.moc"