diff options
Diffstat (limited to 'tests/auto/gui/painting/qpainter/tst_qpainter.cpp')
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 107 |
1 files changed, 45 insertions, 62 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 8c72532122..8a97a9261f 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company 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 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$ ** @@ -81,14 +76,9 @@ Q_OBJECT public: tst_QPainter(); - virtual ~tst_QPainter(); - -public slots: - void init(); - void cleanup(); - void cleanupTestCase(); private slots: + void cleanupTestCase(); void getSetCheck(); #ifndef QT_NO_WIDGETS void drawPixmap_comp_data(); @@ -394,18 +384,6 @@ tst_QPainter::tst_QPainter() QGuiApplication::setDesktopSettingsAware(true); } -tst_QPainter::~tst_QPainter() -{ -} - -void tst_QPainter::init() -{ -} - -void tst_QPainter::cleanup() -{ -} - void tst_QPainter::cleanupTestCase() { QFile::remove(QLatin1String("dest.png")); @@ -665,7 +643,7 @@ QColor tst_QPainter::baseColor( int k, int intensity ) QImage tst_QPainter::getResImage( const QString &dir, const QString &addition, const QString &extension ) { QImage res; - QString resFilename = dir + QString( "/res_%1." ).arg( addition ) + extension; + QString resFilename = dir + QLatin1String("/res_") + addition + QLatin1Char('.') + extension; if ( !res.load( resFilename ) ) { QWARN(QString("Could not load result data %s %1").arg(resFilename).toLatin1()); return QImage(); @@ -676,14 +654,14 @@ QImage tst_QPainter::getResImage( const QString &dir, const QString &addition, c QBitmap tst_QPainter::getBitmap( const QString &dir, const QString &filename, bool mask ) { QBitmap bm; - QString bmFilename = dir + QString( "/%1.xbm" ).arg( filename ); + QString bmFilename = dir + QLatin1Char('/') + filename + QLatin1String(".xbm"); if ( !bm.load( bmFilename ) ) { QWARN(QString("Could not load bitmap '%1'").arg(bmFilename).toLatin1()); return QBitmap(); } if ( mask ) { QBitmap mask; - QString maskFilename = dir + QString( "/%1-mask.xbm" ).arg( filename ); + QString maskFilename = dir + QLatin1Char('/') + filename + QLatin1String("-mask.xbm"); if (!mask.load(maskFilename)) { QWARN(QString("Could not load mask '%1'").arg(maskFilename).toLatin1()); return QBitmap(); @@ -1523,10 +1501,11 @@ void tst_QPainter::drawEllipse_data() // ratio between width and hight is too large/small (task 114874). Those // ratios are therefore currently avoided. for (int w = 10; w < 128; w += 7) { + const QByteArray wB = QByteArray::number(w); for (int h = w/2; h < qMin(2*w, 128); h += 13) { - QString s = QString("%1x%2").arg(w).arg(h); - QTest::newRow(QString("%1 with pen").arg(s).toLatin1()) << QSize(w, h) << true; - QTest::newRow(QString("%1 no pen").arg(s).toLatin1()) << QSize(w, h) << false; + const QByteArray sB = wB + 'x' + QByteArray::number(h); + QTest::newRow((sB + " with pen").constData()) << QSize(w, h) << true; + QTest::newRow((sB + " no pen").constData()) << QSize(w, h) << false; } } } @@ -1564,16 +1543,17 @@ void tst_QPainter::drawClippedEllipse_data() QTest::addColumn<QRect>("rect"); for (int w = 20; w < 128; w += 7) { + const QByteArray wB = QByteArray::number(w); for (int h = w/2; h < qMin(2*w, 128); h += 13) { - QString s = QString("%1x%2").arg(w).arg(h); - QTest::newRow(QString("%1 top").arg(s).toLatin1()) << QRect(0, -h/2, w, h); - QTest::newRow(QString("%1 topright").arg(s).toLatin1()) << QRect(w/2, -h/2, w, h); - QTest::newRow(QString("%1 right").arg(s).toLatin1()) << QRect(w/2, 0, w, h); - QTest::newRow(QString("%1 bottomright").arg(s).toLatin1()) << QRect(w/2, h/2, w, h); - QTest::newRow(QString("%1 bottom").arg(s).toLatin1()) << QRect(0, h/2, w, h); - QTest::newRow(QString("%1 bottomleft").arg(s).toLatin1()) << QRect(-w/2, h/2, w, h); - QTest::newRow(QString("%1 left").arg(s).toLatin1()) << QRect(-w/2, 0, w, h); - QTest::newRow(QString("%1 topleft").arg(s).toLatin1()) << QRect(-w/2, -h/2, w, h); + const QByteArray sB = wB + 'x' + QByteArray::number(h); + QTest::newRow((sB + " top").constData()) << QRect(0, -h/2, w, h); + QTest::newRow((sB + " topright").constData()) << QRect(w/2, -h/2, w, h); + QTest::newRow((sB + " right").constData()) << QRect(w/2, 0, w, h); + QTest::newRow((sB + " bottomright").constData()) << QRect(w/2, h/2, w, h); + QTest::newRow((sB + " bottom").constData()) << QRect(0, h/2, w, h); + QTest::newRow((sB + " bottomleft").constData()) << QRect(-w/2, h/2, w, h); + QTest::newRow((sB + " left").constData()) << QRect(-w/2, 0, w, h); + QTest::newRow((sB + " topleft").constData()) << QRect(-w/2, -h/2, w, h); } } } @@ -1680,13 +1660,14 @@ void tst_QPainter::fillData() QTest::addColumn<bool>("usePen"); for (int w = 3; w < 50; w += 7) { + const QByteArray wB = QByteArray::number(w); for (int h = 3; h < 50; h += 11) { int x = w/2 + 5; int y = h/2 + 5; - QTest::newRow(QString("rect(%1, %2, %3, %4) with pen").arg(x).arg(y).arg(w).arg(h).toLatin1()) - << QRect(x, y, w, h) << true; - QTest::newRow(QString("rect(%1, %2, %3, %4) no pen").arg(x).arg(y).arg(w).arg(h).toLatin1()) - << QRect(x, y, w, h) << false; + const QByteArray rB = "rect(" + QByteArray::number(x) + ", " + QByteArray::number(y) + + ", " + QByteArray::number(w) + ", " + QByteArray::number(h) + ')'; + QTest::newRow((rB + " with pen").constData()) << QRect(x, y, w, h) << true; + QTest::newRow((rB + " no pen").constData()) << QRect(x, y, w, h) << false; } } } @@ -2169,21 +2150,23 @@ void tst_QPainter::clippedLines_data() << QLineF(15, 50, 66, 50); foreach (QLineF line, lines) { - QString desc = QString("line (%1, %2, %3, %4) %5").arg(line.x1()) - .arg(line.y1()).arg(line.x2()).arg(line.y2()); - QTest::newRow(qPrintable(desc.arg(0))) << QSize(100, 100) << line + const QByteArray desc = "line (" + QByteArray::number(line.x1()) + + ", " + QByteArray::number(line.y1()) + ", " + + QByteArray::number(line.x2()) + ", " + QByteArray::number(line.y2()) + + ") "; + QTest::newRow((desc + '0').constData()) << QSize(100, 100) << line << QRect(15, 15, 49, 49) << QPen(Qt::black); - QTest::newRow(qPrintable(desc.arg(1))) << QSize(100, 100) << line + QTest::newRow((desc + '1').constData()) << QSize(100, 100) << line << QRect(15, 15, 50, 50) << QPen(Qt::black); - QTest::newRow(qPrintable(desc.arg(2))) << QSize(100, 100) << line + QTest::newRow((desc + '2').constData()) << QSize(100, 100) << line << QRect(15, 15, 51, 51) << QPen(Qt::black); - QTest::newRow(qPrintable(desc.arg(3))) << QSize(100, 100) << line + QTest::newRow((desc + '3').constData()) << QSize(100, 100) << line << QRect(15, 15, 51, 51) << QPen(Qt::NoPen); - QTest::newRow(qPrintable(desc.arg(4))) << QSize(100, 100) << line + QTest::newRow((desc + '4').constData()) << QSize(100, 100) << line << QRect(15, 15, 51, 51) << pen2; } @@ -4489,7 +4472,7 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate() TestWidget *widget = new TestWidget(); proxy->setWidget(widget); scene->addItem(proxy); - proxy->rotate(45); + proxy->setTransform(QTransform().rotate(45)); w->resize(scene->sceneRect().size().toSize()); w->show(); |