summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qpixmap
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/image/qpixmap')
-rw-r--r--tests/auto/gui/image/qpixmap/CMakeLists.txt23
-rw-r--r--tests/auto/gui/image/qpixmap/qpixmap.pro11
-rw-r--r--tests/auto/gui/image/qpixmap/qpixmap.qrc51
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp97
4 files changed, 72 insertions, 110 deletions
diff --git a/tests/auto/gui/image/qpixmap/CMakeLists.txt b/tests/auto/gui/image/qpixmap/CMakeLists.txt
index b58609a760..8531ef5b7b 100644
--- a/tests/auto/gui/image/qpixmap/CMakeLists.txt
+++ b/tests/auto/gui/image/qpixmap/CMakeLists.txt
@@ -1,9 +1,16 @@
-# Generated from qpixmap.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpixmap Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpixmap LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -22,10 +29,10 @@ file(GLOB_RECURSE test_data_glob
images/*)
list(APPEND test_data ${test_data_glob})
-qt_add_test(tst_qpixmap
+qt_internal_add_test(tst_qpixmap
SOURCES
tst_qpixmap.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -83,7 +90,7 @@ set(qpixmap_resource_files
"loadFromData/designer_rgb32.png"
)
-qt_add_resource(tst_qpixmap "qpixmap"
+qt_internal_add_resource(tst_qpixmap "qpixmap"
PREFIX
"/"
FILES
@@ -94,14 +101,14 @@ qt_add_resource(tst_qpixmap "qpixmap"
## Scopes:
#####################################################################
-qt_extend_target(tst_qpixmap CONDITION TARGET Qt::Widgets
- PUBLIC_LIBRARIES
+qt_internal_extend_target(tst_qpixmap CONDITION TARGET Qt::Widgets
+ LIBRARIES
Qt::Widgets
Qt::WidgetsPrivate
)
-qt_extend_target(tst_qpixmap CONDITION WIN32
- PUBLIC_LIBRARIES
+qt_internal_extend_target(tst_qpixmap CONDITION WIN32
+ LIBRARIES
gdi32
user32
)
diff --git a/tests/auto/gui/image/qpixmap/qpixmap.pro b/tests/auto/gui/image/qpixmap/qpixmap.pro
deleted file mode 100644
index 65294c6aeb..0000000000
--- a/tests/auto/gui/image/qpixmap/qpixmap.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qpixmap
-
-QT += core-private gui-private testlib
-qtHaveModule(widgets): QT += widgets widgets-private
-
-SOURCES += tst_qpixmap.cpp
-win32: QMAKE_USE += user32 gdi32
-
-RESOURCES += qpixmap.qrc
-TESTDATA += convertFromImage/* convertFromToHICON/* loadFromData/* images/*
diff --git a/tests/auto/gui/image/qpixmap/qpixmap.qrc b/tests/auto/gui/image/qpixmap/qpixmap.qrc
deleted file mode 100644
index 3965622dba..0000000000
--- a/tests/auto/gui/image/qpixmap/qpixmap.qrc
+++ /dev/null
@@ -1,51 +0,0 @@
-<RCC>
- <qresource>
- <file>loadFromData/designer_argb32.png</file>
- <file>loadFromData/designer_indexed8_no_alpha_animated.gif</file>
- <file>loadFromData/designer_indexed8_no_alpha.gif</file>
- <file>loadFromData/designer_indexed8_no_alpha.png</file>
- <file>loadFromData/designer_indexed8_with_alpha_animated.gif</file>
- <file>loadFromData/designer_indexed8_with_alpha.gif</file>
- <file>loadFromData/designer_indexed8_with_alpha.png</file>
- <file>loadFromData/designer_rgb32.jpg</file>
- <file>loadFromData/designer_rgb32.png</file>
- <file>convertFromImage/task31722_1/img1.png</file>
- <file>convertFromImage/task31722_1/img2.png</file>
- <file>convertFromToHICON/icon_8bpp_16x16.png</file>
- <file>convertFromToHICON/icon_8bpp_32x32.png</file>
- <file>convertFromToHICON/icon_8bpp_48x48.png</file>
- <file>convertFromToHICON/icon_8bpp.ico</file>
- <file>convertFromToHICON/icon_32bpp_16x16.png</file>
- <file>convertFromToHICON/icon_32bpp_32x32.png</file>
- <file>convertFromToHICON/icon_32bpp_48x48.png</file>
- <file>convertFromToHICON/icon_32bpp_256x256.png</file>
- <file>convertFromToHICON/icon_32bpp.ico</file>
- <file>convertFromImage/task31722_0/img1.png</file>
- <file>convertFromImage/task31722_0/img2.png</file>
- <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/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 33e8671671..d8c553b521 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -1,51 +1,27 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include <qpixmap.h>
-#include <qbitmap.h>
-#include <qimage.h>
-#include <qimagereader.h>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QSet>
+#include <QTemporaryFile>
+#include <QBuffer>
+#include <QTest>
+#include <QPixmap>
+#include <QBitmap>
+#include <QImage>
+#include <QImageReader>
+#include <QPaintEngine>
+
#ifndef QT_NO_WIDGETS
-#include <qsplashscreen.h>
+#include <QSplashScreen>
#endif
-#include <qpaintengine.h>
#include <qpa/qplatformpixmap.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
#include <private/qdrawhelper_p.h>
-#include <QSet>
-
#ifdef Q_OS_WIN
-#include <windows.h>
+#include <qt_windows.h>
#endif
@@ -118,7 +94,9 @@ private slots:
void refUnref();
void copy();
+ void move();
void deepCopyPreservesDpr();
+ void fillPreservesDpr();
void dprPassthrough();
void depthOfNullObjects();
@@ -159,6 +137,7 @@ private slots:
void copyOnNonAlignedBoundary();
void devicePixelRatio();
+ void deviceIndependentSize();
private:
const QString m_prefix;
@@ -1142,6 +1121,20 @@ void tst_QPixmap::copy()
QCOMPARE(trans, transCopy);
}
+void tst_QPixmap::move()
+{
+ QPixmap moveFrom(32, 32);
+
+ QPixmap moveAssigned;
+ moveAssigned = std::move(moveFrom);
+ QVERIFY(!moveAssigned.isNull());
+ QVERIFY(moveFrom.isNull());
+
+ QPixmap moveConstructed(std::move(moveAssigned));
+ QVERIFY(moveAssigned.isNull());
+ QVERIFY(!moveConstructed.isNull());
+}
+
// QTBUG-58653: Force a deep copy of a pixmap by
// having a QPainter and check whether DevicePixelRatio is preserved
void tst_QPixmap::deepCopyPreservesDpr()
@@ -1155,6 +1148,19 @@ void tst_QPixmap::deepCopyPreservesDpr()
QCOMPARE(dest.devicePixelRatio(), dpr);
}
+// Check that the DPR is preserved after doing a fill after an
+// assigned copy of the QPixmap
+void tst_QPixmap::fillPreservesDpr()
+{
+ const qreal dpr = 2;
+ QPixmap src(32, 32);
+ src.setDevicePixelRatio(dpr);
+ src.fill(Qt::red);
+ QPixmap dest = src;
+ dest.fill(Qt::blue);
+ QCOMPARE(dest.devicePixelRatio(), dpr);
+}
+
void tst_QPixmap::dprPassthrough()
{
const qreal dpr = 2;
@@ -1170,8 +1176,10 @@ void tst_QPixmap::dprPassthrough()
pm.convertFromImage(img);
QCOMPARE(pm.devicePixelRatio(), dpr);
+#ifndef QT_NO_IMAGE_HEURISTIC_MASK
QBitmap heuristicMask = src.createHeuristicMask();
QCOMPARE(heuristicMask.devicePixelRatio(), dpr);
+#endif
QBitmap maskFromColor = src.createMaskFromColor(Qt::white);
QCOMPARE(maskFromColor.devicePixelRatio(), dpr);
@@ -1417,7 +1425,7 @@ void tst_QPixmap::loadFromDataImage()
QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef);
QFile file(imagePath);
- file.open(QIODevice::ReadOnly);
+ QVERIFY(file.open(QIODevice::ReadOnly));
QByteArray rawData = file.readAll();
QPixmap directLoadingPixmap;
@@ -1662,5 +1670,14 @@ void tst_QPixmap::devicePixelRatio()
QCOMPARE(b.devicePixelRatio(), qreal(1.0));
}
+void tst_QPixmap::deviceIndependentSize() {
+ QPixmap a(64, 64);
+ a.fill(Qt::white);
+ a.setDevicePixelRatio(1.0);
+ QCOMPARE(a.deviceIndependentSize(), QSizeF(64, 64));
+ a.setDevicePixelRatio(2.0);
+ QCOMPARE(a.deviceIndependentSize(), QSizeF(32, 32));
+}
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"