diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2975d28a0..2312adf36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: destroyed-symlinks - id: check-executables-have-shebangs - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v17.0.6 + rev: v18.1.8 hooks: - id: clang-format exclude: (.json) diff --git a/src/core/Position.cpp b/src/core/Position.cpp index ab49fe0fd..75acf9225 100644 --- a/src/core/Position.cpp +++ b/src/core/Position.cpp @@ -237,7 +237,7 @@ LayoutSaver::Position Positions::serialize() const p.indexOfFloatingWindow = fw->beingDeleted() ? -1 : DockRegistry::self()->floatingWindows().indexOf( - fw); + fw); } else { p.mainWindowUniqueName = mainWindow->uniqueName(); assert(!p.mainWindowUniqueName.isEmpty()); diff --git a/src/core/Separator.cpp b/src/core/Separator.cpp index 93ccd5005..bc74b32b8 100644 --- a/src/core/Separator.cpp +++ b/src/core/Separator.cpp @@ -106,7 +106,7 @@ Separator::Separator(LayoutingHost *host, Qt::Orientation orientation, Core::Ite view()->show(); view()->init(); d->lazyResizeRubberBand = d->usesLazyResize ? Config::self().viewFactory()->createRubberBand( - rubberBandIsTopLevel() ? nullptr : view()) + rubberBandIsTopLevel() ? nullptr : view()) : nullptr; setVisible(true); } diff --git a/src/core/TitleBar.cpp b/src/core/TitleBar.cpp index 6f245d74a..c8fe835eb 100644 --- a/src/core/TitleBar.cpp +++ b/src/core/TitleBar.cpp @@ -41,8 +41,8 @@ using namespace KDDockWidgets::Core; TitleBar::TitleBar(Group *parent) : Controller( - ViewType::TitleBar, - Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr)) + ViewType::TitleBar, + Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr)) , Draggable(view()) , d(new Private()) , m_group(parent) @@ -67,8 +67,8 @@ TitleBar::TitleBar(Group *parent) TitleBar::TitleBar(FloatingWindow *parent) : Controller( - ViewType::TitleBar, - Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr)) + ViewType::TitleBar, + Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr)) , Draggable(view()) , d(new Private()) , m_group(nullptr) diff --git a/tests/clang_format18_workaround.h b/tests/clang_format18_workaround.h new file mode 100644 index 000000000..e1e5809c7 --- /dev/null +++ b/tests/clang_format18_workaround.h @@ -0,0 +1,35 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sérgio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + +#pragma once + +#include "core/Platform.h" + +/// These macros are workaround for clang-format-18 bug: +/// - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); +/// + KDDW_CO_AWAIT Platform::instance() -> tests_wait(1); +/// This is avoided when wrapped in a macro. + +#define EVENT_LOOP(millis) \ + KDDW_CO_AWAIT \ + KDDockWidgets::Core::Platform::instance()->tests_wait(millis) + +#define WAIT_FOR_RESIZE(window) \ + KDDW_CO_AWAIT \ + KDDockWidgets::Core::Platform::instance()->tests_waitForResize(window) + +#define WAIT_FOR_DELETED(window) \ + KDDW_CO_AWAIT \ + KDDockWidgets::Core::Platform::instance()->tests_waitForDeleted(window) + +#define WAIT_FOR_EVENT(window, event) \ + KDDW_CO_AWAIT \ + KDDockWidgets::Core::Platform::instance()->tests_waitForEvent(window, event) diff --git a/tests/core/tst_dockwidget.cpp b/tests/core/tst_dockwidget.cpp index 28ed86407..7839de319 100644 --- a/tests/core/tst_dockwidget.cpp +++ b/tests/core/tst_dockwidget.cpp @@ -52,7 +52,7 @@ KDDW_QCORO_TASK tst_setGuestView() CHECK(dw->guestView()); CHECK(dw->view()); dw->view()->show(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(500); + EVENT_LOOP(500); CHECK(guest->controller()); CHECK(dw->floatingWindow()); @@ -187,7 +187,7 @@ KDDW_QCORO_TASK tst_dwCloseAndReopen() } // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } @@ -203,7 +203,7 @@ KDDW_QCORO_TASK tst_setSize() } // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/core/tst_droparea.cpp b/tests/core/tst_droparea.cpp index 797012afa..3defb02c4 100644 --- a/tests/core/tst_droparea.cpp +++ b/tests/core/tst_droparea.cpp @@ -17,6 +17,7 @@ #include "core/ViewFactory.h" #include "core/Platform.h" #include "tests/utils.h" +#include "../clang_format18_workaround.h" using namespace KDDockWidgets; @@ -54,7 +55,7 @@ KDDW_QCORO_TASK tst_addWidgetHidden() auto group = dw->dptr()->group(); delete dw; - KDDW_CO_AWAIT Core::Platform::instance()->tests_waitForDeleted(group); + WAIT_FOR_DELETED(group); KDDW_TEST_RETURN(true); } diff --git a/tests/core/tst_floatingwindow.cpp b/tests/core/tst_floatingwindow.cpp index f8654345c..d5c8cc6de 100644 --- a/tests/core/tst_floatingwindow.cpp +++ b/tests/core/tst_floatingwindow.cpp @@ -38,7 +38,7 @@ KDDW_QCORO_TASK tst_floatingWindowCtor() CHECK(dw->floatingWindow()); /// Wait for FloatingWindow to be created - KDDW_CO_AWAIT Platform::instance()->tests_wait(100); + EVENT_LOOP(100); auto rootView = dw->view()->rootView(); CHECK(rootView); diff --git a/tests/core/tst_tabbar.cpp b/tests/core/tst_tabbar.cpp index 308aa75a1..fa44b1520 100644 --- a/tests/core/tst_tabbar.cpp +++ b/tests/core/tst_tabbar.cpp @@ -17,6 +17,8 @@ #include "kddockwidgets/Config.h" #include "core/ViewFactory.h" +#include "../clang_format18_workaround.h" + using namespace KDDockWidgets; using namespace KDDockWidgets::Core; @@ -205,7 +207,7 @@ KDDW_QCORO_TASK tst_tabBarDWClosed() } // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/qtquick/tst_qtquick.cpp b/tests/qtquick/tst_qtquick.cpp index 8e753e190..fc7ac2d0e 100644 --- a/tests/qtquick/tst_qtquick.cpp +++ b/tests/qtquick/tst_qtquick.cpp @@ -209,7 +209,7 @@ void TestQtQuick::tst_isFloatingIsEmitted() } // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); } void TestQtQuick::tst_shutdownCrash() @@ -304,7 +304,7 @@ void TestQtQuick::tst_childQmlContext() } // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); } void TestQtQuick::tst_focusBetweenTabs() @@ -321,7 +321,7 @@ void TestQtQuick::tst_focusBetweenTabs() auto floatingDock = DockRegistry::self()->dockByName("floatingDock"); dock1->view()->rootView()->activateWindow(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(2000); + EVENT_LOOP(2000); dock1->dptr()->group()->focus(); QVERIFY(dock1->isFocused()); diff --git a/tests/qtwidgets/tst_qtwidgets.cpp b/tests/qtwidgets/tst_qtwidgets.cpp index c5081906a..9a11f5257 100644 --- a/tests/qtwidgets/tst_qtwidgets.cpp +++ b/tests/qtwidgets/tst_qtwidgets.cpp @@ -2410,14 +2410,14 @@ void TestQtWidgets::tst_focusBetweenTabs() leFloating->setFocus(); QVERIFY(dock3->dockWidget()->isCurrentTab()); m1->view()->activateWindow(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); le3->setFocus(); QVERIFY(le3->hasFocus()); dock2->setAsCurrentTab(); QVERIFY(dock2->dockWidget()->isCurrentTab()); le2->setFocus(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); QVERIFY(le2->hasFocus()); // 2. Now, cycling tabs should toggle focus between le2 and le3 @@ -2443,7 +2443,7 @@ void TestQtWidgets::tst_focusBetweenTabs() auto titlebarFloating = floatingDock->actualTitleBar()->view(); QVERIFY(titlebarFloating->isVisible()); titlebarFloating->setFocus(Qt::MouseFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); QVERIFY(leFloating->hasFocus()); QVERIFY(!le1->hasFocus()); diff --git a/tests/tst_docks.cpp b/tests/tst_docks.cpp index 5c8f267c6..867c14671 100644 --- a/tests/tst_docks.cpp +++ b/tests/tst_docks.cpp @@ -50,22 +50,6 @@ using namespace KDDockWidgets; using namespace KDDockWidgets::Core; using namespace KDDockWidgets::Tests; -/// These macros are workaround for clang-format-18 messing calls with KDDW_CO_AWAIT -#define EVENT_LOOP(millis) \ - KDDW_CO_AWAIT \ - Platform::instance()->tests_wait(millis) - -#define WAIT_FOR_RESIZE(window) \ - KDDW_CO_AWAIT \ - Platform::instance()->tests_waitForResize(window) - -#define WAIT_FOR_DELETED(window) \ - KDDW_CO_AWAIT \ - Platform::instance()->tests_waitForDeleted(window) - -#define WAIT_FOR_EVENT(window, event) \ - KDDW_CO_AWAIT \ - Platform::instance()->tests_waitForEvent(window, event) inline int lengthForSize(Size sz, Qt::Orientation o) { @@ -6406,180 +6390,179 @@ KDDW_QCORO_TASK tst_rect() KDDW_TEST_RETURN(true); } -static const auto s_tests = std::vector -{ +static const auto s_tests = std::vector { TEST(tst_simple1), - TEST(tst_simple2), - TEST(tst_resizeWindow2), - TEST(tst_hasPreviousDockedLocation), - TEST(tst_hasPreviousDockedLocation2), - TEST(tst_LayoutSaverOpenedDocks), - TEST(tst_ghostSeparator), - TEST(tst_detachFromMainWindow), - TEST(tst_floatingWindowSize), - TEST(tst_tabbingWithAffinities), - TEST(tst_floatingWindowTitleBug), - TEST(tst_setFloatingSimple), - TEST(tst_dragOverTitleBar), - TEST(tst_setFloatingGeometry), - TEST(tst_restoreEmpty), - TEST(tst_restoreCentralFrame), - TEST(tst_restoreNonExistingDockWidget), - TEST(tst_shutdown), - TEST(tst_closeDockWidgets), - TEST(tst_closeReason), - TEST(tst_layoutEqually), - TEST(tst_doubleClose), - TEST(tst_maximizeAndRestore), - TEST(tst_restoreWithNonClosableWidget), - TEST(tst_restoreCrash), - TEST(tst_restoreSideBySide), - TEST(tst_restoreGroupOptions), - TEST(tst_restoreWithAffinity), - TEST(tst_marginsAfterRestore), - TEST(tst_restoreWithNewDockWidgets), - TEST(tst_restoreWithDockFactory), - TEST(tst_restoreWithDockFactory2), - TEST(tst_dontCloseDockWidgetBeforeRestore), - TEST(tst_dontCloseDockWidgetBeforeRestore3), - TEST(tst_dontCloseDockWidgetBeforeRestore4), - TEST(tst_skipRestoreInsideMainWindow), - TEST(tst_restoreWithNativeTitleBar), - TEST(tst_closeOnlyCurrentTab), - TEST(tst_tabWidgetCurrentIndex), - TEST(tst_propagateResize2), - TEST(tst_startClosed), - TEST(tst_closeReparentsToNull), - TEST(tst_invalidAnchorGroup), - TEST(tst_addAsPlaceholder), - TEST(tst_repeatedShowHide), - TEST(tst_removeItem), - TEST(tst_clear), - TEST(tst_crash), - TEST(tst_refUnrefItem), - TEST(tst_placeholderCount), - TEST(tst_availableLengthForOrientation), - TEST(tst_closeTabOfCentralFrame), - TEST(tst_centralGroupAffinity), - TEST(tst_setAsCurrentTab), - TEST(tst_placeholderDisappearsOnReadd), - TEST(tst_placeholdersAreRemovedProperly), - TEST(tst_closeAllDockWidgets), - TEST(tst_toggleMiddleDockCrash), - TEST(tst_stealFrame), - TEST(tst_setFloatingWhenWasTabbed), - TEST(tst_setWidget), - TEST(tst_floatingLastPosAfterDoubleClose), - TEST(tst_registry), - TEST(tst_honourGeometryOfHiddenWindow), - TEST(tst_posAfterLeftDetach), - TEST(tst_propagateMinSize), - TEST(tst_createFloatingWindow), - TEST(tst_unfloatTabbedFloatingWidgets), - TEST(tst_unfloatTabbedFloatingWidgets2), - TEST(tst_resizeViaAnchorsAfterPlaceholderCreation), - TEST(tst_rectForDropCrash), - TEST(tst_addDockWidgetToMainWindow), - TEST(tst_addDockWidgetToContainingWindow), - TEST(tst_setFloatingAfterDraggedFromTabToSideBySide), - TEST(tst_setFloatingAFrameWithTabs), - TEST(tst_toggleDockWidgetWithHiddenTitleBar), - TEST(tst_anchorFollowingItselfAssert), - TEST(tst_isInMainWindow), - TEST(tst_sizeConstraintWarning), - TEST(tst_stuckSeparator), - TEST(tst_dockNotFillingSpace), - TEST(tst_titlebar_getter), - TEST(tst_addingOptionHiddenTabbed), - TEST(tst_maxSizedHonouredAfterRemoved), - TEST(tst_addDockWidgetAsTabToDockWidget), - TEST(tst_closeTabHidesDockWidget), - TEST(tst_propagateSizeHonoursMinSize), - TEST(tst_floatingAction), - TEST(tst_constraintsPropagateUp), - TEST(tst_addToSmallMainWindow4), - TEST(tst_addToSmallMainWindow5), - TEST(tst_dragBySingleTab), - TEST(tst_deleteOnClose), - TEST(tst_toggleAction), - TEST(tst_redocksToPreviousTabIndex), - TEST(tst_toggleTabbed2), - TEST(tst_resizePropagatesEvenly), - TEST(tst_persistentCentralWidget), - TEST(tst_titlebarNumDockWidgetsChanged), - TEST(tst_closed), - TEST(tst_restoreFlagsFromVersion16), - TEST(tst_map), - TEST(tst_childViewAt), - TEST(tst_detachPos), - TEST(tst_floatMaintainsSize), - TEST(tst_scopedValueRollback), - TEST(tst_size), - TEST(tst_point), - TEST(tst_rect), - TEST(tst_resizeInLayout), - TEST(tst_mainWindowToggle), - TEST(tst_startDragging), + TEST(tst_simple2), + TEST(tst_resizeWindow2), + TEST(tst_hasPreviousDockedLocation), + TEST(tst_hasPreviousDockedLocation2), + TEST(tst_LayoutSaverOpenedDocks), + TEST(tst_ghostSeparator), + TEST(tst_detachFromMainWindow), + TEST(tst_floatingWindowSize), + TEST(tst_tabbingWithAffinities), + TEST(tst_floatingWindowTitleBug), + TEST(tst_setFloatingSimple), + TEST(tst_dragOverTitleBar), + TEST(tst_setFloatingGeometry), + TEST(tst_restoreEmpty), + TEST(tst_restoreCentralFrame), + TEST(tst_restoreNonExistingDockWidget), + TEST(tst_shutdown), + TEST(tst_closeDockWidgets), + TEST(tst_closeReason), + TEST(tst_layoutEqually), + TEST(tst_doubleClose), + TEST(tst_maximizeAndRestore), + TEST(tst_restoreWithNonClosableWidget), + TEST(tst_restoreCrash), + TEST(tst_restoreSideBySide), + TEST(tst_restoreGroupOptions), + TEST(tst_restoreWithAffinity), + TEST(tst_marginsAfterRestore), + TEST(tst_restoreWithNewDockWidgets), + TEST(tst_restoreWithDockFactory), + TEST(tst_restoreWithDockFactory2), + TEST(tst_dontCloseDockWidgetBeforeRestore), + TEST(tst_dontCloseDockWidgetBeforeRestore3), + TEST(tst_dontCloseDockWidgetBeforeRestore4), + TEST(tst_skipRestoreInsideMainWindow), + TEST(tst_restoreWithNativeTitleBar), + TEST(tst_closeOnlyCurrentTab), + TEST(tst_tabWidgetCurrentIndex), + TEST(tst_propagateResize2), + TEST(tst_startClosed), + TEST(tst_closeReparentsToNull), + TEST(tst_invalidAnchorGroup), + TEST(tst_addAsPlaceholder), + TEST(tst_repeatedShowHide), + TEST(tst_removeItem), + TEST(tst_clear), + TEST(tst_crash), + TEST(tst_refUnrefItem), + TEST(tst_placeholderCount), + TEST(tst_availableLengthForOrientation), + TEST(tst_closeTabOfCentralFrame), + TEST(tst_centralGroupAffinity), + TEST(tst_setAsCurrentTab), + TEST(tst_placeholderDisappearsOnReadd), + TEST(tst_placeholdersAreRemovedProperly), + TEST(tst_closeAllDockWidgets), + TEST(tst_toggleMiddleDockCrash), + TEST(tst_stealFrame), + TEST(tst_setFloatingWhenWasTabbed), + TEST(tst_setWidget), + TEST(tst_floatingLastPosAfterDoubleClose), + TEST(tst_registry), + TEST(tst_honourGeometryOfHiddenWindow), + TEST(tst_posAfterLeftDetach), + TEST(tst_propagateMinSize), + TEST(tst_createFloatingWindow), + TEST(tst_unfloatTabbedFloatingWidgets), + TEST(tst_unfloatTabbedFloatingWidgets2), + TEST(tst_resizeViaAnchorsAfterPlaceholderCreation), + TEST(tst_rectForDropCrash), + TEST(tst_addDockWidgetToMainWindow), + TEST(tst_addDockWidgetToContainingWindow), + TEST(tst_setFloatingAfterDraggedFromTabToSideBySide), + TEST(tst_setFloatingAFrameWithTabs), + TEST(tst_toggleDockWidgetWithHiddenTitleBar), + TEST(tst_anchorFollowingItselfAssert), + TEST(tst_isInMainWindow), + TEST(tst_sizeConstraintWarning), + TEST(tst_stuckSeparator), + TEST(tst_dockNotFillingSpace), + TEST(tst_titlebar_getter), + TEST(tst_addingOptionHiddenTabbed), + TEST(tst_maxSizedHonouredAfterRemoved), + TEST(tst_addDockWidgetAsTabToDockWidget), + TEST(tst_closeTabHidesDockWidget), + TEST(tst_propagateSizeHonoursMinSize), + TEST(tst_floatingAction), + TEST(tst_constraintsPropagateUp), + TEST(tst_addToSmallMainWindow4), + TEST(tst_addToSmallMainWindow5), + TEST(tst_dragBySingleTab), + TEST(tst_deleteOnClose), + TEST(tst_toggleAction), + TEST(tst_redocksToPreviousTabIndex), + TEST(tst_toggleTabbed2), + TEST(tst_resizePropagatesEvenly), + TEST(tst_persistentCentralWidget), + TEST(tst_titlebarNumDockWidgetsChanged), + TEST(tst_closed), + TEST(tst_restoreFlagsFromVersion16), + TEST(tst_map), + TEST(tst_childViewAt), + TEST(tst_detachPos), + TEST(tst_floatMaintainsSize), + TEST(tst_scopedValueRollback), + TEST(tst_size), + TEST(tst_point), + TEST(tst_rect), + TEST(tst_resizeInLayout), + TEST(tst_mainWindowToggle), + TEST(tst_startDragging), #if !defined(KDDW_FRONTEND_FLUTTER) - TEST(tst_placeholderInFloatingWindow), - TEST(tst_closeGroup), - TEST(tst_dockWidgetTabIndexOverride), - TEST(tst_dockWidgetTabIndexOverride), - TEST(tst_restoreWithCentralFrameWithTabs), - TEST(tst_preferredInitialSize), - TEST(tst_preferredInitialSizeVsMinSize), - TEST(tst_fairResizeAfterRemoveWidget), - TEST(tst_minMaxGuest), - TEST(tst_doesntHaveNativeTitleBar), - TEST(tst_sizeAfterRedock), - TEST(tst_honourUserGeometry), - TEST(tst_restoreMaximizedState), - TEST(tst_restoreFloatingMinimizedState), - TEST(tst_dockInternal), - TEST(tst_samePositionAfterHideRestore), - TEST(tst_restoreTwice), - TEST(tst_restoreAfterResize), - TEST(tst_restoreNestedAndTabbed), - TEST(tst_restoreWithPlaceholder), - TEST(tst_restoreAfterMinSizeChanges), - TEST(tst_lastFloatingPositionIsRestored), - TEST(tst_restoreNonClosable), - TEST(tst_restoreNlohmanException), - TEST(tst_restoreWithInvalidCurrentTab), - TEST(tst_restoreRestoresMainWindowPosition), - TEST(tst_dontCloseDockWidgetBeforeRestore2), - TEST(tst_doubleClickTabToDetach), - TEST(tst_doubleClickTabBarRestore), - TEST(tst_doubleClickTabRestore), - TEST(tst_tabTitleChanges), - TEST(tst_preventClose), - TEST(tst_addAndReadd), - TEST(tst_notClosable), - TEST(tst_availableSizeWithPlaceholders), - TEST(tst_moreTitleBarCornerCases), - TEST(tst_raise), - TEST(tst_nonDockable), - TEST(tst_flagDoubleClick), - TEST(tst_constraintsAfterPlaceholder), - TEST(tst_addToSmallMainWindow1), - TEST(tst_addToSmallMainWindow2), - TEST(tst_addToSmallMainWindow3), - TEST(tst_titleBarFocusedWhenTabsChange), - TEST(tst_toggleTabbed), - TEST(tst_currentTabMatchesDockWidget), - TEST(tst_addMDIDockWidget), - TEST(tst_mdiZorder), - TEST(tst_mdiCrash), - TEST(tst_mdiZorder2), - TEST(tst_mdiSetSize), - TEST(tst_mixedMDIRestoreToArea), - TEST(tst_redockToMDIRestoresPosition), - TEST(tst_maximizeButton), - TEST(tst_restoreAfterUnminimized), - TEST(tst_doubleScheduleDelete), - TEST(tst_minimizeRestoreBug), + TEST(tst_placeholderInFloatingWindow), + TEST(tst_closeGroup), + TEST(tst_dockWidgetTabIndexOverride), + TEST(tst_dockWidgetTabIndexOverride), + TEST(tst_restoreWithCentralFrameWithTabs), + TEST(tst_preferredInitialSize), + TEST(tst_preferredInitialSizeVsMinSize), + TEST(tst_fairResizeAfterRemoveWidget), + TEST(tst_minMaxGuest), + TEST(tst_doesntHaveNativeTitleBar), + TEST(tst_sizeAfterRedock), + TEST(tst_honourUserGeometry), + TEST(tst_restoreMaximizedState), + TEST(tst_restoreFloatingMinimizedState), + TEST(tst_dockInternal), + TEST(tst_samePositionAfterHideRestore), + TEST(tst_restoreTwice), + TEST(tst_restoreAfterResize), + TEST(tst_restoreNestedAndTabbed), + TEST(tst_restoreWithPlaceholder), + TEST(tst_restoreAfterMinSizeChanges), + TEST(tst_lastFloatingPositionIsRestored), + TEST(tst_restoreNonClosable), + TEST(tst_restoreNlohmanException), + TEST(tst_restoreWithInvalidCurrentTab), + TEST(tst_restoreRestoresMainWindowPosition), + TEST(tst_dontCloseDockWidgetBeforeRestore2), + TEST(tst_doubleClickTabToDetach), + TEST(tst_doubleClickTabBarRestore), + TEST(tst_doubleClickTabRestore), + TEST(tst_tabTitleChanges), + TEST(tst_preventClose), + TEST(tst_addAndReadd), + TEST(tst_notClosable), + TEST(tst_availableSizeWithPlaceholders), + TEST(tst_moreTitleBarCornerCases), + TEST(tst_raise), + TEST(tst_nonDockable), + TEST(tst_flagDoubleClick), + TEST(tst_constraintsAfterPlaceholder), + TEST(tst_addToSmallMainWindow1), + TEST(tst_addToSmallMainWindow2), + TEST(tst_addToSmallMainWindow3), + TEST(tst_titleBarFocusedWhenTabsChange), + TEST(tst_toggleTabbed), + TEST(tst_currentTabMatchesDockWidget), + TEST(tst_addMDIDockWidget), + TEST(tst_mdiZorder), + TEST(tst_mdiCrash), + TEST(tst_mdiZorder2), + TEST(tst_mdiSetSize), + TEST(tst_mixedMDIRestoreToArea), + TEST(tst_redockToMDIRestoresPosition), + TEST(tst_maximizeButton), + TEST(tst_restoreAfterUnminimized), + TEST(tst_doubleScheduleDelete), + TEST(tst_minimizeRestoreBug), #endif - TEST(tst_keepLast) + TEST(tst_keepLast) }; #include "tests_main.h" diff --git a/tests/tst_docks_slow1.cpp b/tests/tst_docks_slow1.cpp index 025d9f38c..a82dc066c 100644 --- a/tests/tst_docks_slow1.cpp +++ b/tests/tst_docks_slow1.cpp @@ -72,14 +72,14 @@ KDDW_QCORO_TASK tst_invalidPlaceholderPosition() CHECK(!dock1->isOpen()); CHECK(!dock1->view()->isVisible()); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(group2->view()); + WAIT_FOR_RESIZE(group2->view()); // Check that group2 moved up to y=0 CHECK_EQ(group2->view()->y(), 0); // Close 2 dock2->close(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(dock3->view()); + WAIT_FOR_RESIZE(dock3->view()); CHECK(layout->checkSanity()); CHECK_EQ(layout->count(), 3); @@ -99,7 +99,7 @@ KDDW_QCORO_TASK tst_invalidPlaceholderPosition() toRestore2->open(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(group3->view()); + WAIT_FOR_RESIZE(group3->view()); CHECK(layout->checkSanity()); CHECK_EQ(layout->count(), 3); CHECK_EQ(layout->placeholderCount(), 0); @@ -167,7 +167,7 @@ KDDW_QCORO_TASK tst_startHidden2() CHECK_EQ(layout->count(), 2); CHECK_EQ(layout->placeholderCount(), 0); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(dock2->view()); + WAIT_FOR_RESIZE(dock2->view()); } { @@ -193,7 +193,7 @@ KDDW_QCORO_TASK tst_startHidden2() dock2->open(); dock3->open(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(dock2->view()); + WAIT_FOR_RESIZE(dock2->view()); layout->checkSanity(); } @@ -238,7 +238,7 @@ KDDW_QCORO_TASK tst_invalidJSON() KDDW_QCORO_TASK tst_keepLast() { // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/tst_docks_slow2.cpp b/tests/tst_docks_slow2.cpp index bee925d8e..510867c8e 100644 --- a/tests/tst_docks_slow2.cpp +++ b/tests/tst_docks_slow2.cpp @@ -53,7 +53,7 @@ KDDW_QCORO_TASK tst_invalidLayoutAfterRestore() m->addDockWidget(dock2, Location_OnRight); m->addDockWidget(dock3, Location_OnRight); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(layout); + WAIT_FOR_RESIZE(layout); const int oldContentsWidth = layout->layoutWidth(); auto f1 = dock1->dptr()->group(); dock3->close(); @@ -66,8 +66,8 @@ KDDW_QCORO_TASK tst_invalidLayoutAfterRestore() CHECK(dock3->titleBar()->isVisible()); dock2->open(); dock1->open(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(m.get(), Event::LayoutRequest); // So MainWindow min - // size is updated + WAIT_FOR_EVENT(m.get(), Event::LayoutRequest); // So MainWindow min + // size is updated Item *item1 = layout->itemForGroup(dock1->dptr()->group()); Item *item3 = layout->itemForGroup(dock3->dptr()->group()); @@ -84,7 +84,7 @@ KDDW_QCORO_TASK tst_invalidLayoutAfterRestore() f2->detachTab(dock2); CHECK(!f2.data()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); + EVENT_LOOP(200); auto fw2 = dock2->floatingWindow(); CHECK_EQ(layout->view()->minSize().width(), 2 * Item::layoutSpacing + item1->minSize().width() + item3->minSize().width() @@ -143,9 +143,9 @@ KDDW_QCORO_TASK tst_setFloatingWhenSideBySide() CHECK(item2); dock2->close(); dock3->close(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForDeleted(f2); + WAIT_FOR_DELETED(f2); dock2->open(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(dock2->view()); + WAIT_FOR_RESIZE(dock2->view()); CHECK_EQ(item2->geometry(), dock2->dptr()->group()->view()->geometry()); layout->checkSanity(); @@ -171,7 +171,7 @@ KDDW_QCORO_TASK tst_dockWindowWithTwoSideBySideFramesIntoCenter() fw2->view()->move(fw->x() + fw->width() + 100, fw->y()); // QtQuick is a bit more async than QWidgets. Wait for the move. - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(fw2->view()->window(), Event::Move); + WAIT_FOR_EVENT(fw2->view()->window(), Event::Move); auto da2 = fw2->dropArea(); const Point dragDestPos = da2->mapToGlobal(da2->rect().center()); @@ -181,7 +181,7 @@ KDDW_QCORO_TASK tst_dockWindowWithTwoSideBySideFramesIntoCenter() auto f2 = fw2->groups().constFirst(); // run one event loop, needed by flutter - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); CHECK_EQ(f2->dockWidgetCount(), 3); @@ -203,13 +203,13 @@ KDDW_QCORO_TASK tst_dockWindowWithTwoSideBySideFramesIntoRight() fw2->view()->move(fw->x() + fw->width() + 100, fw->y()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); KDDW_CO_AWAIT dragFloatingWindowTo(fw, fw2->dropArea(), DropLocation_Right); // Outer right instead of Left // run one event loop, needed by flutter - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); CHECK_EQ(fw2->groups().size(), 3); CHECK(fw2->dropArea()->checkSanity()); @@ -222,7 +222,7 @@ KDDW_QCORO_TASK tst_dockWindowWithTwoSideBySideFramesIntoLeft() EnsureTopLevelsDeleted e; auto fw = createFloatingWindow(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); fw->view()->move(200, 200); fw->setObjectName("fw1"); @@ -235,12 +235,12 @@ KDDW_QCORO_TASK tst_dockWindowWithTwoSideBySideFramesIntoLeft() fw2->view()->move(fw->x() + fw->width() + 100, fw->y()); CHECK(fw2->dropArea()->checkSanity()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); KDDW_CO_AWAIT dragFloatingWindowTo(fw, fw2->dropArea(), DropLocation_Left); // run one event loop, needed by flutter - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); CHECK_EQ(fw2->groups().size(), 3); CHECK(fw2->dropArea()->checkSanity()); @@ -251,7 +251,7 @@ KDDW_QCORO_TASK tst_dockWindowWithTwoSideBySideFramesIntoLeft() KDDW_QCORO_TASK tst_keepLast() { // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/tst_docks_slow3.cpp b/tests/tst_docks_slow3.cpp index f2a5d95f2..0a49b8317 100644 --- a/tests/tst_docks_slow3.cpp +++ b/tests/tst_docks_slow3.cpp @@ -60,7 +60,7 @@ KDDW_QCORO_TASK tst_dockWidgetGetsFocusWhenDocked() dw2->setGuestView(le2->asWrapper()); dw1->open(); dw2->open(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); + EVENT_LOOP(200); auto fw1 = dw1->floatingWindow(); ObjectGuard fw2 = dw2->floatingWindow(); @@ -76,12 +76,12 @@ KDDW_QCORO_TASK tst_dockWidgetGetsFocusWhenDocked() le1->setFocus(Qt::MouseFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); + EVENT_LOOP(200); CHECK(dw1->isFocused()); CHECK(fw1->view()->isActiveWindow()); KDDW_CO_AWAIT dragFloatingWindowTo(fw2, fw1->dropArea(), DropLocation_Left); - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(fw1, Event::WindowActivate); + WAIT_FOR_EVENT(fw1, Event::WindowActivate); /// We dropped into floating window 1, it should still be active CHECK(fw1->view()->isActiveWindow()); @@ -214,14 +214,14 @@ KDDW_QCORO_TASK tst_close() centralDock->dptr()->group()->view()->geometry().right() + Item::layoutSpacing + 1); leftDock->close(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(250); + EVENT_LOOP(250); CHECK_EQ(centralDock->dptr()->group()->view()->x(), 0); CHECK_EQ(rightDock->dptr()->group()->view()->x(), centralDock->dptr()->group()->view()->geometry().right() + Item::layoutSpacing + 1); rightDock->close(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(250); + EVENT_LOOP(250); Margins margins = mainwindow->centerWidgetMargins(); CHECK_EQ(centralDock->dptr()->group()->view()->width(), mainwindow->width() - 0 * 2 - margins.left() - margins.right()); @@ -295,10 +295,10 @@ KDDW_QCORO_TASK tst_positionWhenShown() auto window = createMainWindow(); auto dock1 = newDockWidget("1"); dock1->open(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); // Wait for group to settle + EVENT_LOOP(1000); // Wait for group to settle const Point desiredPos = Point(100, 100); dock1->view()->window()->setFramePosition(desiredPos); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); // Wait for group to settle + EVENT_LOOP(1000); // Wait for group to settle CHECK_EQ(dock1->view()->window()->framePosition(), desiredPos); dock1->close(); @@ -316,7 +316,7 @@ KDDW_QCORO_TASK tst_positionWhenShown() KDDW_QCORO_TASK tst_keepLast() { // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/tst_docks_slow4.cpp b/tests/tst_docks_slow4.cpp index b14a6aca2..e2d692348 100644 --- a/tests/tst_docks_slow4.cpp +++ b/tests/tst_docks_slow4.cpp @@ -104,7 +104,7 @@ KDDW_QCORO_TASK tst_dock2FloatingWidgetsTabbed() // 2.6 Drag the tabbed group over a 3rd floating window auto dock3 = createDockWidget("doc3"); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); // Test is flaky otherwise + EVENT_LOOP(1000); // Test is flaky otherwise auto fw2 = dock2->floatingWindow(); finalPoint = dock3->window()->geometry().center() + Point(7, 7); @@ -161,7 +161,7 @@ KDDW_QCORO_TASK tst_restoreSimple() const Point dock2FloatingPoint = Point(150, 150); dock2->view()->window()->setFramePosition(dock2FloatingPoint); CHECK(dock2->isVisible()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); // Wait for group to settle + EVENT_LOOP(1000); // Wait for group to settle const Point dock3FloatingPoint = Point(200, 200); dock3->view()->window()->setFramePosition(dock3FloatingPoint); @@ -211,7 +211,7 @@ KDDW_QCORO_TASK tst_restoreSimple() dock3->dptr()->morphIntoFloatingWindow(); // as it would take 1 event loop. Do it now so we can // compare already. - KDDW_CO_AWAIT Platform::instance()->tests_wait(300); + EVENT_LOOP(300); CHECK_EQ(dock3->view()->window()->framePosition(), dock3FloatingPoint); KDDW_CO_RETURN(true); @@ -229,7 +229,7 @@ KDDW_QCORO_TASK tst_restoreSimplest() LayoutSaver saver; CHECK(saver.saveToFile(QStringLiteral("layout_tst_restoreSimplest.json"))); - KDDW_CO_AWAIT Platform::instance()->tests_wait(300); + EVENT_LOOP(300); CHECK(layout->checkSanity()); CHECK(saver.restoreFromFile(QStringLiteral("layout_tst_restoreSimplest.json"))); @@ -241,7 +241,7 @@ KDDW_QCORO_TASK tst_restoreSimplest() KDDW_QCORO_TASK tst_keepLast() { // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/tst_docks_slow5.cpp b/tests/tst_docks_slow5.cpp index 75b09d8ab..f8465a359 100644 --- a/tests/tst_docks_slow5.cpp +++ b/tests/tst_docks_slow5.cpp @@ -73,7 +73,7 @@ KDDW_QCORO_TASK tst_28NestedWidgets() for (int i : docksToHide) { docksToCreate.at(i).createdDock->close(); layout->checkSanity(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); + EVENT_LOOP(200); } layout->checkSanity(); @@ -90,8 +90,8 @@ KDDW_QCORO_TASK tst_28NestedWidgets() for (auto dock : docksToCreate) { if (dock.createdDock && dock.createdDock->isVisible()) { dock.createdDock->close(); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); // Wait for the docks to be closed. TODO Replace with a global event - // filter and wait for any resize ? + EVENT_LOOP(200); // Wait for the docks to be closed. TODO Replace with a global event + // filter and wait for any resize ? } ++i; } @@ -354,8 +354,7 @@ KDDW_QCORO_TASK tst_28NestedWidgets() KDDW_TEST_RETURN(true); } -static const auto s_tests = std::vector -{ +static const auto s_tests = std::vector { #if !defined(KDDW_FRONTEND_FLUTTER) TEST(tst_28NestedWidgets) #endif diff --git a/tests/tst_docks_slow6.cpp b/tests/tst_docks_slow6.cpp index 67d7f65dc..c63b0a4c5 100644 --- a/tests/tst_docks_slow6.cpp +++ b/tests/tst_docks_slow6.cpp @@ -49,15 +49,15 @@ KDDW_QCORO_TASK tst_isFocused() auto dock2 = createDockWidget(QStringLiteral("dock2"), Platform::instance()->tests_createFocusableView({ true })); - KDDW_CO_AWAIT Platform::instance()->tests_wait(400); // macOS is flaky here, needs dock2 to be shown first before focusing dock1, - // otherwise dock1 looses again + EVENT_LOOP(400); // macOS is flaky here, needs dock2 to be shown first before focusing dock1, + // otherwise dock1 looses again dock1->window()->move(400, 200); // 2. Raise dock1 and focus its line edit dock1->raise(); dock1->guestView()->setFocus(Qt::OtherFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(dock1->guestView().get(), Event::FocusIn); + WAIT_FOR_EVENT(dock1->guestView().get(), Event::FocusIn); CHECK(dock1->isFocused()); CHECK(!dock2->isFocused()); @@ -65,10 +65,10 @@ KDDW_QCORO_TASK tst_isFocused() // 3. Raise dock2 and focus its line edit dock2->view()->raiseAndActivate(); if (!dock2->window()->window()->isActive()) - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(dock2->view()->window(), Event::WindowActivate); + WAIT_FOR_EVENT(dock2->view()->window(), Event::WindowActivate); dock2->guestView()->setFocus(Qt::OtherFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(dock1->guestView().get(), Event::FocusIn); + WAIT_FOR_EVENT(dock1->guestView().get(), Event::FocusIn); CHECK(!dock1->isFocused()); CHECK(dock2->guestView()->hasFocus()); @@ -91,7 +91,7 @@ KDDW_QCORO_TASK tst_isFocused() auto oldFw3 = dock3->window(); dock3->raise(); dock3->guestView()->setFocus(Qt::OtherFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(dock1->guestView().get(), Event::FocusIn); + WAIT_FOR_EVENT(dock1->guestView().get(), Event::FocusIn); CHECK(!dock1->isFocused()); CHECK(!dock2->isFocused()); CHECK(dock3->isFocused()); @@ -100,20 +100,19 @@ KDDW_QCORO_TASK tst_isFocused() dock2->addDockWidgetToContainingWindow(dock3, Location_OnLeft); dock2->raise(); dock2->guestView()->setFocus(Qt::OtherFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_waitForEvent(dock2->guestView().get(), Event::FocusIn); + WAIT_FOR_EVENT(dock2->guestView().get(), Event::FocusIn); CHECK(!dock1->isFocused()); CHECK(dock2->isFocused()); CHECK(!dock3->isFocused()); } // Spin one event loop so we so some deleteLater()s run. Makes LSAN happy. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); KDDW_CO_RETURN(true); } -static const auto s_tests = std::vector -{ +static const auto s_tests = std::vector { #if !defined(KDDW_FRONTEND_FLUTTER) TEST(tst_isFocused) #endif diff --git a/tests/tst_docks_slow7.cpp b/tests/tst_docks_slow7.cpp index 99afb1461..ce93aab3a 100644 --- a/tests/tst_docks_slow7.cpp +++ b/tests/tst_docks_slow7.cpp @@ -126,13 +126,13 @@ KDDW_QCORO_TASK tst_negativeAnchorPosition() d2->close(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(d3->view()); + WAIT_FOR_RESIZE(d3->view()); d2->open(); // Should not result in negative anchor positions (Test will fail due to a spdlog warning) - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(d3->view()); + WAIT_FOR_RESIZE(d3->view()); layout->checkSanity(); d2->close(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(d3->view()); + WAIT_FOR_RESIZE(d3->view()); layout->checkSanity(); // Now resize the Window, after removing middle one @@ -145,7 +145,7 @@ KDDW_QCORO_TASK tst_negativeAnchorPosition() layout->setLayoutSize(newSize); d2->destroyLater(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForDeleted(d2); + WAIT_FOR_DELETED(d2); layout->checkSanity(); KDDW_TEST_RETURN(true); @@ -236,7 +236,7 @@ KDDW_QCORO_TASK tst_negativeAnchorPosition4() layout->checkSanity(); docks.at(0).createdDock->destroyLater(); docks.at(4).createdDock->destroyLater(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForDeleted(docks.at(4).createdDock); + WAIT_FOR_DELETED(docks.at(4).createdDock); KDDW_TEST_RETURN(true); } @@ -400,7 +400,7 @@ KDDW_QCORO_TASK tst_crash2() layout->checkSanity(); if (i == 2) { // Wait for the resizes. This used to make the app crash. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1000); + EVENT_LOOP(1000); } docks[i]->setFloating(floatings[i]); @@ -428,7 +428,7 @@ KDDW_QCORO_TASK tst_crash2() KDDW_QCORO_TASK tst_keepLast() { // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); KDDW_TEST_RETURN(true); } diff --git a/tests/tst_docks_slow8.cpp b/tests/tst_docks_slow8.cpp index 93648e988..dd43826d7 100644 --- a/tests/tst_docks_slow8.cpp +++ b/tests/tst_docks_slow8.cpp @@ -115,7 +115,7 @@ void TestDocks::tst_resizeWindow() } m->view()->showMaximized(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(m->view()); + WAIT_FOR_RESIZE(m->view()); const int maximizedWidth1 = dock1->width(); const int maximizedWidth2 = dock2->width(); @@ -126,7 +126,7 @@ void TestDocks::tst_resizeWindow() QVERIFY(relativeDifference <= 0.01); m->view()->showNormal(); - KDDW_CO_AWAIT Platform::instance()->tests_waitForResize(m->view()); + WAIT_FOR_RESIZE(m->view()); const int newWidth1 = dock1->width(); const int newWidth2 = dock2->width(); @@ -343,7 +343,7 @@ void TestDocks::tst_tabBarWithHiddenTitleBar() } // 1 event loop for DelayedDelete. Avoids LSAN warnings. - KDDW_CO_AWAIT Platform::instance()->tests_wait(1); + EVENT_LOOP(1); } int main(int argc, char *argv[]) diff --git a/tests/tst_view.cpp b/tests/tst_view.cpp index b27d6749d..f2365e1f8 100644 --- a/tests/tst_view.cpp +++ b/tests/tst_view.cpp @@ -15,6 +15,8 @@ #include "core/View_p.h" #include "core/ViewGuard.h" +#include "clang_format18_workaround.h" + using namespace KDDockWidgets::Core; using namespace KDDockWidgets; @@ -146,7 +148,7 @@ KDDW_QCORO_TASK tst_viewGeometry() const Rect newChildGeo(1, 2, 300, 301); childView->setGeometry(newChildGeo); - KDDW_CO_AWAIT Platform::instance()->tests_wait(500); + EVENT_LOOP(500); CHECK(!childView->isRootView()); CHECK_EQ(childView->size(), newChildGeo.size()); @@ -231,11 +233,11 @@ KDDW_QCORO_TASK tst_hasFocus() rootView->activateWindow(); CHECK(rootView->controller()->isVisible()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(0); + EVENT_LOOP(0); CHECK(!rootView->hasFocus()); rootView->setFocus(Qt::MouseFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); // QWidget::setFocus() requires 1 event loop iteration + EVENT_LOOP(200); // QWidget::setFocus() requires 1 event loop iteration CHECK(rootView->hasFocus()); CHECK(rootView->equals(Platform::instance()->focusedView())); @@ -244,7 +246,7 @@ KDDW_QCORO_TASK tst_hasFocus() CHECK(rootView->equals(Platform::instance()->focusedView())); child1->controller()->setVisible(true); child1->setFocus(Qt::MouseFocusReason); - KDDW_CO_AWAIT Platform::instance()->tests_wait(200); // QWidget::setFocus() requires 1 event loop iteration + EVENT_LOOP(200); // QWidget::setFocus() requires 1 event loop iteration CHECK(child1->hasFocus()); CHECK(child1->equals(Platform::instance()->focusedView())); @@ -259,7 +261,7 @@ KDDW_QCORO_TASK tst_parentDeletesChildViews() rootView->show(); rootView->activateWindow(); CHECK(rootView->controller()->isVisible()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(0); + EVENT_LOOP(0); auto child = createViewAndWindow({}, rootView); child->show(); CHECK(child->isVisible()); diff --git a/tests/tst_window.cpp b/tests/tst_window.cpp index 2ee74110b..5b0c4cf3c 100644 --- a/tests/tst_window.cpp +++ b/tests/tst_window.cpp @@ -17,6 +17,7 @@ #include "core/View_p.h" #include "core/Platform.h" #include "core/Window_p.h" +#include "clang_format18_workaround.h" using namespace KDDockWidgets::Core; @@ -63,7 +64,7 @@ KDDW_QCORO_TASK tst_resize() const KDDockWidgets::Size newSize(501, 502); window->resize(newSize.width(), newSize.height()); - KDDW_CO_AWAIT Platform::instance()->tests_wait(100); + EVENT_LOOP(100); CHECK_EQ(window->size(), newSize); @@ -106,7 +107,7 @@ KDDW_QCORO_TASK tst_geometry() const auto geo = KDDockWidgets::Rect(100, 100, 1000, 1000); window->setGeometry(geo); - KDDW_CO_AWAIT Platform::instance()->tests_wait(100); + EVENT_LOOP(100); CHECK_EQ(window->geometry(), geo); window->destroy(); diff --git a/tests/utils.cpp b/tests/utils.cpp index 0bbee06ec..d95b152dc 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -161,7 +161,8 @@ void KDDockWidgets::Tests::pressOn(Point globalPos, Window::Ptr receiver) KDDW_QCORO_TASK KDDockWidgets::Tests::releaseOn(Point globalPos, View *receiver) { - KDDW_CO_AWAIT Platform::instance()->tests_releaseOn(globalPos, receiver); + auto instance = Platform::instance(); // separate variable due to weird clang-format issue + KDDW_CO_AWAIT instance->tests_releaseOn(globalPos, receiver); KDDW_CO_RETURN true; } diff --git a/tests/utils.h b/tests/utils.h index f00e46522..1cb7c665a 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -31,6 +31,7 @@ #include "core/ViewFactory.h" #include "core/MainWindow.h" #include "core/Window_p.h" +#include "clang_format18_workaround.h" #include #include @@ -189,7 +190,7 @@ inline KDDW_QCORO_TASK drag(Core::View *sourceWidget, Point pressGlobalPos, Poin { if (buttonActions & ButtonAction_Press) { if (s_pauseBeforePress) - KDDW_CO_AWAIT Core::Platform::instance()->tests_wait(DEBUGGING_PAUSE_DURATION); + EVENT_LOOP(DEBUGGING_PAUSE_DURATION); pressOn(pressGlobalPos, sourceWidget); } @@ -197,7 +198,7 @@ inline KDDW_QCORO_TASK drag(Core::View *sourceWidget, Point pressGlobalPos, Poin sourceWidget->activateWindow(); if (s_pauseBeforeMove) - KDDW_CO_AWAIT Core::Platform::instance()->tests_wait(DEBUGGING_PAUSE_DURATION); + EVENT_LOOP(DEBUGGING_PAUSE_DURATION); KDDW_CO_AWAIT moveMouseTo(globalDest, sourceWidget); pressGlobalPos = sourceWidget->mapToGlobal(Point(10, 10)); @@ -237,7 +238,7 @@ inline KDDW_QCORO_TASK dragFloatingWindowTo(Core::FloatingWindow *fw, Core::Drop DropLocation dropLocation) { // run one event loop, needed by flutter - KDDW_CO_AWAIT Core::Platform::instance()->tests_wait(100); + EVENT_LOOP(100); auto draggable = draggableFor(fw->view()); assert(draggable);