diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-04-20 15:29:45 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-04-21 06:31:32 +0000 |
commit | 92cbfffc5c2a4bd12c9d4dd5862ecbf1c1fdc7c4 (patch) | |
tree | 4471cbab02e8291d6cb4b42ac6650a8637127286 /tests/manual/gifs | |
parent | 6b45995c0cd1dfdc96531feaa67a26cdf1fc129b (diff) |
Add GIFs for Dial
Change-Id: I9b3670e9976a4b743f49a0eae3939e99944ea277
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/manual/gifs')
-rw-r--r-- | tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml | 57 | ||||
-rw-r--r-- | tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml | 56 | ||||
-rw-r--r-- | tests/manual/gifs/tst_gifs.cpp | 86 |
3 files changed, 199 insertions, 0 deletions
diff --git a/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml new file mode 100644 index 00000000..a27a975b --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-dial-no-wrap.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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: dial.implicitWidth + 20 + height: dial.implicitHeight + 20 + visible: true + + property alias dial: dial + + Dial { + id: dial + wrap: false + anchors.centerIn: parent + } +} diff --git a/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml new file mode 100644 index 00000000..55d744ec --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols2-dial-wrap.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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: dial.implicitWidth + 20 + height: dial.implicitHeight + 20 + visible: true + + property alias dial: dial + + Dial { + id: dial + anchors.centerIn: parent + } +} diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index b4dcd745..078813e1 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -62,10 +62,14 @@ private slots: void swipeDelegateBehind(); void delegates_data(); void delegates(); + void dial_data(); + void dial(); private: void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements, QEasingCurve::Type easingCurveType = QEasingCurve::OutQuint, int movementDelay = 15); + void moveSmoothlyAlongArc(QQuickWindow *window, QPoint arcCenter, qreal distanceFromCenter, + qreal startAngleRadians, qreal endAngleRadians, QEasingCurve::Type easingCurveType = QEasingCurve::OutQuint); QString dataDirPath; QDir outputDir; @@ -96,6 +100,29 @@ void tst_Gifs::moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoi } } +QPoint posAlongArc(QPoint arcCenter, qreal startAngleRadians, qreal endAngleRadians, + qreal distanceFromCenter, qreal progress, QEasingCurve::Type easingCurveType) +{ + QEasingCurve curve(easingCurveType); + const qreal angle = startAngleRadians + curve.valueForProgress(progress) * (endAngleRadians - startAngleRadians); + return (arcCenter - QTransform().rotateRadians(angle).map(QPointF(0, distanceFromCenter))).toPoint(); +} + +void tst_Gifs::moveSmoothlyAlongArc(QQuickWindow *window, QPoint arcCenter, qreal distanceFromCenter, + qreal startAngleRadians, qreal endAngleRadians, QEasingCurve::Type easingCurveType) +{ + QEasingCurve curve(easingCurveType); + const qreal angleSpan = endAngleRadians - startAngleRadians; + const int movements = qAbs(angleSpan) * 20 + 20; + + for (int movement = 0; movement < movements; ++movement) { + const qreal progress = movement / qreal(movements); + const QPoint pos = posAlongArc(arcCenter, startAngleRadians, endAngleRadians, + distanceFromCenter, progress, easingCurveType); + QTest::mouseMove(window, pos, 15); + } +} + void tst_Gifs::tumblerWrap() { GifRecorder gifRecorder; @@ -510,6 +537,65 @@ void tst_Gifs::delegates() gifRecorder.waitForFinish(); } +void tst_Gifs::dial_data() +{ + QTest::addColumn<QString>("name"); + + QTest::newRow("dial-wrap") << "wrap"; + QTest::newRow("dial-no-wrap") << "no-wrap"; +} + +void tst_Gifs::dial() +{ + QFETCH(QString, name); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(10); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-dial-%1.qml").arg(name)); + gifRecorder.setHighQuality(false); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *dial = window->property("dial").value<QQuickItem*>(); + QVERIFY(dial); + + const QPoint arcCenter = dial->mapToScene(QPoint(dial->width() / 2, dial->height() / 2)).toPoint(); + const qreal distanceFromCenter = dial->height() * 0.25; + // Go a bit past the actual min/max to ensure that we get the full range. + const qreal minAngle = qDegreesToRadians(-170.0); + const qreal maxAngle = qDegreesToRadians(170.0); + // Drag from start to end. + qreal startAngle = minAngle; + qreal endAngle = maxAngle; + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, posAlongArc( + arcCenter, startAngle, endAngle, distanceFromCenter, 0, QEasingCurve::InOutQuad), 30); + + moveSmoothlyAlongArc(window, arcCenter, distanceFromCenter, startAngle, endAngle, QEasingCurve::InOutQuad); + + // Come back from the end a bit. + startAngle = endAngle; + endAngle -= qDegreesToRadians(50.0); + moveSmoothlyAlongArc(window, arcCenter, distanceFromCenter, startAngle, endAngle, QEasingCurve::InOutQuad); + + // Try to drag over max to show what happens with different wrap settings. + startAngle = endAngle; + endAngle = qDegreesToRadians(270.0); + moveSmoothlyAlongArc(window, arcCenter, distanceFromCenter, startAngle, endAngle, QEasingCurve::InOutQuad); + + // Go back to the start so that it loops nicely. + startAngle = endAngle; + endAngle = minAngle; + moveSmoothlyAlongArc(window, arcCenter, distanceFromCenter, startAngle, endAngle, QEasingCurve::InOutQuad); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, posAlongArc( + arcCenter, startAngle, endAngle, distanceFromCenter, 1, QEasingCurve::InOutQuad), 30); + + gifRecorder.waitForFinish(); +} + QTEST_MAIN(tst_Gifs) #include "tst_gifs.moc" |