diff options
Diffstat (limited to 'tests')
8 files changed, 5 insertions, 1017 deletions
diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index ac0f73f..a36541e 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -129,6 +129,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; QTest::newRow("get1") << "{get(0)}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; + QTest::newRow("get2") << "{get(-1)}" << 0 << "QML ListModel (unknown location) get: index -1 out of range"; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -146,6 +147,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; + QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range"; QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range"; @@ -166,6 +168,7 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; + QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object"; QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object"; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; @@ -175,7 +178,8 @@ void tst_QmlListModel::dynamic_data() QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << ""; QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << ""; QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; - QTest::newRow("setprop4a") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range"; + QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; + QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range"; QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << ""; QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index 2f85265..8433de5 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -6,7 +6,5 @@ SUBDIRS += \ qmlcomponent \ qmlgraphicsimage \ qmlmetaproperty \ - qmlpainting \ script \ - text # qmltime diff --git a/tests/benchmarks/declarative/qmlpainting/qmlpainting.pro b/tests/benchmarks/declarative/qmlpainting/qmlpainting.pro deleted file mode 100644 index 971e18d..0000000 --- a/tests/benchmarks/declarative/qmlpainting/qmlpainting.pro +++ /dev/null @@ -1,6 +0,0 @@ -load(qttest_p4) -TEMPLATE = app -TARGET = tst_qmlpainting -macx:CONFIG -= app_bundle - -SOURCES += tst_qmlpainting.cpp diff --git a/tests/benchmarks/declarative/qmlpainting/tst_qmlpainting.cpp b/tests/benchmarks/declarative/qmlpainting/tst_qmlpainting.cpp deleted file mode 100644 index e14531f..0000000 --- a/tests/benchmarks/declarative/qmlpainting/tst_qmlpainting.cpp +++ /dev/null @@ -1,574 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qtest.h> -#include <QPainter> -#include <QImage> - -#include <math.h> -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -class tst_QmlPainting : public QObject -{ - Q_OBJECT - - public: - tst_QmlPainting() {} - -private slots: - void drawRoundedRect(); - void drawScaledRoundedRect(); - void drawTransformedRoundedRect(); - - void drawAntialiasedRoundedRect(); - void drawScaledAntialiasedRoundedRect_data(); - void drawScaledAntialiasedRoundedRect(); - void drawTransformedAntialiasedRoundedRect_data(); - void drawTransformedAntialiasedRoundedRect(); - - void drawImageRoundedRect(); - void drawScaledImageRoundedRect_data(); - void drawScaledImageRoundedRect(); - void drawTransformedImageRoundedRect_data(); - void drawTransformedImageRoundedRect(); - - void drawScaleGridRoundedRect(); - void drawScaledScaleGridRoundedRect_data(); - void drawScaledScaleGridRoundedRect(); - void drawTransformedScaleGridRoundedRect_data(); - void drawTransformedScaleGridRoundedRect(); - - void drawTransformedTransparentImage_data(); - void drawTransformedTransparentImage(); - void drawTransformedSemiTransparentImage_data(); - void drawTransformedSemiTransparentImage(); - void drawTransformedFilledImage_data(); - void drawTransformedFilledImage(); -}; - -const qreal inv_dist_to_plane = 1. / 1024.; -QTransform transformForAngle(qreal angle) -{ - QTransform transform; - - QTransform rotTrans; - rotTrans.translate(-40, 0); - QTransform rotTrans2; - rotTrans2.translate(40, 0); - - qreal rad = angle * 2. * M_PI / 360.; - qreal c = ::cos(rad); - qreal s = ::sin(rad); - - qreal x = 0; - qreal y = 80; - qreal z = 0; - - qreal len = x * x + y * y + z * z; - if (len != 1.) { - len = ::sqrt(len); - x /= len; - y /= len; - z /= len; - } - - QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane, - y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane, - 0, 0, 1); - - transform *= rotTrans; - transform *= rot; - transform *= rotTrans2; - - return transform; -} - -void tst_QmlPainting::drawRoundedRect() -{ - QImage surface(100, 100, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - p.setPen(QPen(Qt::black, 1)); - p.setBrush(Qt::red); - - QBENCHMARK { - p.drawRoundedRect(QRectF(.5, .5, 80, 80), 10, 10); - } - //surface.save("regular.png"); -} - -void tst_QmlPainting::drawScaledRoundedRect() -{ - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - p.setPen(QPen(Qt::black, 1)); - p.setBrush(Qt::red); - p.scale(3, 3); - - QBENCHMARK { - p.drawRoundedRect(10, 10, 80, 80, 10, 10); - } - //surface.save("scaled.png"); -} - -void tst_QmlPainting::drawTransformedRoundedRect() -{ - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - p.setPen(QPen(Qt::black, 1)); - p.setBrush(Qt::red); - - QBENCHMARK { - p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); - p.drawRoundedRect(100, 100, 80, 80, 10, 10); - } - //surface.save("transformed.png"); -} - -void tst_QmlPainting::drawAntialiasedRoundedRect() -{ - QImage surface(100, 100, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - p.setRenderHint(QPainter::Antialiasing, true); - p.setPen(QPen(Qt::black, 1)); - p.setBrush(Qt::red); - - QBENCHMARK { - p.drawRoundedRect(QRectF(.5, .5, 80, 80), 10, 10); - } - //surface.save("aar.png"); -} - -void tst_QmlPainting::drawScaledAntialiasedRoundedRect_data() -{ - QTest::addColumn<float>("scale"); - - for (float i = 0; i < 3; i += .1) - QTest::newRow(QString(QLatin1String("scale=%1")).arg(i).toLatin1()) << i; -} - -void tst_QmlPainting::drawScaledAntialiasedRoundedRect() -{ - QFETCH(float, scale); - - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - p.setRenderHint(QPainter::Antialiasing, true); - p.setPen(QPen(Qt::black, 1)); - p.setBrush(Qt::red); - p.scale(scale, scale); - - QBENCHMARK { - p.drawRoundedRect(10, 10, 80, 80, 10, 10); - } - //surface.save("aas.png"); -} - -void tst_QmlPainting::drawTransformedAntialiasedRoundedRect_data() -{ - QTest::addColumn<QTransform>("transform"); - - for (float angle = 0; angle < 360; angle += 10) - QTest::newRow(QString(QLatin1String("angle=%1")).arg(angle).toLatin1()) << transformForAngle(angle); -} - -void tst_QmlPainting::drawTransformedAntialiasedRoundedRect() -{ - QFETCH(QTransform, transform); - - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - p.setRenderHint(QPainter::Antialiasing, true); - p.setPen(QPen(Qt::black, 1)); - p.setBrush(Qt::red); - - QBENCHMARK { - p.setWorldTransform(transform); - p.drawRoundedRect(100, 100, 80, 80, 10, 10); - } - //surface.save("aat.png"); -} - -void tst_QmlPainting::drawImageRoundedRect() -{ - //setup image - const int radius = 10; - QImage rectImage(81, 81, QImage::Format_ARGB32_Premultiplied); - rectImage.fill(0); - QPainter rp(&rectImage); - rp.setRenderHint(QPainter::Antialiasing); - rp.setPen(Qt::black); - rp.setBrush(Qt::red); - rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); - - //setup surface - QImage surface(100, 100, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - p.drawImage(0,0, rectImage); - } - //surface.save("ri.png"); -} - -void tst_QmlPainting::drawScaledImageRoundedRect_data() -{ - QTest::addColumn<int>("imageType"); - - QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; -} - -void tst_QmlPainting::drawScaledImageRoundedRect() -{ - QFETCH(int, imageType); - - //setup image - const int radius = 10; - QImage rectImage(81, 81, (QImage::Format)imageType); - rectImage.fill(0); - QPainter rp(&rectImage); - rp.setRenderHint(QPainter::Antialiasing); - rp.setPen(Qt::black); - rp.setBrush(Qt::red); - rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); - - //setup surface - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - p.scale(3, 3); - - QBENCHMARK { - p.drawImage(0,0, rectImage); - } - //surface.save("si.png"); -} - -void tst_QmlPainting::drawTransformedImageRoundedRect_data() -{ - QTest::addColumn<int>("imageType"); - - QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; -} - -void tst_QmlPainting::drawTransformedImageRoundedRect() -{ - QFETCH(int, imageType); - - //setup image - const int radius = 10; - QImage rectImage(81, 81, (QImage::Format)imageType); - rectImage.fill(0); - QPainter rp(&rectImage); - rp.setRenderHint(QPainter::Antialiasing); - rp.setPen(Qt::black); - rp.setBrush(Qt::red); - rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); - - //setup surface - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); - p.drawImage(100,100, rectImage); - } - //surface.save("ti.png"); -} - -//code from QmlGraphicsRectangle for drawing rounded rects -void tst_QmlPainting::drawScaleGridRoundedRect() -{ - //setup image - const int pw = 1; - const int radius = 10; - QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, QImage::Format_ARGB32_Premultiplied); - rectImage.fill(0); - QPainter rp(&rectImage); - rp.setRenderHint(QPainter::Antialiasing); - rp.setPen(Qt::black); - rp.setBrush(Qt::red); - if (pw%2) - rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); - else - rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); - - //setup surface - QImage surface(100, 100, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - const int pw = 2; - int width = 80; - int height = 80; - - int xOffset = (rectPixmap.width()-1)/2; - int yOffset = (rectPixmap.height()-1)/2; - Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); - Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); - - QMargins margins(xOffset, yOffset, xOffset, yOffset); - QTileRules rules(Qt::StretchTile, Qt::StretchTile); - //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects - qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); - } - //surface.save("rsg.png"); -} - -void tst_QmlPainting::drawScaledScaleGridRoundedRect_data() -{ - QTest::addColumn<float>("scale"); - QTest::addColumn<int>("imageType"); - - for (float i = 0; i < 3; i += .1) - QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB32_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB32_Premultiplied; - //for (float i = 0; i < 3; i += .1) - // QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB8565_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB8565_Premultiplied; -} - -//code from QmlGraphicsRectangle for drawing rounded rects -void tst_QmlPainting::drawScaledScaleGridRoundedRect() -{ - QFETCH(float, scale); - QFETCH(int, imageType); - - //setup image - const int pw = 1; - const int radius = 10; - QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, (QImage::Format)imageType); - rectImage.fill(0); - QPainter rp(&rectImage); - rp.setRenderHint(QPainter::Antialiasing); - rp.setPen(Qt::black); - rp.setBrush(Qt::red); - if (pw%2) - rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); - else - rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - - QPixmap rectPixmap = QPixmap::fromImage(rectImage); - - //setup surface - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - p.scale(scale, scale); - - QBENCHMARK { - const int pw = 2; - int width = 80; - int height = 80; - - int xOffset = (rectPixmap.width()-1)/2; - int yOffset = (rectPixmap.height()-1)/2; - Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); - Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); - - QMargins margins(xOffset, yOffset, xOffset, yOffset); - QTileRules rules(Qt::StretchTile, Qt::StretchTile); - //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects - qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); - } - //surface.save("ssg.png"); -} - -void tst_QmlPainting::drawTransformedScaleGridRoundedRect_data() -{ - QTest::addColumn<QTransform>("transform"); - QTest::addColumn<int>("imageType"); - - for (float angle = 0; angle < 360; angle += 10) - QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB32_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB32_Premultiplied; - //for (float angle = 0; angle < 360; angle += 10) - // QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB8565_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB8565_Premultiplied; - -} - -//code from QmlGraphicsRectangle for drawing rounded rects -void tst_QmlPainting::drawTransformedScaleGridRoundedRect() -{ - QFETCH(QTransform, transform); - QFETCH(int, imageType); - - //setup image - const int pw = 1; - const int radius = 10; - QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, (QImage::Format)imageType); - rectImage.fill(0); - QPainter rp(&rectImage); - rp.setRenderHint(QPainter::Antialiasing); - rp.setPen(Qt::black); - rp.setBrush(Qt::red); - if (pw%2) - rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); - else - rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - - QPixmap rectPixmap = QPixmap::fromImage(rectImage); - - //setup surface - QImage surface(400, 400, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - p.setWorldTransform(transform); - const int pw = 2; - //int offset = int(radius+1.5+pw); - int width = 80; - int height = 80; - - int xOffset = (rectPixmap.width()-1)/2; - int yOffset = (rectPixmap.height()-1)/2; - Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); - Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); - - QMargins margins(xOffset, yOffset, xOffset, yOffset); - QTileRules rules(Qt::StretchTile, Qt::StretchTile); - //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects - qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); - } - //surface.save("tsg.png"); -} - -void tst_QmlPainting::drawTransformedTransparentImage_data() -{ - QTest::addColumn<int>("imageType"); - - QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; -} - -void tst_QmlPainting::drawTransformedTransparentImage() -{ - QFETCH(int, imageType); - - //setup image - QImage transImage(200, 200, (QImage::Format)imageType); - transImage.fill(0); - - //setup surface - QImage surface(200, 200, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); - p.drawImage(0,0, transImage); - } -} - -void tst_QmlPainting::drawTransformedSemiTransparentImage_data() -{ - QTest::addColumn<int>("imageType"); - - QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; -} - -void tst_QmlPainting::drawTransformedSemiTransparentImage() -{ - QFETCH(int, imageType); - - //setup image - QImage transImage(200, 200, (QImage::Format)imageType); - transImage.fill(QColor(0,0,0, 128).rgba()); - - //setup surface - QImage surface(200, 200, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); - p.drawImage(0,0, transImage); - } -} - -void tst_QmlPainting::drawTransformedFilledImage_data() -{ - QTest::addColumn<int>("imageType"); - - QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; -} - -void tst_QmlPainting::drawTransformedFilledImage() -{ - QFETCH(int, imageType); - - //setup image - QImage filledImage(200, 200, (QImage::Format)imageType); - filledImage.fill(QColor(0,0,0).rgb()); - - //setup surface - QImage surface(200, 200, QImage::Format_RGB16); - surface.fill(QColor(255,255,255).rgb()); - QPainter p(&surface); - - QBENCHMARK { - p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); - p.drawImage(0,0, filledImage); - } -} - -QTEST_MAIN(tst_QmlPainting) - -#include "tst_qmlpainting.moc" diff --git a/tests/benchmarks/declarative/signalemission/signalemission.pro b/tests/benchmarks/declarative/signalemission/signalemission.pro deleted file mode 100644 index 0119aff..0000000 --- a/tests/benchmarks/declarative/signalemission/signalemission.pro +++ /dev/null @@ -1,7 +0,0 @@ -load(qttest_p4) -TEMPLATE = app -TARGET = tst_signalemission -macx:CONFIG -= app_bundle - -SOURCES += tst_signalemission.cpp - diff --git a/tests/benchmarks/declarative/signalemission/tst_signalemission.cpp b/tests/benchmarks/declarative/signalemission/tst_signalemission.cpp deleted file mode 100644 index 8327638..0000000 --- a/tests/benchmarks/declarative/signalemission/tst_signalemission.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qtest.h> -#include <QObject> -#include <QDebug> - -class LotsOfSignals : public QObject -{ - Q_OBJECT -public: - LotsOfSignals() {} - -signals: - void extraSignal1(); - void extraSignal2(); - void extraSignal3(); - void extraSignal4(); - void extraSignal5(); - void extraSignal6(); - void extraSignal7(); - void extraSignal8(); - void extraSignal9(); - void extraSignal10(); - void extraSignal12(); - void extraSignal13(); - void extraSignal14(); - void extraSignal15(); - void extraSignal16(); - void extraSignal17(); - void extraSignal18(); - void extraSignal19(); - void extraSignal20(); - void extraSignal21(); - void extraSignal22(); - void extraSignal23(); - void extraSignal24(); - void extraSignal25(); - void extraSignal26(); - void extraSignal27(); - void extraSignal28(); - void extraSignal29(); - void extraSignal30(); - void extraSignal31(); - void extraSignal32(); - void extraSignal33(); - void extraSignal34(); - void extraSignal35(); - void extraSignal36(); - void extraSignal37(); - void extraSignal38(); - void extraSignal39(); - void extraSignal40(); - void extraSignal41(); - void extraSignal42(); - void extraSignal43(); - void extraSignal44(); - void extraSignal45(); - void extraSignal46(); - void extraSignal47(); - void extraSignal48(); - void extraSignal49(); - void extraSignal50(); - void extraSignal51(); - void extraSignal52(); - void extraSignal53(); - void extraSignal54(); - void extraSignal55(); - void extraSignal56(); - void extraSignal57(); - void extraSignal58(); - void extraSignal59(); - void extraSignal60(); - void extraSignal61(); - void extraSignal62(); - void extraSignal63(); - void extraSignal64(); - void extraSignal65(); - void extraSignal66(); - void extraSignal67(); - void extraSignal68(); - void extraSignal69(); - void extraSignal70(); -}; - -class tst_signalemission : public QObject -{ - Q_OBJECT -public: - tst_signalemission() {} - -private slots: - void unconnected_data(); - void unconnected(); -}; - -void tst_signalemission::unconnected_data() -{ - QTest::addColumn<int>("signal_index"); - QTest::newRow("9") << 9; - QTest::newRow("32") << 32; - QTest::newRow("33") << 33; - QTest::newRow("64") << 64; - QTest::newRow("65") << 65; - QTest::newRow("70") << 70; -} - -void tst_signalemission::unconnected() -{ - LotsOfSignals *obj = new LotsOfSignals; - QFETCH(int, signal_index); - QVERIFY(obj->metaObject()->methodCount() == 73); - void *v; - QBENCHMARK { - //+1 because QObject has one slot - QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, signal_index+1, &v); - } - delete obj; -} - -QTEST_MAIN(tst_signalemission) -#include "tst_signalemission.moc" diff --git a/tests/benchmarks/declarative/text/text.pro b/tests/benchmarks/declarative/text/text.pro deleted file mode 100644 index 3320f53..0000000 --- a/tests/benchmarks/declarative/text/text.pro +++ /dev/null @@ -1,7 +0,0 @@ -load(qttest_p4) -TEMPLATE = app -TARGET = tst_text -macx:CONFIG -= app_bundle - -SOURCES += tst_text.cpp - diff --git a/tests/benchmarks/declarative/text/tst_text.cpp b/tests/benchmarks/declarative/text/tst_text.cpp deleted file mode 100644 index 33ee237..0000000 --- a/tests/benchmarks/declarative/text/tst_text.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** 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 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qtest.h> -#include <QTextLayout> -#include <QPainter> -#include <QSize> -#include <qmath.h> -#include <private/qtextcontrol_p.h> - -class tst_text : public QObject -{ - Q_OBJECT -public: - tst_text() - { - m_text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; - } - -private slots: - void layout(); - void paintLayoutToPixmap(); - void paintLayoutToPixmap_painterFill(); - void document(); - void paintDocToPixmap(); - void paintDocToPixmap_painterFill(); - void control(); - void paintControlToPixmap(); - void paintControlToPixmap_painterFill(); - void constructControl(); - void constructDocument(); - -private: - QString m_text; -}; - -QSize setupTextLayout(QTextLayout *layout) -{ - bool wrap = true; - int wrapWidth = 300; - layout->setCacheEnabled(true); - - int height = 0; - qreal widthUsed = 0; - qreal lineWidth = 0; - - //set manual width - if (wrap) - lineWidth = wrapWidth; - - layout->beginLayout(); - - while (1) { - QTextLine line = layout->createLine(); - if (!line.isValid()) - break; - - if (wrap) - line.setLineWidth(lineWidth); - } - layout->endLayout(); - - for (int i = 0; i < layout->lineCount(); ++i) { - QTextLine line = layout->lineAt(i); - widthUsed = qMax(widthUsed, line.naturalTextWidth()); - line.setPosition(QPointF(0, height)); - height += int(line.height()); - } - return QSize(qCeil(widthUsed), height); -} - -void tst_text::layout() -{ - //get rid of initialization effects - QTextLayout layout(m_text); - setupTextLayout(&layout); - - QBENCHMARK { - QTextLayout layout(m_text); - setupTextLayout(&layout); - } -} - -void tst_text::paintLayoutToPixmap() -{ - QTextLayout layout(m_text); - QSize size = setupTextLayout(&layout); - - QBENCHMARK { - QPixmap img(size); - img.fill(Qt::transparent); - QPainter p(&img); - layout.draw(&p, QPointF(0, 0)); - } -} - -void tst_text::paintLayoutToPixmap_painterFill() -{ - QTextLayout layout(m_text); - QSize size = setupTextLayout(&layout); - - QBENCHMARK { - QPixmap img(size); - QPainter p(&img); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - layout.draw(&p, QPointF(0, 0)); - } -} - -void tst_text::document() -{ - QTextDocument *doc = new QTextDocument; - - QBENCHMARK { - QTextDocument *doc = new QTextDocument; - doc->setHtml(m_text); - } -} - -void tst_text::paintDocToPixmap() -{ - QTextDocument *doc = new QTextDocument; - doc->setHtml(m_text); - doc->setTextWidth(300); - QSize size = doc->size().toSize(); - - QBENCHMARK { - QPixmap img(size); - img.fill(Qt::transparent); - QPainter p(&img); - doc->drawContents(&p); - } -} - -void tst_text::paintDocToPixmap_painterFill() -{ - QTextDocument *doc = new QTextDocument; - doc->setHtml(m_text); - doc->setTextWidth(300); - QSize size = doc->size().toSize(); - - QBENCHMARK { - QPixmap img(size); - QPainter p(&img); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - doc->drawContents(&p); - } -} - -void tst_text::control() -{ - QTextControl *control = new QTextControl(m_text); - - QBENCHMARK { - QTextControl *control = new QTextControl; - QTextDocument *doc = control->document(); - doc->setHtml(m_text); - } -} - -void tst_text::paintControlToPixmap() -{ - QTextControl *control = new QTextControl; - QTextDocument *doc = control->document(); - doc->setHtml(m_text); - doc->setTextWidth(300); - QSize size = doc->size().toSize(); - - QBENCHMARK { - QPixmap img(size); - img.fill(Qt::transparent); - QPainter p(&img); - control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size))); - } -} - -void tst_text::paintControlToPixmap_painterFill() -{ - QTextControl *control = new QTextControl; - QTextDocument *doc = control->document(); - doc->setHtml(m_text); - doc->setTextWidth(300); - QSize size = doc->size().toSize(); - - QBENCHMARK { - QPixmap img(size); - QPainter p(&img); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size))); - } -} - -void tst_text::constructControl() -{ - QTextControl *control = new QTextControl; - delete control; - - QBENCHMARK { - QTextControl *control = new QTextControl; - delete control; - } -} - -void tst_text::constructDocument() -{ - QTextDocument *doc = new QTextDocument; - delete doc; - - QBENCHMARK { - QTextDocument *doc = new QTextDocument; - delete doc; - } -} - -QTEST_MAIN(tst_text) -#include "tst_text.moc" |