aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/gifs/tst_gifs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/gifs/tst_gifs.cpp')
-rw-r--r--tests/manual/gifs/tst_gifs.cpp623
1 files changed, 607 insertions, 16 deletions
diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp
index 7f2a985c..d3fb5f6d 100644
--- a/tests/manual/gifs/tst_gifs.cpp
+++ b/tests/manual/gifs/tst_gifs.cpp
@@ -51,16 +51,41 @@ private slots:
void tumblerWrap();
void slider();
+ void sliderSnap_data();
+ void sliderSnap();
void rangeSlider();
void busyIndicator();
void switchGif();
+ void button_data();
void button();
void tabBar();
void menu();
+ void swipeView();
+ void swipeDelegate_data();
+ void swipeDelegate();
+ void swipeDelegateBehind();
+ void delegates_data();
+ void delegates();
+ void dial_data();
+ void dial();
+ void scrollBar();
+ void scrollIndicator();
+ void progressBar_data();
+ void progressBar();
+ void triState_data();
+ void triState();
+ void checkables_data();
+ void checkables();
+ void comboBox();
+ void stackView_data();
+ void stackView();
+ void drawer();
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;
@@ -85,19 +110,42 @@ void tst_Gifs::moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoi
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);
+ from.x() + qRound(curve.valueForProgress(movement / qreal(qAbs(xDifference))) * xDifference),
+ from.y() + qRound(curve.valueForProgress(movement / qreal(qAbs(yDifference))) * yDifference));
QTest::mouseMove(window, pos, movementDelay);
}
}
+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;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
gifRecorder.setRecordingDuration(4);
- gifRecorder.setQmlFileName("qtlabscontrols-tumbler-wrap.qml");
+ gifRecorder.setQmlFileName("qtquickcontrols2-tumbler-wrap.qml");
gifRecorder.start();
@@ -156,7 +204,8 @@ void tst_Gifs::tumblerWrap()
gifRecorder.waitForFinish();
- foreach (CapturedEvent event, eventCapturer.capturedEvents())
+ const auto capturedEvents = eventCapturer.capturedEvents();
+ for (CapturedEvent event : capturedEvents)
qDebug().noquote() << event.cppCommand();
}
@@ -167,7 +216,7 @@ void tst_Gifs::slider()
gifRecorder.setOutputDir(outputDir);
gifRecorder.setRecordingDuration(5);
gifRecorder.setHighQuality(true);
- gifRecorder.setQmlFileName("qtlabscontrols-slider.qml");
+ gifRecorder.setQmlFileName("qtquickcontrols2-slider.qml");
gifRecorder.start();
@@ -197,6 +246,58 @@ void tst_Gifs::slider()
gifRecorder.waitForFinish();
}
+void tst_Gifs::sliderSnap_data()
+{
+ QTest::addColumn<QString>("gifBaseName");
+ QTest::addColumn<int>("snapMode");
+ QTest::newRow("NoSnap") << "qtquickcontrols2-slider-nosnap" << 0;
+ QTest::newRow("SnapAlways") << "qtquickcontrols2-slider-snapalways" << 1;
+ QTest::newRow("SnapOnRelease") << "qtquickcontrols2-slider-snaponrelease" << 2;
+}
+
+void tst_Gifs::sliderSnap()
+{
+ QFETCH(QString, gifBaseName);
+ QFETCH(int, snapMode);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(8);
+ gifRecorder.setHighQuality(true);
+ gifRecorder.setQmlFileName("qtquickcontrols2-slider-snap.qml");
+ gifRecorder.setOutputFileBaseName(gifBaseName);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *slider = window->property("slider").value<QQuickItem*>();
+ QVERIFY(slider);
+ QVERIFY(slider->setProperty("snapMode", QVariant(snapMode)));
+ QCOMPARE(slider->property("snapMode").toInt(), snapMode);
+ QQuickItem *handle = slider->property("handle").value<QQuickItem*>();
+ QVERIFY(handle);
+
+ const QPoint startPos(slider->property("leftPadding").toReal(), slider->height() / 2);
+ const int trackWidth = slider->property("availableWidth").toReal();
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 200);
+ QPoint pos1 = startPos + QPoint(trackWidth * 0.3, 0);
+ moveSmoothly(window, startPos, pos1, pos1.x() - startPos.x(), QEasingCurve::OutQuint, 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, pos1, 0);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 400);
+ const QPoint pos2 = startPos + QPoint(trackWidth * 0.6, 0);
+ moveSmoothly(window, pos1, pos2, pos2.x() - pos1.x(), QEasingCurve::OutQuint, 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, pos2, 0);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, pos2, 400);
+ moveSmoothly(window, pos2, startPos, qAbs(startPos.x() - pos2.x()) / 2, QEasingCurve::OutQuint, 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos, 0);
+
+ gifRecorder.waitForFinish();
+}
+
void tst_Gifs::rangeSlider()
{
GifRecorder gifRecorder;
@@ -204,7 +305,7 @@ void tst_Gifs::rangeSlider()
gifRecorder.setOutputDir(outputDir);
gifRecorder.setRecordingDuration(7);
gifRecorder.setHighQuality(true);
- gifRecorder.setQmlFileName("qtlabscontrols-rangeslider.qml");
+ gifRecorder.setQmlFileName("qtquickcontrols2-rangeslider.qml");
gifRecorder.start();
@@ -251,25 +352,25 @@ void tst_Gifs::busyIndicator()
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
- gifRecorder.setRecordingDuration(3);
+ gifRecorder.setRecordingDuration(6);
gifRecorder.setHighQuality(true);
- gifRecorder.setQmlFileName("qtlabscontrols-busyindicator.qml");
+ gifRecorder.setQmlFileName("qtquickcontrols2-busyindicator.qml");
gifRecorder.start();
QQuickWindow *window = gifRecorder.window();
// Record nothing for a bit to make it smoother.
- QTest::qWait(400);
+ QTest::qWait(800 * 2);
QQuickItem *busyIndicator = window->property("busyIndicator").value<QQuickItem*>();
QVERIFY(busyIndicator);
- busyIndicator->setProperty("running", true);
+ busyIndicator->setProperty("running", false);
// 800 ms is the duration of one rotation animation cycle for BusyIndicator.
QTest::qWait(800 * 2);
- busyIndicator->setProperty("running", false);
+ busyIndicator->setProperty("running", true);
gifRecorder.waitForFinish();
}
@@ -280,7 +381,7 @@ void tst_Gifs::switchGif()
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
gifRecorder.setRecordingDuration(3);
- gifRecorder.setQmlFileName("qtlabscontrols-switch.qml");
+ gifRecorder.setQmlFileName("qtquickcontrols2-switch.qml");
gifRecorder.setHighQuality(true);
gifRecorder.start();
@@ -292,14 +393,23 @@ void tst_Gifs::switchGif()
gifRecorder.waitForFinish();
}
+void tst_Gifs::button_data()
+{
+ QTest::addColumn<QString>("qmlFileName");
+ QTest::newRow("button") << QString::fromLatin1("qtquickcontrols2-button.qml");
+ QTest::newRow("button-flat") << QString::fromLatin1("qtquickcontrols2-button-flat.qml");
+ QTest::newRow("button-highlighted") << QString::fromLatin1("qtquickcontrols2-button-highlighted.qml");
+}
+
void tst_Gifs::button()
{
+ QFETCH(QString, qmlFileName);
+
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
gifRecorder.setOutputDir(outputDir);
gifRecorder.setRecordingDuration(3);
- gifRecorder.setQmlFileName("qtlabscontrols-button.qml");
- gifRecorder.setHighQuality(true);
+ gifRecorder.setQmlFileName(qmlFileName);
gifRecorder.start();
@@ -312,7 +422,7 @@ void tst_Gifs::button()
void tst_Gifs::tabBar()
{
- const QString qmlFileName = QStringLiteral("qtlabscontrols-tabbar.qml");
+ const QString qmlFileName = QStringLiteral("qtquickcontrols2-tabbar.qml");
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
@@ -341,7 +451,7 @@ void tst_Gifs::tabBar()
void tst_Gifs::menu()
{
- const QString qmlFileName = QStringLiteral("qtlabscontrols-menu.qml");
+ const QString qmlFileName = QStringLiteral("qtquickcontrols2-menu.qml");
GifRecorder gifRecorder;
gifRecorder.setDataDirPath(dataDirPath);
@@ -372,6 +482,487 @@ void tst_Gifs::menu()
gifRecorder.waitForFinish();
}
+void tst_Gifs::swipeView()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(8);
+ gifRecorder.setQmlFileName(QStringLiteral("qtquickcontrols2-swipeview.qml"));
+ gifRecorder.setHighQuality(true);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *swipeView = window->property("swipeView").value<QQuickItem*>();
+ QVERIFY(swipeView);
+
+ QTest::qWait(1200);
+ swipeView->setProperty("currentIndex", 1);
+ QTest::qWait(2000);
+ swipeView->setProperty("currentIndex", 2);
+ QTest::qWait(2000);
+ swipeView->setProperty("currentIndex", 0);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::swipeDelegate_data()
+{
+ QTest::addColumn<QString>("qmlFileName");
+ QTest::newRow("qtquickcontrols2-swipedelegate.qml") << QString::fromLatin1("qtquickcontrols2-swipedelegate.qml");
+ QTest::newRow("qtquickcontrols2-swipedelegate-leading-trailing.qml") << QString::fromLatin1("qtquickcontrols2-swipedelegate-leading-trailing.qml");
+}
+
+void tst_Gifs::swipeDelegate()
+{
+ QFETCH(QString, qmlFileName);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(10);
+ gifRecorder.setQmlFileName(qmlFileName);
+ gifRecorder.setHighQuality(true);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *swipeDelegate = window->property("swipeDelegate").value<QQuickItem*>();
+ QVERIFY(swipeDelegate);
+
+ // Show left item.
+ const QPoint leftTarget = QPoint(swipeDelegate->width() * 0.2, 0);
+ const QPoint rightTarget = QPoint(swipeDelegate->width() * 0.8, 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 100);
+ const int movements = rightTarget.x() - leftTarget.x();
+ moveSmoothly(window, leftTarget, rightTarget, movements, QEasingCurve::OutQuint, 5);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 20);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 1000);
+ moveSmoothly(window, rightTarget, leftTarget, movements, QEasingCurve::OutQuint, 5);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 20);
+
+ QTest::qWait(1000);
+
+ // Show right item.
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 1000);
+ moveSmoothly(window, rightTarget, leftTarget, movements, QEasingCurve::OutQuint, 5);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 20);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 1000);
+ moveSmoothly(window, leftTarget, rightTarget, movements, QEasingCurve::OutQuint, 5);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 20);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::swipeDelegateBehind()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(14);
+ gifRecorder.setQmlFileName(QStringLiteral("qtquickcontrols2-swipedelegate-behind.qml"));
+ gifRecorder.setHighQuality(true);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *swipeDelegate = window->property("swipeDelegate").value<QQuickItem*>();
+ QVERIFY(swipeDelegate);
+
+ // Show wrapping around left item.
+ const QPoint leftTarget = QPoint(swipeDelegate->width() * 0.2, 0);
+ const QPoint rightTarget = QPoint(swipeDelegate->width() * 0.8, 0);
+ const int movements = rightTarget.x() - leftTarget.x();
+ for (int i = 0; i < 4; ++i) {
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 100);
+ moveSmoothly(window, leftTarget, rightTarget, movements, QEasingCurve::OutQuint, 5);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 20);
+
+ QTest::qWait(500);
+ }
+
+ QTest::qWait(1000);
+
+ // Show wrapping around right item.
+ for (int i = 0; i < 4; ++i) {
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rightTarget, 100);
+ moveSmoothly(window, rightTarget, leftTarget, movements, QEasingCurve::OutQuint, 5);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, leftTarget, 20);
+
+ QTest::qWait(500);
+ }
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::delegates_data()
+{
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<QVector<int> >("pressIndices");
+ QTest::addColumn<int>("duration");
+
+ QTest::newRow("ItemDelegate") << "itemdelegate" << (QVector<int>() << 0 << 1 << 2) << 5;
+ QTest::newRow("CheckDelegate") << "checkdelegate" << (QVector<int>() << 0 << 0) << 5;
+ QTest::newRow("RadioDelegate") << "radiodelegate" << (QVector<int>() << 1 << 0) << 5;
+ QTest::newRow("SwitchDelegate") << "switchdelegate" << (QVector<int>() << 0 << 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(duration);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name));
+ gifRecorder.setHighQuality(true);
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *delegate = window->property("delegate").value<QQuickItem*>();
+ QVERIFY(delegate);
+
+ 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();
+}
+
+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();
+}
+
+void tst_Gifs::checkables_data()
+{
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<QVector<int> >("pressIndices");
+
+ QTest::newRow("checkbox") << "checkbox" << (QVector<int>() << 1 << 2 << 2 << 1);
+ QTest::newRow("radiobutton") << "radiobutton" << (QVector<int>() << 1 << 2 << 1 << 0);
+}
+
+void tst_Gifs::checkables()
+{
+ QFETCH(QString, name);
+ QFETCH(QVector<int>, pressIndices);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name));
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+
+ for (int i = 0; i < pressIndices.size(); ++i) {
+ const int pressIndex = pressIndices.at(i);
+ const char *controlId = qPrintable(QString::fromLatin1("control%1").arg(pressIndex + 1));
+ QQuickItem *control = window->property(controlId).value<QQuickItem*>();
+ QVERIFY(control);
+
+ const QPoint pos = control->mapToScene(QPointF(control->width() / 2, control->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, pos, 800);
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, pos, 300);
+ }
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::comboBox()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName(QStringLiteral("qtquickcontrols2-combobox.qml"));
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *comboBox = window->property("comboBox").value<QQuickItem*>();
+ QVERIFY(comboBox);
+
+ // Open the popup.
+ const QPoint center = comboBox->mapToScene(
+ QPoint(comboBox->width() / 2, comboBox->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, center, 800);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, center, 80);
+
+ // Select the third item.
+ QObject *popup = comboBox->property("popup").value<QObject*>();
+ QVERIFY(popup);
+ QQuickItem *popupContent = popup->property("contentItem").value<QQuickItem*>();
+ QVERIFY(popupContent);
+ const QPoint lastItemPos = popupContent->mapToScene(
+ QPoint(popupContent->width() / 2, popupContent->height() * 0.8)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, lastItemPos, 600);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, lastItemPos, 200);
+
+ // Open the popup.
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, center, 1500);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, center, 80);
+
+ // Select the first item.
+ const QPoint firstItemPos = popupContent->mapToScene(
+ QPoint(popupContent->width() / 2, popupContent->height() * 0.2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, firstItemPos, 600);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, firstItemPos, 200);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::triState_data()
+{
+ QTest::addColumn<QString>("name");
+
+ QTest::newRow("checkbox-tristate") << "checkbox-tristate";
+ QTest::newRow("checkdelegate-tristate") << "checkdelegate-tristate";
+}
+
+void tst_Gifs::triState()
+{
+ QFETCH(QString, name);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-%1.qml").arg(name));
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *english = window->property("english").value<QQuickItem*>();
+ QVERIFY(english);
+ QQuickItem *norwegian = window->property("norwegian").value<QQuickItem*>();
+ QVERIFY(norwegian);
+
+ const QPoint englishCenter = english->mapToScene(
+ QPointF(english->width() / 2, english->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 300);
+
+ const QPoint norwegianCenter = norwegian->mapToScene(
+ QPointF(norwegian->width() / 2, norwegian->height() / 2)).toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 300);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, norwegianCenter, 300);
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 1000);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, englishCenter, 300);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::scrollBar()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName("qtquickcontrols2-scrollbar.qml");
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QQuickItem *scrollBar = window->property("scrollBar").value<QQuickItem*>();
+ QVERIFY(scrollBar);
+
+ // Flick in the center of the screen to show that there's a scroll bar.
+ const QPoint lhsWindowBottom = QPoint(0, window->height() - 1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, lhsWindowBottom, 100);
+ QTest::mouseMove(window, lhsWindowBottom - QPoint(0, 10), 30);
+ QTest::mouseMove(window, lhsWindowBottom - QPoint(0, 30), 30);
+ QTest::mouseMove(window, lhsWindowBottom - QPoint(0, 60), 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, lhsWindowBottom - QPoint(0, 100), 30);
+
+ // Scroll with the scroll bar.
+ const QPoint rhsWindowBottom = QPoint(window->width() - 1, window->height() - 1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, rhsWindowBottom, 2000);
+ const QPoint rhsWindowTop = QPoint(window->width() - 1, 1);
+ moveSmoothly(window, rhsWindowBottom, rhsWindowTop,
+ qAbs(rhsWindowTop.y() - rhsWindowBottom.y()), QEasingCurve::InCubic, 10);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, rhsWindowTop, 20);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::scrollIndicator()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(6);
+ gifRecorder.setQmlFileName("qtquickcontrols2-scrollindicator.qml");
+
+ gifRecorder.start();
+
+ // Flick in the center of the screen to show that there's a scroll indicator.
+ QQuickWindow *window = gifRecorder.window();
+ const QPoint windowBottom = QPoint(0, window->height() - 1);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowBottom, 100);
+ QTest::mouseMove(window, windowBottom - QPoint(0, 10), 30);
+ QTest::mouseMove(window, windowBottom - QPoint(0, 30), 30);
+ QTest::mouseMove(window, windowBottom - QPoint(0, 60), 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowBottom - QPoint(0, 100), 30);
+
+ // Scroll back down.
+ const QPoint windowTop = QPoint(0, 0);
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowTop, 2000);
+ QTest::mouseMove(window, windowTop + QPoint(0, 10), 30);
+ QTest::mouseMove(window, windowTop + QPoint(0, 30), 30);
+ QTest::mouseMove(window, windowTop + QPoint(0, 60), 30);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowTop + QPoint(0, 100), 30);
+
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::progressBar_data()
+{
+ QTest::addColumn<bool>("indeterminate");
+
+ QTest::newRow("indeterminate:false") << false;
+ QTest::newRow("indeterminate:true") << true;
+}
+
+void tst_Gifs::progressBar()
+{
+ QFETCH(bool, indeterminate);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(4);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-progressbar%1").arg(
+ indeterminate ? QLatin1String("-indeterminate.qml") : QLatin1String(".qml")));
+
+ gifRecorder.start();
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::stackView_data()
+{
+ QTest::addColumn<QString>("name");
+ QTest::addColumn<int>("duration");
+
+ QTest::newRow("push") << "push" << 8;
+ QTest::newRow("pop") << "pop" << 6;
+ QTest::newRow("unwind") << "unwind" << 6;
+ QTest::newRow("replace") << "replace" << 6;
+}
+
+void tst_Gifs::stackView()
+{
+ QFETCH(QString, name);
+ QFETCH(int, duration);
+
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(duration);
+ gifRecorder.setHighQuality(true);
+ gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols2-stackview-%1.qml").arg(name));
+
+ gifRecorder.start();
+ gifRecorder.waitForFinish();
+}
+
+void tst_Gifs::drawer()
+{
+ GifRecorder gifRecorder;
+ gifRecorder.setDataDirPath(dataDirPath);
+ gifRecorder.setOutputDir(outputDir);
+ gifRecorder.setRecordingDuration(4);
+ gifRecorder.setHighQuality(true);
+ gifRecorder.setQmlFileName("qtquickcontrols2-drawer.qml");
+
+ gifRecorder.start();
+
+ QQuickWindow *window = gifRecorder.window();
+ QObject *drawer = window->property("drawer").value<QObject*>();
+ qreal width = drawer->property("width").toReal();
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1), 100);
+ moveSmoothly(window, QPoint(1, 1), QPoint(width, 1), width, QEasingCurve::InOutBack, 1);
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(width, 1), 30);
+
+ QTest::qWait(1000);
+ QMetaObject::invokeMethod(drawer, "close");
+
+ gifRecorder.waitForFinish();
+}
+
QTEST_MAIN(tst_Gifs)
#include "tst_gifs.moc"