Add auto tests for color filter bug

This commit is contained in:
Peter Hartmann 2023-04-03 09:56:49 +02:00
parent 78a9d911ce
commit c41e5c431d
7 changed files with 57 additions and 1 deletions

10
features/qskautotest.prf Normal file
View File

@ -0,0 +1,10 @@
TEMPLATE = app
CONFIG += qskinny qsktestsupport testcase
QT += testlib
DEFINES += QSK_DLL
DESTDIR = $$clean_path( $${OUT_PWD}/../bin )
target.path = $${QSK_INSTALL_AUTOTESTS}/bin
INSTALLS = target

View File

@ -31,6 +31,7 @@ QSK_INSTALL_LIBS = $${QSK_INSTALL_PREFIX}/lib
QSK_INSTALL_BINS = $${QSK_INSTALL_PREFIX}/bin
QSK_INSTALL_PLUGINS = $${QSK_INSTALL_PREFIX}/plugins
QSK_INSTALL_EXAMPLES = $${QSK_INSTALL_PREFIX}/examples
QSK_INSTALL_AUTOTESTS = $${QSK_INSTALL_PREFIX}/tests
CONFIG += no_private_qt_headers_warning

View File

@ -8,7 +8,8 @@ SUBDIRS = \
tools \
support \
examples \
playground
playground \
tests
OTHER_FILES = \
doc/Doxyfile \
@ -25,3 +26,4 @@ tools.depends = src
support.depends = src skins
examples.depends = tools support skins qmlexport
playground.depends = tools support skins qmlexport
tests.depends = support

View File

@ -0,0 +1,3 @@
TEMPLATE=subdirs
SUBDIRS=\
qskcolorfilter \

View File

@ -0,0 +1,4 @@
CONFIG += qskautotest
TARGET = testQskColorFilter
SOURCES += testQskColorFilter.cpp

View File

@ -0,0 +1,33 @@
#include <QskColorFilter.h>
#include <QBrush>
#include <QTest>
class TestQskColorFilter : public QObject
{
Q_OBJECT
private Q_SLOTS:
void substituteBrush();
};
void TestQskColorFilter::substituteBrush()
{
QskColorFilter filter;
filter.addColorSubstitution( Qt::white, Qt::black );
QLinearGradient gradient;
QGradientStops originalStops( { { 0.0, Qt::white }, { 1.0, Qt::blue } } );
gradient.setStops( originalStops );
QBrush originalBrush( gradient );
auto newBrush = filter.substituted( originalBrush );
QGradientStops newStops( { { 0.0, Qt::black }, { 1.0, Qt::blue } } );
QVERIFY( originalBrush.gradient()->stops() == originalStops );
QVERIFY( newBrush.gradient()->stops() == newStops );
}
QTEST_GUILESS_MAIN( TestQskColorFilter )
#include "testQskColorFilter.moc"

3
tests/tests.pro Normal file
View File

@ -0,0 +1,3 @@
TEMPLATE=subdirs
SUBDIRS=\
graphic \