diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-20 01:02:53 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-20 01:02:53 +0200 |
commit | f06cbeb00b00e54826a67816663920cb468141a2 (patch) | |
tree | 9d073663750cfaf11ace6488f880be093b40b2bd /tests/auto | |
parent | eef179c9eb2c2d24e67c27742618555267e45e89 (diff) | |
parent | 6734ee9a6ddb6a3870556514a70d904836258559 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I939b8ddc8b24e9c9853a72eb22da317023c7a2c4
Diffstat (limited to 'tests/auto')
8 files changed, 199 insertions, 9 deletions
diff --git a/tests/auto/qml/qquickfolderlistmodel/data/sortdir/Uppercase.txt b/tests/auto/qml/qquickfolderlistmodel/data/sortdir/Uppercase.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/sortdir/Uppercase.txt diff --git a/tests/auto/qml/qquickfolderlistmodel/data/sortdir/lowercase.txt b/tests/auto/qml/qquickfolderlistmodel/data/sortdir/lowercase.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/sortdir/lowercase.txt diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index 77fda3b555..4b2ae45bae 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -73,7 +73,8 @@ private slots: void showDotAndDotDot_data(); void sortReversed(); void introspectQrc(); - + void sortCaseSensitive_data(); + void sortCaseSensitive(); private: void checkNoErrors(const QQmlComponent& component); QQmlEngine engine; @@ -126,7 +127,7 @@ void tst_qquickfolderlistmodel::basicProperties() QSignalSpy folderChangedSpy(flm, SIGNAL(folderChanged())); flm->setProperty("folder", dataDirectoryUrl()); QVERIFY(folderChangedSpy.wait()); - QCOMPARE(flm->property("count").toInt(), 8); + QCOMPARE(flm->property("count").toInt(), 9); QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl()); QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath())); QCOMPARE(flm->property("sortField").toInt(), int(Name)); @@ -166,12 +167,12 @@ void tst_qquickfolderlistmodel::showFiles() QVERIFY(flm != nullptr); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(), 8); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(), 9); // wait for refresh QCOMPARE(flm->property("showFiles").toBool(), true); flm->setProperty("showFiles", false); QCOMPARE(flm->property("showFiles").toBool(), false); - QTRY_COMPARE(flm->property("count").toInt(), 2); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(), 3); // wait for refresh } void tst_qquickfolderlistmodel::resetFiltering() @@ -238,7 +239,7 @@ void tst_qquickfolderlistmodel::refresh() QVERIFY(flm != nullptr); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(),8); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(), 9); // wait for refresh int count = flm->rowCount(); @@ -342,7 +343,7 @@ void tst_qquickfolderlistmodel::showDotAndDotDot() flm->setProperty("rootFolder", rootFolder); flm->setProperty("showDotAndDotDot", showDotAndDotDot); - int count = 9; + int count = 10; if (showDot) count++; if (showDotDot) count++; QTRY_COMPARE(flm->property("count").toInt(), count); // wait for refresh @@ -373,7 +374,7 @@ void tst_qquickfolderlistmodel::sortReversed() QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); QVERIFY(flm != nullptr); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(), 9); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(), 10); // wait for refresh QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("txtdir")); } @@ -387,6 +388,36 @@ void tst_qquickfolderlistmodel::introspectQrc() QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("hello.txt")); } +void tst_qquickfolderlistmodel::sortCaseSensitive_data() +{ + QTest::addColumn<bool>("sortCaseSensitive"); + QTest::addColumn<QStringList>("expectedOrder"); + + const QString upperFile = QLatin1String("Uppercase.txt"); + const QString lowerFile = QLatin1String("lowercase.txt"); + + QTest::newRow("caseSensitive") << true << (QStringList() << upperFile << lowerFile); + QTest::newRow("caseInsensitive") << false << (QStringList() << lowerFile << upperFile); +} + +void tst_qquickfolderlistmodel::sortCaseSensitive() +{ + QFETCH(bool, sortCaseSensitive); + QFETCH(QStringList, expectedOrder); + QQmlComponent component(&engine); + component.setData("import Qt.labs.folderlistmodel 1.0\n" + "FolderListModel { }", QUrl()); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + flm->setProperty("folder", QUrl::fromLocalFile(dataDirectoryUrl().path() + QLatin1String("/sortdir"))); + flm->setProperty("sortCaseSensitive", sortCaseSensitive); + QTRY_COMPARE(flm->property("count").toInt(), 2); // wait for refresh + for (int i = 0; i < 2; ++i) + QTRY_COMPARE(flm->data(flm->index(i),FileNameRole).toString(), expectedOrder.at(i)); +} + QTEST_MAIN(tst_qquickfolderlistmodel) #include "tst_qquickfolderlistmodel.moc" diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp index f8e76fdf5c..da7b610978 100644 --- a/tests/auto/qml/v4misc/tst_v4misc.cpp +++ b/tests/auto/qml/v4misc/tst_v4misc.cpp @@ -114,6 +114,7 @@ void tst_v4misc::parserMisc_data() QTest::newRow("for (var f in ++!binaryMathg) ;") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference."); QTest::newRow("for (va() in obj) {}") << QString("ReferenceError: Invalid left-hand side expression for 'in' expression"); QTest::newRow("[1]=7[A=8=9]") << QString("ReferenceError: left-hand side of assignment operator is not an lvalue"); + QTest::newRow("var asmvalsLen = asmvals{{{{{ngth}}}}};") << QString("SyntaxError: Expected token `;'"); } void tst_v4misc::parserMisc() diff --git a/tests/auto/quick/qquicklistview/data/sectionSnapping.qml b/tests/auto/quick/qquicklistview/data/sectionSnapping.qml new file mode 100644 index 0000000000..2583cc0377 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/sectionSnapping.qml @@ -0,0 +1,49 @@ +import QtQuick 2.0 + +ListView { + width: 400 + height: 400 + preferredHighlightBegin: 100 + preferredHighlightEnd: 100 + highlightRangeMode: ListView.StrictlyEnforceRange + + model: ListModel { + ListElement { section: "1" } + ListElement { section: "1" } + ListElement { section: "1" } + ListElement { section: "2" } + ListElement { section: "2" } + ListElement { section: "2" } + } + + delegate: Rectangle { + width: parent.width + height: 50 + color: index % 2 ? "lightsteelblue" : "steelblue" + Text { + anchors.centerIn: parent + color: "white" + text: model.index + } + } + + section.property: "section" + section.delegate: Rectangle { + width: parent.width + height: 50 + color: "green" + Text { + anchors.centerIn: parent + color: "white" + text: "section" + } + } + + highlight: Rectangle { + y: 100 + z: 100 + width: parent.width + height: 50 + color: "#80FF0000" + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 2574eb9c6c..ae02352293 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -132,6 +132,8 @@ private slots: void sectionPropertyChange(); void sectionDelegateChange(); void sectionsItemInsertion(); + void sectionsSnap_data(); + void sectionsSnap(); void cacheBuffer(); void positionViewAtBeginningEnd(); void positionViewAtIndex(); @@ -2667,6 +2669,62 @@ void tst_QQuickListView::sectionsItemInsertion() } } +void tst_QQuickListView::sectionsSnap_data() +{ + QTest::addColumn<QQuickListView::SnapMode>("snapMode"); + QTest::addColumn<QPoint>("point"); + QTest::addColumn<int>("duration"); + + QTest::newRow("drag") << QQuickListView::NoSnap << QPoint(100, 45) << 500; + QTest::newRow("flick") << QQuickListView::SnapOneItem << QPoint(100, 75) << 50; +} + +void tst_QQuickListView::sectionsSnap() +{ + QFETCH(QQuickListView::SnapMode, snapMode); + QFETCH(QPoint, point); + QFETCH(int, duration); + + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("sectionSnapping.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); + QTRY_VERIFY(listview != nullptr); + listview->setSnapMode(snapMode); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_COMPARE(listview->currentIndex(), 0); + QCOMPARE(listview->contentY(), qreal(-50)); + + // move down + flick(window.data(), QPoint(100, 100), point, duration); + QTRY_VERIFY(!listview->isMovingVertically()); + QCOMPARE(listview->contentY(), qreal(0)); + + flick(window.data(), QPoint(100, 100), point, duration); + QTRY_VERIFY(!listview->isMovingVertically()); + QCOMPARE(listview->contentY(), qreal(50)); + + flick(window.data(), QPoint(100, 100), point, duration); + QTRY_VERIFY(!listview->isMovingVertically()); + QCOMPARE(listview->contentY(), qreal(150)); + + // move back up + flick(window.data(), point, QPoint(100, 100), duration); + QTRY_VERIFY(!listview->isMovingVertically()); + QCOMPARE(listview->contentY(), qreal(50)); + + flick(window.data(), point, QPoint(100, 100), duration); + QTRY_VERIFY(!listview->isMovingVertically()); + QCOMPARE(listview->contentY(), qreal(0)); + + flick(window.data(), point, QPoint(100, 100), duration); + QTRY_VERIFY(!listview->isMovingVertically()); + QCOMPARE(listview->contentY(), qreal(-50)); +} + void tst_QQuickListView::currentIndex_delayedItemCreation() { QFETCH(bool, setCurrentToZero); diff --git a/tests/auto/quick/qquicktableview/testmodel.h b/tests/auto/quick/qquicktableview/testmodel.h index 28ea466b82..50f434019e 100644 --- a/tests/auto/quick/qquicktableview/testmodel.h +++ b/tests/auto/quick/qquicktableview/testmodel.h @@ -68,14 +68,13 @@ public: return { {Qt::DisplayRole, "display"} }; } - Q_INVOKABLE void setModelData(const QPoint &cell, const QSize &span, const QString &prefix) + Q_INVOKABLE void setModelData(const QPoint &cell, const QSize &span, const QString &string) { for (int c = 0; c < span.width(); ++c) { for (int r = 0; r < span.height(); ++r) { const int changedRow = cell.y() + r; const int changedColumn = cell.x() + c; const int serializedIndex = changedRow + (changedColumn * m_rows); - const QString string = prefix + QStringLiteral("%1,%2").arg(changedColumn).arg(changedRow); modelData.insert(serializedIndex, string); } } @@ -129,10 +128,22 @@ public: return true; } + void swapRows(int row1, int row2) + { + layoutAboutToBeChanged(); + Q_ASSERT(modelData.contains(row1)); + Q_ASSERT(modelData.contains(row2)); + const QString tmp = modelData[row1]; + modelData[row1] = modelData[row2]; + modelData[row2] = tmp; + layoutChanged(); + } + void clear() { beginResetModel(); m_rows = 0; m_columns = 0; + modelData.clear(); endResetModel(); } diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 60b938d127..d475ef9c4d 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -141,6 +141,7 @@ private slots: void flickOvershoot(); void checkRowColumnCount(); void modelSignals(); + void checkModelSignalsUpdateLayout(); void dataChangedSignal(); void checkThatPoolIsDrainedWhenReuseIsFalse(); void checkIfDelegatesAreReused_data(); @@ -1466,9 +1467,48 @@ void tst_QQuickTableView::modelSignals() QCOMPARE(tableView->columns(), 10); model.clear(); + model.setColumnCount(1); + WAIT_UNTIL_POLISHED; + QCOMPARE(tableView->rows(), 0); + QCOMPARE(tableView->columns(), 1); +} + +void tst_QQuickTableView::checkModelSignalsUpdateLayout() +{ + // Check that if the model rearranges rows and emit the + // 'layoutChanged' signal, TableView will be updated correctly. + LOAD_TABLEVIEW("plaintableview.qml"); + + TestModel model(0, 1); + tableView->setModel(QVariant::fromValue(&model)); WAIT_UNTIL_POLISHED; + QCOMPARE(tableView->rows(), 0); QCOMPARE(tableView->columns(), 1); + + QString modelRow1Text = QStringLiteral("firstRow"); + QString modelRow2Text = QStringLiteral("secondRow"); + model.insertRow(0); + model.insertRow(0); + model.setModelData(QPoint(0, 0), QSize(1, 1), modelRow1Text); + model.setModelData(QPoint(0, 1), QSize(1, 1), modelRow2Text); + WAIT_UNTIL_POLISHED; + + QCOMPARE(tableView->rows(), 2); + QCOMPARE(tableView->columns(), 1); + + QString delegate1text = tableViewPrivate->loadedTableItem(QPoint(0, 0))->item->property("modelDataBinding").toString(); + QString delegate2text = tableViewPrivate->loadedTableItem(QPoint(0, 1))->item->property("modelDataBinding").toString(); + QCOMPARE(delegate1text, modelRow1Text); + QCOMPARE(delegate2text, modelRow2Text); + + model.swapRows(0, 1); + WAIT_UNTIL_POLISHED; + + delegate1text = tableViewPrivate->loadedTableItem(QPoint(0, 0))->item->property("modelDataBinding").toString(); + delegate2text = tableViewPrivate->loadedTableItem(QPoint(0, 1))->item->property("modelDataBinding").toString(); + QCOMPARE(delegate1text, modelRow2Text); + QCOMPARE(delegate2text, modelRow1Text); } void tst_QQuickTableView::dataChangedSignal() |