diff options
author | Martin Jones <martin.jones@nokia.com> | 2012-07-03 15:04:19 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-03 07:27:22 +0200 |
commit | f39c22ecec295d44eb1604e0a5dd5400093f0322 (patch) | |
tree | 836c1f2d9abe90bf6214e19301dd518a65201f8b /tests | |
parent | e1b3ad7c831023c3e336414a16b69773adea4e26 (diff) |
Allow resetting a Rectangle gradient.
If a gradient and a color are set on a rectangle, the gradient is used.
This means that if you wish to override the gradient on a component with
a color, you have to unset the gradient.
Also remove the unused QQuickGradient::gradient() method.
Task-number: QTBUG-23238
Change-Id: Ibd43cfe1bd4b867e4f6103f1d0dc0ed6176ab5c1
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickrectangle/data/gradient.qml | 14 | ||||
-rw-r--r-- | tests/auto/quick/qquickrectangle/qquickrectangle.pro | 12 | ||||
-rw-r--r-- | tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp | 93 | ||||
-rw-r--r-- | tests/auto/quick/quick.pro | 1 |
4 files changed, 120 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickrectangle/data/gradient.qml b/tests/auto/quick/qquickrectangle/data/gradient.qml new file mode 100644 index 0000000000..6d2a3c4646 --- /dev/null +++ b/tests/auto/quick/qquickrectangle/data/gradient.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + + function resetGradient() { + gradient = undefined + } + + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } +} + diff --git a/tests/auto/quick/qquickrectangle/qquickrectangle.pro b/tests/auto/quick/qquickrectangle/qquickrectangle.pro new file mode 100644 index 0000000000..daefb5fe75 --- /dev/null +++ b/tests/auto/quick/qquickrectangle/qquickrectangle.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_qquickrectangle +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickrectangle.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +TESTDATA = data/* + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp new file mode 100644 index 0000000000..dd667c2ab7 --- /dev/null +++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 <qtest.h> + +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcomponent.h> +#include <private/qquickrectangle_p.h> + +#include "../../shared/util.h" + +class tst_qquickrectangle : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickrectangle(); + +private slots: + void gradient(); + +private: + QQmlEngine engine; +}; + +tst_qquickrectangle::tst_qquickrectangle() +{ +} + +void tst_qquickrectangle::gradient() +{ + QQmlComponent component(&engine, testFileUrl("gradient.qml")); + QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(component.create()); + QVERIFY(rect); + + QQuickGradient *grad = rect->gradient(); + QVERIFY(grad); + + QQmlListProperty<QQuickGradientStop> stops = grad->stops(); + QCOMPARE(stops.count(&stops), 2); + QCOMPARE(stops.at(&stops, 0)->position(), 0.0); + QCOMPARE(stops.at(&stops, 0)->color(), QColor("gray")); + QCOMPARE(stops.at(&stops, 1)->position(), 1.0); + QCOMPARE(stops.at(&stops, 1)->color(), QColor("white")); + + QMetaObject::invokeMethod(rect, "resetGradient"); + + grad = rect->gradient(); + QVERIFY(!grad); + + delete rect; +} + + +QTEST_MAIN(tst_qquickrectangle) + +#include "tst_qquickrectangle.moc" diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index fd78da2746..aed2ae964e 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -60,6 +60,7 @@ QUICKTESTS = \ qquickpathview \ qquickpincharea \ qquickpositioners \ + qquickrectangle \ qquickrepeater \ qquickshadereffect \ qquickspritesequence \ |