diff options
Diffstat (limited to 'tests/auto/widgets/widgets')
5 files changed, 135 insertions, 10 deletions
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 6cc19051d2..67b79e3faf 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -1689,14 +1689,16 @@ void tst_QMdiArea::tileSubWindows() workspace.setActiveSubWindow(0); QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect()); - // Make sure the active window is placed in top left corner regardless + // Make sure the active window does not move position after a tile regardless // of whether we have any windows with staysOnTopHint or not. + workspace.tileSubWindows(); windows.at(3)->setWindowFlags(windows.at(3)->windowFlags() | Qt::WindowStaysOnTopHint); QMdiSubWindow *activeSubWindow = windows.at(6); workspace.setActiveSubWindow(activeSubWindow); QCOMPARE(workspace.activeSubWindow(), activeSubWindow); + QPoint pos = activeSubWindow->geometry().topLeft(); workspace.tileSubWindows(); - QCOMPARE(activeSubWindow->geometry().topLeft(), QPoint(0, 0)); + QCOMPARE(activeSubWindow->geometry().topLeft(), pos); // Verify that we try to resize the area such that all sub-windows are visible. // It's important that tiled windows are NOT overlapping. @@ -1713,6 +1715,8 @@ void tst_QMdiArea::tileSubWindows() // Prevent scrollbars from messing up the expected viewport calculation below workspace.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); workspace.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QCOMPARE(workspace.horizontalScrollBarPolicy(), Qt::ScrollBarAlwaysOff); + QCOMPARE(workspace.verticalScrollBarPolicy(), Qt::ScrollBarAlwaysOff); workspace.tileSubWindows(); // The sub-windows are now tiled like this: @@ -1731,9 +1735,11 @@ void tst_QMdiArea::tileSubWindows() const QSize expectedViewportSize(3 * minSize.width() + spacing, 3 * minSize.height() + spacing); QTRY_COMPARE(workspace.viewport()->rect().size(), expectedViewportSize); - // Restore original scrollbar behavior for test below + // Enable scroll bar for test below (default property for QMdiArea is Qt::ScrollBarAlwaysOff) workspace.setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); workspace.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + QCOMPARE(workspace.horizontalScrollBarPolicy(), Qt::ScrollBarAsNeeded); + QCOMPARE(workspace.verticalScrollBarPolicy(), Qt::ScrollBarAsNeeded); // Not enough space for all sub-windows to be visible -> provide scroll bars. workspace.resize(160, 150); @@ -1754,13 +1760,16 @@ void tst_QMdiArea::tileSubWindows() QCOMPARE(vBar->value(), 0); QCOMPARE(vBar->minimum(), 0); + // Tile windows with scroll bars enabled. workspace.tileSubWindows(); QVERIFY(QTest::qWaitForWindowExposed(&workspace)); qApp->processEvents(); - QTRY_VERIFY(workspace.size() != QSize(150, 150)); - QTRY_VERIFY(!vBar->isVisible()); - QTRY_VERIFY(!hBar->isVisible()); + // Workspace should not have changed size after tile. + QTRY_VERIFY(workspace.size() == QSize(160, 150)); + // Scroll bars should be visible. + QTRY_VERIFY(vBar->isVisible()); + QTRY_VERIFY(hBar->isVisible()); } void tst_QMdiArea::cascadeAndTileSubWindows() @@ -2180,7 +2189,7 @@ void tst_QMdiArea::setActivationOrder_data() list << 2 << 1 << 0 << 1 << 2 << 3 << 4; list2 << 0 << 1 << 2 << 3 << 4; - list3 << 1 << 4 << 3 << 1 << 2 << 0; + list3 << 4 << 3 << 2 << 4 << 1 << 0; // Most recently created window is in top-left position QTest::newRow("CreationOrder") << QMdiArea::CreationOrder << 5 << 3 << 1 << list << list2 << list3; list = QList<int>(); @@ -2188,7 +2197,7 @@ void tst_QMdiArea::setActivationOrder_data() list2 = QList<int>(); list2 << 0 << 2 << 4 << 1 << 3; list3 = QList<int>(); - list3 << 1 << 3 << 4 << 1 << 2 << 0; + list3 << 3 << 1 << 4 << 3 << 2 << 0; // Window with "stays-on-top" flag set will be in the top-left position QTest::newRow("StackingOrder") << QMdiArea::StackingOrder << 5 << 3 << 1 << list << list2 << list3; list = QList<int>(); diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index a88fd8d19c..634e258250 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1143,8 +1143,16 @@ void tst_QMenu::QTBUG7411_submenus_activate() QTRY_VERIFY(sub1.isVisible()); } +static bool isPlatformWayland() +{ + return !QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive); +} + void tst_QMenu::QTBUG30595_rtl_submenu() { + if (isPlatformWayland()) + QSKIP("Creating xdg_popups on Wayland requires real input events. Positions would be off."); + QMenu menu("Test Menu"); menu.setLayoutDirection(Qt::RightToLeft); QMenu sub("&sub"); @@ -1179,6 +1187,9 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() #ifndef Q_OS_MACOS void tst_QMenu::click_while_dismissing_submenu() { + if (isPlatformWayland()) + QSKIP("Wayland: Creating (grabbing) popups requires real mouse events."); + QMenu menu("Test Menu"); QAction *action = menu.addAction("action"); QMenu sub("&sub"); diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index cfa2ddc4cc..be19cbc9d1 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -140,6 +140,11 @@ private slots: void findBackwardWithRegExp(); void findWithRegExpReturnsFalseIfNoMoreResults(); #endif +#if QT_CONFIG(regularexpression) + void findWithRegularExpression(); + void findBackwardWithRegularExpression(); + void findWithRegularExpressionReturnsFalseIfNoMoreResults(); +#endif void layoutAfterMultiLineRemove(); void undoCommandRemovesAndReinsertsBlock(); void taskQTBUG_43562_lineCountCrash(); @@ -147,6 +152,9 @@ private slots: void contextMenu(); #endif void inputMethodCursorRect(); +#if QT_CONFIG(scrollbar) + void updateAfterChangeCenterOnScroll(); +#endif private: void createSelection(); @@ -1579,6 +1587,45 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() } #endif +#if QT_CONFIG(regularexpression) +void tst_QPlainTextEdit::findWithRegularExpression() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QRegularExpression rx("\\w{2}xt"); + + bool found = ed->find(rx); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} + +void tst_QPlainTextEdit::findBackwardWithRegularExpression() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QTextCursor cursor = ed->textCursor(); + cursor.movePosition(QTextCursor::End); + ed->setTextCursor(cursor); + QRegularExpression rx("a\\w*t"); + + bool found = ed->find(rx, QTextDocument::FindBackward); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); +} + +void tst_QPlainTextEdit::findWithRegularExpressionReturnsFalseIfNoMoreResults() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QRegularExpression rx("t.xt"); + ed->find(rx); + + bool found = ed->find(rx); + + QVERIFY(!found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} +#endif + void tst_QPlainTextEdit::layoutAfterMultiLineRemove() { ed->setVisible(true); // The widget must be visible to reproduce this bug. @@ -1727,5 +1774,20 @@ void tst_QPlainTextEdit::inputMethodCursorRect() QCOMPARE(cursorRectV.toRect(), cursorRect.toRect()); } +#if QT_CONFIG(scrollbar) +// QTBUG-64730: Verify that the scrollbar is updated after center on scroll was set +void tst_QPlainTextEdit::updateAfterChangeCenterOnScroll() +{ + ed->setPlainText("Line1\nLine2Line3\nLine3"); + ed->show(); + ed->setCenterOnScroll(true); + const int maxWithCenterOnScroll = ed->verticalScrollBar()->maximum(); + ed->setCenterOnScroll(false); + const int maxWithoutCenterOnScroll = ed->verticalScrollBar()->maximum(); + QVERIFY(maxWithCenterOnScroll > maxWithoutCenterOnScroll); +} + +#endif + QTEST_MAIN(tst_QPlainTextEdit) #include "tst_qplaintextedit.moc" diff --git a/tests/auto/widgets/widgets/qsplitter/BLACKLIST b/tests/auto/widgets/widgets/qsplitter/BLACKLIST deleted file mode 100644 index 1352805cd7..0000000000 --- a/tests/auto/widgets/widgets/qsplitter/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[replaceWidget:visible, not collapsed] -xcb diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 6a2ae4951b..5f5cd78215 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -199,6 +199,12 @@ private slots: void findWithRegExpReturnsFalseIfNoMoreResults(); #endif +#if QT_CONFIG(regularexpression) + void findWithRegularExpression(); + void findBackwardWithRegularExpression(); + void findWithRegularExpressionReturnsFalseIfNoMoreResults(); +#endif + #if QT_CONFIG(wheelevent) void wheelEvent(); #endif @@ -2572,6 +2578,45 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() } #endif +#if QT_CONFIG(regularexpression) +void tst_QTextEdit::findWithRegularExpression() +{ + ed->setHtml(QStringLiteral("arbitrary te<span style=\"color:#ff0000\">xt</span>")); + QRegularExpression rx("\\w{2}xt"); + + bool found = ed->find(rx); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} + +void tst_QTextEdit::findBackwardWithRegularExpression() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QTextCursor cursor = ed->textCursor(); + cursor.movePosition(QTextCursor::End); + ed->setTextCursor(cursor); + QRegularExpression rx("a\\w*t"); + + bool found = ed->find(rx, QTextDocument::FindBackward); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); +} + +void tst_QTextEdit::findWithRegularExpressionReturnsFalseIfNoMoreResults() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QRegularExpression rx("t.xt"); + ed->find(rx); + + bool found = ed->find(rx); + + QVERIFY(!found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} +#endif + #if QT_CONFIG(wheelevent) class TextEdit : public QTextEdit |