diff options
Diffstat (limited to 'tests/auto')
10 files changed, 231 insertions, 44 deletions
diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 16e5170a47..0b8686560c 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -81,6 +81,8 @@ private slots: void setData_emits_both_roles_data(); void setData_emits_both_roles(); + void setData_emits_on_change_only(); + void supportedDragDropActions(); void moveRows_data(); @@ -422,6 +424,24 @@ void tst_QStringListModel::setItemData() QCOMPARE(dataChangedArguments.at(2).value<QVector<int> >(), changeRoles); } +void tst_QStringListModel::setData_emits_on_change_only() +{ + QStringListModel model(QStringList{QStringLiteral("one"), QStringLiteral("two")}); + QSignalSpy dataChangedSpy(&model, &QAbstractItemModel::dataChanged); + QVERIFY(dataChangedSpy.isValid()); + const QModelIndex modelIdx = model.index(0, 0); + const QString newStringData = QStringLiteral("test"); + QVERIFY(model.setData(modelIdx, newStringData)); + QCOMPARE(dataChangedSpy.count(), 1); + const QList<QVariant> spyList = dataChangedSpy.takeFirst(); + QCOMPARE(spyList.at(0).value<QModelIndex>(), modelIdx); + QCOMPARE(spyList.at(1).value<QModelIndex>(), modelIdx); + const QVector<int> expectedRoles{Qt::DisplayRole, Qt::EditRole}; + QCOMPARE(spyList.at(2).value<QVector<int> >(), expectedRoles); + QVERIFY(model.setData(modelIdx, newStringData)); + QVERIFY(dataChangedSpy.isEmpty()); +} + void tst_QStringListModel::supportedDragDropActions() { QStringListModel model; diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index c23ee3b0ba..c02756d76a 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -2169,47 +2169,47 @@ void tst_QRegularExpression::wildcard_data() addRow("*.html", "test.html", 0); addRow("*.html", "test.htm", -1); - addRow("bar*", "foobarbaz", 3); + addRow("*bar*", "foobarbaz", 0); addRow("*", "Qt Rocks!", 0); - addRow(".html", "test.html", 4); - addRow(".h", "test.cpp", -1); - addRow(".???l", "test.html", 4); - addRow("?", "test.html", 0); - addRow("?m", "test.html", 6); - addRow("[*]", "test.html", -1); - addRow("[?]","test.html", -1); - addRow("[?]","test.h?ml", 6); - addRow("[[]","test.h[ml", 6); - addRow("[]]","test.h]ml", 6); - addRow(".h[a-z]ml", "test.html", 4); - addRow(".h[A-Z]ml", "test.html", -1); - addRow(".h[A-Z]ml", "test.hTml", 4); - addRow(".h[!A-Z]ml", "test.hTml", -1); - addRow(".h[!A-Z]ml", "test.html", 4); - addRow(".h[!T]ml", "test.hTml", -1); - addRow(".h[!T]ml", "test.html", 4); - addRow(".h[!T]m[!L]", "test.htmL", -1); - addRow(".h[!T]m[!L]", "test.html", 4); - addRow(".h[][!]", "test.h]ml", 4); - addRow(".h[][!]", "test.h[ml", 4); - addRow(".h[][!]", "test.h!ml", 4); - - addRow("foo/*/bar", "Qt/foo/baz/bar", 3); - addRow("foo/(*)/bar", "Qt/foo/baz/bar", -1); - addRow("foo/(*)/bar", "Qt/foo/(baz)/bar", 3); - addRow("foo/?/bar", "Qt/foo/Q/bar", 3); - addRow("foo/?/bar", "Qt/foo/Qt/bar", -1); - addRow("foo/(?)/bar", "Qt/foo/Q/bar", -1); - addRow("foo/(?)/bar", "Qt/foo/(Q)/bar", 3); + addRow("*.html", "test.html", 0); + addRow("*.h", "test.cpp", -1); + addRow("*.???l", "test.html", 0); + addRow("*?", "test.html", 0); + addRow("*?ml", "test.html", 0); + addRow("*[*]", "test.html", -1); + addRow("*[?]","test.html", -1); + addRow("*[?]ml","test.h?ml", 0); + addRow("*[[]ml","test.h[ml", 0); + addRow("*[]]ml","test.h]ml", 0); + addRow("*.h[a-z]ml", "test.html", 0); + addRow("*.h[A-Z]ml", "test.html", -1); + addRow("*.h[A-Z]ml", "test.hTml", 0); + addRow("*.h[!A-Z]ml", "test.hTml", -1); + addRow("*.h[!A-Z]ml", "test.html", 0); + addRow("*.h[!T]ml", "test.hTml", -1); + addRow("*.h[!T]ml", "test.html", 0); + addRow("*.h[!T]m[!L]", "test.htmL", -1); + addRow("*.h[!T]m[!L]", "test.html", 0); + addRow("*.h[][!]ml", "test.h]ml", 0); + addRow("*.h[][!]ml", "test.h[ml", 0); + addRow("*.h[][!]ml", "test.h!ml", 0); + + addRow("foo/*/bar", "foo/baz/bar", 0); + addRow("foo/(*)/bar", "foo/baz/bar", -1); + addRow("foo/(*)/bar", "foo/(baz)/bar", 0); + addRow("foo/?/bar", "foo/Q/bar", 0); + addRow("foo/?/bar", "foo/Qt/bar", -1); + addRow("foo/(?)/bar", "foo/Q/bar", -1); + addRow("foo/(?)/bar", "foo/(Q)/bar", 0); #ifdef Q_OS_WIN - addRow("foo\\*\\bar", "Qt\\foo\\baz\\bar", 3); - addRow("foo\\(*)\\bar", "Qt\\foo\\baz\\bar", -1); - addRow("foo\\(*)\\bar", "Qt\\foo\\(baz)\\bar", 3); - addRow("foo\\?\\bar", "Qt\\foo\\Q\\bar", 3); - addRow("foo\\?\\bar", "Qt\\foo\\Qt\\bar", -1); - addRow("foo\\(?)\\bar", "Qt\\foo\\Q\\bar", -1); - addRow("foo\\(?)\\bar", "Qt\\foo\\(Q)\\bar", 3); + addRow("foo\\*\\bar", "foo\\baz\\bar", 0); + addRow("foo\\(*)\\bar", "foo\\baz\\bar", -1); + addRow("foo\\(*)\\bar", "foo\\(baz)\\bar", 0); + addRow("foo\\?\\bar", "foo\\Q\\bar", 0); + addRow("foo\\?\\bar", "foo\\Qt\\bar", -1); + addRow("foo\\(?)\\bar", "foo\\Q\\bar", -1); + addRow("foo\\(?)\\bar", "foo\\(Q)\\bar", 0); #endif } diff --git a/tests/auto/gui/text/qfontmetrics/testfont.qrc b/tests/auto/gui/text/qfontmetrics/testfont.qrc index bc0c0b0959..30b4a3f82e 100644 --- a/tests/auto/gui/text/qfontmetrics/testfont.qrc +++ b/tests/auto/gui/text/qfontmetrics/testfont.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/fonts"> <file>ucs4font.ttf</file> + <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file> </qresource> </RCC> diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 9e705b4a00..a0e8525268 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -58,6 +58,7 @@ private slots: void lineWidth(); void mnemonicTextWidth(); void leadingBelowLine(); + void elidedMetrics(); }; void tst_QFontMetrics::same() @@ -331,5 +332,31 @@ void tst_QFontMetrics::leadingBelowLine() QCOMPARE(line.base(), line.ascent); } +void tst_QFontMetrics::elidedMetrics() +{ + QString testFont = QFINDTESTDATA("fonts/testfont.ttf"); + QVERIFY(!testFont.isEmpty()); + + int id = QFontDatabase::addApplicationFont(testFont); + QVERIFY(id >= 0); + + QFont font(QFontDatabase::applicationFontFamilies(id).at(0)); + font.setPixelSize(12.0); + + QFontMetricsF metrics(font); + QString s = QStringLiteral("VeryLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongText"); + + QRectF boundingRect = metrics.boundingRect(s); + + QString elided = metrics.elidedText(s, Qt::ElideRight, boundingRect.width() / 2.0); + + QRectF elidedBoundingRect = metrics.boundingRect(elided); + + QCOMPARE(boundingRect.height(), elidedBoundingRect.height()); + QCOMPARE(boundingRect.y(), elidedBoundingRect.y()); + + QFontDatabase::removeApplicationFont(id); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" diff --git a/tests/auto/gui/text/qglyphrun/BLACKLIST b/tests/auto/gui/text/qglyphrun/BLACKLIST index 57f32c683d..d8dbdabb4b 100644 --- a/tests/auto/gui/text/qglyphrun/BLACKLIST +++ b/tests/auto/gui/text/qglyphrun/BLACKLIST @@ -1,3 +1,4 @@ [mixedScripts] ubuntu-18.04 b2qt +windows diff --git a/tests/auto/gui/text/qrawfont/BLACKLIST b/tests/auto/gui/text/qrawfont/BLACKLIST new file mode 100644 index 0000000000..c076f11635 --- /dev/null +++ b/tests/auto/gui/text/qrawfont/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-72836 +[unsupportedWritingSystem] +windows diff --git a/tests/auto/tools/moc/cxx11-enums.h b/tests/auto/tools/moc/cxx11-enums.h index 93ab16c157..cc14c0acda 100644 --- a/tests/auto/tools/moc/cxx11-enums.h +++ b/tests/auto/tools/moc/cxx11-enums.h @@ -40,13 +40,22 @@ public: enum class TypedEnumClass : char { C0, C1, C2, C3 }; enum NormalEnum { D2 = 2, D3, D0 =0 , D1 }; enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8}; + + enum struct EnumStruct { G0, G1, G2, G3 }; + enum struct TypedEnumStruct : char { H0, H1, H2, H3 }; + enum struct StructFlag { I0 = 1, I1 = 2, I2 = 4, I3 = 8}; + Q_DECLARE_FLAGS(ClassFlags, ClassFlag) + Q_DECLARE_FLAGS(StructFlags, StructFlag) Q_ENUM(EnumClass) Q_ENUM(TypedEnum) Q_ENUM(TypedEnumClass) Q_ENUM(NormalEnum) + Q_ENUM(EnumStruct) + Q_ENUM(TypedEnumStruct) Q_FLAG(ClassFlags) + Q_FLAG(StructFlags) }; // Also test the Q_ENUMS macro diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index f1888aebab..74ddfd5620 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -2267,6 +2267,9 @@ void tst_Moc::cxx11Enums_data() QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false; QTest::newRow("ClassFlags") << meta1 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true; QTest::newRow("ClassFlags 2") << meta2 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true; + QTest::newRow("EnumStruct") << meta1 << QByteArray("EnumStruct") << QByteArray("EnumStruct") << 'G' << true; + QTest::newRow("TypedEnumStruct") << meta1 << QByteArray("TypedEnumStruct") << QByteArray("TypedEnumStruct") << 'H' << true; + QTest::newRow("StructFlags") << meta1 << QByteArray("StructFlags") << QByteArray("StructFlag") << 'I' << true; } void tst_Moc::cxx11Enums() diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 3b31a74adf..eeda17074b 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -110,6 +110,10 @@ private slots: void setInformativeText(); void iconPixmap(); + // QTBUG-44131 + void acceptedRejectedSignals(); + void acceptedRejectedSignals_data(); + void cleanup(); }; @@ -717,5 +721,96 @@ void tst_QMessageBox::iconPixmap() QCOMPARE(messageBox.iconPixmap(), QPixmap()); } +using SignalSignature = void(QDialog::*)(); +Q_DECLARE_METATYPE(SignalSignature); +Q_DECLARE_METATYPE(QMessageBox::ButtonRole) + +using ButtonsCreator = std::function<QVector<QPushButton*>(QMessageBox &)>; +Q_DECLARE_METATYPE(ButtonsCreator); + +using RoleSet = QSet<QMessageBox::ButtonRole>; +Q_DECLARE_METATYPE(RoleSet); + +void tst_QMessageBox::acceptedRejectedSignals() +{ + QMessageBox messageBox(QMessageBox::Information, "Test window", "Test text"); + + QFETCH(ButtonsCreator, buttonsCreator); + QVERIFY(buttonsCreator); + + const auto buttons = buttonsCreator(messageBox); + QVERIFY(!buttons.isEmpty()); + + QFETCH(RoleSet, roles); + QFETCH(SignalSignature, signalSignature); + for (auto button: buttons) { + QVERIFY(button); + + messageBox.show(); + QVERIFY(QTest::qWaitForWindowExposed(&messageBox)); + + QSignalSpy spy(&messageBox, signalSignature); + QVERIFY(spy.isValid()); + button->click(); + + if (roles.contains(messageBox.buttonRole(button))) + QCOMPARE(spy.count(), 1); + else + QVERIFY(spy.isEmpty()); + } +} + +static void addAcceptedRow(const char *title, ButtonsCreator bc) +{ + QTest::newRow(title) << (RoleSet() << QMessageBox::AcceptRole << QMessageBox::YesRole) + << &QDialog::accepted << bc; +} + +static void addRejectedRow(const char *title, ButtonsCreator bc) +{ + QTest::newRow(title) << (RoleSet() << QMessageBox::RejectRole << QMessageBox::NoRole) + << &QDialog::rejected << bc; +} + +static void addCustomButtonsData() +{ + ButtonsCreator buttonsCreator = [](QMessageBox &messageBox) { + QVector<QPushButton*> buttons(QMessageBox::NRoles); + for (int i = QMessageBox::AcceptRole; i < QMessageBox::NRoles; ++i) { + buttons[i] = messageBox.addButton( + QString("Button role: %1").arg(i), QMessageBox::ButtonRole(i)); + } + + return buttons; + }; + + addAcceptedRow("Accepted_CustomButtons", buttonsCreator); + addRejectedRow("Rejected_CustomButtons", buttonsCreator); +} + +static void addStandardButtonsData() +{ + ButtonsCreator buttonsCreator = [](QMessageBox &messageBox) { + QVector<QPushButton*> buttons; + for (int i = QMessageBox::FirstButton; i <= QMessageBox::LastButton; i <<= 1) + buttons << messageBox.addButton(QMessageBox::StandardButton(i)); + + return buttons; + }; + + addAcceptedRow("Accepted_StandardButtons", buttonsCreator); + addRejectedRow("Rejected_StandardButtons", buttonsCreator); +} + +void tst_QMessageBox::acceptedRejectedSignals_data() +{ + QTest::addColumn<RoleSet>("roles"); + QTest::addColumn<SignalSignature>("signalSignature"); + QTest::addColumn<ButtonsCreator>("buttonsCreator"); + + addStandardButtonsData(); + addCustomButtonsData(); +} + QTEST_MAIN(tst_QMessageBox) #include "tst_qmessagebox.moc" diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 228d03350a..e8ee735915 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -1264,19 +1264,47 @@ void tst_QTableView::moveCursorStrikesBack_data() for (int i = 0; i < 7; ++i) fullList << i; - QTest::newRow("All disabled, wrap forward. Timeout => FAIL") << -1 << -1 + QTest::newRow("All disabled, wrap forward. => invalid index") << -1 << -1 << fullList << fullList << QRect() << 1 << 0 << (IntList() << int(QtTestTableView::MoveNext)) - << 1 << 0; + << -1 << -1; - QTest::newRow("All disabled, wrap backwards. Timeout => FAIL") << -1 << -1 + QTest::newRow("All disabled, wrap backwards. => invalid index") << -1 << -1 << fullList << fullList << QRect() << 1 << 0 << (IntList() << int(QtTestTableView::MovePrevious)) + << -1 << -1; + + QTest::newRow("Last column disabled, MoveEnd. QTBUG-72400") << -1 << -1 + << IntList() + << (IntList() << 6) + << QRect() + << 0 << 0 << (IntList() << int(QtTestTableView::MoveEnd)) + << 0 << 5; + + QTest::newRow("First column disabled, MoveHome. QTBUG-72400") << -1 << -1 + << IntList() + << (IntList() << 0) + << QRect() + << 0 << 6 << (IntList() << int(QtTestTableView::MoveHome)) + << 0 << 1; + + QTest::newRow("First row disabled, MovePageUp. QTBUG-72400") << -1 << -1 + << (IntList() << 0) + << IntList() + << QRect() + << 2 << 0 << (IntList() << int(QtTestTableView::MovePageUp)) << 1 << 0; + + QTest::newRow("Last row disabled, MovePageDown. QTBUG-72400") << -1 << -1 + << (IntList() << 6) + << IntList() + << QRect() + << 4 << 0 << (IntList() << int(QtTestTableView::MovePageDown)) + << 5 << 0; } void tst_QTableView::moveCursorStrikesBack() @@ -1302,6 +1330,9 @@ void tst_QTableView::moveCursorStrikesBack() if (span.height() && span.width()) view.setSpan(span.top(), span.left(), span.height(), span.width()); view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + // resize to make sure there are scrollbars + view.resize(view.columnWidth(0) * 7, view.rowHeight(0) * 7); QModelIndex index = model.index(startRow, startColumn); view.setCurrentIndex(index); @@ -1320,9 +1351,6 @@ void tst_QTableView::moveCursorStrikesBack() newColumn = newIndex.column(); } - // expected fails, task 119433 - if(newRow == -1) - return; QCOMPARE(newRow, expectedRow); QCOMPARE(newColumn, expectedColumn); } |