aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/gifs
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2016-03-31 16:58:08 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-11 19:26:11 +0000
commitb663020c9a60704dc53014522a3faa23892280a0 (patch)
tree80dd4f47910ce2313491d19167f3dfb94ea9d9e5 /tests/manual/gifs
parent1acb34a40ea0fbc0c0730cdc81dcfd46bdeb4ef7 (diff)
Add RadioDelegate
RadioDelegate is an item delegate that is used in lists, and can be checked and unchecked. It derives from QQuickItemDelegate and hence has background press effects. The order of the indicator and text is reversed (compared to RadioButton) to reflect what is most commonly seen on mobile. Change-Id: I143ee9a30cd8ce1d624354f4cb981c41dfddc2d2 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests/manual/gifs')
-rw-r--r--tests/manual/gifs/data/qtquickcontrols-radiodelegate.qml70
-rw-r--r--tests/manual/gifs/tst_gifs.cpp25
2 files changed, 86 insertions, 9 deletions
diff --git a/tests/manual/gifs/data/qtquickcontrols-radiodelegate.qml b/tests/manual/gifs/data/qtquickcontrols-radiodelegate.qml
new file mode 100644
index 00000000..9cc542f6
--- /dev/null
+++ b/tests/manual/gifs/data/qtquickcontrols-radiodelegate.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Window 2.0
+import Qt.labs.controls 1.0
+
+Window {
+ width: column.implicitWidth
+ height: column.implicitHeight
+ visible: true
+
+ property var delegate: repeater.count > 0 ? repeater.itemAt(0) : null
+
+ ButtonGroup {
+ id: buttonGroup
+ }
+
+ Column {
+ id: column
+ anchors.centerIn: parent
+
+ Repeater {
+ id: repeater
+ model: ["Option 1", "Option 2", "Option 3"]
+ delegate: RadioDelegate {
+ checked: index == 0
+ text: modelData
+ ButtonGroup.group: buttonGroup
+ }
+ }
+ }
+}
diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp
index 6c0ef288..3b9cad02 100644
--- a/tests/manual/gifs/tst_gifs.cpp
+++ b/tests/manual/gifs/tst_gifs.cpp
@@ -471,18 +471,24 @@ void tst_Gifs::swipeDelegateBehind()
void tst_Gifs::delegates_data()
{
QTest::addColumn<QString>("name");
- QTest::newRow("ItemDelegate") << "itemdelegate";
- QTest::newRow("CheckDelegate") << "checkdelegate";
+ QTest::addColumn<QVector<int> >("pressIndices");
+ QTest::addColumn<int>("duration");
+
+ QTest::newRow("ItemDelegate") << "itemdelegate" << (QVector<int>() << 0 << 0) << 5;
+ QTest::newRow("CheckDelegate") << "checkdelegate" << (QVector<int>() << 0 << 0) << 5;
+ QTest::newRow("RadioDelegate") << "radiodelegate" << (QVector<int>() << 1 << 0) << 5;
}
void tst_Gifs::delegates()
{
QFETCH(QString, name);
+ QFETCH(QVector<int>, pressIndices);
+ QFETCH(int, duration);
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
- gifRecorder.setRecordingDuration(5);
+ gifRecorder.setRecordingDuration(duration);
gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols-%1.qml").arg(name));
gifRecorder.setHighQuality(true);
@@ -492,12 +498,13 @@ void tst_Gifs::delegates()
QQuickItem *delegate = window->property("delegate").value<QQuickItem*>();
QVERIFY(delegate);
- const QPoint delegateCenter(delegate->mapToScene(QPointF(delegate->width() / 2, delegate->height() / 2)).toPoint());
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 200);
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400);
-
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 1000);
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400);
+ for (int i = 0; i < pressIndices.size(); ++i) {
+ const int pressIndex = pressIndices.at(i);
+ const QPoint delegateCenter(delegate->mapToScene(QPointF(
+ delegate->width() / 2, delegate->height() / 2 + delegate->height() * pressIndex)).toPoint());
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, i == 0 ? 200 : 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400);
+ }
gifRecorder.waitForFinish();
}