aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/gifs/tst_gifs.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-10-08 12:48:06 +0200
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-10-14 11:58:33 +0000
commit090db511a36464c78f11df3b6596a56f09986951 (patch)
tree389bf7e9b04fa6cf7dfbc035e9568b98cf7b8e44 /tests/manual/gifs/tst_gifs.cpp
parentb5b6fc732bb7a09996c06b1df3b71cf2548b0d7c (diff)
Add RangeSlider
This is basically Slider, except with two handles. It's used to specify a range of values. Task-number: QTBUG-48667 Change-Id: Ib4f9afe5dc8343e307610943d338a2b574a01e4d Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests/manual/gifs/tst_gifs.cpp')
-rw-r--r--tests/manual/gifs/tst_gifs.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp
index df636cd2..16e78706 100644
--- a/tests/manual/gifs/tst_gifs.cpp
+++ b/tests/manual/gifs/tst_gifs.cpp
@@ -51,12 +51,17 @@ private slots:
void tumblerWrap();
void slider();
+ void rangeSlider();
void busyIndicator();
void switchGif();
void button();
void tabBar();
private:
+ void moveSmoothly(const QPoint &from, const QPoint &to, int movements,
+ QEasingCurve::Type easingCurveType = QEasingCurve::OutQuint,
+ int movementDelay = 15);
+
QQuickView view;
QString dataDirPath;
QDir outputDir;
@@ -75,6 +80,19 @@ void tst_Gifs::initTestCase()
view.setFlags(view.flags() | Qt::FramelessWindowHint);
}
+void tst_Gifs::moveSmoothly(const QPoint &from, const QPoint &to, int movements, QEasingCurve::Type easingCurveType, int movementDelay)
+{
+ QEasingCurve curve(easingCurveType);
+ int xDifference = to.x() - from.x();
+ int yDifference = to.y() - from.y();
+ for (int movement = 0; movement < movements; ++movement) {
+ QPoint pos = QPoint(
+ from.x() + curve.valueForProgress(movement / qreal(qAbs(xDifference))) * xDifference,
+ from.y() + curve.valueForProgress(movement / qreal(qAbs(yDifference))) * yDifference);
+ QTest::mouseMove(&view, pos, movementDelay);
+ }
+}
+
void tst_Gifs::tumblerWrap()
{
GifRecorder gifRecorder;
@@ -266,6 +284,39 @@ void tst_Gifs::slider()
gifRecorder.waitForFinish();
}
+void tst_Gifs::rangeSlider()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(5);
+ gifRecorder.setHighQuality(true);
+ gifRecorder.setQmlFileName("qtlabscontrols-rangeslider.qml");
+ gifRecorder.setView(&view);
+
+ view.show();
+
+ gifRecorder.start();
+
+ QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, QPoint(17, 18), 200);
+ moveSmoothly(QPoint(0, 17), QPoint(54, 17), 54);
+ QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, QPoint(54, 17), 20);
+
+ QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, QPoint(182, 14), 200);
+ moveSmoothly(QPoint(183, 17), QPoint(145, 17), 183 - 145);
+ QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, QPoint(145, 17), 20);
+
+ QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, QPoint(142, 13), 200);
+ moveSmoothly(QPoint(143, 17), QPoint(189, 17), 189 - 143);
+ QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, QPoint(189, 12), 20);
+
+ QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, QPoint(63, 14), 200);
+ moveSmoothly(QPoint(62, 17), QPoint(6, 17), 62 - 6);
+ QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, QPoint(6, 17), 20);
+
+ gifRecorder.waitForFinish();
+}
+
void tst_Gifs::busyIndicator()
{
GifRecorder gifRecorder;