diff options
Diffstat (limited to 'tests/auto/widgets')
195 files changed, 3188 insertions, 5463 deletions
diff --git a/tests/auto/widgets/CMakeLists.txt b/tests/auto/widgets/CMakeLists.txt new file mode 100644 index 0000000000..5870f28db0 --- /dev/null +++ b/tests/auto/widgets/CMakeLists.txt @@ -0,0 +1,10 @@ +# Generated from widgets.pro. + +add_subdirectory(dialogs) +add_subdirectory(effects) +add_subdirectory(graphicsview) +add_subdirectory(itemviews) +add_subdirectory(kernel) +add_subdirectory(styles) +add_subdirectory(util) +add_subdirectory(widgets) diff --git a/tests/auto/widgets/dialogs/CMakeLists.txt b/tests/auto/widgets/dialogs/CMakeLists.txt new file mode 100644 index 0000000000..508093e7ad --- /dev/null +++ b/tests/auto/widgets/dialogs/CMakeLists.txt @@ -0,0 +1,19 @@ +add_subdirectory(qcolordialog) +add_subdirectory(qdialog) +add_subdirectory(qerrormessage) +if (NOT WINRT) + add_subdirectory(qfiledialog) + add_subdirectory(qfiledialog2) + add_subdirectory(qmessagebox) +endif() +if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR NOT WIN32) + add_subdirectory(qfilesystemmodel) +endif() +add_subdirectory(qfontdialog) +add_subdirectory(qinputdialog) +add_subdirectory(qprogressdialog) +if (QT_FEATURE_private_tests) + add_subdirectory(qsidebar) +endif() +add_subdirectory(qwizard) + diff --git a/tests/auto/widgets/dialogs/qcolordialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qcolordialog/CMakeLists.txt new file mode 100644 index 0000000000..81ffdeff90 --- /dev/null +++ b/tests/auto/widgets/dialogs/qcolordialog/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qcolordialog.pro. + +##################################################################### +## tst_qcolordialog Test: +##################################################################### + +add_qt_test(tst_qcolordialog + SOURCES + tst_qcolordialog.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/dialogs/qdialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qdialog/CMakeLists.txt new file mode 100644 index 0000000000..2c003f6fb6 --- /dev/null +++ b/tests/auto/widgets/dialogs/qdialog/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qdialog.pro. + +##################################################################### +## tst_qdialog Test: +##################################################################### + +add_qt_test(tst_qdialog + SOURCES + tst_qdialog.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 10a3746e36..94915d0e40 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -52,9 +52,6 @@ class DummyDialog : public QDialog { public: DummyDialog(): QDialog() {} -#if QT_DEPRECATED_SINCE(5, 13) - using QDialog::showExtension; -#endif }; class tst_QDialog : public QObject @@ -66,10 +63,6 @@ public: private slots: void cleanup(); void getSetCheck(); -#if QT_DEPRECATED_SINCE(5, 13) - void showExtension_data(); - void showExtension(); -#endif void defaultButtons(); void showMaximized(); void showMinimized(); @@ -80,9 +73,6 @@ private slots: void deleteInExec(); #if QT_CONFIG(sizegrip) void showSizeGrip(); -#if QT_DEPRECATED_SINCE(5, 13) - void showSizeGrip_deprecated(); -#endif #endif void setVisible(); void reject(); @@ -96,17 +86,6 @@ private slots: void tst_QDialog::getSetCheck() { QDialog obj1; -#if QT_DEPRECATED_SINCE(5, 13) - // QWidget* QDialog::extension() - // void QDialog::setExtension(QWidget*) - QWidget *var1 = new QWidget; - obj1.setExtension(var1); - QCOMPARE(var1, obj1.extension()); - obj1.setExtension((QWidget *)0); - QCOMPARE((QWidget *)0, obj1.extension()); - // No delete var1, since setExtension takes ownership -#endif - // int QDialog::result() // void QDialog::setResult(int) obj1.setResult(0); @@ -155,59 +134,6 @@ void tst_QDialog::cleanup() QVERIFY(QApplication::topLevelWidgets().isEmpty()); } -#if QT_DEPRECATED_SINCE(5, 13) -void tst_QDialog::showExtension_data() -{ - QTest::addColumn<QSize>("dlgSize"); - QTest::addColumn<QSize>("extSize"); - QTest::addColumn<bool>("horizontal"); - QTest::addColumn<QSize>("result"); - - //next we fill it with data - QTest::newRow( "data0" ) << QSize(200,100) << QSize(50,50) << false << QSize(200,150); - QTest::newRow( "data1" ) << QSize(200,100) << QSize(220,50) << false << QSize(220,150); - QTest::newRow( "data2" ) << QSize(200,100) << QSize(50,50) << true << QSize(250,100); - QTest::newRow( "data3" ) << QSize(200,100) << QSize(50,120) << true << QSize(250,120); -} - -void tst_QDialog::showExtension() -{ - QFETCH( QSize, dlgSize ); - QFETCH( QSize, extSize ); - QFETCH( bool, horizontal ); - - DummyDialog testWidget; - testWidget.resize(200, 200); - testWidget.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(':') - + QLatin1String(QTest::currentDataTag())); - testWidget.show(); - QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); - - testWidget.setFixedSize( dlgSize ); - QWidget *ext = new QWidget( &testWidget ); - ext->setFixedSize( extSize ); - testWidget.setExtension( ext ); - testWidget.setOrientation( horizontal ? Qt::Horizontal : Qt::Vertical ); - - QCOMPARE( testWidget.size(), dlgSize ); - QPoint oldPosition = testWidget.pos(); - - // show - testWidget.showExtension( true ); -// while ( testWidget->size() == dlgSize ) -// qApp->processEvents(); - - QTEST( testWidget.size(), "result" ); - - QCOMPARE(testWidget.pos(), oldPosition); - - // hide extension. back to old size ? - testWidget.showExtension( false ); - QCOMPARE( testWidget.size(), dlgSize ); - - testWidget.setExtension( 0 ); -} -#endif void tst_QDialog::defaultButtons() { @@ -434,7 +360,6 @@ void tst_QDialog::deleteInExec() #if QT_CONFIG(sizegrip) -// From Task 124269 void tst_QDialog::showSizeGrip() { QDialog dialog(nullptr); @@ -461,62 +386,6 @@ void tst_QDialog::showSizeGrip() QVERIFY(!sizeGrip->isVisible()); } -#if QT_DEPRECATED_SINCE(5, 13) -void tst_QDialog::showSizeGrip_deprecated() -{ - QDialog dialog(0); - dialog.show(); - QWidget *ext = new QWidget(&dialog); - QVERIFY(!dialog.extension()); - QVERIFY(!dialog.isSizeGripEnabled()); - - dialog.setSizeGripEnabled(true); - QPointer<QSizeGrip> sizeGrip = dialog.findChild<QSizeGrip *>(); - QVERIFY(sizeGrip); - QVERIFY(sizeGrip->isVisible()); - QVERIFY(dialog.isSizeGripEnabled()); - - dialog.setExtension(ext); - QVERIFY(dialog.extension() && !dialog.extension()->isVisible()); - QVERIFY(dialog.isSizeGripEnabled()); - - // normal show/hide sequence - dialog.showExtension(true); - QVERIFY(dialog.extension() && dialog.extension()->isVisible()); - QVERIFY(!dialog.isSizeGripEnabled()); - QVERIFY(!sizeGrip); - - dialog.showExtension(false); - QVERIFY(dialog.extension() && !dialog.extension()->isVisible()); - QVERIFY(dialog.isSizeGripEnabled()); - sizeGrip = dialog.findChild<QSizeGrip *>(); - QVERIFY(sizeGrip); - QVERIFY(sizeGrip->isVisible()); - - // show/hide sequence with interleaved size grip update - dialog.showExtension(true); - QVERIFY(dialog.extension() && dialog.extension()->isVisible()); - QVERIFY(!dialog.isSizeGripEnabled()); - QVERIFY(!sizeGrip); - - dialog.setSizeGripEnabled(false); - QVERIFY(!dialog.isSizeGripEnabled()); - - dialog.showExtension(false); - QVERIFY(dialog.extension() && !dialog.extension()->isVisible()); - QVERIFY(!dialog.isSizeGripEnabled()); - - dialog.setSizeGripEnabled(true); - sizeGrip = dialog.findChild<QSizeGrip *>(); - QVERIFY(sizeGrip); - QVERIFY(sizeGrip->isVisible()); - sizeGrip->hide(); - dialog.hide(); - dialog.show(); - QVERIFY(!sizeGrip->isVisible()); -} -#endif // QT_DEPRECATED_SINCE(5, 13) - #endif // QT_CONFIG(sizegrip) void tst_QDialog::setVisible() diff --git a/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt b/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt new file mode 100644 index 0000000000..9463020c66 --- /dev/null +++ b/tests/auto/widgets/dialogs/qerrormessage/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qerrormessage.pro. + +##################################################################### +## tst_qerrormessage Test: +##################################################################### + +add_qt_test(tst_qerrormessage + SOURCES + tst_qerrormessage.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +#### Keys ignored in scope 1:.:.:qerrormessage.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/auto/widgets/dialogs/qfiledialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qfiledialog/CMakeLists.txt new file mode 100644 index 0000000000..7b6d004776 --- /dev/null +++ b/tests/auto/widgets/dialogs/qfiledialog/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qfiledialog.pro. + +##################################################################### +## tst_qfiledialog Test: +##################################################################### + +add_qt_test(tst_qfiledialog + SOURCES + tst_qfiledialog.cpp + DEFINES + SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\" + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index afb24bc528..9f09c7cfd1 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -801,9 +801,6 @@ void tst_QFiledialog::isReadOnly() QAction* renameAction = fd.findChild<QAction*>("qt_rename_action"); QAction* deleteAction = fd.findChild<QAction*>("qt_delete_action"); -#if QT_DEPRECATED_SINCE(5, 13) - QCOMPARE(fd.isReadOnly(), false); -#endif QCOMPARE(fd.testOption(QFileDialog::ReadOnly), false); // This is dependent upon the file/dir, find cross platform way to test diff --git a/tests/auto/widgets/dialogs/qfiledialog2/CMakeLists.txt b/tests/auto/widgets/dialogs/qfiledialog2/CMakeLists.txt new file mode 100644 index 0000000000..2fb610a784 --- /dev/null +++ b/tests/auto/widgets/dialogs/qfiledialog2/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qfiledialog2.pro. + +##################################################################### +## tst_qfiledialog2 Test: +##################################################################### + +add_qt_test(tst_qfiledialog2 + SOURCES + tst_qfiledialog2.cpp + DEFINES + SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\" + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt b/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt new file mode 100644 index 0000000000..346e2a7d5a --- /dev/null +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt @@ -0,0 +1,27 @@ +# Generated from qfilesystemmodel.pro. + +##################################################################### +## tst_qfilesystemmodel Test: +##################################################################### + +add_qt_test(tst_qfilesystemmodel + SOURCES + ../../../../shared/emulationdetector.h + tst_qfilesystemmodel.cpp + INCLUDE_DIRECTORIES + ../../../../shared + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +#### Keys ignored in scope 2:.:.:qfilesystemmodel.pro:WIN32: +# testcase.timeout = "900" + +#### Keys ignored in scope 3:.:.:qfilesystemmodel.pro:MACOS: +# testcase.timeout = "900" diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 2c0b3f2bcb..63bf103725 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1071,7 +1071,7 @@ void tst_QFileSystemModel::roleNames() QVERIFY(roles.contains(role)); QFETCH(QByteArray, roleName); - QCOMPARE(roles.values(role).count(), 1); + QCOMPARE(roles.contains(role), true); QCOMPARE(roles.value(role), roleName); } diff --git a/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt new file mode 100644 index 0000000000..af858c8946 --- /dev/null +++ b/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt @@ -0,0 +1,39 @@ +# Generated from qfontdialog.pro. + +##################################################################### +## tst_qfontdialog Test: +##################################################################### + +add_qt_test(tst_qfontdialog + SOURCES + tst_qfontdialog.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +# Resources: +set_source_files_properties("../../../shared/resources/test.ttf" + PROPERTIES QT_RESOURCE_ALIAS "test.ttf" +) +set_source_files_properties("../../../shared/resources/testfont.ttf" + PROPERTIES QT_RESOURCE_ALIAS "testfont.ttf" +) +set(testfonts_resource_files + "../../../shared/resources/test.ttf" + "../../../shared/resources/testfont.ttf" +) + +add_qt_resource(tst_qfontdialog "testfonts" + PREFIX + "/" + FILES + ${testfonts_resource_files} +) + + +## Scopes: +##################################################################### diff --git a/tests/auto/widgets/dialogs/qinputdialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qinputdialog/CMakeLists.txt new file mode 100644 index 0000000000..7cd02a04c0 --- /dev/null +++ b/tests/auto/widgets/dialogs/qinputdialog/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qinputdialog.pro. + +##################################################################### +## tst_qinputdialog Test: +##################################################################### + +add_qt_test(tst_qinputdialog + SOURCES + tst_qinputdialog.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/dialogs/qmessagebox/CMakeLists.txt b/tests/auto/widgets/dialogs/qmessagebox/CMakeLists.txt new file mode 100644 index 0000000000..ae12c58ca2 --- /dev/null +++ b/tests/auto/widgets/dialogs/qmessagebox/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qmessagebox.pro. + +##################################################################### +## tst_qmessagebox Test: +##################################################################### + +add_qt_test(tst_qmessagebox + SOURCES + tst_qmessagebox.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) + +#### Keys ignored in scope 1:.:.:qmessagebox.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/auto/widgets/dialogs/qprogressdialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qprogressdialog/CMakeLists.txt new file mode 100644 index 0000000000..2f20ff0d81 --- /dev/null +++ b/tests/auto/widgets/dialogs/qprogressdialog/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qprogressdialog.pro. + +##################################################################### +## tst_qprogressdialog Test: +##################################################################### + +add_qt_test(tst_qprogressdialog + SOURCES + tst_qprogressdialog.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/dialogs/qsidebar/CMakeLists.txt b/tests/auto/widgets/dialogs/qsidebar/CMakeLists.txt new file mode 100644 index 0000000000..d1e2a6686c --- /dev/null +++ b/tests/auto/widgets/dialogs/qsidebar/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qsidebar.pro. + +##################################################################### +## tst_qsidebar Test: +##################################################################### + +add_qt_test(tst_qsidebar + SOURCES + tst_qsidebar.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt b/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt new file mode 100644 index 0000000000..bbe7bddd9d --- /dev/null +++ b/tests/auto/widgets/dialogs/qwizard/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from qwizard.pro. + +##################################################################### +## tst_qwizard Test: +##################################################################### + +add_qt_test(tst_qwizard + SOURCES + tst_qwizard.cpp + tst_qwizard_2.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +# Resources: +set(qwizard_resource_files + "images/background.png" + "images/banner.png" + "images/logo.png" + "images/watermark.png" +) + +add_qt_resource(tst_qwizard "qwizard" + PREFIX + "/" + FILES + ${qwizard_resource_files} +) + diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 78616009a2..5b7ded0ecb 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -96,8 +96,9 @@ private slots: void task248107_backButton(); void task255350_fieldObjectDestroyed(); void taskQTBUG_25691_fieldObjectDestroyed2(); +#if QT_CONFIG(shortcut) void taskQTBUG_46894_nextButtonShortcut(); - +#endif /* Things that could be added: @@ -2703,6 +2704,8 @@ void tst_QWizard::taskQTBUG_25691_fieldObjectDestroyed2() ::taskQTBUG_25691_fieldObjectDestroyed2(); } +#if QT_CONFIG(shortcut) + void tst_QWizard::taskQTBUG_46894_nextButtonShortcut() { for (int i = 0; i < QWizard::NStyles; ++i) { @@ -2717,5 +2720,7 @@ void tst_QWizard::taskQTBUG_46894_nextButtonShortcut() } } +#endif // QT_CONFIG(shortcut) + QTEST_MAIN(tst_QWizard) #include "tst_qwizard.moc" diff --git a/tests/auto/widgets/effects/CMakeLists.txt b/tests/auto/widgets/effects/CMakeLists.txt new file mode 100644 index 0000000000..2e2045e33e --- /dev/null +++ b/tests/auto/widgets/effects/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(qgraphicseffect) +add_subdirectory(qpixmapfilter) diff --git a/tests/auto/widgets/effects/qgraphicseffect/CMakeLists.txt b/tests/auto/widgets/effects/qgraphicseffect/CMakeLists.txt new file mode 100644 index 0000000000..4cdeb6b4e5 --- /dev/null +++ b/tests/auto/widgets/effects/qgraphicseffect/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qgraphicseffect.pro. + +##################################################################### +## tst_qgraphicseffect Test: +##################################################################### + +add_qt_test(tst_qgraphicseffect + SOURCES + tst_qgraphicseffect.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/effects/qpixmapfilter/CMakeLists.txt b/tests/auto/widgets/effects/qpixmapfilter/CMakeLists.txt new file mode 100644 index 0000000000..6ffd2c4029 --- /dev/null +++ b/tests/auto/widgets/effects/qpixmapfilter/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qpixmapfilter.pro. + +##################################################################### +## tst_qpixmapfilter Test: +##################################################################### + +add_qt_test(tst_qpixmapfilter + SOURCES + tst_qpixmapfilter.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/graphicsview/CMakeLists.txt b/tests/auto/widgets/graphicsview/CMakeLists.txt new file mode 100644 index 0000000000..be1ae7253a --- /dev/null +++ b/tests/auto/widgets/graphicsview/CMakeLists.txt @@ -0,0 +1,35 @@ +# Generated from graphicsview.pro. + +if(QT_FEATURE_private_tests) + add_subdirectory(qgraphicsanchorlayout) + add_subdirectory(qgraphicsanchorlayout1) + add_subdirectory(qgraphicsitem) + add_subdirectory(qgraphicsscene) + add_subdirectory(qgraphicssceneindex) +endif() +add_subdirectory(qgraphicseffectsource) +add_subdirectory(qgraphicsgridlayout) +add_subdirectory(qgraphicsitemanimation) +add_subdirectory(qgraphicslayout) +add_subdirectory(qgraphicslayoutitem) +add_subdirectory(qgraphicslinearlayout) +add_subdirectory(qgraphicsobject) +add_subdirectory(qgraphicspixmapitem) +add_subdirectory(qgraphicspolygonitem) +add_subdirectory(qgraphicstransform) +if(QT_FEATURE_style_fusion) + # special case begin + # These tests are never run in coin with qmake since the statement + # !qtConfig(style-fusion): always passes causing the subdirs to be removed. + # For these tests to be generated the .pro file needs to be patched and + # the above line changed to !qtConfig(style-fusion). That being said, + # one of the test fails and needs to be corrected by someone with know how in + # that area. Until then we will disable them to mimic the behavior seen in + # coin. + #add_subdirectory(qgraphicsproxywidget) + #add_subdirectory(qgraphicswidget) + # special case end +endif() +if(NOT WINRT) + add_subdirectory(qgraphicsview) +endif() diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt new file mode 100644 index 0000000000..db323fcb15 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qgraphicsanchorlayout.pro. + +##################################################################### +## tst_qgraphicsanchorlayout Test: +##################################################################### + +add_qt_test(tst_qgraphicsanchorlayout + SOURCES + tst_qgraphicsanchorlayout.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt new file mode 100644 index 0000000000..9d9fc68832 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qgraphicsanchorlayout1.pro. + +##################################################################### +## tst_qgraphicsanchorlayout1 Test: +##################################################################### + +add_qt_test(tst_qgraphicsanchorlayout1 + SOURCES + tst_qgraphicsanchorlayout1.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt new file mode 100644 index 0000000000..ac1ac91f8b --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicseffectsource/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qgraphicseffectsource.pro. + +##################################################################### +## tst_qgraphicseffectsource Test: +##################################################################### + +add_qt_test(tst_qgraphicseffectsource + SOURCES + tst_qgraphicseffectsource.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt new file mode 100644 index 0000000000..c02f142182 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgraphicsgridlayout.pro. + +##################################################################### +## tst_qgraphicsgridlayout Test: +##################################################################### + +add_qt_test(tst_qgraphicsgridlayout + SOURCES + tst_qgraphicsgridlayout.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt new file mode 100644 index 0000000000..1be66372b6 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/CMakeLists.txt @@ -0,0 +1,27 @@ +# Generated from qgraphicsitem.pro. + +##################################################################### +## tst_qgraphicsitem Test: +##################################################################### + +add_qt_test(tst_qgraphicsitem + SOURCES + tst_qgraphicsitem.cpp + DEFINES + QT_NO_CAST_TO_ASCII + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +extend_target(tst_qgraphicsitem CONDITION WIN32 AND NOT WINRT + PUBLIC_LIBRARIES + user32 +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 5f2a9aad70..1cc793503a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -451,7 +451,9 @@ private slots: void modality_keyEvents(); void itemIsInFront(); void scenePosChange(); +#if QT_CONFIG(shortcut) void textItem_shortcuts(); +#endif void scroll(); void focusHandling_data(); void focusHandling(); @@ -4495,19 +4497,6 @@ protected: break; case QGraphicsItem::ItemPositionHasChanged: break; -#if QT_DEPRECATED_SINCE(5, 14) - case QGraphicsItem::ItemMatrixChange: { -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QVariant variant; - variant.setValue<QMatrix>(matrix()); - oldValues << variant; -QT_WARNING_POP -#endif - } - break; -#endif case QGraphicsItem::ItemTransformChange: { QVariant variant; variant.setValue<QTransform>(transform()); @@ -4625,32 +4614,7 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.oldValues.constLast(), QVariant(true)); QCOMPARE(tester.isEnabled(), true); } -#if QT_DEPRECATED_SINCE(5, 13) { -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen() - // ItemMatrixChange / ItemTransformHasChanged - tester.itemChangeReturnValue.setValue<QMatrix>(QMatrix().rotate(90)); - tester.setMatrix(QMatrix().translate(50, 0), true); - ++changeCount; // notification sent too - QCOMPARE(tester.changes.size(), ++changeCount); - QCOMPARE(int(tester.changes.at(tester.changes.size() - 2)), int(QGraphicsItem::ItemMatrixChange)); - QCOMPARE(int(tester.changes.last()), int(QGraphicsItem::ItemTransformHasChanged)); - QCOMPARE(qvariant_cast<QMatrix>(tester.values.at(tester.values.size() - 2)), - QMatrix().translate(50, 0)); - QCOMPARE(tester.values.constLast(), QVariant(QTransform(QMatrix().rotate(90)))); - QVariant variant; - variant.setValue<QMatrix>(QMatrix()); - QCOMPARE(tester.oldValues.constLast(), variant); - QCOMPARE(tester.matrix(), QMatrix().rotate(90)); -QT_WARNING_POP - } -#endif - { - tester.resetTransform(); - ++changeCount; - ++changeCount; // notification sent too - // ItemTransformChange / ItemTransformHasChanged tester.itemChangeReturnValue.setValue<QTransform>(QTransform().rotate(90)); tester.setTransform(QTransform::fromTranslate(50, 0), true); @@ -8015,21 +7979,10 @@ public: //Doesn't use the extended style option so the exposed rect is the boundingRect if (!(flags() & QGraphicsItem::ItemUsesExtendedStyleOption)) { QCOMPARE(option->exposedRect, boundingRect()); -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QCOMPARE(option->matrix, QMatrix()); -QT_WARNING_POP -#endif } else { QVERIFY(option->exposedRect != QRect()); QVERIFY(option->exposedRect != boundingRect()); -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QCOMPARE(option->matrix, sceneTransform().toAffine()); -QT_WARNING_POP -#endif + QCOMPARE(option->matrix, sceneTransform()); } } QGraphicsRectItem::paint(painter, option, widget); @@ -10812,6 +10765,8 @@ void tst_QGraphicsItem::scenePosChange() QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); } +#if QT_CONFIG(shortcut) + void tst_QGraphicsItem::textItem_shortcuts() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) @@ -10851,6 +10806,8 @@ void tst_QGraphicsItem::textItem_shortcuts() QTRY_COMPARE(item->textCursor().selectedText(), item->toPlainText()); } +#endif // QT_CONFIG(shortcut) + void tst_QGraphicsItem::scroll() { // Create two overlapping rectangles in the scene: diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt new file mode 100644 index 0000000000..179b6c8497 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qgraphicsitemanimation.pro. + +##################################################################### +## tst_qgraphicsitemanimation Test: +##################################################################### + +add_qt_test(tst_qgraphicsitemanimation + SOURCES + tst_qgraphicsitemanimation.cpp + DEFINES + QT_NO_CAST_TO_ASCII + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt new file mode 100644 index 0000000000..9a149f9df1 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicslayout/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qgraphicslayout.pro. + +##################################################################### +## tst_qgraphicslayout Test: +##################################################################### + +add_qt_test(tst_qgraphicslayout + SOURCES + tst_qgraphicslayout.cpp + DEFINES + QT_USE_USING_NAMESPACE + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt new file mode 100644 index 0000000000..56b9f73127 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgraphicslayoutitem.pro. + +##################################################################### +## tst_qgraphicslayoutitem Test: +##################################################################### + +add_qt_test(tst_qgraphicslayoutitem + SOURCES + tst_qgraphicslayoutitem.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt new file mode 100644 index 0000000000..1a44be75a1 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgraphicslinearlayout.pro. + +##################################################################### +## tst_qgraphicslinearlayout Test: +##################################################################### + +add_qt_test(tst_qgraphicslinearlayout + SOURCES + tst_qgraphicslinearlayout.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt new file mode 100644 index 0000000000..0e29191792 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsobject/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qgraphicsobject.pro. + +##################################################################### +## tst_qgraphicsobject Test: +##################################################################### + +add_qt_test(tst_qgraphicsobject + SOURCES + tst_qgraphicsobject.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt new file mode 100644 index 0000000000..cca35623e8 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgraphicspixmapitem.pro. + +##################################################################### +## tst_qgraphicspixmapitem Test: +##################################################################### + +add_qt_test(tst_qgraphicspixmapitem + SOURCES + tst_qgraphicspixmapitem.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt new file mode 100644 index 0000000000..86c6965756 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicspolygonitem/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgraphicspolygonitem.pro. + +##################################################################### +## tst_qgraphicspolygonitem Test: +##################################################################### + +add_qt_test(tst_qgraphicspolygonitem + SOURCES + tst_qgraphicspolygonitem.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt new file mode 100644 index 0000000000..accec5ff40 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qgraphicsproxywidget.pro. + +##################################################################### +## tst_qgraphicsproxywidget Test: +##################################################################### + +add_qt_test(tst_qgraphicsproxywidget + SOURCES + tst_qgraphicsproxywidget.cpp + DEFINES + QTEST_QPA_MOUSE_HANDLING + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt new file mode 100644 index 0000000000..c566b6c1bf --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt @@ -0,0 +1,77 @@ +# Generated from qgraphicsscene.pro. + +##################################################################### +## tst_qgraphicsscene Test: +##################################################################### + +add_qt_test(tst_qgraphicsscene + SOURCES + tst_qgraphicsscene.cpp + DEFINES + QT_NO_CAST_TO_ASCII + SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\" + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +# Resources: +set(images_resource_files + "Ash_European.jpg" +) + +add_qt_resource(tst_qgraphicsscene "images" + PREFIX + "/" + FILES + ${images_resource_files} +) +set(testdata_resource_files + "testData/render/all-all-45-deg-left.png" + "testData/render/all-all-45-deg-right.png" + "testData/render/all-all-scale-2x.png" + "testData/render/all-all-translate-0-50.png" + "testData/render/all-all-translate-50-0.png" + "testData/render/all-all-untransformed-clip-ellipse.png" + "testData/render/all-all-untransformed-clip-rect.png" + "testData/render/all-all-untransformed.png" + "testData/render/all-bottomleft-untransformed.png" + "testData/render/all-bottomright-untransformed.png" + "testData/render/all-topleft-untransformed.png" + "testData/render/all-topright-untransformed.png" + "testData/render/bottom-bottomright-untransformed.png" + "testData/render/bottom-topleft-untransformed.png" + "testData/render/bottomleft-all-untransformed.png" + "testData/render/bottomleft-topleft-untransformed.png" + "testData/render/bottomright-all-untransformed.png" + "testData/render/bottomright-topleft-untransformed.png" + "testData/render/left-bottomright-untransformed.png" + "testData/render/left-topleft-untransformed.png" + "testData/render/right-bottomright-untransformed.png" + "testData/render/right-topleft-untransformed.png" + "testData/render/top-bottomright-untransformed.png" + "testData/render/top-topleft-untransformed.png" + "testData/render/topleft-all-untransformed.png" + "testData/render/topleft-topleft-untransformed.png" + "testData/render/topright-all-untransformed.png" + "testData/render/topright-topleft-untransformed.png" +) + +add_qt_resource(tst_qgraphicsscene "testdata" + PREFIX + "/" + FILES + ${testdata_resource_files} +) + + +## Scopes: +##################################################################### + +extend_target(tst_qgraphicsscene CONDITION WIN32 AND NOT WINRT + PUBLIC_LIBRARIES + user32 +) diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt new file mode 100644 index 0000000000..5fa72f7b46 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/CMakeLists.txt @@ -0,0 +1,23 @@ +# Generated from qgraphicssceneindex.pro. + +if(NOT QT_FEATURE_private_tests) + return() +endif() + +##################################################################### +## tst_qgraphicssceneindex Test: +##################################################################### + +add_qt_test(tst_qgraphicssceneindex + SOURCES + tst_qgraphicssceneindex.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +#### Keys ignored in scope 1:.:.:qgraphicssceneindex.pro:<TRUE>: +# _REQUIREMENTS = "qtConfig(private_tests)" diff --git a/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt new file mode 100644 index 0000000000..450c0269f3 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicstransform/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgraphicstransform.pro. + +##################################################################### +## tst_qgraphicstransform Test: +##################################################################### + +add_qt_test(tst_qgraphicstransform + SOURCES + tst_qgraphicstransform.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt new file mode 100644 index 0000000000..48064c2bf4 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsview/CMakeLists.txt @@ -0,0 +1,32 @@ +# Generated from qgraphicsview.pro. + +##################################################################### +## tst_qgraphicsview Test: +##################################################################### + +add_qt_test(tst_qgraphicsview + SOURCES + tst_qgraphicsview.cpp tst_qgraphicsview.h + tst_qgraphicsview_2.cpp + DEFINES + QT_NO_CAST_TO_ASCII + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +#### Keys ignored in scope 1:.:.:qgraphicsview.pro:<TRUE>: +# testcase.timeout = "500" + +## Scopes: +##################################################################### + +extend_target(tst_qgraphicsview CONDITION QT_FEATURE_opengl + PUBLIC_LIBRARIES + Qt::OpenGL + Qt::OpenGLWidgets +) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro index 8ed19697a4..13998d5494 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro @@ -4,6 +4,7 @@ TARGET = tst_qgraphicsview QT += widgets widgets-private testlib QT += core-private gui-private testlib-private +qtConfig(opengl): QT += opengl openglwidgets SOURCES += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp HEADERS += tst_qgraphicsview.h diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index a8baf03af9..157c07f922 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -48,8 +48,8 @@ #include <QtWidgets/QBoxLayout> #include <QtWidgets/QStyle> #include <QtWidgets/QPushButton> -#ifndef QT_NO_OPENGL -#include <QtWidgets/QOpenGLWidget> +#if QT_CONFIG(opengl) +#include <QtOpenGLWidgets/QOpenGLWidget> #endif #include <private/qgraphicsscene_p.h> #include <private/qgraphicsview_p.h> @@ -154,7 +154,7 @@ private slots: void sceneRect_growing(); void setSceneRect(); void viewport(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void openGLViewport(); #endif void dragMode_scrollHand(); @@ -659,7 +659,7 @@ void tst_QGraphicsView::viewport() QVERIFY(QTest::qWaitForWindowExposed(&view)); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_QGraphicsView::openGLViewport() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) @@ -2125,8 +2125,8 @@ void tst_QGraphicsView::mapFromScenePath() QPainterPath path2; path2.addPolygon(polygon2); - QPolygonF pathPoly = view.mapFromScene(path).toFillPolygon(QTransform()); - QPolygonF path2Poly = path2.toFillPolygon(QTransform()); + QPolygonF pathPoly = view.mapFromScene(path).toFillPolygon(); + QPolygonF path2Poly = path2.toFillPolygon(); for (int i = 0; i < pathPoly.size(); ++i) { QVERIFY(qAbs(pathPoly[i].x() - path2Poly[i].x()) < 3); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp index aedb96f19a..297e83421b 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp @@ -40,7 +40,6 @@ Q_DECLARE_METATYPE(ExpectedValueDescription) Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QRectF>) -Q_DECLARE_METATYPE(QMatrix) Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::ScrollBarPolicy) Q_DECLARE_METATYPE(ScrollBarCount) diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt new file mode 100644 index 0000000000..7325f7eb21 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qgraphicswidget.pro. + +##################################################################### +## tst_qgraphicswidget Test: +##################################################################### + +add_qt_test(tst_qgraphicswidget + SOURCES + tst_qgraphicswidget.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/CMakeLists.txt b/tests/auto/widgets/itemviews/CMakeLists.txt new file mode 100644 index 0000000000..e7dc78b18c --- /dev/null +++ b/tests/auto/widgets/itemviews/CMakeLists.txt @@ -0,0 +1,21 @@ +# Generated from itemviews.pro. + +add_subdirectory(qabstractitemview) +add_subdirectory(qdatawidgetmapper) +add_subdirectory(qdirmodel) +add_subdirectory(qfileiconprovider) +add_subdirectory(qheaderview) +add_subdirectory(qitemdelegate) +add_subdirectory(qitemeditorfactory) +add_subdirectory(qitemview) +add_subdirectory(qlistview) +add_subdirectory(qtableview) +add_subdirectory(qtablewidget) +add_subdirectory(qtreeview) +add_subdirectory(qtreewidget) +add_subdirectory(qtreewidgetitemiterator) + +if(QT_FEATURE_private_tests) + add_subdirectory(qcolumnview) + add_subdirectory(qlistwidget) +endif() diff --git a/tests/auto/widgets/itemviews/qabstractitemview/CMakeLists.txt b/tests/auto/widgets/itemviews/qabstractitemview/CMakeLists.txt new file mode 100644 index 0000000000..2fc8c14eb6 --- /dev/null +++ b/tests/auto/widgets/itemviews/qabstractitemview/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qabstractitemview.pro. + +##################################################################### +## tst_qabstractitemview Test: +##################################################################### + +add_qt_test(tst_qabstractitemview + SOURCES + tst_qabstractitemview.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro b/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro index 809a996324..b9091a134e 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro +++ b/tests/auto/widgets/itemviews/qabstractitemview/qabstractitemview.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qabstractitemview -QT += widgets testlib testlib-private gui-private +QT += widgets testlib testlib-private gui-private widgets-private SOURCES += tst_qabstractitemview.cpp diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 0bdf61e1e1..ba4c1473e8 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -51,6 +51,7 @@ #include <QTest> #include <QVBoxLayout> #include <QtTest/private/qtesthelpers_p.h> +#include <private/qabstractitemview_p.h> Q_DECLARE_METATYPE(Qt::ItemFlags); @@ -115,6 +116,9 @@ private slots: void setCurrentIndex_data(); void setCurrentIndex(); + void checkIntersectedRect_data(); + void checkIntersectedRect(); + void task221955_selectedEditor(); void task250754_fontChange(); void task200665_itemEntered(); @@ -469,7 +473,8 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view) view->setCurrentIndex(QModelIndex()); // protected methods - view->dataChanged(QModelIndex(), QModelIndex()); + // will assert because an invalid index is passed + //view->dataChanged(QModelIndex(), QModelIndex()); view->rowsInserted(QModelIndex(), -1, -1); view->rowsAboutToBeRemoved(QModelIndex(), -1, -1); view->selectionChanged(QItemSelection(), QItemSelection()); @@ -1099,6 +1104,101 @@ void tst_QAbstractItemView::setCurrentIndex() QVERIFY(view->currentIndex() == model->index(result ? 1 : 0, 0)); } +void tst_QAbstractItemView::checkIntersectedRect_data() +{ + auto createModel = [](int rowCount) -> QStandardItemModel* + { + QStandardItemModel *model = new QStandardItemModel; + for (int i = 0; i < rowCount; ++i) { + const QList<QStandardItem *> sil({new QStandardItem(QLatin1String("Row %1 Item").arg(i)), + new QStandardItem(QLatin1String("2nd column"))}); + model->appendRow(sil); + } + return model; + }; + QTest::addColumn<QStandardItemModel *>("model"); + QTest::addColumn<QVector<QModelIndex>>("changedIndexes"); + QTest::addColumn<bool>("isEmpty"); + { + auto model = createModel(5); + QTest::newRow("multiple columns") << model + << QVector<QModelIndex>({model->index(0, 0), + model->index(0, 1)}) + << false; + } + { + auto model = createModel(5); + QTest::newRow("multiple rows") << model + << QVector<QModelIndex>({model->index(0, 0), + model->index(1, 0), + model->index(2, 0)}) + << false; + } + { + auto model = createModel(5); + QTest::newRow("hidden rows") << model + << QVector<QModelIndex>({model->index(3, 0), + model->index(4, 0)}) + << true; + } + { + auto model = createModel(500); + QTest::newRow("rows outside viewport") << model + << QVector<QModelIndex>({model->index(498, 0), + model->index(499, 0)}) + << true; + } +} + +void tst_QAbstractItemView::checkIntersectedRect() +{ + QFETCH(QStandardItemModel *, model); + QFETCH(const QVector<QModelIndex>, changedIndexes); + QFETCH(bool, isEmpty); + + class TableView : public QTableView + { + public: + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override + { + QTableView::dataChanged(topLeft, bottomRight, roles); + // we want to check the base class implementation here! + QAbstractItemViewPrivate *av = static_cast<QAbstractItemViewPrivate*>(qt_widget_private(this)); + m_intersectecRect = av->intersectedRect(av->viewport->rect(), topLeft, bottomRight); + } + mutable QRect m_intersectecRect; + }; + + TableView view; + model->setParent(&view); + view.setModel(model); + view.resize(400, 400); + view.show(); + view.setRowHidden(3, true); + view.setRowHidden(4, true); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + view.m_intersectecRect = QRect(); + emit view.model()->dataChanged(changedIndexes.first(), changedIndexes.last()); + if (isEmpty) { + QVERIFY(view.m_intersectecRect.isEmpty()); + } else { + const auto parent = changedIndexes.first().parent(); + const int rCount = view.model()->rowCount(parent); + const int cCount = view.model()->columnCount(parent); + for (int r = 0; r < rCount; ++r) { + for (int c = 0; c < cCount; ++c) { + const QModelIndex &idx = view.model()->index(r, c, parent); + const auto rect = view.visualRect(idx); + if (changedIndexes.contains(idx)) + QVERIFY(view.m_intersectecRect.contains(rect)); + else + QVERIFY(!view.m_intersectecRect.contains(rect)); + } + } + } +} + void tst_QAbstractItemView::task221955_selectedEditor() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) diff --git a/tests/auto/widgets/itemviews/qcolumnview/CMakeLists.txt b/tests/auto/widgets/itemviews/qcolumnview/CMakeLists.txt new file mode 100644 index 0000000000..d33e3b9c2e --- /dev/null +++ b/tests/auto/widgets/itemviews/qcolumnview/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qcolumnview.pro. + +##################################################################### +## tst_qcolumnview Test: +##################################################################### + +add_qt_test(tst_qcolumnview + SOURCES + ../../../../shared/fakedirmodel.h + tst_qcolumnview.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/CMakeLists.txt b/tests/auto/widgets/itemviews/qdatawidgetmapper/CMakeLists.txt new file mode 100644 index 0000000000..f3e4af0c23 --- /dev/null +++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qdatawidgetmapper.pro. + +##################################################################### +## tst_qdatawidgetmapper Test: +##################################################################### + +add_qt_test(tst_qdatawidgetmapper + SOURCES + tst_qdatawidgetmapper.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/itemviews/qdirmodel/CMakeLists.txt b/tests/auto/widgets/itemviews/qdirmodel/CMakeLists.txt new file mode 100644 index 0000000000..d47cc3457d --- /dev/null +++ b/tests/auto/widgets/itemviews/qdirmodel/CMakeLists.txt @@ -0,0 +1,49 @@ +# Generated from qdirmodel.pro. + +##################################################################### +## tst_qdirmodel Test: +##################################################################### + +add_qt_test(tst_qdirmodel + SOURCES + ../../../../shared/emulationdetector.h + tst_qdirmodel.cpp + INCLUDE_DIRECTORIES + ../../../../shared + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +## Scopes: +##################################################################### + +extend_target(tst_qdirmodel CONDITION ANDROID + DEFINES + SRCDIR=\\\"./\\\" +) + +extend_target(tst_qdirmodel CONDITION NOT ANDROID + DEFINES + SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\" +) + +if(ANDROID AND NOT ANDROID_EMBEDDED) + # Resources: + set(testdata_resource_files + "dirtest/test1/dummy" + "dirtest/test1/test" + "test/file01.tst" + "test/file02.tst" + "test/file03.tst" + "test/file04.tst" + "tst_qdirmodel.cpp" + ) + + add_qt_resource(tst_qdirmodel "testdata" + PREFIX + "/android_testdata" + FILES + ${testdata_resource_files} + ) +endif() diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp index 546b2ab3a8..925c578300 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp @@ -713,7 +713,7 @@ void tst_QDirModel::roleNames() QVERIFY(roles.contains(role)); QFETCH(QByteArray, roleName); - QCOMPARE(roles.values(role).count(), 1); + QCOMPARE(roles.contains(role), true); QCOMPARE(roles.value(role), roleName); } diff --git a/tests/auto/widgets/itemviews/qfileiconprovider/CMakeLists.txt b/tests/auto/widgets/itemviews/qfileiconprovider/CMakeLists.txt new file mode 100644 index 0000000000..024519ad9c --- /dev/null +++ b/tests/auto/widgets/itemviews/qfileiconprovider/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qfileiconprovider.pro. + +##################################################################### +## tst_qfileiconprovider Test: +##################################################################### + +add_qt_test(tst_qfileiconprovider + SOURCES + tst_qfileiconprovider.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/itemviews/qheaderview/CMakeLists.txt b/tests/auto/widgets/itemviews/qheaderview/CMakeLists.txt new file mode 100644 index 0000000000..8949ac4957 --- /dev/null +++ b/tests/auto/widgets/itemviews/qheaderview/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qheaderview.pro. + +##################################################################### +## tst_qheaderview Test: +##################################################################### + +add_qt_test(tst_qheaderview + SOURCES + tst_qheaderview.cpp + DEFINES + QT_DISABLE_DEPRECATED_BEFORE=0 + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index d5813d64ff..bb098f32c2 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -1744,7 +1744,7 @@ void tst_QHeaderView::restoreQt4State() QCOMPARE(h2.length(), old_length); QCOMPARE(h2.saveState(), old_state); #else - QSKIP("Qt4 compatibility no longer needed in Qt6") + QSKIP("Qt4 compatibility no longer needed in Qt6"); #endif } diff --git a/tests/auto/widgets/itemviews/qitemdelegate/CMakeLists.txt b/tests/auto/widgets/itemviews/qitemdelegate/CMakeLists.txt new file mode 100644 index 0000000000..af1bac9ff0 --- /dev/null +++ b/tests/auto/widgets/itemviews/qitemdelegate/CMakeLists.txt @@ -0,0 +1,22 @@ +# Generated from qitemdelegate.pro. + +##################################################################### +## tst_qitemdelegate Test: +##################################################################### + +add_qt_test(tst_qitemdelegate + SOURCES + tst_qitemdelegate.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +extend_target(tst_qitemdelegate CONDITION WIN32 AND NOT WINRT + PUBLIC_LIBRARIES + user32 +) diff --git a/tests/auto/widgets/itemviews/qitemeditorfactory/CMakeLists.txt b/tests/auto/widgets/itemviews/qitemeditorfactory/CMakeLists.txt new file mode 100644 index 0000000000..4dfb46ff4d --- /dev/null +++ b/tests/auto/widgets/itemviews/qitemeditorfactory/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qitemeditorfactory.pro. + +##################################################################### +## tst_qitemeditorfactory Test: +##################################################################### + +add_qt_test(tst_qitemeditorfactory + SOURCES + tst_qitemeditorfactory.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/itemviews/qitemview/CMakeLists.txt b/tests/auto/widgets/itemviews/qitemview/CMakeLists.txt new file mode 100644 index 0000000000..b27f456246 --- /dev/null +++ b/tests/auto/widgets/itemviews/qitemview/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qitemview.pro. + +##################################################################### +## tst_qitemview Test: +##################################################################### + +add_qt_test(tst_qitemview + SOURCES + tst_qitemview.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/itemviews/qlistview/CMakeLists.txt b/tests/auto/widgets/itemviews/qlistview/CMakeLists.txt new file mode 100644 index 0000000000..07c290128e --- /dev/null +++ b/tests/auto/widgets/itemviews/qlistview/CMakeLists.txt @@ -0,0 +1,25 @@ +# Generated from qlistview.pro. + +##################################################################### +## tst_qlistview Test: +##################################################################### + +add_qt_test(tst_qlistview + SOURCES + tst_qlistview.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +extend_target(tst_qlistview CONDITION WIN32 AND NOT WINRT + PUBLIC_LIBRARIES + user32 +) diff --git a/tests/auto/widgets/itemviews/qlistwidget/CMakeLists.txt b/tests/auto/widgets/itemviews/qlistwidget/CMakeLists.txt new file mode 100644 index 0000000000..aebcb4c49e --- /dev/null +++ b/tests/auto/widgets/itemviews/qlistwidget/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qlistwidget.pro. + +##################################################################### +## tst_qlistwidget Test: +##################################################################### + +add_qt_test(tst_qlistwidget + SOURCES + tst_qlistwidget.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 67d8764b61..4a3c886430 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -407,15 +407,6 @@ void tst_QListWidget::closePersistentEditor() void tst_QListWidget::setItemHidden() { -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - // Boundary checking - testWidget->setItemHidden(nullptr, true); - testWidget->setItemHidden(nullptr, false); -QT_WARNING_POP -#endif - auto countHidden = [](QListWidget *testWidget) { int totalHidden = 0; diff --git a/tests/auto/widgets/itemviews/qtableview/CMakeLists.txt b/tests/auto/widgets/itemviews/qtableview/CMakeLists.txt new file mode 100644 index 0000000000..20e50d2de3 --- /dev/null +++ b/tests/auto/widgets/itemviews/qtableview/CMakeLists.txt @@ -0,0 +1,17 @@ +# Generated from qtableview.pro. + +##################################################################### +## tst_qtableview Test: +##################################################################### + +add_qt_test(tst_qtableview + SOURCES + tst_qtableview.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index ea3eb5fd0c..ccc6997f26 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -243,6 +243,14 @@ public: verticalHeader()->setMinimumSectionSize(0); } + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override + { + QTableView::dataChanged(topLeft, bottomRight, roles); + QTableViewPrivate *av = static_cast<QTableViewPrivate*>(qt_widget_private(this)); + m_intersectecRect = av->intersectedRect(av->viewport->rect(), topLeft, bottomRight); + } + mutable QRect m_intersectecRect; + using QTableView::moveCursor; using QTableView::isIndexHidden; using QTableView::setSelection; @@ -331,8 +339,10 @@ private slots: void selectColumn_data(); void selectColumn(); +#if QT_CONFIG(shortcut) void selectall_data(); void selectall(); +#endif void visualRect_data(); void visualRect(); @@ -400,6 +410,9 @@ private slots: void selectionSignal(); void setCurrentIndex(); + void checkIntersectedRect_data(); + void checkIntersectedRect(); + // task-specific tests: void task173773_updateVerticalHeader(); void task227953_setRootIndex(); @@ -1843,6 +1856,8 @@ void tst_QTableView::selectColumn() QCOMPARE(view.selectionModel()->selectedIndexes().at(i).column(), column); } +#if QT_CONFIG(shortcut) + void tst_QTableView::selectall_data() { QTest::addColumn<int>("rowCount"); @@ -1999,6 +2014,8 @@ void tst_QTableView::selectall() QCOMPARE(view.selectedIndexes().count(), 0); } +#endif // QT_CONFIG(shortcut) + void tst_QTableView::visualRect_data() { QTest::addColumn<int>("rowCount"); @@ -3836,6 +3853,121 @@ void tst_QTableView::setCurrentIndex() QCOMPARE(model.submit_count, 4); } +void tst_QTableView::checkIntersectedRect_data() +{ + QTest::addColumn<QtTestTableModel *>("model"); + QTest::addColumn<QVector<QModelIndex>>("changedIndexes"); + QTest::addColumn<bool>("isEmpty"); + QTest::addColumn<bool>("swapFirstAndLastIndexRow"); // for QHeaderView::sectionsMoved() + QTest::addColumn<bool>("swapFirstAndLastIndexColumn"); // for QHeaderView::sectionsMoved() + QTest::addColumn<Qt::LayoutDirection>("layoutDirection"); + QTest::addColumn<int>("hiddenRow"); + QTest::addColumn<int>("hiddenCol"); + const auto testName = [](const QByteArray &prefix, Qt::LayoutDirection dir, bool r, bool c) + { + const char *strDir = dir == Qt::LeftToRight ? ", LeftToRight" : ", RightToLeft"; + const char *strRow = r ? ", rowsSwapped" : ""; + const char *strCol = c ? ", colsSwapped" : ""; + return prefix + strDir + strRow + strCol; + }; + for (int i = 0; i < 2; ++i) { + const Qt::LayoutDirection dir(i == 0 ? Qt::LeftToRight : Qt::RightToLeft); + for (int j = 0; j < 4; ++j) { + const bool swapRow = ((j & 1) == 1); + const bool swapColumn = ((j & 2) == 2); + { + QtTestTableModel *model = new QtTestTableModel(10, 3); + QTest::newRow(testName("multiple columns", dir, swapRow, swapColumn).data()) + << model + << QVector<QModelIndex>({model->index(0, 0), + model->index(0, 1)}) + << false << swapRow << swapColumn << dir << -1 << -1; + } + { + QtTestTableModel *model = new QtTestTableModel(10, 3); + QTest::newRow(testName("multiple rows", dir, swapRow, swapColumn).data()) + << model + << QVector<QModelIndex>({model->index(0, 0), + model->index(1, 0), + model->index(2, 0)}) + << false << swapRow << swapColumn << dir << -1 << -1; + } + { + QtTestTableModel *model = new QtTestTableModel(10, 3); + QTest::newRow(testName("hidden row", dir, swapRow, swapColumn).data()) + << model + << QVector<QModelIndex>({model->index(3, 0), + model->index(3, 1)}) + << true << swapRow << swapColumn << dir << 3 << -1; + } + { + QtTestTableModel *model = new QtTestTableModel(50, 2); + QTest::newRow(testName("row outside viewport", dir, swapRow, swapColumn).data()) + << model + << QVector<QModelIndex>({model->index(49, 0), + model->index(49, 1)}) + << true << swapRow << swapColumn << dir << -1 << -1; + } + } + } +} + +void tst_QTableView::checkIntersectedRect() +{ + QFETCH(QtTestTableModel *, model); + QFETCH(const QVector<QModelIndex>, changedIndexes); + QFETCH(bool, isEmpty); + QFETCH(bool, swapFirstAndLastIndexRow); + QFETCH(bool, swapFirstAndLastIndexColumn); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(int, hiddenRow); + QFETCH(int, hiddenCol); + + QtTestTableView view; + model->setParent(&view); + view.setLayoutDirection(layoutDirection); + view.setModel(model); + view.resize(400, 400); + view.show(); + if (hiddenRow >= 0) + view.hideRow(hiddenRow); + if (hiddenCol >= 0) + view.hideRow(hiddenCol); + if (swapFirstAndLastIndexRow) + view.verticalHeader()->swapSections(changedIndexes.first().row(), changedIndexes.last().row()); + if (swapFirstAndLastIndexColumn) + view.horizontalHeader()->swapSections(changedIndexes.first().column(), changedIndexes.last().column()); + + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + const auto toString = [](const QModelIndex &idx) + { + return QStringLiteral("idx: %1/%2").arg(idx.row()).arg(idx.column()); + }; + + view.m_intersectecRect = QRect(); + emit view.model()->dataChanged(changedIndexes.first(), changedIndexes.last()); + if (isEmpty) { + QVERIFY(view.m_intersectecRect.isEmpty()); + } else if (!changedIndexes.first().isValid()) { + QCOMPARE(view.m_intersectecRect, view.viewport()->rect()); + } else { + const auto parent = changedIndexes.first().parent(); + const int rCount = view.model()->rowCount(parent); + const int cCount = view.model()->columnCount(parent); + for (int r = 0; r < rCount; ++r) { + for (int c = 0; c < cCount; ++c) { + const QModelIndex &idx = view.model()->index(r, c, parent); + const auto rect = view.visualRect(idx); + if (changedIndexes.contains(idx)) + QVERIFY2(view.m_intersectecRect.contains(rect), qPrintable(toString(idx))); + else + QVERIFY2(!view.m_intersectecRect.contains(rect), qPrintable(toString(idx))); + } + } + } +} + class task173773_EventFilter : public QObject { int paintEventCount_ = 0; diff --git a/tests/auto/widgets/itemviews/qtablewidget/CMakeLists.txt b/tests/auto/widgets/itemviews/qtablewidget/CMakeLists.txt new file mode 100644 index 0000000000..66344e9d32 --- /dev/null +++ b/tests/auto/widgets/itemviews/qtablewidget/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtablewidget.pro. + +##################################################################### +## tst_qtablewidget Test: +##################################################################### + +add_qt_test(tst_qtablewidget + SOURCES + tst_qtablewidget.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/itemviews/qtreeview/CMakeLists.txt b/tests/auto/widgets/itemviews/qtreeview/CMakeLists.txt new file mode 100644 index 0000000000..40a6a1a6d6 --- /dev/null +++ b/tests/auto/widgets/itemviews/qtreeview/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qtreeview.pro. + +##################################################################### +## tst_qtreeview Test: +##################################################################### + +add_qt_test(tst_qtreeview + SOURCES + ../../../../shared/fakedirmodel.h + tst_qtreeview.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 339f5b39e6..760dcac608 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -89,6 +89,13 @@ public: QTreeView::paintEvent(event); wasPainted = true; } + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override + { + QTreeView::dataChanged(topLeft, bottomRight, roles); + QTreeViewPrivate *av = static_cast<QTreeViewPrivate*>(qt_widget_private(this)); + m_intersectecRect = av->intersectedRect(av->viewport->rect(), topLeft, bottomRight); + } + mutable QRect m_intersectecRect; bool wasPainted = false; public slots: void handleSelectionChanged() @@ -208,6 +215,8 @@ private slots: void statusTip_data(); void statusTip(); void fetchMoreOnScroll(); + void checkIntersectedRect_data(); + void checkIntersectedRect(); // task-specific tests: void task174627_moveLeftToRoot(); @@ -4842,6 +4851,111 @@ void tst_QTreeView::fetchMoreOnScroll() QCOMPARE(im.item(19)->rowCount(), 20); } +void tst_QTreeView::checkIntersectedRect_data() +{ + auto createModel = [](int rowCount) + { + QStandardItemModel *model = new QStandardItemModel; + for (int i = 0; i < rowCount; ++i) { + const QList<QStandardItem *> sil({new QStandardItem(QLatin1String("Row %1 Item").arg(i)), + new QStandardItem(QLatin1String("2nd column"))}); + model->appendRow(sil); + } + for (int i = 2; i < 4; ++i) { + const QList<QStandardItem *> sil({new QStandardItem(QLatin1String("Row %1 Item").arg(i)), + new QStandardItem(QLatin1String("2nd column"))}); + model->item(i)->appendRow(sil); + } + return model; + }; + QTest::addColumn<QStandardItemModel *>("model"); + QTest::addColumn<QVector<QModelIndex>>("changedIndexes"); + QTest::addColumn<bool>("isEmpty"); + { + auto model = createModel(5); + QTest::newRow("multiple columns") << model + << QVector<QModelIndex>({model->index(0, 0), + model->index(0, 1)}) + << false; + } + { + auto model = createModel(5); + QTest::newRow("multiple rows") << model + << QVector<QModelIndex>({model->index(0, 0), + model->index(1, 0), + model->index(2, 0)}) + << false; + } + { + auto model = createModel(5); + const QModelIndex idxRow2(model->indexFromItem(model->item(2))); + QTest::newRow("child row") << model + << QVector<QModelIndex>({model->index(0, 0, idxRow2), + model->index(0, 1, idxRow2)}) + << false; + } + { + auto model = createModel(5); + QTest::newRow("hidden row") << model + << QVector<QModelIndex>({model->index(3, 0), + model->index(3, 1)}) + << true; + } + { + auto model = createModel(5); + const QModelIndex idxRow3(model->indexFromItem(model->item(3))); + QTest::newRow("hidden child row") << model + << QVector<QModelIndex>({model->index(0, 0, idxRow3), + model->index(0, 1, idxRow3)}) + << true; + } + { + auto model = createModel(50); + QTest::newRow("row outside viewport") << model + << QVector<QModelIndex>({model->index(49, 0), + model->index(49, 1)}) + << true; + } +} + +void tst_QTreeView::checkIntersectedRect() +{ + QFETCH(QStandardItemModel *, model); + QFETCH(const QVector<QModelIndex>, changedIndexes); + QFETCH(bool, isEmpty); + + TreeView view; + model->setParent(&view); + view.setModel(model); + view.resize(400, 400); + view.show(); + view.expandAll(); + view.setRowHidden(3, QModelIndex(), true); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + view.m_intersectecRect = QRect(); + emit view.model()->dataChanged(changedIndexes.first(), changedIndexes.last()); + if (isEmpty) { + QVERIFY(view.m_intersectecRect.isEmpty()); + } else if (!changedIndexes.first().isValid()) { + QCOMPARE(view.m_intersectecRect, view.viewport()->rect()); + } else { + const auto parent = changedIndexes.first().parent(); + const int rCount = view.model()->rowCount(parent); + const int cCount = view.model()->columnCount(parent); + for (int r = 0; r < rCount; ++r) { + for (int c = 0; c < cCount; ++c) { + const QModelIndex &idx = view.model()->index(r, c, parent); + const auto rect = view.visualRect(idx); + if (changedIndexes.contains(idx)) + QVERIFY(view.m_intersectecRect.contains(rect)); + else + QVERIFY(!view.m_intersectecRect.contains(rect)); + } + } + } +} + static void fillModeltaskQTBUG_8376(QAbstractItemModel &model) { model.insertRow(0); diff --git a/tests/auto/widgets/itemviews/qtreewidget/CMakeLists.txt b/tests/auto/widgets/itemviews/qtreewidget/CMakeLists.txt new file mode 100644 index 0000000000..dde2e9d4ab --- /dev/null +++ b/tests/auto/widgets/itemviews/qtreewidget/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtreewidget.pro. + +##################################################################### +## tst_qtreewidget Test: +##################################################################### + +add_qt_test(tst_qtreewidget + SOURCES + tst_qtreewidget.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 7da56ab797..17617e0734 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -866,15 +866,6 @@ void tst_QTreeWidget::selectedItems() } } -#if QT_DEPRECATED_SINCE(5, 13) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - // Possible to select null without crashing? - testWidget->setItemSelected(nullptr, true); - QVERIFY(!testWidget->isItemSelected(nullptr)); -QT_WARNING_POP -#endif - // unselect for (const auto &itemPath : selectedItems) { QTreeWidgetItem *item = nullptr; @@ -3337,8 +3328,8 @@ void tst_QTreeWidget::task239150_editorWidth() QStyleOptionFrame opt; opt.init(&tree); - const int minWidth = tree.style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(0, 0). - expandedTo(QApplication::globalStrut()), nullptr).width(); + const int minWidth = tree.style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(0, 0) + , nullptr).width(); { QTreeWidgetItem item; diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/CMakeLists.txt b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/CMakeLists.txt new file mode 100644 index 0000000000..65ac8cda8b --- /dev/null +++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtreewidgetitemiterator.pro. + +##################################################################### +## tst_qtreewidgetitemiterator Test: +##################################################################### + +add_qt_test(tst_qtreewidgetitemiterator + SOURCES + tst_qtreewidgetitemiterator.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/CMakeLists.txt b/tests/auto/widgets/kernel/CMakeLists.txt new file mode 100644 index 0000000000..51759264b2 --- /dev/null +++ b/tests/auto/widgets/kernel/CMakeLists.txt @@ -0,0 +1,23 @@ +# Generated from kernel.pro. + +add_subdirectory(qaction) +add_subdirectory(qactiongroup) +add_subdirectory(qapplication) +add_subdirectory(qboxlayout) +add_subdirectory(qdesktopwidget) +add_subdirectory(qformlayout) +add_subdirectory(qgridlayout) +add_subdirectory(qlayout) +add_subdirectory(qstackedlayout) +add_subdirectory(qtooltip) +add_subdirectory(qwidget) +add_subdirectory(qwidget_window) +add_subdirectory(qwidgetaction) +add_subdirectory(qwidgetmetatype) +add_subdirectory(qwidgetsvariant) +add_subdirectory(qwindowcontainer) +add_subdirectory(qshortcut) +add_subdirectory(qsizepolicy) +if(NOT APPLE) + add_subdirectory(qgesturerecognizer) +endif() diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index af85a2bd13..c66c1822b2 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -1,7 +1,5 @@ TEMPLATE=subdirs SUBDIRS=\ - qaction \ - qactiongroup \ qapplication \ qboxlayout \ qdesktopwidget \ @@ -13,12 +11,19 @@ SUBDIRS=\ qtooltip \ qwidget \ qwidget_window \ - qwidgetaction \ qwidgetmetatype \ qwidgetsvariant \ qwindowcontainer \ qshortcut \ qsizepolicy -darwin:SUBDIRS -= \ # Uses native recognizers +darwin:SUBDIRS -= \ qgesturerecognizer \ + +qtConfig(action):SUBDIRS += \ + qaction \ + qactiongroup \ + qwidgetaction + +!qtConfig(shortcut): SUBDIRS -= \ + qshortcut diff --git a/tests/auto/widgets/kernel/qaction/.gitignore b/tests/auto/widgets/kernel/qaction/.gitignore deleted file mode 100644 index bf81f5bf2c..0000000000 --- a/tests/auto/widgets/kernel/qaction/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qaction diff --git a/tests/auto/widgets/kernel/qaction/CMakeLists.txt b/tests/auto/widgets/kernel/qaction/CMakeLists.txt new file mode 100644 index 0000000000..469cc4d597 --- /dev/null +++ b/tests/auto/widgets/kernel/qaction/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qaction.pro. + +##################################################################### +## tst_qaction Test: +##################################################################### + +add_qt_test(tst_qaction + SOURCES + tst_qaction.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 1247f48dd0..b4c259a1ef 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -33,6 +33,7 @@ #include <qapplication.h> #include <qevent.h> #include <qaction.h> +#include <qactiongroup.h> #include <qmenu.h> #include <qpa/qplatformtheme.h> #include <qpa/qplatformintegration.h> @@ -50,25 +51,20 @@ public: private slots: void init(); void cleanup(); - void getSetCheck(); - void setText_data(); - void setText(); - void setIconText_data() { setText_data(); } - void setIconText(); void setUnknownFont(); void actionEvent(); - void setStandardKeys(); +#if QT_CONFIG(shortcut) void alternateShortcuts(); void enabledVisibleInteraction(); - void task200823_tooltip(); - void task229128TriggeredSignalWithoutActiongroup(); +#endif void task229128TriggeredSignalWhenInActiongroup(); +#if QT_CONFIG(shortcut) void repeat(); - void setData(); void keysequence(); // QTBUG-53381 void disableShortcutsWithBlockedWidgets_data(); void disableShortcutsWithBlockedWidgets(); void shortcutFromKeyEvent(); // QTBUG-48325 +#endif private: QEvent::Type m_lastEventType; @@ -92,33 +88,6 @@ void tst_QAction::cleanup() QVERIFY(QApplication::topLevelWidgets().isEmpty()); } -// Testing get/set functions -void tst_QAction::getSetCheck() -{ - QAction obj1(nullptr); - // QActionGroup * QAction::actionGroup() - // void QAction::setActionGroup(QActionGroup *) - QActionGroup *var1 = new QActionGroup(nullptr); - obj1.setActionGroup(var1); - QCOMPARE(var1, obj1.actionGroup()); - obj1.setActionGroup(nullptr); - QCOMPARE(obj1.actionGroup(), nullptr); - delete var1; - - // QMenu * QAction::menu() - // void QAction::setMenu(QMenu *) - QMenu *var2 = new QMenu(nullptr); - obj1.setMenu(var2); - QCOMPARE(var2, obj1.menu()); - obj1.setMenu(nullptr); - QCOMPARE(obj1.menu(), nullptr); - delete var2; - - QCOMPARE(obj1.priority(), QAction::NormalPriority); - obj1.setPriority(QAction::LowPriority); - QCOMPARE(obj1.priority(), QAction::LowPriority); -} - class MyWidget : public QWidget { Q_OBJECT @@ -133,43 +102,6 @@ private: tst_QAction *m_test; }; -void tst_QAction::setText_data() -{ - QTest::addColumn<QString>("text"); - QTest::addColumn<QString>("iconText"); - QTest::addColumn<QString>("textFromIconText"); - - //next we fill it with data - QTest::newRow("Normal") << "Action" << "Action" << "Action"; - QTest::newRow("Ampersand") << "Search && Destroy" << "Search & Destroy" << "Search && Destroy"; - QTest::newRow("Mnemonic and ellipsis") << "O&pen File ..." << "Open File" << "Open File"; -} - -void tst_QAction::setText() -{ - QFETCH(QString, text); - - QAction action(nullptr); - action.setText(text); - - QCOMPARE(action.text(), text); - - QFETCH(QString, iconText); - QCOMPARE(action.iconText(), iconText); -} - -void tst_QAction::setIconText() -{ - QFETCH(QString, iconText); - - QAction action(nullptr); - action.setIconText(iconText); - QCOMPARE(action.iconText(), iconText); - - QFETCH(QString, textFromIconText); - QCOMPARE(action.text(), textFromIconText); -} - void tst_QAction::setUnknownFont() // QTBUG-42728 { QAction action(nullptr); @@ -221,34 +153,7 @@ void tst_QAction::actionEvent() QCOMPARE(m_lastAction, &a); } -//basic testing of standard keys -void tst_QAction::setStandardKeys() -{ - QAction act(nullptr); - act.setShortcut(QKeySequence("CTRL+L")); - QList<QKeySequence> list; - act.setShortcuts(list); - act.setShortcuts(QKeySequence::Copy); - QCOMPARE(act.shortcut(), act.shortcuts().constFirst()); - - QList<QKeySequence> expected; - const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); - const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); - switch (m_keyboardScheme) { - case QPlatformTheme::MacKeyboardScheme: - expected << ctrlC; - break; - case QPlatformTheme::WindowsKeyboardScheme: - expected << ctrlC << ctrlInsert; - break; - default: // X11 - expected << ctrlC << ctrlInsert << QKeySequence(QStringLiteral("F16")); - break; - } - - QCOMPARE(act.shortcuts(), expected); -} - +#if QT_CONFIG(shortcut) void tst_QAction::alternateShortcuts() { @@ -354,38 +259,7 @@ void tst_QAction::enabledVisibleInteraction() QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger } -void tst_QAction::task200823_tooltip() -{ - const QScopedPointer<QAction> action(new QAction("foo", nullptr)); - QString shortcut("ctrl+o"); - action->setShortcut(shortcut); - - // we want a non-standard tooltip that shows the shortcut - action->setToolTip(action->text() + QLatin1String(" (") + action->shortcut().toString() + QLatin1Char(')')); - - QString ref = QLatin1String("foo (") + QKeySequence(shortcut).toString() + QLatin1Char(')'); - QCOMPARE(action->toolTip(), ref); -} - -void tst_QAction::task229128TriggeredSignalWithoutActiongroup() -{ - // test without a group - const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr)); - QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered)); - QCOMPARE(spyWithoutGroup.count(), 0); - actionWithoutGroup->trigger(); - // signal should be emitted - QCOMPARE(spyWithoutGroup.count(), 1); - - // it is now a checkable checked action - actionWithoutGroup->setCheckable(true); - actionWithoutGroup->setChecked(true); - spyWithoutGroup.clear(); - QCOMPARE(spyWithoutGroup.count(), 0); - actionWithoutGroup->trigger(); - // signal should be emitted - QCOMPARE(spyWithoutGroup.count(), 1); -} +#endif // QT_CONFIG(shortcut) void tst_QAction::task229128TriggeredSignalWhenInActiongroup() { @@ -408,6 +282,8 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup() QCOMPARE(actionSpy.count(), 1); } +#if QT_CONFIG(shortcut) + void tst_QAction::repeat() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -452,21 +328,6 @@ void tst_QAction::repeat() QCOMPARE(spy.count(), 2); } -void tst_QAction::setData() // QTBUG-62006 -{ - QAction act(nullptr); - QSignalSpy spy(&act, &QAction::changed); - QCOMPARE(act.data(), QVariant()); - QCOMPARE(spy.count(), 0); - act.setData(QVariant()); - QCOMPARE(spy.count(), 0); - - act.setData(-1); - QCOMPARE(spy.count(), 1); - act.setData(-1); - QCOMPARE(spy.count(), 1); -} - void tst_QAction::disableShortcutsWithBlockedWidgets_data() { QTest::addColumn<Qt::ShortcutContext>("shortcutContext"); @@ -556,5 +417,7 @@ void tst_QAction::shortcutFromKeyEvent() QCOMPARE(testWidget.shortcutOverrideCount, 1); } +#endif // QT_CONFIG(shortcut) + QTEST_MAIN(tst_QAction) #include "tst_qaction.moc" diff --git a/tests/auto/widgets/kernel/qactiongroup/CMakeLists.txt b/tests/auto/widgets/kernel/qactiongroup/CMakeLists.txt new file mode 100644 index 0000000000..a55acf2efb --- /dev/null +++ b/tests/auto/widgets/kernel/qactiongroup/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qactiongroup.pro. + +##################################################################### +## tst_qactiongroup Test: +##################################################################### + +add_qt_test(tst_qactiongroup + SOURCES + tst_qactiongroup.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp index 524040d003..539ff9c67f 100644 --- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp +++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp @@ -31,6 +31,7 @@ #include <qmainwindow.h> #include <qmenu.h> #include <qaction.h> +#include <qactiongroup.h> class tst_QActionGroup : public QObject { @@ -38,166 +39,9 @@ class tst_QActionGroup : public QObject private slots: void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } - void enabledPropagation(); - void visiblePropagation(); - void exclusive(); - void exclusiveOptional(); void separators(); - void testActionInTwoQActionGroup(); - void unCheckCurrentAction(); }; -void tst_QActionGroup::enabledPropagation() -{ - QActionGroup testActionGroup(nullptr); - - QAction* childAction = new QAction( &testActionGroup ); - QAction* anotherChildAction = new QAction( &testActionGroup ); - QAction* freeAction = new QAction(nullptr); - - QVERIFY( testActionGroup.isEnabled() ); - QVERIFY( childAction->isEnabled() ); - - testActionGroup.setEnabled( false ); - QVERIFY( !testActionGroup.isEnabled() ); - QVERIFY( !childAction->isEnabled() ); - QVERIFY( !anotherChildAction->isEnabled() ); - - childAction->setEnabled(true); - QVERIFY( !childAction->isEnabled()); - - anotherChildAction->setEnabled( false ); - - testActionGroup.setEnabled( true ); - QVERIFY( testActionGroup.isEnabled() ); - QVERIFY( childAction->isEnabled() ); - QVERIFY( !anotherChildAction->isEnabled() ); - - testActionGroup.setEnabled( false ); - QAction *lastChildAction = new QAction(&testActionGroup); - - QVERIFY(!lastChildAction->isEnabled()); - testActionGroup.setEnabled( true ); - QVERIFY(lastChildAction->isEnabled()); - - freeAction->setEnabled(false); - testActionGroup.addAction(freeAction); - QVERIFY(!freeAction->isEnabled()); - delete freeAction; -} - -void tst_QActionGroup::visiblePropagation() -{ - QActionGroup testActionGroup(nullptr); - - QAction* childAction = new QAction( &testActionGroup ); - QAction* anotherChildAction = new QAction( &testActionGroup ); - QAction* freeAction = new QAction(nullptr); - - QVERIFY( testActionGroup.isVisible() ); - QVERIFY( childAction->isVisible() ); - - testActionGroup.setVisible( false ); - QVERIFY( !testActionGroup.isVisible() ); - QVERIFY( !childAction->isVisible() ); - QVERIFY( !anotherChildAction->isVisible() ); - - anotherChildAction->setVisible(false); - - testActionGroup.setVisible( true ); - QVERIFY( testActionGroup.isVisible() ); - QVERIFY( childAction->isVisible() ); - - QVERIFY( !anotherChildAction->isVisible() ); - - testActionGroup.setVisible( false ); - QAction *lastChildAction = new QAction(&testActionGroup); - - QVERIFY(!lastChildAction->isVisible()); - testActionGroup.setVisible( true ); - QVERIFY(lastChildAction->isVisible()); - - freeAction->setVisible(false); - testActionGroup.addAction(freeAction); - QVERIFY(!freeAction->isVisible()); - delete freeAction; -} - -void tst_QActionGroup::exclusive() -{ - QActionGroup group(nullptr); - group.setExclusive(false); - QVERIFY( !group.isExclusive() ); - - QAction* actOne = new QAction( &group ); - actOne->setCheckable( true ); - QAction* actTwo = new QAction( &group ); - actTwo->setCheckable( true ); - QAction* actThree = new QAction( &group ); - actThree->setCheckable( true ); - - group.setExclusive( true ); - QVERIFY( !actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - actOne->setChecked( true ); - QVERIFY( actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - actTwo->setChecked( true ); - QVERIFY( !actOne->isChecked() ); - QVERIFY( actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); -} - -void tst_QActionGroup::exclusiveOptional() -{ - QActionGroup group(0); - group.setExclusive(true); - QVERIFY( group.isExclusive() ); - - QAction* actOne = new QAction( &group ); - actOne->setCheckable( true ); - QAction* actTwo = new QAction( &group ); - actTwo->setCheckable( true ); - QAction* actThree = new QAction( &group ); - actThree->setCheckable( true ); - - QVERIFY( !actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - actOne->trigger(); - QVERIFY( actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - actOne->trigger(); - QVERIFY( actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - group.setExclusionPolicy( QActionGroup::ExclusionPolicy::ExclusiveOptional ); - QVERIFY( group.isExclusive() ); - - actOne->trigger(); - QVERIFY( !actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - actTwo->trigger(); - QVERIFY( !actOne->isChecked() ); - QVERIFY( actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); - - actTwo->trigger(); - QVERIFY( !actOne->isChecked() ); - QVERIFY( !actTwo->isChecked() ); - QVERIFY( !actThree->isChecked() ); -} - void tst_QActionGroup::separators() { QMainWindow mw; @@ -233,40 +77,5 @@ void tst_QActionGroup::separators() QCOMPARE(menu.actions().size(), 3); } -void tst_QActionGroup::testActionInTwoQActionGroup() -{ - QAction action1("Action 1", this); - - QActionGroup group1(this); - QActionGroup group2(this); - - group1.addAction(&action1); - group2.addAction(&action1); - - QCOMPARE(action1.actionGroup(), &group2); - QCOMPARE(group2.actions().first(), &action1); - QCOMPARE(group1.actions().isEmpty(), true); -} - -void tst_QActionGroup::unCheckCurrentAction() -{ - QActionGroup group(nullptr); - QAction action1(&group) ,action2(&group); - action1.setCheckable(true); - action2.setCheckable(true); - QVERIFY(!action1.isChecked()); - QVERIFY(!action2.isChecked()); - action1.setChecked(true); - QVERIFY(action1.isChecked()); - QVERIFY(!action2.isChecked()); - QAction *current = group.checkedAction(); - QCOMPARE(current, &action1); - current->setChecked(false); - QVERIFY(!action1.isChecked()); - QVERIFY(!action2.isChecked()); - QVERIFY(!group.checkedAction()); -} - - QTEST_MAIN(tst_QActionGroup) #include "tst_qactiongroup.moc" diff --git a/tests/auto/widgets/kernel/qapplication/CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/CMakeLists.txt new file mode 100644 index 0000000000..8e68089f5e --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/CMakeLists.txt @@ -0,0 +1,7 @@ +# Generated from qapplication.pro. + +add_subdirectory(test) +if(NOT WINRT) + add_subdirectory(desktopsettingsaware) + add_subdirectory(modal) +endif() diff --git a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/.prev_CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/.prev_CMakeLists.txt new file mode 100644 index 0000000000..df5f5f4e6c --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/.prev_CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from desktopsettingsaware.pro. + +##################################################################### +## desktopsettingsaware Binary: +##################################################################### + +add_qt_executable(desktopsettingsaware + SOURCES + main.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +## Scopes: +##################################################################### diff --git a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/CMakeLists.txt new file mode 100644 index 0000000000..98a38da7c0 --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from desktopsettingsaware.pro. + +##################################################################### +## desktopsettingsaware Binary: +##################################################################### + +add_qt_executable(desktopsettingsaware_helper # special case + SOURCES + main.cpp + OUTPUT_DIRECTORY # special case + ${CMAKE_CURRENT_BINARY_DIR}/.. # special case + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +## Scopes: +##################################################################### diff --git a/tests/auto/widgets/kernel/qapplication/modal/.prev_CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/modal/.prev_CMakeLists.txt new file mode 100644 index 0000000000..fc990e790e --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/modal/.prev_CMakeLists.txt @@ -0,0 +1,17 @@ +# Generated from modal.pro. + +##################################################################### +## modal Binary: +##################################################################### + +add_qt_executable(modal + SOURCES + base.cpp base.h + main.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +## Scopes: +##################################################################### diff --git a/tests/auto/widgets/kernel/qapplication/modal/CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/modal/CMakeLists.txt new file mode 100644 index 0000000000..c598ca600a --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/modal/CMakeLists.txt @@ -0,0 +1,19 @@ +# Generated from modal.pro. + +##################################################################### +## modal Binary: +##################################################################### + +add_qt_executable(modal_helper # special case + SOURCES + base.cpp base.h + main.cpp + OUTPUT_DIRECTORY # special case + ${CMAKE_CURRENT_BINARY_DIR}/.. # special case + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +## Scopes: +##################################################################### diff --git a/tests/auto/widgets/kernel/qapplication/test/.prev_CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/test/.prev_CMakeLists.txt new file mode 100644 index 0000000000..40e612f0de --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/test/.prev_CMakeLists.txt @@ -0,0 +1,42 @@ +# Generated from test.pro. + +##################################################################### +## test Test: +##################################################################### + +# Collect test data +list(APPEND test_data "../test/test.pro") +list(APPEND test_data "../tmp/README") +list(APPEND test_data "../modal") + +add_qt_test(test + SOURCES + ../tst_qapplication.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate + TESTDATA ${test_data} +) + +## Scopes: +##################################################################### + +extend_target(test CONDITION builtin_testdata + DEFINES + BUILTIN_TESTDATA +) + +#### Keys ignored in scope 3:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# SUBPROGRAMS = "desktopsettingsaware" "modal" + +#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# TEST_HELPER_INSTALLS = "../debug/helper" + +#### Keys ignored in scope 8:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# TEST_HELPER_INSTALLS = "../release/helper" + +#### Keys ignored in scope 10:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# TEST_HELPER_INSTALLS = "../helper" diff --git a/tests/auto/widgets/kernel/qapplication/test/CMakeLists.txt b/tests/auto/widgets/kernel/qapplication/test/CMakeLists.txt new file mode 100644 index 0000000000..171ee1b273 --- /dev/null +++ b/tests/auto/widgets/kernel/qapplication/test/CMakeLists.txt @@ -0,0 +1,43 @@ +# Generated from test.pro. + +##################################################################### +## test Test: +##################################################################### + +# Collect test data +list(APPEND test_data "../test/test.pro") +list(APPEND test_data "../tmp/README") +list(APPEND test_data "../modal") + +add_qt_test(tst_qapplication # special case + SOURCES + ../tst_qapplication.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate + TESTDATA ${test_data} + OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." # special case +) + +## Scopes: +##################################################################### + +extend_target(tst_qapplication CONDITION builtin_testdata # special case + DEFINES + BUILTIN_TESTDATA +) + +#### Keys ignored in scope 3:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# SUBPROGRAMS = "desktopsettingsaware" "modal" + +#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# TEST_HELPER_INSTALLS = "../debug/helper" + +#### Keys ignored in scope 8:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# TEST_HELPER_INSTALLS = "../release/helper" + +#### Keys ignored in scope 10:.:.:test.pro:NOT ANDROID AND NOT WINRT: +# TEST_HELPER_INSTALLS = "../helper" diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 9ab7e4e315..59ea12ce70 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -2207,8 +2207,6 @@ void tst_QApplication::staticFunctions() QApplication::setActiveWindow(nullptr); QApplication::widgetAt(QPoint(0, 0)); QApplication::topLevelAt(QPoint(0, 0)); - QApplication::setGlobalStrut(QSize(0, 0)); - QApplication::globalStrut(); QApplication::isEffectEnabled(Qt::UI_General); QApplication::setEffectEnabled(Qt::UI_General, false); } diff --git a/tests/auto/widgets/kernel/qboxlayout/CMakeLists.txt b/tests/auto/widgets/kernel/qboxlayout/CMakeLists.txt new file mode 100644 index 0000000000..901d20f1e3 --- /dev/null +++ b/tests/auto/widgets/kernel/qboxlayout/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qboxlayout.pro. + +##################################################################### +## tst_qboxlayout Test: +##################################################################### + +add_qt_test(tst_qboxlayout + SOURCES + tst_qboxlayout.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qdesktopwidget/CMakeLists.txt b/tests/auto/widgets/kernel/qdesktopwidget/CMakeLists.txt new file mode 100644 index 0000000000..79790049fe --- /dev/null +++ b/tests/auto/widgets/kernel/qdesktopwidget/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qdesktopwidget.pro. + +##################################################################### +## tst_qdesktopwidget Test: +##################################################################### + +add_qt_test(tst_qdesktopwidget + SOURCES + tst_qdesktopwidget.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qformlayout/CMakeLists.txt b/tests/auto/widgets/kernel/qformlayout/CMakeLists.txt new file mode 100644 index 0000000000..f786f3331c --- /dev/null +++ b/tests/auto/widgets/kernel/qformlayout/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qformlayout.pro. + +##################################################################### +## tst_qformlayout Test: +##################################################################### + +add_qt_test(tst_qformlayout + SOURCES + tst_qformlayout.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index c6760000f4..45a35fe4f1 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -99,7 +99,9 @@ class tst_QFormLayout : public QObject private slots: void cleanup(); void rowCount(); +#if QT_CONFIG(shortcut) void buddies(); +#endif void getItemPosition(); void wrapping(); void spacing(); @@ -190,6 +192,8 @@ void tst_QFormLayout::rowCount() //TODO: remove items } +#if QT_CONFIG(shortcut) + void tst_QFormLayout::buddies() { QWidget w; @@ -218,6 +222,8 @@ void tst_QFormLayout::buddies() //TODO: empty label? } +#endif // QT_CONFIG(shortcut) + void tst_QFormLayout::getItemPosition() { QWidget w; @@ -687,17 +693,21 @@ void tst_QFormLayout::insertRow_QString_QWidget() layout->insertRow(-5, "&Name:", fld1); QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label1 != 0); +#if QT_CONFIG(shortcut) QCOMPARE(label1->buddy(), fld1); - +#endif layout->insertRow(0, "&Email:", fld2); QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label2 != 0); +#if QT_CONFIG(shortcut) QCOMPARE(label2->buddy(), fld2); - +#endif layout->insertRow(5, "&Age:", fld3); QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QVERIFY(label3 != 0); +#if QT_CONFIG(shortcut) QCOMPARE(label3->buddy(), fld3); +#endif } void tst_QFormLayout::insertRow_QString_QLayout() @@ -711,21 +721,27 @@ void tst_QFormLayout::insertRow_QString_QLayout() layout->insertRow(-5, "&Name:", fld1); QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label1 != 0); +#if QT_CONFIG(shortcut) QVERIFY(!label1->buddy()); +#endif QCOMPARE(layout->rowCount(), 1); layout->insertRow(0, "&Email:", fld2); QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget()); QVERIFY(label2 != 0); +#if QT_CONFIG(shortcut) QVERIFY(!label2->buddy()); +#endif QCOMPARE(layout->rowCount(), 2); layout->insertRow(5, "&Age:", fld3); QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget()); QVERIFY(label3 != 0); +#if QT_CONFIG(shortcut) QVERIFY(!label3->buddy()); +#endif QCOMPARE(layout->rowCount(), 3); } diff --git a/tests/auto/widgets/kernel/qgesturerecognizer/CMakeLists.txt b/tests/auto/widgets/kernel/qgesturerecognizer/CMakeLists.txt new file mode 100644 index 0000000000..61bf8d303a --- /dev/null +++ b/tests/auto/widgets/kernel/qgesturerecognizer/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qgesturerecognizer.pro. + +##################################################################### +## tst_qgesturerecognizer Test: +##################################################################### + +add_qt_test(tst_qgesturerecognizer + SOURCES + tst_qgesturerecognizer.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qgridlayout/CMakeLists.txt b/tests/auto/widgets/kernel/qgridlayout/CMakeLists.txt new file mode 100644 index 0000000000..79995454f7 --- /dev/null +++ b/tests/auto/widgets/kernel/qgridlayout/CMakeLists.txt @@ -0,0 +1,20 @@ +# Generated from qgridlayout.pro. + +##################################################################### +## tst_qgridlayout Test: +##################################################################### + +add_qt_test(tst_qgridlayout + SOURCES + sortdialog.ui + tst_qgridlayout.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate + ENABLE_AUTOGEN_TOOLS + uic +) diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 1d63d140fb..26dbab5e15 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -449,33 +449,33 @@ class Qt42Style : public QProxyStyle public: Qt42Style() : QProxyStyle(QStyleFactory::create("windows")) { - spacing = 6; - margin = 9; - margin_toplevel = 11; } - virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, - const QWidget * widget = 0 ) const; + virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = nullptr, + const QWidget * widget = nullptr ) const; - int spacing; - int margin; - int margin_toplevel; + int spacing = 6; + int margin = 9; + int margin_toplevel = 11; }; -int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * option /*= 0*/, - const QWidget * widget /*= 0*/ ) const +int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * option, + const QWidget * widget) const { switch (metric) { - case PM_DefaultLayoutSpacing: - return spacing; - break; - case PM_DefaultTopLevelMargin: - return margin_toplevel; - break; - case PM_DefaultChildMargin: + case PM_LayoutLeftMargin: + case PM_LayoutRightMargin: + case PM_LayoutTopMargin: + case PM_LayoutBottomMargin: + if (option && option->state & State_Window) + return margin_toplevel; + if (widget && widget->isWindow()) + return margin_toplevel; return margin; - break; + case PM_LayoutHorizontalSpacing: + case PM_LayoutVerticalSpacing: + return spacing; default: break; } diff --git a/tests/auto/widgets/kernel/qlayout/CMakeLists.txt b/tests/auto/widgets/kernel/qlayout/CMakeLists.txt new file mode 100644 index 0000000000..e63a80117f --- /dev/null +++ b/tests/auto/widgets/kernel/qlayout/CMakeLists.txt @@ -0,0 +1,39 @@ +# Generated from qlayout.pro. + +##################################################################### +## tst_qlayout Test: +##################################################################### + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + baseline/*) +list(APPEND test_data ${test_data_glob}) + +add_qt_test(tst_qlayout + SOURCES + tst_qlayout.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate + TESTDATA ${test_data} +) + +## Scopes: +##################################################################### + +if(ANDROID AND NOT ANDROID_EMBEDDED) + # Resources: + set(testdata_resource_files + "baseline/smartmaxsize" + ) + + add_qt_resource(tst_qlayout "testdata" + PREFIX + "/" + FILES + ${testdata_resource_files} + ) +endif() diff --git a/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt b/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt new file mode 100644 index 0000000000..5d077c87ec --- /dev/null +++ b/tests/auto/widgets/kernel/qshortcut/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qshortcut.pro. + +##################################################################### +## tst_qshortcut Test: +##################################################################### + +add_qt_test(tst_qshortcut + SOURCES + tst_qshortcut.cpp + INCLUDE_DIRECTORIES + .. + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qsizepolicy/CMakeLists.txt b/tests/auto/widgets/kernel/qsizepolicy/CMakeLists.txt new file mode 100644 index 0000000000..582f0d582d --- /dev/null +++ b/tests/auto/widgets/kernel/qsizepolicy/CMakeLists.txt @@ -0,0 +1,17 @@ +# Generated from qsizepolicy.pro. + +##################################################################### +## tst_qsizepolicy Test: +##################################################################### + +add_qt_test(tst_qsizepolicy + SOURCES + tst_qsizepolicy.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### diff --git a/tests/auto/widgets/kernel/qstackedlayout/CMakeLists.txt b/tests/auto/widgets/kernel/qstackedlayout/CMakeLists.txt new file mode 100644 index 0000000000..a41957c9a6 --- /dev/null +++ b/tests/auto/widgets/kernel/qstackedlayout/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qstackedlayout.pro. + +##################################################################### +## tst_qstackedlayout Test: +##################################################################### + +add_qt_test(tst_qstackedlayout + SOURCES + tst_qstackedlayout.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qtooltip/CMakeLists.txt b/tests/auto/widgets/kernel/qtooltip/CMakeLists.txt new file mode 100644 index 0000000000..f63b6e63cd --- /dev/null +++ b/tests/auto/widgets/kernel/qtooltip/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtooltip.pro. + +##################################################################### +## tst_qtooltip Test: +##################################################################### + +add_qt_test(tst_qtooltip + SOURCES + tst_qtooltip.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qwidget/CMakeLists.txt b/tests/auto/widgets/kernel/qwidget/CMakeLists.txt new file mode 100644 index 0000000000..dc47e7d9d9 --- /dev/null +++ b/tests/auto/widgets/kernel/qwidget/CMakeLists.txt @@ -0,0 +1,58 @@ +# Generated from qwidget.pro. + +##################################################################### +## tst_qwidget Test: +##################################################################### + +add_qt_test(tst_qwidget + SOURCES + tst_qwidget.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +# Resources: +set(qwidget_resource_files + "geometry-fullscreen.dat" + "geometry-maximized.dat" + "geometry.dat" + "hellotr_la.qm" +) + +add_qt_resource(tst_qwidget "qwidget" + PREFIX + "/" + FILES + ${qwidget_resource_files} +) + + +#### Keys ignored in scope 1:.:.:qwidget.pro:<TRUE>: +# testcase.timeout = "600" + +## Scopes: +##################################################################### + +extend_target(tst_qwidget CONDITION AIX + COMPILE_OPTIONS + -fpermissive +) + +extend_target(tst_qwidget CONDITION APPLE + SOURCES + tst_qwidget_mac_helpers.mm + PUBLIC_LIBRARIES + ${FWAppKit} + ${FWSecurity} +) + +extend_target(tst_qwidget CONDITION WIN32 AND NOT WINRT + PUBLIC_LIBRARIES + gdi32 + user32 +) diff --git a/tests/auto/widgets/kernel/qwidget_window/CMakeLists.txt b/tests/auto/widgets/kernel/qwidget_window/CMakeLists.txt new file mode 100644 index 0000000000..201c271103 --- /dev/null +++ b/tests/auto/widgets/kernel/qwidget_window/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qwidget_window.pro. + +##################################################################### +## tst_qwidget_window Test: +##################################################################### + +add_qt_test(tst_qwidget_window + SOURCES + tst_qwidget_window.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qwidgetaction/CMakeLists.txt b/tests/auto/widgets/kernel/qwidgetaction/CMakeLists.txt new file mode 100644 index 0000000000..06a4156b57 --- /dev/null +++ b/tests/auto/widgets/kernel/qwidgetaction/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qwidgetaction.pro. + +##################################################################### +## tst_qwidgetaction Test: +##################################################################### + +add_qt_test(tst_qwidgetaction + SOURCES + tst_qwidgetaction.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qwidgetmetatype/CMakeLists.txt b/tests/auto/widgets/kernel/qwidgetmetatype/CMakeLists.txt new file mode 100644 index 0000000000..dd935fdbd7 --- /dev/null +++ b/tests/auto/widgets/kernel/qwidgetmetatype/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qwidgetmetatype.pro. + +##################################################################### +## tst_qwidgetmetatype Test: +##################################################################### + +add_qt_test(tst_qwidgetmetatype + SOURCES + tst_qwidgetmetatype.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/CMakeLists.txt b/tests/auto/widgets/kernel/qwidgetsvariant/CMakeLists.txt new file mode 100644 index 0000000000..076f66cd78 --- /dev/null +++ b/tests/auto/widgets/kernel/qwidgetsvariant/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qwidgetsvariant.pro. + +##################################################################### +## tst_qwidgetsvariant Test: +##################################################################### + +add_qt_test(tst_qwidgetsvariant + SOURCES + tst_qwidgetsvariant.cpp + INCLUDE_DIRECTORIES + ../../../other/qvariant_common + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/kernel/qwindowcontainer/CMakeLists.txt b/tests/auto/widgets/kernel/qwindowcontainer/CMakeLists.txt new file mode 100644 index 0000000000..63b8b44e6f --- /dev/null +++ b/tests/auto/widgets/kernel/qwindowcontainer/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qwindowcontainer.pro. + +##################################################################### +## tst_qwindowcontainer Test: +##################################################################### + +add_qt_test(tst_qwindowcontainer + SOURCES + tst_qwindowcontainer.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/styles/CMakeLists.txt b/tests/auto/widgets/styles/CMakeLists.txt new file mode 100644 index 0000000000..4ded7b9d80 --- /dev/null +++ b/tests/auto/widgets/styles/CMakeLists.txt @@ -0,0 +1,12 @@ +# Generated from styles.pro. + +if (MACOS) + add_subdirectory(qmacstyle) +endif() +add_subdirectory(qstyle) +if (NOT UIKIT AND NOT ANDROID AND NOT QNX) + add_subdirectory(qstyleoption) +endif() +if (QT_FEATURE_private_tests) + add_subdirectory(qstylesheetstyle) +endif() diff --git a/tests/auto/widgets/styles/qmacstyle/CMakeLists.txt b/tests/auto/widgets/styles/qmacstyle/CMakeLists.txt new file mode 100644 index 0000000000..44053dbe3d --- /dev/null +++ b/tests/auto/widgets/styles/qmacstyle/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qmacstyle.pro. + +##################################################################### +## tst_qmacstyle Test: +##################################################################### + +add_qt_test(tst_qmacstyle + SOURCES + tst_qmacstyle.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/styles/qstyle/CMakeLists.txt b/tests/auto/widgets/styles/qstyle/CMakeLists.txt new file mode 100644 index 0000000000..21d81113f4 --- /dev/null +++ b/tests/auto/widgets/styles/qstyle/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qstyle.pro. + +##################################################################### +## tst_qstyle Test: +##################################################################### + +add_qt_test(tst_qstyle + SOURCES + tst_qstyle.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 4cec54856f..58dbfeb118 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -83,7 +83,6 @@ private slots: #endif void testStyleFactory(); void testProxyStyle(); - void pixelMetric(); #if !defined(QT_NO_STYLE_WINDOWS) && !defined(QT_NO_STYLE_FUSION) void progressBarChangeStyle(); #endif @@ -348,57 +347,6 @@ void MyWidget::paintEvent(QPaintEvent *) } -class Qt42Style : public QCommonStyle -{ - Q_OBJECT -public: - int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, - const QWidget *widget = nullptr) const override; - - int margin_toplevel = 10; - int margin = 5; - int spacing = 0; -}; - -int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * /* option = 0*/, - const QWidget * /* widget = 0*/ ) const -{ - switch (metric) { - case QStyle::PM_DefaultTopLevelMargin: - return margin_toplevel; - case QStyle::PM_DefaultChildMargin: - return margin; - case QStyle::PM_DefaultLayoutSpacing: - return spacing; - default: - break; - } - return -1; -} - - -void tst_QStyle::pixelMetric() -{ - QScopedPointer<Qt42Style> style(new Qt42Style); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), 10); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), 5); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), 0); - - style->margin_toplevel = 0; - style->margin = 0; - style->spacing = 0; - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), 0); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), 0); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), 0); - - style->margin_toplevel = -1; - style->margin = -1; - style->spacing = -1; - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), -1); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), -1); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), -1); -} - #if !defined(QT_NO_STYLE_WINDOWS) && !defined(QT_NO_STYLE_FUSION) void tst_QStyle::progressBarChangeStyle() { diff --git a/tests/auto/widgets/styles/qstyleoption/CMakeLists.txt b/tests/auto/widgets/styles/qstyleoption/CMakeLists.txt new file mode 100644 index 0000000000..e174057cbb --- /dev/null +++ b/tests/auto/widgets/styles/qstyleoption/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qstyleoption.pro. + +##################################################################### +## tst_qstyleoption Test: +##################################################################### + +add_qt_test(tst_qstyleoption + SOURCES + tst_qstyleoption.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) + +#### Keys ignored in scope 1:.:.:qstyleoption.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/auto/widgets/styles/qstylesheetstyle/CMakeLists.txt b/tests/auto/widgets/styles/qstylesheetstyle/CMakeLists.txt new file mode 100644 index 0000000000..01c4df38fe --- /dev/null +++ b/tests/auto/widgets/styles/qstylesheetstyle/CMakeLists.txt @@ -0,0 +1,37 @@ +# Generated from qstylesheetstyle.pro. + +if(NOT QT_FEATURE_private_tests) + return() +endif() + +##################################################################### +## tst_qstylesheetstyle Test: +##################################################################### + +add_qt_test(tst_qstylesheetstyle + SOURCES + tst_qstylesheetstyle.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +# Resources: +set(resources_resource_files + "images/testimage.png" + "images/testimage@2x.png" +) + +add_qt_resource(tst_qstylesheetstyle "resources" + PREFIX + "/" + FILES + ${resources_resource_files} +) + + +#### Keys ignored in scope 1:.:.:qstylesheetstyle.pro:<TRUE>: +# _REQUIREMENTS = "qtConfig(private_tests)" diff --git a/tests/auto/widgets/util/CMakeLists.txt b/tests/auto/widgets/util/CMakeLists.txt new file mode 100644 index 0000000000..20accb3150 --- /dev/null +++ b/tests/auto/widgets/util/CMakeLists.txt @@ -0,0 +1,5 @@ +# Generated from util.pro. + +add_subdirectory(qcompleter) +add_subdirectory(qscroller) +add_subdirectory(qsystemtrayicon) diff --git a/tests/auto/widgets/util/qcompleter/CMakeLists.txt b/tests/auto/widgets/util/qcompleter/CMakeLists.txt new file mode 100644 index 0000000000..fb87c3beec --- /dev/null +++ b/tests/auto/widgets/util/qcompleter/CMakeLists.txt @@ -0,0 +1,17 @@ +# Generated from qcompleter.pro. + +##################################################################### +## tst_qcompleter Test: +##################################################################### + +add_qt_test(tst_qcompleter + SOURCES + tst_qcompleter.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) + +#### Keys ignored in scope 1:.:.:qcompleter.pro:<TRUE>: +# TEMPLATE = "app" diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 89c4a74739..fe3e3c7f72 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1807,7 +1807,7 @@ void tst_QCompleter::QTBUG_52028_tabAutoCompletes() QApplication::setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); - QSignalSpy activatedSpy(&cbox, QOverload<int>::of(&QComboBox::activated)); + QSignalSpy activatedSpy(&cbox, &QComboBox::activated); // Tab key will complete but not activate cbox.lineEdit()->clear(); @@ -1851,7 +1851,7 @@ void tst_QCompleter::QTBUG_51889_activatedSentTwice() QApplication::setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); - QSignalSpy activatedSpy(&cbox, QOverload<int>::of(&QComboBox::activated)); + QSignalSpy activatedSpy(&cbox, &QComboBox::activated); // Navigate + enter activates only once (first item) cbox.lineEdit()->clear(); diff --git a/tests/auto/widgets/util/qscroller/CMakeLists.txt b/tests/auto/widgets/util/qscroller/CMakeLists.txt new file mode 100644 index 0000000000..b6c6efcc2f --- /dev/null +++ b/tests/auto/widgets/util/qscroller/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qscroller.pro. + +##################################################################### +## tst_qscroller Test: +##################################################################### + +add_qt_test(tst_qscroller + SOURCES + tst_qscroller.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/util/qsystemtrayicon/CMakeLists.txt b/tests/auto/widgets/util/qsystemtrayicon/CMakeLists.txt new file mode 100644 index 0000000000..df6efa7281 --- /dev/null +++ b/tests/auto/widgets/util/qsystemtrayicon/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qsystemtrayicon.pro. + +##################################################################### +## tst_qsystemtrayicon Test: +##################################################################### + +add_qt_test(tst_qsystemtrayicon + SOURCES + tst_qsystemtrayicon.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/util/qundogroup/.gitignore b/tests/auto/widgets/util/qundogroup/.gitignore deleted file mode 100644 index bc3e8c4691..0000000000 --- a/tests/auto/widgets/util/qundogroup/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qundogroup diff --git a/tests/auto/widgets/util/qundogroup/qundogroup.pro b/tests/auto/widgets/util/qundogroup/qundogroup.pro deleted file mode 100644 index bd8dac197b..0000000000 --- a/tests/auto/widgets/util/qundogroup/qundogroup.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -QT += widgets testlib -SOURCES += tst_qundogroup.cpp -TARGET = tst_qundogroup diff --git a/tests/auto/widgets/util/qundogroup/testdata/qundogroup.ts b/tests/auto/widgets/util/qundogroup/testdata/qundogroup.ts deleted file mode 100644 index a059bcb486..0000000000 --- a/tests/auto/widgets/util/qundogroup/testdata/qundogroup.ts +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.0" language="en"> -<context> - <name>QUndoGroup</name> - <message> - <source>Undo %1</source> - <translation>undo-prefix %1 undo-suffix</translation> - </message> - <message> - <source>Undo</source> - <comment>Default text for undo action</comment> - <translation>Undo-default-text</translation> - </message> - <message> - <source>Redo %1</source> - <translation>redo-prefix %1 redo-suffix</translation> - </message> - <message> - <source>Redo</source> - <comment>Default text for redo action</comment> - <translation>Redo-default-text</translation> - </message> -</context> -</TS> diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp deleted file mode 100644 index c1524d870d..0000000000 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ /dev/null @@ -1,641 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include <QtTest/QtTest> -#include <QUndoGroup> -#include <QUndoStack> -#include <QAction> - -/****************************************************************************** -** Commands -*/ - -class InsertCommand : public QUndoCommand -{ -public: - InsertCommand(QString *str, int idx, const QString &text, - QUndoCommand *parent = 0); - - virtual void undo(); - virtual void redo(); - -private: - QString *m_str; - int m_idx; - QString m_text; -}; - -class RemoveCommand : public QUndoCommand -{ -public: - RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent = 0); - - virtual void undo(); - virtual void redo(); - -private: - QString *m_str; - int m_idx; - QString m_text; -}; - -class AppendCommand : public QUndoCommand -{ -public: - AppendCommand(QString *str, const QString &text, QUndoCommand *parent = 0); - - virtual void undo(); - virtual void redo(); - virtual int id() const; - virtual bool mergeWith(const QUndoCommand *other); - - bool merged; - -private: - QString *m_str; - QString m_text; -}; - -InsertCommand::InsertCommand(QString *str, int idx, const QString &text, - QUndoCommand *parent) - : QUndoCommand(parent) -{ - QVERIFY(str->length() >= idx); - - setText("insert"); - - m_str = str; - m_idx = idx; - m_text = text; -} - -void InsertCommand::redo() -{ - QVERIFY(m_str->length() >= m_idx); - - m_str->insert(m_idx, m_text); -} - -void InsertCommand::undo() -{ - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); - - m_str->remove(m_idx, m_text.length()); -} - -RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent) - : QUndoCommand(parent) -{ - QVERIFY(str->length() >= idx + len); - - setText("remove"); - - m_str = str; - m_idx = idx; - m_text = m_str->mid(m_idx, len); -} - -void RemoveCommand::redo() -{ - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); - - m_str->remove(m_idx, m_text.length()); -} - -void RemoveCommand::undo() -{ - QVERIFY(m_str->length() >= m_idx); - - m_str->insert(m_idx, m_text); -} - -AppendCommand::AppendCommand(QString *str, const QString &text, QUndoCommand *parent) - : QUndoCommand(parent) -{ - setText("append"); - - m_str = str; - m_text = text; - merged = false; -} - -void AppendCommand::redo() -{ - m_str->append(m_text); -} - -void AppendCommand::undo() -{ - QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text); - - m_str->truncate(m_str->length() - m_text.length()); -} - -int AppendCommand::id() const -{ - return 1; -} - -bool AppendCommand::mergeWith(const QUndoCommand *other) -{ - if (other->id() != id()) - return false; - m_text += static_cast<const AppendCommand*>(other)->m_text; - merged = true; - return true; -} - -/****************************************************************************** -** tst_QUndoStack -*/ - -class tst_QUndoGroup : public QObject -{ - Q_OBJECT -public: - tst_QUndoGroup(); - -private slots: - void setActive(); - void addRemoveStack(); - void deleteStack(); - void checkSignals(); - void addStackAndDie(); - void commandTextFormat(); -}; - -tst_QUndoGroup::tst_QUndoGroup() -{ -} - -void tst_QUndoGroup::setActive() -{ - QUndoGroup group; - QUndoStack stack1(&group), stack2(&group); - - QCOMPARE(group.activeStack(), nullptr); - QCOMPARE(stack1.isActive(), false); - QCOMPARE(stack2.isActive(), false); - - QUndoStack stack3; - QCOMPARE(stack3.isActive(), true); - - group.addStack(&stack3); - QCOMPARE(stack3.isActive(), false); - - stack1.setActive(); - QCOMPARE(group.activeStack(), &stack1); - QCOMPARE(stack1.isActive(), true); - QCOMPARE(stack2.isActive(), false); - QCOMPARE(stack3.isActive(), false); - - group.setActiveStack(&stack2); - QCOMPARE(group.activeStack(), &stack2); - QCOMPARE(stack1.isActive(), false); - QCOMPARE(stack2.isActive(), true); - QCOMPARE(stack3.isActive(), false); - - group.removeStack(&stack2); - QCOMPARE(group.activeStack(), nullptr); - QCOMPARE(stack1.isActive(), false); - QCOMPARE(stack2.isActive(), true); - QCOMPARE(stack3.isActive(), false); - - group.removeStack(&stack2); - QCOMPARE(group.activeStack(), nullptr); - QCOMPARE(stack1.isActive(), false); - QCOMPARE(stack2.isActive(), true); - QCOMPARE(stack3.isActive(), false); -} - -void tst_QUndoGroup::addRemoveStack() -{ - QUndoGroup group; - - QUndoStack stack1(&group); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1); - - QUndoStack stack2; - group.addStack(&stack2); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1 << &stack2); - - group.addStack(&stack1); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1 << &stack2); - - group.removeStack(&stack1); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack2); - - group.removeStack(&stack1); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack2); - - group.removeStack(&stack2); - QCOMPARE(group.stacks(), QList<QUndoStack*>()); -} - -void tst_QUndoGroup::deleteStack() -{ - QUndoGroup group; - - QUndoStack *stack1 = new QUndoStack(&group); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1); - QCOMPARE(group.activeStack(), nullptr); - - stack1->setActive(); - QCOMPARE(group.activeStack(), stack1); - - QUndoStack *stack2 = new QUndoStack(&group); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1 << stack2); - QCOMPARE(group.activeStack(), stack1); - - QUndoStack *stack3 = new QUndoStack(&group); - QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1 << stack2 << stack3); - QCOMPARE(group.activeStack(), stack1); - - delete stack2; - QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1 << stack3); - QCOMPARE(group.activeStack(), stack1); - - delete stack1; - QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack3); - QCOMPARE(group.activeStack(), nullptr); - - stack3->setActive(false); - QCOMPARE(group.activeStack(), nullptr); - - stack3->setActive(true); - QCOMPARE(group.activeStack(), stack3); - - group.removeStack(stack3); - QCOMPARE(group.stacks(), QList<QUndoStack*>()); - QCOMPARE(group.activeStack(), nullptr); - - delete stack3; -} - -static QString glue(const QString &s1, const QString &s2) -{ - QString result; - - result.append(s1); - if (!s1.isEmpty() && !s2.isEmpty()) - result.append(' '); - result.append(s2); - - return result; -} - -#define CHECK_STATE(_activeStack, _clean, _canUndo, _undoText, _canRedo, _redoText, \ - _cleanChanged, _indexChanged, _undoChanged, _redoChanged) \ - QCOMPARE(group.activeStack(), (QUndoStack*)_activeStack); \ - QCOMPARE(group.isClean(), _clean); \ - QCOMPARE(group.canUndo(), _canUndo); \ - QCOMPARE(group.undoText(), QString(_undoText)); \ - QCOMPARE(group.canRedo(), _canRedo); \ - QCOMPARE(group.redoText(), QString(_redoText)); \ - if (_indexChanged) { \ - QCOMPARE(indexChangedSpy.count(), 1); \ - indexChangedSpy.clear(); \ - } else { \ - QCOMPARE(indexChangedSpy.count(), 0); \ - } \ - if (_cleanChanged) { \ - QCOMPARE(cleanChangedSpy.count(), 1); \ - QCOMPARE(cleanChangedSpy.at(0).at(0).toBool(), _clean); \ - cleanChangedSpy.clear(); \ - } else { \ - QCOMPARE(cleanChangedSpy.count(), 0); \ - } \ - if (_undoChanged) { \ - QCOMPARE(canUndoChangedSpy.count(), 1); \ - QCOMPARE(canUndoChangedSpy.at(0).at(0).toBool(), _canUndo); \ - QCOMPARE(undo_action->isEnabled(), _canUndo); \ - QCOMPARE(undoTextChangedSpy.count(), 1); \ - QCOMPARE(undoTextChangedSpy.at(0).at(0).toString(), QString(_undoText)); \ - QCOMPARE(undo_action->text(), glue("foo", _undoText)); \ - canUndoChangedSpy.clear(); \ - undoTextChangedSpy.clear(); \ - } else { \ - QCOMPARE(canUndoChangedSpy.count(), 0); \ - QCOMPARE(undoTextChangedSpy.count(), 0); \ - } \ - if (_redoChanged) { \ - QCOMPARE(canRedoChangedSpy.count(), 1); \ - QCOMPARE(canRedoChangedSpy.at(0).at(0).toBool(), _canRedo); \ - QCOMPARE(redo_action->isEnabled(), _canRedo); \ - QCOMPARE(redoTextChangedSpy.count(), 1); \ - QCOMPARE(redoTextChangedSpy.at(0).at(0).toString(), QString(_redoText)); \ - QCOMPARE(redo_action->text(), glue("bar", _redoText)); \ - canRedoChangedSpy.clear(); \ - redoTextChangedSpy.clear(); \ - } else { \ - QCOMPARE(canRedoChangedSpy.count(), 0); \ - QCOMPARE(redoTextChangedSpy.count(), 0); \ - } - -void tst_QUndoGroup::checkSignals() -{ - QUndoGroup group; - const QScopedPointer<QAction> undo_action(group.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redo_action(group.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&group, &QUndoGroup::indexChanged); - QSignalSpy cleanChangedSpy(&group, &QUndoGroup::cleanChanged); - QSignalSpy canUndoChangedSpy(&group, &QUndoGroup::canUndoChanged); - QSignalSpy undoTextChangedSpy(&group, &QUndoGroup::undoTextChanged); - QSignalSpy canRedoChangedSpy(&group, &QUndoGroup::canRedoChanged); - QSignalSpy redoTextChangedSpy(&group, &QUndoGroup::redoTextChanged); - - QString str; - - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - group.undo(); - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - group.redo(); - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - QUndoStack *stack1 = new QUndoStack(&group); - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - stack1->push(new AppendCommand(&str, "foo")); - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - stack1->setActive(); - CHECK_STATE(stack1, // activeStack - false, // clean - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - stack1->push(new InsertCommand(&str, 0, "bar")); - CHECK_STATE(stack1, // activeStack - false, // clean - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - stack1->undo(); - CHECK_STATE(stack1, // activeStack - false, // clean - true, // canUndo - "append", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - stack1->undo(); - CHECK_STATE(stack1, // activeStack - true, // clean - false, // canUndo - "", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - stack1->undo(); - CHECK_STATE(stack1, // activeStack - true, // clean - false, // canUndo - "", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - group.undo(); - CHECK_STATE(stack1, // activeStack - true, // clean - false, // canUndo - "", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - group.redo(); - CHECK_STATE(stack1, // activeStack - false, // clean - true, // canUndo - "append", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - stack1->setActive(false); - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - QUndoStack *stack2 = new QUndoStack(&group); - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false) // redoChanged - - stack2->setActive(); - CHECK_STATE(stack2, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - stack1->setActive(); - CHECK_STATE(stack1, // activeStack - false, // clean - true, // canUndo - "append", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged - - delete stack1; - CHECK_STATE(0, // activeStack - true, // clean - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true) // redoChanged -} - -void tst_QUndoGroup::addStackAndDie() -{ - // Test that QUndoStack doesn't keep a reference to QUndoGroup after the - // group is deleted. - QUndoStack *stack = new QUndoStack; - QUndoGroup *group = new QUndoGroup; - group->addStack(stack); - delete group; - stack->setActive(true); - delete stack; -} - -void tst_QUndoGroup::commandTextFormat() -{ -#if !QT_CONFIG(process) - QSKIP("No QProcess available"); -#else - QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); - - if (QProcess::execute(binDir + "/lrelease -version") != 0) - QSKIP("lrelease is missing or broken"); - - const QString tsFile = QFINDTESTDATA("testdata/qundogroup.ts"); - QVERIFY(!tsFile.isEmpty()); - QFile::remove("qundogroup.qm"); // Avoid confusion by strays. - QVERIFY(!QProcess::execute(binDir + "/lrelease -silent " + tsFile + " -qm qundogroup.qm")); - - QTranslator translator; - - QVERIFY(translator.load("qundogroup.qm")); - QFile::remove("qundogroup.qm"); - qApp->installTranslator(&translator); - - QUndoGroup group; - const QScopedPointer<QAction> undo_action(group.createUndoAction(0)); - const QScopedPointer<QAction> redo_action(group.createRedoAction(0)); - - QCOMPARE(undo_action->text(), QString("Undo-default-text")); - QCOMPARE(redo_action->text(), QString("Redo-default-text")); - - QUndoStack stack(&group); - stack.setActive(); - QString str; - - stack.push(new AppendCommand(&str, "foo")); - QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); - QCOMPARE(redo_action->text(), QString("Redo-default-text")); - - stack.push(new InsertCommand(&str, 0, "bar")); - stack.undo(); - QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); - QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix")); - - stack.undo(); - QCOMPARE(undo_action->text(), QString("Undo-default-text")); - QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix")); - - qApp->removeTranslator(&translator); -#endif -} - -QTEST_MAIN(tst_QUndoGroup) - -#include "tst_qundogroup.moc" - diff --git a/tests/auto/widgets/util/qundostack/.gitignore b/tests/auto/widgets/util/qundostack/.gitignore deleted file mode 100644 index f8faf2771f..0000000000 --- a/tests/auto/widgets/util/qundostack/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qundostack diff --git a/tests/auto/widgets/util/qundostack/qundostack.pro b/tests/auto/widgets/util/qundostack/qundostack.pro deleted file mode 100644 index 294debb51c..0000000000 --- a/tests/auto/widgets/util/qundostack/qundostack.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -QT += widgets testlib -SOURCES += tst_qundostack.cpp -TARGET = tst_qundostack diff --git a/tests/auto/widgets/util/qundostack/testdata/qundostack.ts b/tests/auto/widgets/util/qundostack/testdata/qundostack.ts deleted file mode 100644 index 4584036af2..0000000000 --- a/tests/auto/widgets/util/qundostack/testdata/qundostack.ts +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.0" language="en"> -<context> - <name>QUndoStack</name> - <message> - <source>Undo %1</source> - <translation>undo-prefix %1 undo-suffix</translation> - </message> - <message> - <source>Undo</source> - <comment>Default text for undo action</comment> - <translation>Undo-default-text</translation> - </message> - <message> - <source>Redo %1</source> - <translation>redo-prefix %1 redo-suffix</translation> - </message> - <message> - <source>Redo</source> - <comment>Default text for redo action</comment> - <translation>Redo-default-text</translation> - </message> -</context> -</TS> diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp deleted file mode 100644 index f3185086b8..0000000000 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ /dev/null @@ -1,3930 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QtTest/QtTest> -#include <QAction> -#include <QUndoStack> - -/****************************************************************************** -** Commands -*/ - -class InsertCommand : public QUndoCommand -{ -public: - InsertCommand(QString *str, int idx, const QString &text, - QUndoCommand *parent = 0); - - virtual void undo(); - virtual void redo(); - -private: - QString *m_str; - int m_idx; - QString m_text; -}; - -class RemoveCommand : public QUndoCommand -{ -public: - RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent = 0); - - virtual void undo(); - virtual void redo(); - -private: - QString *m_str; - int m_idx; - QString m_text; -}; - -class AppendCommand : public QUndoCommand -{ -public: - AppendCommand(QString *str, const QString &text, bool _fail_merge = false, - QUndoCommand *parent = 0); - ~AppendCommand(); - - virtual void undo(); - virtual void redo(); - virtual int id() const; - virtual bool mergeWith(const QUndoCommand *other); - - bool merged; - bool fail_merge; - static int delete_cnt; - -private: - QString *m_str; - QString m_text; -}; - -class IdleCommand : public QUndoCommand -{ -public: - IdleCommand(QUndoCommand *parent = 0); - ~IdleCommand(); - - virtual void undo(); - virtual void redo(); -}; - -class MoveMouseCommand : public QUndoCommand -{ -public: - MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent = 0); - ~MoveMouseCommand(); - - virtual void undo(); - virtual void redo(); - virtual int id() const; - virtual bool mergeWith(const QUndoCommand *other); - -private: - QPoint *m_mouse; - QPoint m_oldPoint; - QPoint m_newPoint; -}; - -InsertCommand::InsertCommand(QString *str, int idx, const QString &text, - QUndoCommand *parent) - : QUndoCommand(parent) -{ - QVERIFY(str->length() >= idx); - - setText("insert"); - - m_str = str; - m_idx = idx; - m_text = text; -} - -void InsertCommand::redo() -{ - QVERIFY(m_str->length() >= m_idx); - - m_str->insert(m_idx, m_text); -} - -void InsertCommand::undo() -{ - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); - - m_str->remove(m_idx, m_text.length()); -} - -RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent) - : QUndoCommand(parent) -{ - QVERIFY(str->length() >= idx + len); - - setText("remove"); - - m_str = str; - m_idx = idx; - m_text = m_str->mid(m_idx, len); -} - -void RemoveCommand::redo() -{ - QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); - - m_str->remove(m_idx, m_text.length()); -} - -void RemoveCommand::undo() -{ - QVERIFY(m_str->length() >= m_idx); - - m_str->insert(m_idx, m_text); -} - -int AppendCommand::delete_cnt = 0; - -AppendCommand::AppendCommand(QString *str, const QString &text, bool _fail_merge, - QUndoCommand *parent) - : QUndoCommand(parent) -{ - setText("append"); - - m_str = str; - m_text = text; - merged = false; - fail_merge = _fail_merge; -} - -AppendCommand::~AppendCommand() -{ - ++delete_cnt; -} - -void AppendCommand::redo() -{ - m_str->append(m_text); -} - -void AppendCommand::undo() -{ - QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text); - - m_str->truncate(m_str->length() - m_text.length()); -} - -int AppendCommand::id() const -{ - return 1; -} - -bool AppendCommand::mergeWith(const QUndoCommand *other) -{ - if (other->id() != id()) - return false; - if (fail_merge) - return false; - m_text += static_cast<const AppendCommand*>(other)->m_text; - merged = true; - return true; -} - -IdleCommand::IdleCommand(QUndoCommand *parent) - : QUndoCommand(parent) -{ - // "idle-item" goes to QUndoStack::{redo,undo}Text - // "idle-action" goes to all other places (e.g. QUndoView) - setText("idle-item\nidle-action"); -} - -IdleCommand::~IdleCommand() -{ -} - -void IdleCommand::redo() -{ -} - -void IdleCommand::undo() -{ -} - -MoveMouseCommand::MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent) - : QUndoCommand(parent) -{ - setText("move mouse"); - - m_mouse = mouse; - m_oldPoint = oldPoint; - m_newPoint = newPoint; - - if (m_oldPoint == m_newPoint) - setObsolete(true); -} - -MoveMouseCommand::~MoveMouseCommand() -{ -} - -void MoveMouseCommand::redo() -{ - *m_mouse = m_newPoint; -} - -void MoveMouseCommand::undo() -{ - *m_mouse = m_oldPoint; -} - -int MoveMouseCommand::id() const -{ - return 2; -} - -bool MoveMouseCommand::mergeWith(const QUndoCommand *other) -{ - m_newPoint = static_cast<const MoveMouseCommand*>(other)->m_newPoint; - - if (m_newPoint == m_oldPoint) - setObsolete(true); - - return true; -} - -/****************************************************************************** -** tst_QUndoStack -*/ - -class tst_QUndoStack : public QObject -{ - Q_OBJECT -public: - tst_QUndoStack(); - -private slots: - void undoRedo(); - void setIndex(); - void setClean(); - void clear(); - void childCommand(); - void macroBeginEnd(); - void compression(); - void obsolete(); - void undoLimit(); - void commandTextFormat(); - void separateUndoText(); -}; - -tst_QUndoStack::tst_QUndoStack() -{ -} - -static QString glue(const QString &s1, const QString &s2) -{ - QString result; - - result.append(s1); - if (!s1.isEmpty() && !s2.isEmpty()) - result.append(' '); - result.append(s2); - - return result; -} - -static void checkState(QSignalSpy &redoTextChangedSpy, - QSignalSpy &canRedoChangedSpy, - QSignalSpy &undoTextChangedSpy, - const QScopedPointer<QAction> &redoAction, - const QScopedPointer<QAction> &undoAction, - QSignalSpy &canUndoChangedSpy, - QSignalSpy &cleanChangedSpy, - QSignalSpy &indexChangedSpy, - QUndoStack &stack, - const bool _clean, - const int _count, - const int _index, - const bool _canUndo, - const QString &_undoText, - const bool _canRedo, - const QString &_redoText, - const bool _cleanChanged, - const bool _indexChanged, - const bool _undoChanged, - const bool _redoChanged) -{ - QCOMPARE(stack.count(), _count); - QCOMPARE(stack.isClean(), _clean); - QCOMPARE(stack.index(), _index); - QCOMPARE(stack.canUndo(), _canUndo); - QCOMPARE(stack.undoText(), QString(_undoText)); - QCOMPARE(stack.canRedo(), _canRedo); - QCOMPARE(stack.redoText(), QString(_redoText)); - if (_indexChanged) { - QCOMPARE(indexChangedSpy.count(), 1); - QCOMPARE(indexChangedSpy.at(0).at(0).toInt(), _index); - indexChangedSpy.clear(); - } else { - QCOMPARE(indexChangedSpy.count(), 0); - } - if (_cleanChanged) { - QCOMPARE(cleanChangedSpy.count(), 1); - QCOMPARE(cleanChangedSpy.at(0).at(0).toBool(), _clean); - cleanChangedSpy.clear(); - } else { - QCOMPARE(cleanChangedSpy.count(), 0); - } - if (_undoChanged) { - QCOMPARE(canUndoChangedSpy.count(), 1); - QCOMPARE(canUndoChangedSpy.at(0).at(0).toBool(), _canUndo); - QCOMPARE(undoAction->isEnabled(), _canUndo); - QCOMPARE(undoTextChangedSpy.count(), 1); - QCOMPARE(undoTextChangedSpy.at(0).at(0).toString(), QString(_undoText)); - QCOMPARE(undoAction->text(), glue("foo", _undoText)); - canUndoChangedSpy.clear(); - undoTextChangedSpy.clear(); - } else { - QCOMPARE(canUndoChangedSpy.count(), 0); - QCOMPARE(undoTextChangedSpy.count(), 0); - } - if (_redoChanged) { - QCOMPARE(canRedoChangedSpy.count(), 1); - QCOMPARE(canRedoChangedSpy.at(0).at(0).toBool(), _canRedo); - QCOMPARE(redoAction->isEnabled(), _canRedo); - QCOMPARE(redoTextChangedSpy.count(), 1); - QCOMPARE(redoTextChangedSpy.at(0).at(0).toString(), QString(_redoText)); - QCOMPARE(redoAction->text(), glue("bar", _redoText)); - canRedoChangedSpy.clear(); - redoTextChangedSpy.clear(); - } else { - QCOMPARE(canRedoChangedSpy.count(), 0); - QCOMPARE(redoTextChangedSpy.count(), 0); - } -} - -void tst_QUndoStack::undoRedo() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - // push, undo, redo - - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.undo(); // nothing to undo - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new InsertCommand(&str, 0, "hello")); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 2, "123")); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - - stack.undo(); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.redo(); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.redo(); // nothing to redo - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); // nothing to undo - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - // push after undo - check that undone commands get deleted - - stack.redo(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new RemoveCommand(&str, 2, 2)); - QCOMPARE(str, QString("heo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - still 2, last command got deleted - 2, // index - true, // canUndo - "remove", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "remove", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 0, "goodbye")); - QCOMPARE(str, QString("goodbye")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - two commands got deleted - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::setIndex() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - stack.setIndex(10); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.setIndex(0); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.setIndex(-10); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new InsertCommand(&str, 0, "hello")); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 2, "123")); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(2); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.setIndex(0); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(10); // should set index to 2 - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(-10); // should set index to 0 - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(1); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(2); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::setClean() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - QCOMPARE(stack.cleanIndex(), 0); - stack.setClean(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 0); - - stack.push(new InsertCommand(&str, 0, "goodbye")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 0); - - stack.setClean(); - QCOMPARE(str, QString("goodbye")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.push(new AppendCommand(&str, " cowboy")); - QCOMPARE(str, QString("goodbye cowboy")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.undo(); // reaching clean state from above - QCOMPARE(str, QString("goodbye")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.undo(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.redo(); // reaching clean state from below - QCOMPARE(str, QString("goodbye")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.undo(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.push(new InsertCommand(&str, 0, "foo")); // the clean state gets deleted! - QCOMPARE(str, QString("foo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - stack.undo(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - stack.setClean(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 0); - - stack.resetClean(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - stack.redo(); - QCOMPARE(str, QString("foo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - stack.setClean(); - QCOMPARE(str, QString("foo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.undo(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), 1); - - stack.resetClean(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); -} - -void tst_QUndoStack::clear() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - stack.clear(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new InsertCommand(&str, 0, "hello")); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 2, "123")); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.clear(); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - str.clear(); - stack.push(new InsertCommand(&str, 0, "hello")); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 2, "123")); - QCOMPARE(str, QString("he123llo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(0); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.clear(); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::childCommand() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - stack.push(new InsertCommand(&str, 0, "hello")); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - QUndoCommand *cmd = new QUndoCommand(); - cmd->setText("ding"); - new InsertCommand(&str, 5, "world", cmd); - new RemoveCommand(&str, 4, 1, cmd); - stack.push(cmd); - QCOMPARE(str, QString("hellworld")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "ding", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "ding", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.redo(); - QCOMPARE(str, QString("hellworld")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "ding", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::macroBeginEnd() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - stack.beginMacro("ding"); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setClean(); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.undo(); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.redo(); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.setIndex(0); // should do nothing - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.endMacro(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - endMacro() increments index - true, // canUndo - "ding", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 0, "h")); - QCOMPARE(str, QString("h")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 1, "owdy")); - QCOMPARE(str, QString("howdy")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(2); - QCOMPARE(str, QString("h")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.beginMacro("dong"); // the "owdy" command gets deleted - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 1, "ello")); - QCOMPARE(str, QString("hello")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new RemoveCommand(&str, 1, 2)); - QCOMPARE(str, QString("hlo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.beginMacro("dong2"); - QCOMPARE(str, QString("hlo")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new RemoveCommand(&str, 1, 1)); - QCOMPARE(str, QString("ho")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.endMacro(); - QCOMPARE(str, QString("ho")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.endMacro(); - QCOMPARE(str, QString("ho")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "dong", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("h")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "dong", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 1, // index - true, // canUndo - "ding", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(3); - QCOMPARE(str, QString("ho")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "dong", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setIndex(1); - QCOMPARE(str, QString()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 1, // index - true, // canUndo - "ding", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::compression() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QString str; - - AppendCommand::delete_cnt = 0; - - stack.push(new InsertCommand(&str, 0, "ene")); - QCOMPARE(str, QString("ene")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, " due")); // #1 - QCOMPARE(str, QString("ene due")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, " rike")); // #2 should merge - QCOMPARE(str, QString("ene due rike")); - QCOMPARE(AppendCommand::delete_cnt, 1); // #2 should be deleted - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setClean(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new AppendCommand(&str, " fake")); // #3 should NOT merge, since the stack was clean - QCOMPARE(str, QString("ene due rike fake")); // and we want to be able to return to this state - QCOMPARE(AppendCommand::delete_cnt, 1); // #3 should not be deleted - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("ene due rike")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 3, // count - 2, // index - true, // canUndo - "append", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("ene")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "ma", true)); // #4 clean state gets deleted! - QCOMPARE(str, QString("enema")); - QCOMPARE(AppendCommand::delete_cnt, 3); // #1 got deleted - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "trix")); // #5 should NOT merge - QCOMPARE(str, QString("enematrix")); - QCOMPARE(AppendCommand::delete_cnt, 3); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("enema")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - true, // canUndo - "append", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - // and now for command compression inside macros - - stack.setClean(); - QCOMPARE(str, QString("enema")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 3, // count - 2, // index - true, // canUndo - "append", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.beginMacro("ding"); - QCOMPARE(str, QString("enema")); - QCOMPARE(AppendCommand::delete_cnt, 4); // #5 gets deleted - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - true, // undoChanged - true); // redoChanged - - AppendCommand *merge_cmd = new AppendCommand(&str, "top"); - stack.push(merge_cmd); // #6 - QCOMPARE(merge_cmd->merged, false); - QCOMPARE(str, QString("enematop")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new AppendCommand(&str, "eja")); // #7 should merge - QCOMPARE(str, QString("enematopeja")); - QCOMPARE(merge_cmd->merged, true); - QCOMPARE(AppendCommand::delete_cnt, 5); // #7 gets deleted - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - merge_cmd->merged = false; - - stack.push(new InsertCommand(&str, 2, "123")); // should not merge - QCOMPARE(str, QString("en123ematopeja")); - QCOMPARE(merge_cmd->merged, false); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.endMacro(); - QCOMPARE(str, QString("en123ematopeja")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "ding", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("enema")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 3, // count - 2, // index - true, // canUndo - "append", // undoText - true, // canRedo - "ding", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.redo(); - QCOMPARE(str, QString("en123ematopeja")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "ding", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::obsolete() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - QPoint mouse(0, 0); - QString str; - MoveMouseCommand *cmd1 = 0; - MoveMouseCommand *cmd2 = 0; - - stack.resetClean(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #1 should not merge but will be deleted (b/c oldPoint == newPoint) - QCOMPARE(mouse, QPoint(0, 0)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(12, 0))); // #2 should not merge or be deleted (b/c oldPoint != newPoint) - QCOMPARE(mouse, QPoint(12, 0)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(8, 2))); // #3 should merge and not be deleted (b/c oldPoint != newPoint) - QCOMPARE(mouse, QPoint(8, 2)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #4 should merge and be deleted (b/c oldPoint == newPoint) - QCOMPARE(mouse, QPoint(0, 0)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 0, // count - 0, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - - - - stack.push(new InsertCommand(&str, 0, "ene")); // #5 should not merge or be deleted - QCOMPARE(str, QString("ene")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - cmd1 = new MoveMouseCommand(&mouse, mouse, QPoint(6, 5)); - stack.push(cmd1); // #6 should not merge or be deleted (b/c oldPoint != newPoint) - QCOMPARE(mouse, QPoint(6, 5)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 3, "ma")); // #7 should not merge or be deleted - QCOMPARE(str, QString("enema")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - cmd2 = new MoveMouseCommand(&mouse, mouse, QPoint(12, 4)); - stack.push(cmd2); // #8 should not merge or be deleted (b/c oldPoint != newPoint) - QCOMPARE(mouse, QPoint(12, 4)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 4, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setClean(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 4, // count - 4, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 4); - - cmd2->setObsolete(true); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 4, // count - 4, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.undo(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - stack.undo(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - true, // canUndo - "move mouse", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setClean(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 3, // count - 2, // index - true, // canUndo - "move mouse", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 2); - - stack.undo(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "move mouse", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - cmd1->setObsolete(true); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "move mouse", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.redo(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "insert", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - stack.redo(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - cmd1 = new MoveMouseCommand(&mouse, mouse, QPoint(13, 2)); - stack.push(cmd1); // #9 should not merge or be deleted (b/c oldPoint != newPoint) - QCOMPARE(mouse, QPoint(13, 2)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new InsertCommand(&str, 3, "ma")); // #10 should not merge or be deleted - QCOMPARE(str, QString("enemama")); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 4, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - cmd2 = new MoveMouseCommand(&mouse, mouse, QPoint(6, 20)); - stack.push(cmd2); // #11 should not merge or be deleted (b/c oldPoint != newPoint) - QCOMPARE(mouse, QPoint(6, 20)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 5, // count - 5, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - cmd1->setObsolete(true); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 5, // count - 5, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.setClean(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 5, // count - 5, // index - true, // canUndo - "move mouse", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - QCOMPARE(stack.cleanIndex(), 5); - - stack.setIndex(0); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - QCOMPARE(stack.cleanIndex(), -1); - - cmd2->setObsolete(true); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "insert", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.setIndex(stack.count()); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 3, // index - true, // canUndo - "insert", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - mouse = QPoint(0, 0); // Reset mouse position - stack.beginMacro("ding"); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 3, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(7, 7))); // #12 should not merge or be deleted (b/c oldPoint != newPoint & in macro) - QCOMPARE(mouse, QPoint(7, 7)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 3, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #13 should merge and be deleted (b/c oldPoint = newPoint) - QCOMPARE(mouse, QPoint(0, 0)); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 3, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.endMacro(); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 4, // count - 4, // index - true, // canUndo - "ding", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::undoLimit() -{ - QUndoStack stack; - const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); - const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); - QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); - QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); - QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); - QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); - QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); - AppendCommand::delete_cnt = 0; - QString str; - - QCOMPARE(stack.undoLimit(), 0); - stack.setUndoLimit(2); - QCOMPARE(stack.undoLimit(), 2); - - stack.push(new AppendCommand(&str, "1", true)); - QCOMPARE(str, QString("1")); - QCOMPARE(AppendCommand::delete_cnt, 0); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "2", true)); - QCOMPARE(str, QString("12")); - QCOMPARE(AppendCommand::delete_cnt, 0); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.setClean(); - QCOMPARE(str, QString("12")); - QCOMPARE(AppendCommand::delete_cnt, 0); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new AppendCommand(&str, "3", true)); - QCOMPARE(str, QString("123")); - QCOMPARE(AppendCommand::delete_cnt, 1); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "4", true)); - QCOMPARE(str, QString("1234")); - QCOMPARE(AppendCommand::delete_cnt, 2); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("123")); - QCOMPARE(AppendCommand::delete_cnt, 2); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "append", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("12")); - QCOMPARE(AppendCommand::delete_cnt, 2); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - true, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "append", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "3", true)); - QCOMPARE(str, QString("123")); - QCOMPARE(AppendCommand::delete_cnt, 4); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - true, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "4", true)); - QCOMPARE(str, QString("1234")); - QCOMPARE(AppendCommand::delete_cnt, 4); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "5", true)); - QCOMPARE(str, QString("12345")); - QCOMPARE(AppendCommand::delete_cnt, 5); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("1234")); - QCOMPARE(AppendCommand::delete_cnt, 5); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "append", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("123")); - QCOMPARE(AppendCommand::delete_cnt, 5); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "4", true)); - QCOMPARE(str, QString("1234")); - QCOMPARE(AppendCommand::delete_cnt, 7); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 1, // count - 1, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "5")); - QCOMPARE(str, QString("12345")); - QCOMPARE(AppendCommand::delete_cnt, 7); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "6", true)); // should be merged - QCOMPARE(str, QString("123456")); - QCOMPARE(AppendCommand::delete_cnt, 8); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "append", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.beginMacro("foo"); - QCOMPARE(str, QString("123456")); - QCOMPARE(AppendCommand::delete_cnt, 8); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.push(new AppendCommand(&str, "7", true)); - QCOMPARE(str, QString("1234567")); - QCOMPARE(AppendCommand::delete_cnt, 8); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.push(new AppendCommand(&str, "8")); - QCOMPARE(str, QString("12345678")); - QCOMPARE(AppendCommand::delete_cnt, 8); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 3, // count - 2, // index - false, // canUndo - "", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - false, // indexChanged - false, // undoChanged - false); // redoChanged - - stack.endMacro(); - QCOMPARE(str, QString("12345678")); - QCOMPARE(AppendCommand::delete_cnt, 9); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 2, // index - true, // canUndo - "foo", // undoText - false, // canRedo - "", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("123456")); - QCOMPARE(AppendCommand::delete_cnt, 9); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 1, // index - true, // canUndo - "append", // undoText - true, // canRedo - "foo", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged - - stack.undo(); - QCOMPARE(str, QString("1234")); - QCOMPARE(AppendCommand::delete_cnt, 9); - checkState(redoTextChangedSpy, - canRedoChangedSpy, - undoTextChangedSpy, - redoAction, - undoAction, - canUndoChangedSpy, - cleanChangedSpy, - indexChangedSpy, - stack, - false, // clean - 2, // count - 0, // index - false, // canUndo - "", // undoText - true, // canRedo - "append", // redoText - false, // cleanChanged - true, // indexChanged - true, // undoChanged - true); // redoChanged -} - -void tst_QUndoStack::commandTextFormat() -{ -#if !QT_CONFIG(process) - QSKIP("No QProcess available"); -#else - QString binDir = QLibraryInfo::location(QLibraryInfo::BinariesPath); - - if (QProcess::execute(binDir + "/lrelease -version") != 0) - QSKIP("lrelease is missing or broken"); - - const QString tsFile = QFINDTESTDATA("testdata/qundostack.ts"); - QVERIFY(!tsFile.isEmpty()); - QFile::remove("qundostack.qm"); // Avoid confusion by strays. - QVERIFY(!QProcess::execute(binDir + "/lrelease -silent " + tsFile + " -qm qundostack.qm")); - - QTranslator translator; - QVERIFY(translator.load("qundostack.qm")); - QFile::remove("qundostack.qm"); - qApp->installTranslator(&translator); - - QUndoStack stack; - const QScopedPointer<QAction> undo_action(stack.createUndoAction(0)); - const QScopedPointer<QAction> redo_action(stack.createRedoAction(0)); - - QCOMPARE(undo_action->text(), QString("Undo-default-text")); - QCOMPARE(redo_action->text(), QString("Redo-default-text")); - - QString str; - - stack.push(new AppendCommand(&str, "foo")); - QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); - QCOMPARE(redo_action->text(), QString("Redo-default-text")); - - stack.push(new InsertCommand(&str, 0, "bar")); - stack.undo(); - QCOMPARE(undo_action->text(), QString("undo-prefix append undo-suffix")); - QCOMPARE(redo_action->text(), QString("redo-prefix insert redo-suffix")); - - stack.undo(); - QCOMPARE(undo_action->text(), QString("Undo-default-text")); - QCOMPARE(redo_action->text(), QString("redo-prefix append redo-suffix")); - - qApp->removeTranslator(&translator); -#endif -} - -void tst_QUndoStack::separateUndoText() -{ - QUndoStack stack; - const QScopedPointer<QAction> undo_action(stack.createUndoAction(0)); - const QScopedPointer<QAction> redo_action(stack.createRedoAction(0)); - - QUndoCommand *command1 = new IdleCommand(); - QUndoCommand *command2 = new IdleCommand(); - stack.push(command1); - stack.push(command2); - stack.undo(); - - QCOMPARE(undo_action->text(), QString("Undo idle-action")); - QCOMPARE(redo_action->text(), QString("Redo idle-action")); - QCOMPARE(command1->actionText(), QString("idle-action")); - - QCOMPARE(command1->text(), QString("idle-item")); - QCOMPARE(stack.text(0), QString("idle-item")); - - command1->setText("idle"); - QCOMPARE(command1->actionText(), QString("idle")); - QCOMPARE(command1->text(), QString("idle")); - - command1->setText("idle-item\nidle-action"); - QCOMPARE(command1->actionText(), QString("idle-action")); - QCOMPARE(command1->text(), QString("idle-item")); -} - -QTEST_MAIN(tst_QUndoStack) - -#include "tst_qundostack.moc" diff --git a/tests/auto/widgets/util/util.pro b/tests/auto/widgets/util/util.pro index 33f2845001..66d2a288ee 100644 --- a/tests/auto/widgets/util/util.pro +++ b/tests/auto/widgets/util/util.pro @@ -2,6 +2,4 @@ TEMPLATE=subdirs SUBDIRS=\ qcompleter \ qscroller \ - qsystemtrayicon \ - qundogroup \ - qundostack \ + qsystemtrayicon diff --git a/tests/auto/widgets/widgets/CMakeLists.txt b/tests/auto/widgets/widgets/CMakeLists.txt new file mode 100644 index 0000000000..60776f5da2 --- /dev/null +++ b/tests/auto/widgets/widgets/CMakeLists.txt @@ -0,0 +1,55 @@ +# Generated from widgets.pro. + +add_subdirectory(qabstractbutton) +add_subdirectory(qabstractscrollarea) +add_subdirectory(qabstractslider) +add_subdirectory(qbuttongroup) +add_subdirectory(qcalendarwidget) +add_subdirectory(qcheckbox) +add_subdirectory(qcommandlinkbutton) +add_subdirectory(qdatetimeedit) +add_subdirectory(qdial) +add_subdirectory(qdialogbuttonbox) +add_subdirectory(qdockwidget) +add_subdirectory(qdoublespinbox) +add_subdirectory(qfocusframe) +add_subdirectory(qfontcombobox) +add_subdirectory(qframe) +add_subdirectory(qgroupbox) +add_subdirectory(qkeysequenceedit) +add_subdirectory(qlabel) +add_subdirectory(qlcdnumber) +add_subdirectory(qlineedit) +add_subdirectory(qmdiarea) +add_subdirectory(qmdisubwindow) +add_subdirectory(qmenu) +add_subdirectory(qmenubar) +add_subdirectory(qplaintextedit) +add_subdirectory(qprogressbar) +add_subdirectory(qpushbutton) +add_subdirectory(qradiobutton) +add_subdirectory(qscrollarea) +add_subdirectory(qscrollbar) +add_subdirectory(qsizegrip) +add_subdirectory(qslider) +add_subdirectory(qspinbox) +add_subdirectory(qsplitter) +add_subdirectory(qstackedwidget) +add_subdirectory(qstatusbar) +add_subdirectory(qtabbar) +add_subdirectory(qtabwidget) +add_subdirectory(qtextbrowser) +add_subdirectory(qtoolbox) +add_subdirectory(qtoolbutton) + +if(QT_FEATURE_private_tests) + add_subdirectory(qabstractspinbox) + add_subdirectory(qcombobox) + add_subdirectory(qmainwindow) + add_subdirectory(qtextedit) + add_subdirectory(qtoolbar) +endif() + +if(NOT WINRT AND QT_FEATURE_opengl) + add_subdirectory(qopenglwidget) +endif() diff --git a/tests/auto/widgets/widgets/qabstractbutton/CMakeLists.txt b/tests/auto/widgets/widgets/qabstractbutton/CMakeLists.txt new file mode 100644 index 0000000000..48a174b6e1 --- /dev/null +++ b/tests/auto/widgets/widgets/qabstractbutton/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qabstractbutton.pro. + +##################################################################### +## tst_qabstractbutton Test: +##################################################################### + +add_qt_test(tst_qabstractbutton + SOURCES + tst_qabstractbutton.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp index eb108a40de..e5a891912f 100644 --- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp @@ -34,7 +34,9 @@ #include <qapplication.h> #include <qpainter.h> #include <qstyleoption.h> -#include <qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <qkeysequence.h> +#endif #include <qevent.h> #include <qgridlayout.h> #include <qabstractbutton.h> @@ -59,7 +61,9 @@ private slots: void setText(); void setIcon(); +#if QT_CONFIG(shortcut) void setShortcut(); +#endif void animateClick(); @@ -68,7 +72,9 @@ private slots: void isChecked(); void toggled(); void setEnabled(); +#if QT_CONFIG(shortcut) void shortcutEvents(); +#endif void stopRepeatTimer(); void mouseReleased(); // QTBUG-53244 @@ -164,8 +170,10 @@ void tst_QAbstractButton::init() testWidget->setEnabled( true ); testWidget->setDown( false ); testWidget->setAutoRepeat( false ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif toggle_count = 0; press_count = 0; @@ -336,17 +344,17 @@ void tst_QAbstractButton::setText() QCOMPARE( testWidget->text(), QString("simple") ); testWidget->setText("&ersand"); QCOMPARE( testWidget->text(), QString("&ersand") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+A")); #endif testWidget->setText("te&st"); QCOMPARE( testWidget->text(), QString("te&st") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+S")); #endif testWidget->setText("foo"); QCOMPARE( testWidget->text(), QString("foo") ); -#ifndef Q_OS_MAC // no mneonics on Mac. +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) // no mnemonics on Mac. QCOMPARE( testWidget->shortcut(), QKeySequence()); #endif } @@ -471,6 +479,7 @@ void tst_QAbstractButton::toggled() testWidget->setCheckable(false); } +#if QT_CONFIG(shortcut) void tst_QAbstractButton::setShortcut() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) @@ -502,6 +511,7 @@ void tst_QAbstractButton::setShortcut() // qDebug() << click_count; } +#endif // QT_CONFIG(shortcut) void tst_QAbstractButton::animateClick() { @@ -512,6 +522,8 @@ void tst_QAbstractButton::animateClick() QTRY_VERIFY( !testWidget->isDown() ); } +#if QT_CONFIG(shortcut) + void tst_QAbstractButton::shortcutEvents() { MyButton button; @@ -535,6 +547,8 @@ void tst_QAbstractButton::shortcutEvents() QCOMPARE(clickedSpy.count(), 3); } +#endif // QT_CONFIG(shortcut) + void tst_QAbstractButton::stopRepeatTimer() { MyButton button; diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/CMakeLists.txt b/tests/auto/widgets/widgets/qabstractscrollarea/CMakeLists.txt new file mode 100644 index 0000000000..cb1b2aa936 --- /dev/null +++ b/tests/auto/widgets/widgets/qabstractscrollarea/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qabstractscrollarea.pro. + +##################################################################### +## tst_qabstractscrollarea Test: +##################################################################### + +add_qt_test(tst_qabstractscrollarea + SOURCES + tst_qabstractscrollarea.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qabstractslider/CMakeLists.txt b/tests/auto/widgets/widgets/qabstractslider/CMakeLists.txt new file mode 100644 index 0000000000..0dbbf63239 --- /dev/null +++ b/tests/auto/widgets/widgets/qabstractslider/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qabstractslider.pro. + +##################################################################### +## tst_qabstractslider Test: +##################################################################### + +add_qt_test(tst_qabstractslider + SOURCES + tst_qabstractslider.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qabstractspinbox/CMakeLists.txt b/tests/auto/widgets/widgets/qabstractspinbox/CMakeLists.txt new file mode 100644 index 0000000000..32c814c535 --- /dev/null +++ b/tests/auto/widgets/widgets/qabstractspinbox/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qabstractspinbox.pro. + +##################################################################### +## tst_qabstractspinbox Test: +##################################################################### + +add_qt_test(tst_qabstractspinbox + SOURCES + tst_qabstractspinbox.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qbuttongroup/CMakeLists.txt b/tests/auto/widgets/widgets/qbuttongroup/CMakeLists.txt new file mode 100644 index 0000000000..92d04e0c26 --- /dev/null +++ b/tests/auto/widgets/widgets/qbuttongroup/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qbuttongroup.pro. + +##################################################################### +## tst_qbuttongroup Test: +##################################################################### + +add_qt_test(tst_qbuttongroup + SOURCES + tst_qbuttongroup.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index 7454acbec7..dd8a3e5839 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -457,7 +457,6 @@ void tst_QButtonGroup::task106609() qRegisterMetaType<QAbstractButton*>("QAbstractButton*"); QSignalSpy spy1(buttons, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy spy2(buttons, SIGNAL(buttonClicked(int))); QApplication::setActiveWindow(&dlg); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&dlg)); @@ -466,8 +465,6 @@ void tst_QButtonGroup::task106609() radio1->setChecked(true); QTestEventLoop::instance().enterLoop(1); - //qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count(); - QCOMPARE(spy2.count(), 2); QCOMPARE(spy1.count(), 2); } @@ -512,11 +509,12 @@ public: : group(group) , deleteButton(deleteButton) { - connect(group, SIGNAL(buttonClicked(int)), SLOT(buttonClicked(int))); + connect(group, &QButtonGroup::buttonClicked, + this, &task209485_ButtonDeleter::buttonClicked); } private slots: - void buttonClicked(int) + void buttonClicked() { if (deleteButton) group->removeButton(group->buttons().first()); @@ -532,7 +530,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler_data() QTest::addColumn<bool>("deleteButton"); QTest::addColumn<int>("signalCount"); QTest::newRow("buttonPress 1") << true << 1; - QTest::newRow("buttonPress 2") << false << 2; + QTest::newRow("buttonPress 2") << false << 1; } void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() @@ -548,12 +546,11 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() task209485_ButtonDeleter buttonDeleter(&group, deleteButton); QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy spy2(&group, SIGNAL(buttonClicked(int))); // NOTE: Reintroducing the bug of this task will cause the following line to crash: QTest::mouseClick(button, Qt::LeftButton); - QCOMPARE(spy1.count() + spy2.count(), signalCount); + QCOMPARE(spy1.count(), signalCount); } void tst_QButtonGroup::autoIncrementId() diff --git a/tests/auto/widgets/widgets/qcalendarwidget/CMakeLists.txt b/tests/auto/widgets/widgets/qcalendarwidget/CMakeLists.txt new file mode 100644 index 0000000000..10e24a1016 --- /dev/null +++ b/tests/auto/widgets/widgets/qcalendarwidget/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qcalendarwidget.pro. + +##################################################################### +## tst_qcalendarwidget Test: +##################################################################### + +add_qt_test(tst_qcalendarwidget + SOURCES + tst_qcalendarwidget.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qcheckbox/CMakeLists.txt b/tests/auto/widgets/widgets/qcheckbox/CMakeLists.txt new file mode 100644 index 0000000000..2418791e5d --- /dev/null +++ b/tests/auto/widgets/widgets/qcheckbox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qcheckbox.pro. + +##################################################################### +## tst_qcheckbox Test: +##################################################################### + +add_qt_test(tst_qcheckbox + SOURCES + tst_qcheckbox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qcombobox/CMakeLists.txt b/tests/auto/widgets/widgets/qcombobox/CMakeLists.txt new file mode 100644 index 0000000000..95fbe14eec --- /dev/null +++ b/tests/auto/widgets/widgets/qcombobox/CMakeLists.txt @@ -0,0 +1,24 @@ +# Generated from qcombobox.pro. + +##################################################################### +## tst_qcombobox Test: +##################################################################### + +# Collect test data +list(APPEND test_data "qtlogo.png") +list(APPEND test_data "qtlogoinverted.png") + +add_qt_test(tst_qcombobox + SOURCES + tst_qcombobox.cpp + DEFINES + QTEST_QPA_MOUSE_HANDLING + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate + TESTDATA ${test_data} +) diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index c934f8e27b..10430e1796 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -1209,7 +1209,6 @@ void tst_QComboBox::currentIndex() // spy on currentIndexChanged QSignalSpy indexChangedInt(testWidget, SIGNAL(currentIndexChanged(int))); - QSignalSpy indexChangedString(testWidget, SIGNAL(currentIndexChanged(QString))); // stuff items into it foreach(QString text, initialItems) { @@ -1234,15 +1233,11 @@ void tst_QComboBox::currentIndex() // check that signal count is correct QCOMPARE(indexChangedInt.count(), expectedSignalCount); - QCOMPARE(indexChangedString.count(), expectedSignalCount); // compare with last sent signal values if (indexChangedInt.count()) QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(), testWidget->currentIndex()); - if (indexChangedString.count()) - QCOMPARE(indexChangedString.at(indexChangedString.count() - 1).at(0).toString(), - testWidget->currentText()); if (edit) { testWidget->setCurrentIndex(-1); @@ -2486,7 +2481,7 @@ void tst_QComboBox::task247863_keyBoardSelection() QApplication::setActiveWindow(&combo); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo)); - QSignalSpy spy(&combo, SIGNAL(activated(QString))); + QSignalSpy spy(&combo, &QComboBox::activated); qApp->setEffectEnabled(Qt::UI_AnimateCombo, false); QTest::keyClick(&combo, Qt::Key_Space); qApp->setEffectEnabled(Qt::UI_AnimateCombo, true); @@ -2767,7 +2762,7 @@ void tst_QComboBox::resetModel() }; QComboBox cb; StringListModel model({"1", "2"}); - QSignalSpy spy(&cb, QOverload<int>::of(&QComboBox::currentIndexChanged)); + QSignalSpy spy(&cb, &QComboBox::currentIndexChanged); QCOMPARE(spy.count(), 0); QCOMPARE(cb.currentIndex(), -1); //no selection diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/CMakeLists.txt b/tests/auto/widgets/widgets/qcommandlinkbutton/CMakeLists.txt new file mode 100644 index 0000000000..59ba375358 --- /dev/null +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qcommandlinkbutton.pro. + +##################################################################### +## tst_qcommandlinkbutton Test: +##################################################################### + +add_qt_test(tst_qcommandlinkbutton + SOURCES + tst_qcommandlinkbutton.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index 0044d33c66..45a23984e0 100644 --- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -51,7 +51,9 @@ private slots: void getSetCheck(); void pressed(); +#if QT_CONFIG(shortcut) void setAccel(); +#endif void isCheckable(); void setDown(); void popupCrash(); @@ -133,8 +135,10 @@ void tst_QCommandLinkButton::init() testWidget->setText("Test"); testWidget->setDescription("Description text."); testWidget->setEnabled( true ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif resetCounters(); } @@ -327,6 +331,8 @@ void tst_QCommandLinkButton::toggled() QVERIFY( click_count == 1 ); } +#if QT_CONFIG(shortcut) + /* If we press an accelerator key we ONLY get a pressed signal and NOT a released or clicked signal. @@ -355,6 +361,8 @@ void tst_QCommandLinkButton::setAccel() QTest::qWait(200); } +#endif // QT_CONFIG(shortcut) + void tst_QCommandLinkButton::animateClick() { QVERIFY( !testWidget->isDown() ); diff --git a/tests/auto/widgets/widgets/qdatetimeedit/CMakeLists.txt b/tests/auto/widgets/widgets/qdatetimeedit/CMakeLists.txt new file mode 100644 index 0000000000..8eb294d361 --- /dev/null +++ b/tests/auto/widgets/widgets/qdatetimeedit/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qdatetimeedit.pro. + +##################################################################### +## tst_qdatetimeedit Test: +##################################################################### + +add_qt_test(tst_qdatetimeedit + SOURCES + tst_qdatetimeedit.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 6345d238e1..08c80c96ab 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -264,6 +264,8 @@ private slots: void timeSpec(); void timeSpecBug(); void timeSpecInit(); + void setDateTime_data(); + void setDateTime(); void monthEdgeCase(); void setLocale(); @@ -3599,6 +3601,54 @@ void tst_QDateTimeEdit::timeSpecInit() QCOMPARE(widget.dateTime(), utc); } +void tst_QDateTimeEdit::setDateTime_data() +{ + QTest::addColumn<Qt::TimeSpec>("spec"); + QDateTime localNoon(QDate(2019, 12, 24), QTime(12, 0), Qt::LocalTime); +#if 0 // Not yet supported + QTest::addColumn<int>("offset"); + QTest::addColumn<QByteArray>("zoneName"); + + QTest::newRow("OffsetFromUTC/LocalTime") + << Qt::OffsetFromUTC << 7200 << "" + << localNoon << localNoon.toOffsetFromUtc(7200); +#if QT_CONFIG(timezone) + QTest::newRow("TimeZone/LocalTime") + << Qt::TimeZone << 0 << "Europe/Berlin" + << localNoon << localNoon.toTimeZone(QTimeZone("Europe/Berlin")); +#endif +#endif // unsupported + QTest::addColumn<QDateTime>("store"); + QTest::addColumn<QDateTime>("expect"); + QTest::newRow("LocalTime/LocalTime") + << Qt::LocalTime // << 0 << "" + << localNoon << localNoon; + QTest::newRow("LocalTime/UTC") + << Qt::LocalTime // << 0 << "" + << localNoon.toUTC() << localNoon; + QTest::newRow("UTC/LocalTime") + << Qt::UTC // << 0 << "" + << localNoon << localNoon.toUTC(); + QTest::newRow("UTC/UTC") + << Qt::UTC // << 0 << "" + << localNoon.toUTC() << localNoon.toUTC(); +} + +void tst_QDateTimeEdit::setDateTime() +{ + QFETCH(const Qt::TimeSpec, spec); +#if 0 // Not yet supported + QFETCH(const int, offset); + QFETCH(const QByteArray, zoneName); +#endif // configuring the spec, when OffsetFromUTC or TimeZone + QFETCH(const QDateTime, store); + QFETCH(const QDateTime, expect); + QDateTimeEdit editor; + editor.setTimeSpec(spec); + editor.setDateTime(store); + QCOMPARE(editor.dateTime(), expect); +} + void tst_QDateTimeEdit::cachedDayTest() { testWidget->setDisplayFormat("MM/dd"); diff --git a/tests/auto/widgets/widgets/qdial/CMakeLists.txt b/tests/auto/widgets/widgets/qdial/CMakeLists.txt new file mode 100644 index 0000000000..e725edacb6 --- /dev/null +++ b/tests/auto/widgets/widgets/qdial/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qdial.pro. + +##################################################################### +## tst_qdial Test: +##################################################################### + +add_qt_test(tst_qdial + SOURCES + tst_qdial.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/CMakeLists.txt b/tests/auto/widgets/widgets/qdialogbuttonbox/CMakeLists.txt new file mode 100644 index 0000000000..c4961f13a1 --- /dev/null +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qdialogbuttonbox.pro. + +##################################################################### +## tst_qdialogbuttonbox Test: +##################################################################### + +add_qt_test(tst_qdialogbuttonbox + SOURCES + tst_qdialogbuttonbox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp index 6a2c8893d2..58a90dd572 100644 --- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp +++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp @@ -30,7 +30,7 @@ #include <QtWidgets/QStyle> #include <QtWidgets/QLayout> #include <QtWidgets/QDialog> -#include <QtWidgets/QAction> +#include <QtGui/QAction> #include <qdialogbuttonbox.h> #include <limits.h> diff --git a/tests/auto/widgets/widgets/qdockwidget/CMakeLists.txt b/tests/auto/widgets/widgets/qdockwidget/CMakeLists.txt new file mode 100644 index 0000000000..e2b6cc5942 --- /dev/null +++ b/tests/auto/widgets/widgets/qdockwidget/CMakeLists.txt @@ -0,0 +1,16 @@ +# Generated from qdockwidget.pro. + +##################################################################### +## tst_qdockwidget Test: +##################################################################### + +add_qt_test(tst_qdockwidget + SOURCES + tst_qdockwidget.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 9a16c39014..8ece03983b 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -103,8 +103,6 @@ void tst_QDockWidget::getSetCheck() QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetMovable), obj1.features()); obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable)); QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable), obj1.features()); - obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures)); - QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures), obj1.features()); obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures)); QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures), obj1.features()); } @@ -207,9 +205,9 @@ void tst_QDockWidget::features() QSignalSpy spy(&dw, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures))); // default features for dock widgets - int allDockWidgetFeatures = QDockWidget::DockWidgetClosable | - QDockWidget::DockWidgetMovable | - QDockWidget::DockWidgetFloatable; + const auto allDockWidgetFeatures = QDockWidget::DockWidgetClosable | + QDockWidget::DockWidgetMovable | + QDockWidget::DockWidgetFloatable; // defaults QCOMPARE(dw.features(), allDockWidgetFeatures); @@ -323,8 +321,8 @@ void tst_QDockWidget::features() QCOMPARE(spy.count(), 0); spy.clear(); - dw.setFeatures(QDockWidget::AllDockWidgetFeatures); - QCOMPARE(dw.features(), QDockWidget::AllDockWidgetFeatures); + dw.setFeatures(allDockWidgetFeatures); + QCOMPARE(dw.features(), allDockWidgetFeatures); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); diff --git a/tests/auto/widgets/widgets/qdoublespinbox/CMakeLists.txt b/tests/auto/widgets/widgets/qdoublespinbox/CMakeLists.txt new file mode 100644 index 0000000000..b639289db8 --- /dev/null +++ b/tests/auto/widgets/widgets/qdoublespinbox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qdoublespinbox.pro. + +##################################################################### +## tst_qdoublespinbox Test: +##################################################################### + +add_qt_test(tst_qdoublespinbox + SOURCES + tst_qdoublespinbox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index c293a4bdd2..cec2da1d57 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -166,7 +166,9 @@ private slots: void doubleDot(); +#if QT_CONFIG(shortcut) void undoRedo(); +#endif void valueFromTextAndValidate_data(); void valueFromTextAndValidate(); @@ -417,7 +419,7 @@ void tst_QDoubleSpinBox::setTracking() spin.setDecimals(decimals); spin.show(); - connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(QString))); + connect(&spin, SIGNAL(textChanged(QString)), this, SLOT(valueChangedHelper(QString))); keys.simulate(&spin); QCOMPARE(actualTexts, texts); @@ -1025,6 +1027,8 @@ void tst_QDoubleSpinBox::doubleDot() QCOMPARE(spin.lineEdit()->cursorPosition(), 2); } +#if QT_CONFIG(shortcut) + void tst_QDoubleSpinBox::undoRedo() { //test undo/redo feature (in conjunction with the "undoRedoEnabled" property) @@ -1073,6 +1077,8 @@ void tst_QDoubleSpinBox::undoRedo() QVERIFY(!spin.lineEdit()->isRedoAvailable()); } +#endif // QT_CONFIG(shortcut) + struct task199226_DoubleSpinBox : public QDoubleSpinBox { task199226_DoubleSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {} @@ -1768,7 +1774,7 @@ void tst_QDoubleSpinBox::stepModifierPressAndHold() stepModifierStyle->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); spin.setStyle(stepModifierStyle.data()); - QSignalSpy spy(&spin, QOverload<double>::of(&DoubleSpinBox::valueChanged)); + QSignalSpy spy(&spin, &DoubleSpinBox::valueChanged); spin.show(); QVERIFY(QTest::qWaitForWindowExposed(&spin)); diff --git a/tests/auto/widgets/widgets/qfocusframe/CMakeLists.txt b/tests/auto/widgets/widgets/qfocusframe/CMakeLists.txt new file mode 100644 index 0000000000..85160faed7 --- /dev/null +++ b/tests/auto/widgets/widgets/qfocusframe/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qfocusframe.pro. + +##################################################################### +## tst_qfocusframe Test: +##################################################################### + +add_qt_test(tst_qfocusframe + SOURCES + tst_qfocusframe.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qfontcombobox/CMakeLists.txt b/tests/auto/widgets/widgets/qfontcombobox/CMakeLists.txt new file mode 100644 index 0000000000..777abc48c5 --- /dev/null +++ b/tests/auto/widgets/widgets/qfontcombobox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qfontcombobox.pro. + +##################################################################### +## tst_qfontcombobox Test: +##################################################################### + +add_qt_test(tst_qfontcombobox + SOURCES + tst_qfontcombobox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qframe/CMakeLists.txt b/tests/auto/widgets/widgets/qframe/CMakeLists.txt new file mode 100644 index 0000000000..ae23555fa5 --- /dev/null +++ b/tests/auto/widgets/widgets/qframe/CMakeLists.txt @@ -0,0 +1,20 @@ +# Generated from qframe.pro. + +##################################################################### +## tst_qframe Test: +##################################################################### + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + images/*) +list(APPEND test_data ${test_data_glob}) + +add_qt_test(tst_qframe + SOURCES + tst_qframe.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + TESTDATA ${test_data} +) diff --git a/tests/auto/widgets/widgets/qgroupbox/CMakeLists.txt b/tests/auto/widgets/widgets/qgroupbox/CMakeLists.txt new file mode 100644 index 0000000000..09d4623cd9 --- /dev/null +++ b/tests/auto/widgets/widgets/qgroupbox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qgroupbox.pro. + +##################################################################### +## tst_qgroupbox Test: +##################################################################### + +add_qt_test(tst_qgroupbox + SOURCES + tst_qgroupbox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/CMakeLists.txt b/tests/auto/widgets/widgets/qkeysequenceedit/CMakeLists.txt new file mode 100644 index 0000000000..c57f8b5c0a --- /dev/null +++ b/tests/auto/widgets/widgets/qkeysequenceedit/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qkeysequenceedit.pro. + +##################################################################### +## tst_qkeysequenceedit Test: +##################################################################### + +add_qt_test(tst_qkeysequenceedit + SOURCES + tst_qkeysequenceedit.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qlabel/CMakeLists.txt b/tests/auto/widgets/widgets/qlabel/CMakeLists.txt new file mode 100644 index 0000000000..a4fe508a02 --- /dev/null +++ b/tests/auto/widgets/widgets/qlabel/CMakeLists.txt @@ -0,0 +1,27 @@ +# Generated from qlabel.pro. + +##################################################################### +## tst_qlabel Test: +##################################################################### + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + testdata/*) +list(APPEND test_data ${test_data_glob}) +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + *.png) +list(APPEND test_data ${test_data_glob}) + +add_qt_test(tst_qlabel + SOURCES + tst_qlabel.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate + TESTDATA ${test_data} +) diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index f599ac73c6..eb34a5ad4e 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -38,6 +38,8 @@ #include <qmovie.h> #include <qpicture.h> #include <qmessagebox.h> +#include <qfontmetrics.h> +#include <qmath.h> #include <private/qlabel_p.h> class Widget : public QWidget @@ -68,7 +70,7 @@ private Q_SLOTS: void setText_data(); void setText(); void setTextFormat(); -#ifndef Q_OS_MAC +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) void setBuddy(); #endif void setNum(); @@ -88,8 +90,10 @@ private Q_SLOTS: void unicodeText_data(); void unicodeText(); +#if QT_CONFIG(shortcut) void mnemonic_data(); void mnemonic(); +#endif void selection(); #ifndef QT_NO_CONTEXTMENU @@ -116,6 +120,7 @@ void tst_QLabel::getSetCheck() obj1.setWordWrap(true); QCOMPARE(true, obj1.wordWrap()); +#if QT_CONFIG(shortcut) // QWidget * QLabel::buddy() // void QLabel::setBuddy(QWidget *) QWidget *var2 = new QWidget(); @@ -124,6 +129,7 @@ void tst_QLabel::getSetCheck() obj1.setBuddy((QWidget *)0); QCOMPARE((QWidget *)0, obj1.buddy()); delete var2; +#endif // QT_CONFIG(shortcut) // QMovie * QLabel::movie() // void QLabel::setMovie(QMovie *) @@ -153,7 +159,9 @@ void tst_QLabel::cleanupTestCase() void tst_QLabel::init() { testWidget->setTextFormat( Qt::AutoText ); +# if QT_CONFIG(shortcut) testWidget->setBuddy( 0 ); +#endif testWidget->setIndent( 0 ); testWidget->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); testWidget->setScaledContents( false ); @@ -169,7 +177,7 @@ void tst_QLabel::cleanup() } // Set buddy doesn't make much sense on OS X -#ifndef Q_OS_MAC +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) void tst_QLabel::setBuddy() { testWidget->hide(); @@ -204,7 +212,7 @@ void tst_QLabel::setBuddy() delete test_box; } -#endif +#endif // QT_CONFIG(shortcut) && !Q_OS_DARWIN void tst_QLabel::setText_data() { @@ -367,8 +375,16 @@ void tst_QLabel::sizeHint() l1.setAlignment(Qt::AlignVCenter); l1.setTextInteractionFlags(Qt::TextSelectableByMouse); // will now use qtextcontrol int h1 = l1.sizeHint().height(); - QCOMPARE(h1, h); + QFontMetricsF fontMetrics(QApplication::font()); + qreal leading = fontMetrics.leading(); + qreal ascent = fontMetrics.ascent(); + qreal descent = fontMetrics.descent(); + + bool leadingOverflow = qCeil(ascent + descent) < qCeil(ascent + descent + leading); + if (leadingOverflow) + QEXPECT_FAIL("", "See QTBUG-82954", Continue); + QCOMPARE(h1, h); } void tst_QLabel::task226479_movieResize() @@ -469,6 +485,8 @@ void tst_QLabel::unicodeText() testWidget->show(); } +#if QT_CONFIG(shortcut) + void tst_QLabel::mnemonic_data() { QTest::addColumn<QString>("text"); @@ -513,6 +531,8 @@ void tst_QLabel::mnemonic() QCOMPARE(d->shortcutCursor.selectedText(), expectedShortcutCursor); } +#endif // QT_CONFIG(shortcut) + void tst_QLabel::selection() { QLabel label; diff --git a/tests/auto/widgets/widgets/qlcdnumber/CMakeLists.txt b/tests/auto/widgets/widgets/qlcdnumber/CMakeLists.txt new file mode 100644 index 0000000000..fbd9ff5913 --- /dev/null +++ b/tests/auto/widgets/widgets/qlcdnumber/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qlcdnumber.pro. + +##################################################################### +## tst_qlcdnumber Test: +##################################################################### + +add_qt_test(tst_qlcdnumber + SOURCES + tst_qlcdnumber.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qlineedit/CMakeLists.txt b/tests/auto/widgets/widgets/qlineedit/CMakeLists.txt new file mode 100644 index 0000000000..615a5a98cb --- /dev/null +++ b/tests/auto/widgets/widgets/qlineedit/CMakeLists.txt @@ -0,0 +1,25 @@ +# Generated from qlineedit.pro. + +##################################################################### +## tst_qlineedit Test: +##################################################################### + +add_qt_test(tst_qlineedit + SOURCES + tst_qlineedit.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +extend_target(tst_qlineedit CONDITION MACOS + PUBLIC_LIBRARIES + ${FWAppKit} +) diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 6408df3f11..6b0beb614a 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -56,7 +56,9 @@ #include <qsortfilterproxymodel.h> #include <qdebug.h> #include <qscreen.h> -#include <qshortcut.h> +#if QT_CONFIG(shortcut) +# include <qshortcut.h> +#endif #include "qcommonstyle.h" #include "qstyleoption.h" @@ -133,9 +135,11 @@ private slots: void clearInputMask(); +#if QT_CONFIG(shortcut) void keypress_inputMask_data(); void keypress_inputMask(); void keypress_inputMethod_inputMask(); +#endif void inputMaskAndValidator_data(); void inputMaskAndValidator(); @@ -217,7 +221,7 @@ private slots: void setSelection_data(); void setSelection(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void cut(); void cutWithoutSelection(); #endif @@ -297,8 +301,10 @@ private slots: void shouldShowPlaceholderText(); void QTBUG1266_setInputMaskEmittingTextEdited(); +#if QT_CONFIG(shortcut) void shortcutOverrideOnReadonlyLineEdit_data(); void shortcutOverrideOnReadonlyLineEdit(); +#endif void QTBUG59957_clearButtonLeftmostAction(); void QTBUG_60319_setInputMaskCheckImSurroundingText(); void testQuickSelectionWithMouse(); @@ -317,7 +323,9 @@ private: void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = {}); void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = {}); bool unselectingWithLeftOrRightChangesCursorPosition(); +#if QT_CONFIG(shortcut) void addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey); +#endif QLineEdit *ensureTestWidget(); bool validInput; @@ -713,6 +721,8 @@ void tst_QLineEdit::clearInputMask() QCOMPARE(testWidget->inputMask(), QString()); } +#if QT_CONFIG(shortcut) + void tst_QLineEdit::keypress_inputMask_data() { QTest::addColumn<QString>("mask"); @@ -838,6 +848,8 @@ void tst_QLineEdit::keypress_inputMethod_inputMask() QCOMPARE(testWidget->text(), QStringLiteral("EE.EE.EE")); } +#endif // QT_CONFIG(shortcut) + void tst_QLineEdit::hasAcceptableInputMask_data() { QTest::addColumn<QString>("optionalMask"); @@ -1989,6 +2001,8 @@ void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardMo keys.addKeyClick(key, pressState); } +#if QT_CONFIG(shortcut) + void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence::StandardKey key) { QKeySequence keyseq = QKeySequence(key); @@ -1996,6 +2010,8 @@ void tst_QLineEdit::addKeySequenceStandardKey(QTestEventList &keys, QKeySequence keys.addKeyClick( Qt::Key( keyseq[i] & ~Qt::KeyboardModifierMask), Qt::KeyboardModifier(keyseq[i] & Qt::KeyboardModifierMask) ); } +#endif // QT_CONFIG(shortcut) + void tst_QLineEdit::cursorPosition() { QLineEdit *testWidget = ensureTestWidget(); @@ -3026,7 +3042,7 @@ void tst_QLineEdit::setSelection() QCOMPARE(testWidget->cursorPosition(), expectedCursor); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut) void tst_QLineEdit::cut() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -3127,7 +3143,7 @@ void tst_QLineEdit::cutWithoutSelection() QCOMPARE(clipboard->text(), origText.left(selectionLength)); } -#endif // !QT_NO_CLIPBOARD +#endif // QT_CONFIG(clipboard) && QT_CONFIG(shortcut) class InputMaskValidator : public QValidator { @@ -3566,18 +3582,6 @@ void tst_QLineEdit::textMargin() QCOMPARE(right, margins.right()); QCOMPARE(bottom, margins.bottom()); -#if QT_DEPRECATED_SINCE(5, 14) - int l; - int t; - int r; - int b; - testWidget.getTextMargins(&l, &t, &r, &b); - QCOMPARE(left, l); - QCOMPARE(top, t); - QCOMPARE(right, r); - QCOMPARE(bottom, b); -#endif - QTest::mouseClick(&testWidget, Qt::LeftButton, {}, mousePressPos); QTRY_COMPARE(testWidget.cursorPosition(), cursorPosition); } @@ -3975,7 +3979,9 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() le.setReadOnly(true); QAction action(QString::fromLatin1("hello"), &le); +#if QT_CONFIG(shortcut) action.setShortcut(QString::fromLatin1("p")); +#endif QSignalSpy spy(&action, SIGNAL(triggered())); le.addAction(&action); @@ -4710,6 +4716,8 @@ void tst_QLineEdit::QTBUG1266_setInputMaskEmittingTextEdited() QCOMPARE(spy.count(), 0); } +#if QT_CONFIG(shortcut) + void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit_data() { QTest::addColumn<QKeySequence>("keySequence"); @@ -4769,6 +4777,8 @@ void tst_QLineEdit::shortcutOverrideOnReadonlyLineEdit() QCOMPARE(spy.count(), activationCount); } +#endif // QT_CONFIG(shortcut) + void tst_QLineEdit::QTBUG59957_clearButtonLeftmostAction() { #ifndef QT_BUILD_INTERNAL diff --git a/tests/auto/widgets/widgets/qmainwindow/CMakeLists.txt b/tests/auto/widgets/widgets/qmainwindow/CMakeLists.txt new file mode 100644 index 0000000000..55bcf941d0 --- /dev/null +++ b/tests/auto/widgets/widgets/qmainwindow/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qmainwindow.pro. + +##################################################################### +## tst_qmainwindow Test: +##################################################################### + +add_qt_test(tst_qmainwindow + SOURCES + tst_qmainwindow.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt b/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt new file mode 100644 index 0000000000..961bd09492 --- /dev/null +++ b/tests/auto/widgets/widgets/qmdiarea/CMakeLists.txt @@ -0,0 +1,32 @@ +# Generated from qmdiarea.pro. + +##################################################################### +## tst_qmdiarea Test: +##################################################################### + +add_qt_test(tst_qmdiarea + SOURCES + tst_qmdiarea.cpp + DEFINES + QT_NO_CAST_FROM_ASCII + QT_NO_CAST_TO_ASCII + INCLUDE_DIRECTORIES + . + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Widgets +) + +## Scopes: +##################################################################### + +extend_target(tst_qmdiarea CONDITION TARGET Qt::OpenGL + PUBLIC_LIBRARIES + Qt::OpenGL +) + +extend_target(tst_qmdiarea CONDITION APPLE + PUBLIC_LIBRARIES + ${FWSecurity} +) diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index e3b046e448..068742f33f 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -886,7 +886,7 @@ void tst_QMdiArea::minimumSizeHint() QAbstractScrollArea dummyScrollArea; dummyScrollArea.setFrameStyle(QFrame::NoFrame); expectedSize = expectedSize.expandedTo(dummyScrollArea.minimumSizeHint()); - QCOMPARE(workspace.minimumSizeHint(), expectedSize.expandedTo(qApp->globalStrut())); + QCOMPARE(workspace.minimumSizeHint(), expectedSize); QWidget *window = workspace.addSubWindow(new QWidget); qApp->processEvents(); @@ -908,7 +908,7 @@ void tst_QMdiArea::sizeHint() workspace.show(); QSize desktopSize = QApplication::desktop()->size(); QSize expectedSize(desktopSize.width() * 2/3, desktopSize.height() * 2/3); - QCOMPARE(workspace.sizeHint(), expectedSize.expandedTo(qApp->globalStrut())); + QCOMPARE(workspace.sizeHint(), expectedSize); QWidget *window = workspace.addSubWindow(new QWidget); qApp->processEvents(); @@ -2694,30 +2694,6 @@ void tst_QMdiArea::nativeSubWindows() foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList()) QVERIFY(subWindow->internalWinId()); } - -#ifndef QT_NO_OPENGL - { - if (!QGLFormat::hasOpenGL()) - QSKIP("QGL not supported on this platform"); - - QMdiArea mdiArea; - QGLWidget *glViewport = new QGLWidget; - mdiArea.setViewport(glViewport); - mdiArea.addSubWindow(new QWidget); - mdiArea.addSubWindow(new QWidget); - mdiArea.show(); - QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); - - const QGLContext *context = glViewport->context(); - if (!context || !context->isValid()) - QSKIP("QGL is broken, cannot continue test"); - - // The viewport and all the sub-windows must be native. - QVERIFY(mdiArea.viewport()->internalWinId()); - foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList()) - QVERIFY(subWindow->internalWinId()); - } -#endif } void tst_QMdiArea::task_209615() diff --git a/tests/auto/widgets/widgets/qmdisubwindow/CMakeLists.txt b/tests/auto/widgets/widgets/qmdisubwindow/CMakeLists.txt new file mode 100644 index 0000000000..791d411970 --- /dev/null +++ b/tests/auto/widgets/widgets/qmdisubwindow/CMakeLists.txt @@ -0,0 +1,19 @@ +# Generated from qmdisubwindow.pro. + +##################################################################### +## tst_qmdisubwindow Test: +##################################################################### + +add_qt_test(tst_qmdisubwindow + SOURCES + tst_qmdisubwindow.cpp + DEFINES + QT_NO_CAST_FROM_ASCII + QT_NO_CAST_TO_ASCII + INCLUDE_DIRECTORIES + . + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 1c19bf96d6..dfba506cf9 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -255,25 +255,33 @@ void tst_QMdiSubWindow::sizeHint() void tst_QMdiSubWindow::minimumSizeHint() { - const auto globalStrut = QApplication::globalStrut(); + class Widget : public QWidget + { + public: + Widget() = default; + + QSize minimumSizeHint() const + { + return QSize(100, 100); + } + + }; QMdiSubWindow window; window.setWindowTitle(QLatin1String(QTest::currentTestFunction())); window.show(); - QCOMPARE(window.minimumSizeHint(), globalStrut); + QCOMPARE(window.minimumSizeHint(), QSize(0, 0)); window.setWidget(new QWidget); - QCOMPARE(window.minimumSizeHint(), window.layout()->minimumSize() - .expandedTo(globalStrut)); + QCOMPARE(window.minimumSizeHint(), window.layout()->minimumSize()); delete window.widget(); delete window.layout(); - window.setWidget(new QWidget); - QCOMPARE(window.minimumSizeHint(), globalStrut); + window.setWidget(new Widget); + QCOMPARE(window.minimumSizeHint(), QSize(0, 0)); window.widget()->show(); - QCOMPARE(window.minimumSizeHint(), window.widget()->minimumSizeHint() - .expandedTo(globalStrut)); + QCOMPARE(window.minimumSizeHint(), window.widget()->minimumSizeHint()); } void tst_QMdiSubWindow::minimumSize() diff --git a/tests/auto/widgets/widgets/qmenu/CMakeLists.txt b/tests/auto/widgets/widgets/qmenu/CMakeLists.txt new file mode 100644 index 0000000000..63037b7eaa --- /dev/null +++ b/tests/auto/widgets/widgets/qmenu/CMakeLists.txt @@ -0,0 +1,30 @@ +# Generated from qmenu.pro. + +##################################################################### +## tst_qmenu Test: +##################################################################### + +add_qt_test(tst_qmenu + SOURCES + tst_qmenu.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::TestPrivate + Qt::Widgets +) + +## Scopes: +##################################################################### + +extend_target(tst_qmenu CONDITION MACOS + SOURCES + tst_qmenu_mac.mm + PUBLIC_LIBRARIES + objc +) + +extend_target(tst_qmenu CONDITION NOT MACOS + DEFINES + QTEST_QPA_MOUSE_HANDLING +) diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 5a24995caf..9ee239aceb 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -484,7 +484,7 @@ void tst_QMenu::overrideMenuAction() // On Mac and Windows CE, we need to create native key events to test menu // action activation, so skip this part of the test. -#if !defined(Q_OS_DARWIN) +#if QT_CONFIG(shortcut) && !defined(Q_OS_DARWIN) QAction *aQuit = new QAction("Quit", &w); aQuit->setShortcut(QKeySequence("Ctrl+X")); m->addAction(aQuit); @@ -502,7 +502,7 @@ void tst_QMenu::overrideMenuAction() //test if the menu still pops out QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier); QTRY_VERIFY(m->isVisible()); -#endif +#endif // QT_CONFIG(shortcut) && !Q_OS_DARWIN delete aFileMenu; @@ -974,8 +974,7 @@ void tst_QMenu::menuSizeHint() QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(hmargin + cm.right() + panelWidth, vmargin + cm.top() + panelWidth); - resSize = menu.style()->sizeFromContents(QStyle::CT_Menu, &opt, - resSize.expandedTo(QApplication::globalStrut()), &menu); + resSize = menu.style()->sizeFromContents(QStyle::CT_Menu, &opt, resSize, &menu); QCOMPARE(resSize, menu.sizeHint()); } @@ -1845,10 +1844,13 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts() QSKIP("Window activation is not supported"); QAction *actionKamen = new QAction("Action Kamen"); +#if QT_CONFIG(shortcut) actionKamen->setShortcut(QKeySequence(QLatin1String("K"))); - +#endif QAction *actionJoe = new QAction("Action Joe"); +#if QT_CONFIG(shortcut) actionJoe->setShortcut(QKeySequence(QLatin1String("Ctrl+J"))); +#endif QMenu menu; menu.addAction(actionKamen); diff --git a/tests/auto/widgets/widgets/qmenubar/CMakeLists.txt b/tests/auto/widgets/widgets/qmenubar/CMakeLists.txt new file mode 100644 index 0000000000..415f2aa79f --- /dev/null +++ b/tests/auto/widgets/widgets/qmenubar/CMakeLists.txt @@ -0,0 +1,24 @@ +# Generated from qmenubar.pro. + +##################################################################### +## tst_qmenubar Test: +##################################################################### + +add_qt_test(tst_qmenubar + SOURCES + tst_qmenubar.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) + +## Scopes: +##################################################################### + +extend_target(tst_qmenubar CONDITION MACOS + SOURCES + tst_qmenubar_mac.mm + PUBLIC_LIBRARIES + ${FWAppKit} +) diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 53f1e1fc5c..1638ac846f 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -232,19 +232,25 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) { connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); QMenu *menu = mb->addMenu(QStringLiteral("&accel")); QAction *action = menu->addAction(QStringLiteral("menu1") ); +#if QT_CONFIG(shortcut) action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); +#endif connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); result.menus << menu; result.actions << action; menu = mb->addMenu(QStringLiteral("accel1")); action = menu->addAction(QStringLiteral("&Open...") ); +#if QT_CONFIG(shortcut) action->setShortcut(Qt::Key_O); +#endif result.actions << action; action = menu->addAction(QStringLiteral("action")); +#if QT_CONFIG(shortcut) action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z)); +#endif result.actions << action; result.menus << menu; @@ -283,7 +289,9 @@ QAction *tst_QMenuBar::createCharacterAction(QMenu *menu, char lowerAscii) QAction *action = menu->addAction(text); action->setObjectName(text); action->setData(QVariant(int(lowerAscii))); +#if QT_CONFIG(shortcut) action->setShortcut(Qt::CTRL + (lowerAscii - 'a' + Qt::Key_A)); +#endif connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); return action; } @@ -318,7 +326,9 @@ TestMenu tst_QMenuBar::initComplexMenuBar(QMenuBar *mb) QAction *action = mb->addAction(QStringLiteral("M&enu 3")); action->setData(QVariant(3)); +#if QT_CONFIG(shortcut) action->setShortcut(Qt::ALT + Qt::Key_J); +#endif connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered())); result.actions << action; @@ -1406,10 +1416,7 @@ void tst_QMenuBar::menubarSizeHint() QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(panelWidth + hmargin, panelWidth + vmargin); - - resSize = style.sizeFromContents(QStyle::CT_MenuBar, &opt, - resSize.expandedTo(QApplication::globalStrut()), - &mb); + resSize = style.sizeFromContents(QStyle::CT_MenuBar, &opt, resSize, &mb); QCOMPARE(resSize, mb.sizeHint()); } @@ -1422,7 +1429,9 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten() menubar.setNativeMenuBar(false); QMenu menu("menu1"); QAction *first = menubar.addMenu(&menu); +#if QT_CONFIG(shortcut) menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); +#endif centerOnScreen(&menubar); menubar.show(); QApplication::setActiveWindow(&menubar); diff --git a/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt b/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt new file mode 100644 index 0000000000..c3fdf39fe1 --- /dev/null +++ b/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qopenglwidget.pro. + +##################################################################### +## tst_qopenglwidget Test: +##################################################################### + +add_qt_test(tst_qopenglwidget + SOURCES + tst_qopenglwidget.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::OpenGL + Qt::OpenGLPrivate + Qt::OpenGLWidgets + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro b/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro index 2d4cff9e10..792bbf4529 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro +++ b/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qopenglwidget -QT += gui-private core-private testlib widgets +QT += opengl opengl-private gui-private core-private testlib widgets openglwidgets SOURCES += tst_qopenglwidget.cpp diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 7d70d49019..cb4fc201f6 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -26,7 +26,7 @@ ** ****************************************************************************/ -#include <QtWidgets/QOpenGLWidget> +#include <QtOpenGLWidgets/QOpenGLWidget> #include <QtGui/QOpenGLFunctions> #include <QtGui/QPainter> #include <QtGui/QScreen> diff --git a/tests/auto/widgets/widgets/qplaintextedit/CMakeLists.txt b/tests/auto/widgets/widgets/qplaintextedit/CMakeLists.txt new file mode 100644 index 0000000000..cb00d5dd93 --- /dev/null +++ b/tests/auto/widgets/widgets/qplaintextedit/CMakeLists.txt @@ -0,0 +1,25 @@ +# Generated from qplaintextedit.pro. + +##################################################################### +## tst_qplaintextedit Test: +##################################################################### + +add_qt_test(tst_qplaintextedit + SOURCES + tst_qplaintextedit.cpp + INCLUDE_DIRECTORIES + .. + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +extend_target(tst_qplaintextedit CONDITION MACOS + PUBLIC_LIBRARIES + ${FWAppKit} +) diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index a86784f2ec..fa702f8661 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -135,11 +135,6 @@ private slots: void insertAndScrollToBottom(); void inputMethodQueryImHints_data(); void inputMethodQueryImHints(); -#ifndef QT_NO_REGEXP - void findWithRegExp(); - void findBackwardWithRegExp(); - void findWithRegExpReturnsFalseIfNoMoreResults(); -#endif #if QT_CONFIG(regularexpression) void findWithRegularExpression(); void findBackwardWithRegularExpression(); @@ -1562,45 +1557,6 @@ void tst_QPlainTextEdit::inputMethodQueryImHints() QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints); } -#ifndef QT_NO_REGEXP -void tst_QPlainTextEdit::findWithRegExp() -{ - ed->setPlainText(QStringLiteral("arbitrary text")); - QRegExp rx("\\w{2}xt"); - - bool found = ed->find(rx); - - QVERIFY(found); - QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); -} - -void tst_QPlainTextEdit::findBackwardWithRegExp() -{ - ed->setPlainText(QStringLiteral("arbitrary text")); - QTextCursor cursor = ed->textCursor(); - cursor.movePosition(QTextCursor::End); - ed->setTextCursor(cursor); - QRegExp rx("a\\w*t"); - - bool found = ed->find(rx, QTextDocument::FindBackward); - - QVERIFY(found); - QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); -} - -void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() -{ - ed->setPlainText(QStringLiteral("arbitrary text")); - QRegExp rx("t.xt"); - ed->find(rx); - - bool found = ed->find(rx); - - QVERIFY(!found); - QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); -} -#endif - #if QT_CONFIG(regularexpression) void tst_QPlainTextEdit::findWithRegularExpression() { diff --git a/tests/auto/widgets/widgets/qprogressbar/CMakeLists.txt b/tests/auto/widgets/widgets/qprogressbar/CMakeLists.txt new file mode 100644 index 0000000000..f8b3ac38d9 --- /dev/null +++ b/tests/auto/widgets/widgets/qprogressbar/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qprogressbar.pro. + +##################################################################### +## tst_qprogressbar Test: +##################################################################### + +add_qt_test(tst_qprogressbar + SOURCES + tst_qprogressbar.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qpushbutton/CMakeLists.txt b/tests/auto/widgets/widgets/qpushbutton/CMakeLists.txt new file mode 100644 index 0000000000..8d1300de79 --- /dev/null +++ b/tests/auto/widgets/widgets/qpushbutton/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qpushbutton.pro. + +##################################################################### +## tst_qpushbutton Test: +##################################################################### + +add_qt_test(tst_qpushbutton + SOURCES + tst_qpushbutton.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp index 6f4838be7a..d0ed68c0c8 100644 --- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp @@ -53,7 +53,9 @@ private slots: void getSetCheck(); void autoRepeat(); void pressed(); +#if QT_CONFIG(shortcut) void setAccel(); +#endif void isCheckable(); void setDown(); void popupCrash(); @@ -65,7 +67,9 @@ private slots: void defaultAndAutoDefault(); void sizeHint_data(); void sizeHint(); +#if QT_CONFIG(shortcut) void taskQTBUG_20191_shortcutWithKeypadModifer(); +#endif void emitReleasedAfterChange(); protected slots: @@ -125,8 +129,10 @@ void tst_QPushButton::init() testWidget->setDown( false ); testWidget->setText("Test"); testWidget->setEnabled( true ); +#if QT_CONFIG(shortcut) QKeySequence seq; testWidget->setShortcut( seq ); +#endif resetCounters(); } @@ -318,6 +324,8 @@ void tst_QPushButton::toggled() QVERIFY( click_count == 1 ); } +#if QT_CONFIG(shortcut) + /* If we press an accelerator key we ONLY get a pressed signal and NOT a released or clicked signal. @@ -349,6 +357,8 @@ void tst_QPushButton::setAccel() QTRY_VERIFY( !testWidget->isDown() ); } +#endif // QT_CONFIG(shortcut) + void tst_QPushButton::animateClick() { QVERIFY( !testWidget->isDown() ); @@ -571,6 +581,8 @@ void tst_QPushButton::sizeHint() } } +#if QT_CONFIG(shortcut) + void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() { // setup a dialog with two buttons @@ -617,6 +629,8 @@ void tst_QPushButton::taskQTBUG_20191_shortcutWithKeypadModifer() QCOMPARE(spy2.count(), 1); } +#endif // QT_CONFIG(shortcut) + void tst_QPushButton::emitReleasedAfterChange() { QPushButton *button1 = new QPushButton("A"); diff --git a/tests/auto/widgets/widgets/qradiobutton/CMakeLists.txt b/tests/auto/widgets/widgets/qradiobutton/CMakeLists.txt new file mode 100644 index 0000000000..10db8a2db8 --- /dev/null +++ b/tests/auto/widgets/widgets/qradiobutton/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qradiobutton.pro. + +##################################################################### +## tst_qradiobutton Test: +##################################################################### + +add_qt_test(tst_qradiobutton + SOURCES + tst_qradiobutton.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp index 7123acfdc3..5c7d3bf1e9 100644 --- a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp +++ b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp @@ -44,12 +44,16 @@ public: virtual ~tst_QRadioButton(){}; private slots: +#if QT_CONFIG(shortcut) void task190739_focus(); +#endif void minimumSizeHint(); private: }; +#if QT_CONFIG(shortcut) + void tst_QRadioButton::task190739_focus() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -84,6 +88,7 @@ void tst_QRadioButton::task190739_focus() QVERIFY(!radio1.hasFocus()); } +#endif // QT_CONFIG(shortcut) void tst_QRadioButton::minimumSizeHint() { diff --git a/tests/auto/widgets/widgets/qscrollarea/CMakeLists.txt b/tests/auto/widgets/widgets/qscrollarea/CMakeLists.txt new file mode 100644 index 0000000000..cdfb32e0a2 --- /dev/null +++ b/tests/auto/widgets/widgets/qscrollarea/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qscrollarea.pro. + +##################################################################### +## tst_qscrollarea Test: +##################################################################### + +add_qt_test(tst_qscrollarea + SOURCES + tst_qscrollarea.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qscrollbar/CMakeLists.txt b/tests/auto/widgets/widgets/qscrollbar/CMakeLists.txt new file mode 100644 index 0000000000..83d091755f --- /dev/null +++ b/tests/auto/widgets/widgets/qscrollbar/CMakeLists.txt @@ -0,0 +1,14 @@ +# Generated from qscrollbar.pro. + +##################################################################### +## tst_qscrollbar Test: +##################################################################### + +add_qt_test(tst_qscrollbar + SOURCES + tst_qscrollbar.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::TestPrivate + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qsizegrip/CMakeLists.txt b/tests/auto/widgets/widgets/qsizegrip/CMakeLists.txt new file mode 100644 index 0000000000..d3b28797f2 --- /dev/null +++ b/tests/auto/widgets/widgets/qsizegrip/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qsizegrip.pro. + +##################################################################### +## tst_qsizegrip Test: +##################################################################### + +add_qt_test(tst_qsizegrip + SOURCES + tst_qsizegrip.cpp + INCLUDE_DIRECTORIES + . + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qslider/CMakeLists.txt b/tests/auto/widgets/widgets/qslider/CMakeLists.txt new file mode 100644 index 0000000000..583f12a1fb --- /dev/null +++ b/tests/auto/widgets/widgets/qslider/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qslider.pro. + +##################################################################### +## tst_qslider Test: +##################################################################### + +add_qt_test(tst_qslider + SOURCES + tst_qslider.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qspinbox/CMakeLists.txt b/tests/auto/widgets/widgets/qspinbox/CMakeLists.txt new file mode 100644 index 0000000000..826de28cb4 --- /dev/null +++ b/tests/auto/widgets/widgets/qspinbox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qspinbox.pro. + +##################################################################### +## tst_qspinbox Test: +##################################################################### + +add_qt_test(tst_qspinbox + SOURCES + tst_qspinbox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index f8022559b2..a8b47ffc46 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -47,7 +47,9 @@ #include <QLocale> #include <QDoubleSpinBox> #include <QVBoxLayout> -#include <QKeySequence> +#if QT_CONFIG(shortcut) +# include <QKeySequence> +#endif #include <QStackedWidget> #include <QDebug> #include <QStyleOptionSpinBox> @@ -173,7 +175,10 @@ private slots: void removeAll(); void startWithDash(); + +#if QT_CONFIG(shortcut) void undoRedo(); +#endif void specialValue(); void textFromValue(); @@ -1025,6 +1030,8 @@ void tst_QSpinBox::startWithDash() QCOMPARE(spin.text(), QString("0")); } +#if QT_CONFIG(shortcut) + void tst_QSpinBox::undoRedo() { //test undo/redo feature (in conjunction with the "undoRedoEnabled" property) @@ -1077,6 +1084,8 @@ void tst_QSpinBox::undoRedo() QVERIFY(!spin.lineEdit()->isRedoAvailable()); } +#endif // QT_CONFIG(shortcut) + void tst_QSpinBox::specialValue() { if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) @@ -1821,9 +1830,9 @@ void tst_QSpinBox::stepModifierPressAndHold() stepModifierStyle->stepModifier = static_cast<Qt::KeyboardModifier>(stepModifier); spin.setStyle(stepModifierStyle.data()); - QSignalSpy spy(&spin, QOverload<int>::of(&SpinBox::valueChanged)); + QSignalSpy spy(&spin, &SpinBox::valueChanged); // TODO: remove debug output when QTBUG-69492 is fixed - connect(&spin, QOverload<int>::of(&SpinBox::valueChanged), [=]() { + connect(&spin, &SpinBox::valueChanged, [=]() { qDebug() << QTime::currentTime() << "valueChanged emitted"; }); diff --git a/tests/auto/widgets/widgets/qsplashscreen/CMakeLists.txt b/tests/auto/widgets/widgets/qsplashscreen/CMakeLists.txt new file mode 100644 index 0000000000..babe84f43e --- /dev/null +++ b/tests/auto/widgets/widgets/qsplashscreen/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qsplashscreen.pro. + +##################################################################### +## tst_qsplashscreen Test: +##################################################################### + +add_qt_test(tst_qsplashscreen + SOURCES + tst_qsplashscreen.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qsplitter/CMakeLists.txt b/tests/auto/widgets/widgets/qsplitter/CMakeLists.txt new file mode 100644 index 0000000000..98c165f034 --- /dev/null +++ b/tests/auto/widgets/widgets/qsplitter/CMakeLists.txt @@ -0,0 +1,18 @@ +# Generated from qsplitter.pro. + +##################################################################### +## tst_qsplitter Test: +##################################################################### + +# Collect test data +list(APPEND test_data "extradata.txt") +list(APPEND test_data "setSizes3.dat") + +add_qt_test(tst_qsplitter + SOURCES + tst_qsplitter.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + TESTDATA ${test_data} +) diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index cc65accdc3..332aa7c6d3 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -763,7 +763,7 @@ void tst_QSplitter::replaceWidget() // the same size on the new widget. Because of QLabel's sizing // constraints (they can expand but not shrink) the easiest is // to set a shorter label. - QLabel *newWidget = new QLabel(QLatin1String("<b>NEW</b>")); + QLabel *newWidget = new QLabel(QLatin1String("NEW")); EventCounterSpy ef(&sp); ef.installEventFilter(); diff --git a/tests/auto/widgets/widgets/qstackedwidget/CMakeLists.txt b/tests/auto/widgets/widgets/qstackedwidget/CMakeLists.txt new file mode 100644 index 0000000000..37807eb73a --- /dev/null +++ b/tests/auto/widgets/widgets/qstackedwidget/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qstackedwidget.pro. + +##################################################################### +## tst_qstackedwidget Test: +##################################################################### + +add_qt_test(tst_qstackedwidget + SOURCES + tst_qstackedwidget.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qstatusbar/CMakeLists.txt b/tests/auto/widgets/widgets/qstatusbar/CMakeLists.txt new file mode 100644 index 0000000000..56f3c960fd --- /dev/null +++ b/tests/auto/widgets/widgets/qstatusbar/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qstatusbar.pro. + +##################################################################### +## tst_qstatusbar Test: +##################################################################### + +add_qt_test(tst_qstatusbar + SOURCES + tst_qstatusbar.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qtabbar/CMakeLists.txt b/tests/auto/widgets/widgets/qtabbar/CMakeLists.txt new file mode 100644 index 0000000000..d23d23d88f --- /dev/null +++ b/tests/auto/widgets/widgets/qtabbar/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtabbar.pro. + +##################################################################### +## tst_qtabbar Test: +##################################################################### + +add_qt_test(tst_qtabbar + SOURCES + tst_qtabbar.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qtabwidget/CMakeLists.txt b/tests/auto/widgets/widgets/qtabwidget/CMakeLists.txt new file mode 100644 index 0000000000..9bd0018082 --- /dev/null +++ b/tests/auto/widgets/widgets/qtabwidget/CMakeLists.txt @@ -0,0 +1,24 @@ +# Generated from qtabwidget.pro. + +##################################################################### +## tst_qtabwidget Test: +##################################################################### + +add_qt_test(tst_qtabwidget + SOURCES + tst_qtabwidget.cpp + INCLUDE_DIRECTORIES + .. + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + Qt::WidgetsPrivate +) + +## Scopes: +##################################################################### + +extend_target(tst_qtabwidget CONDITION WIN32 AND NOT WINRT + PUBLIC_LIBRARIES + user32 +) diff --git a/tests/auto/widgets/widgets/qtextbrowser/CMakeLists.txt b/tests/auto/widgets/widgets/qtextbrowser/CMakeLists.txt new file mode 100644 index 0000000000..503dc32a83 --- /dev/null +++ b/tests/auto/widgets/widgets/qtextbrowser/CMakeLists.txt @@ -0,0 +1,37 @@ +# Generated from qtextbrowser.pro. + +##################################################################### +## tst_qtextbrowser Test: +##################################################################### + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + *.html) +list(APPEND test_data ${test_data_glob}) +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + *.md) +list(APPEND test_data ${test_data_glob}) +list(APPEND test_data "markdown.really") +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + subdir/*) +list(APPEND test_data ${test_data_glob}) + +add_qt_test(tst_qtextbrowser + SOURCES + tst_qtextbrowser.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets + TESTDATA ${test_data} +) + +## Scopes: +##################################################################### + +extend_target(tst_qtextbrowser CONDITION builtin_testdata + DEFINES + BUILTIN_TESTDATA +) diff --git a/tests/auto/widgets/widgets/qtextedit/CMakeLists.txt b/tests/auto/widgets/widgets/qtextedit/CMakeLists.txt new file mode 100644 index 0000000000..719acd8dbc --- /dev/null +++ b/tests/auto/widgets/widgets/qtextedit/CMakeLists.txt @@ -0,0 +1,28 @@ +# Generated from qtextedit.pro. + +##################################################################### +## tst_qtextedit Test: +##################################################################### + +# Collect test data +list(APPEND test_data "fullWidthSelection") + +add_qt_test(tst_qtextedit + SOURCES + tst_qtextedit.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate + TESTDATA ${test_data} +) + +## Scopes: +##################################################################### + +extend_target(tst_qtextedit CONDITION MACOS + PUBLIC_LIBRARIES + ${FWAppKit} +) diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 485a0b0f93..716e7da490 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -194,12 +194,6 @@ private slots: void countTextChangedOnRemove(); -#ifndef QT_NO_REGEXP - void findWithRegExp(); - void findBackwardWithRegExp(); - void findWithRegExpReturnsFalseIfNoMoreResults(); -#endif - #if QT_CONFIG(regularexpression) void findWithRegularExpression(); void findBackwardWithRegularExpression(); @@ -2136,7 +2130,7 @@ void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imag QCOMPARE(image.depth(), 32); QCOMPARE(original.depth(), image.depth()); - const int bytesPerLine = image.bytesPerLine(); + const qsizetype bytesPerLine = image.bytesPerLine(); const int width = image.width(); const int height = image.height(); @@ -2609,45 +2603,6 @@ void tst_QTextEdit::countTextChangedOnRemove() QCOMPARE(spy.count(), 1); } -#ifndef QT_NO_REGEXP -void tst_QTextEdit::findWithRegExp() -{ - ed->setHtml(QStringLiteral("arbitrary te<span style=\"color:#ff0000\">xt</span>")); - QRegExp rx("\\w{2}xt"); - - bool found = ed->find(rx); - - QVERIFY(found); - QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); -} - -void tst_QTextEdit::findBackwardWithRegExp() -{ - ed->setPlainText(QStringLiteral("arbitrary text")); - QTextCursor cursor = ed->textCursor(); - cursor.movePosition(QTextCursor::End); - ed->setTextCursor(cursor); - QRegExp rx("a\\w*t"); - - bool found = ed->find(rx, QTextDocument::FindBackward); - - QVERIFY(found); - QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); -} - -void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() -{ - ed->setPlainText(QStringLiteral("arbitrary text")); - QRegExp rx("t.xt"); - ed->find(rx); - - bool found = ed->find(rx); - - QVERIFY(!found); - QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); -} -#endif - #if QT_CONFIG(regularexpression) void tst_QTextEdit::findWithRegularExpression() { diff --git a/tests/auto/widgets/widgets/qtoolbar/CMakeLists.txt b/tests/auto/widgets/widgets/qtoolbar/CMakeLists.txt new file mode 100644 index 0000000000..d3aef03fa1 --- /dev/null +++ b/tests/auto/widgets/widgets/qtoolbar/CMakeLists.txt @@ -0,0 +1,15 @@ +# Generated from qtoolbar.pro. + +##################################################################### +## tst_qtoolbar Test: +##################################################################### + +add_qt_test(tst_qtoolbar + SOURCES + tst_qtoolbar.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::GuiPrivate + Qt::Widgets + Qt::WidgetsPrivate +) diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp index 61252831ed..1d5ac7c819 100644 --- a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp @@ -40,7 +40,9 @@ #include <qwidgetaction.h> #include <qtoolbutton.h> #include <qlineedit.h> -#include <qkeysequence.h> +#if QT_CONFIG(shortcut) +# include <qkeysequence.h> +#endif #include <qmenu.h> #include <qlabel.h> #include <private/qtoolbarextension_p.h> diff --git a/tests/auto/widgets/widgets/qtoolbox/CMakeLists.txt b/tests/auto/widgets/widgets/qtoolbox/CMakeLists.txt new file mode 100644 index 0000000000..dc3e5d016c --- /dev/null +++ b/tests/auto/widgets/widgets/qtoolbox/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtoolbox.pro. + +##################################################################### +## tst_qtoolbox Test: +##################################################################### + +add_qt_test(tst_qtoolbox + SOURCES + tst_qtoolbox.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/qtoolbutton/CMakeLists.txt b/tests/auto/widgets/widgets/qtoolbutton/CMakeLists.txt new file mode 100644 index 0000000000..ae36488341 --- /dev/null +++ b/tests/auto/widgets/widgets/qtoolbutton/CMakeLists.txt @@ -0,0 +1,13 @@ +# Generated from qtoolbutton.pro. + +##################################################################### +## tst_qtoolbutton Test: +##################################################################### + +add_qt_test(tst_qtoolbutton + SOURCES + tst_qtoolbutton.cpp + PUBLIC_LIBRARIES + Qt::Gui + Qt::Widgets +) diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro index c6325aac15..66950fa85a 100644 --- a/tests/auto/widgets/widgets/widgets.pro +++ b/tests/auto/widgets/widgets/widgets.pro @@ -47,6 +47,9 @@ SUBDIRS=\ qtoolbox \ qtoolbutton \ +!qtConfig(shortcut): SUBDIRS -= \ + qkeysequenceedit + # The following tests depend on private API: !qtConfig(private_tests): SUBDIRS -= \ qabstractspinbox \ |