Skip to content

Commit

Permalink
Remove CO_AWAIT
Browse files Browse the repository at this point in the history
We're not using qcoro anymore
  • Loading branch information
iamsergio committed Jan 27, 2025
1 parent e96f84c commit da2847c
Show file tree
Hide file tree
Showing 29 changed files with 442 additions and 452 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: true
SpacesInParentheses: false
StatementAttributeLikeMacros: [emit,KDDW_CO_AWAIT]
StatementAttributeLikeMacros: [emit]
...
5 changes: 0 additions & 5 deletions src/QtCompat_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@ class Polygon : public Vector<Point>

}

// TODO: Remove
#define KDDW_QCORO_TASK bool
#define KDDW_CO_AWAIT
#define KDDW_CO_RETURN return

#ifndef KDDW_QTGUI_TYPES

// Dummy Qt macros, to avoid too much ifdefs in core/
Expand Down
24 changes: 12 additions & 12 deletions src/core/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,33 +218,33 @@ class DOCKS_EXPORT Platform
/// @brief halts the test during the specified number of milliseconds
/// The event loop keeps running. Use this for debugging purposes so you can interact with your
/// test and see what's going on
virtual KDDW_QCORO_TASK tests_wait(int ms) const = 0;
virtual bool tests_wait(int ms) const = 0;

/// @brief Waits for the specified view to receive a resize event
/// Returns true if the view was resized until timeout was reached
virtual KDDW_QCORO_TASK tests_waitForResize(View *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual KDDW_QCORO_TASK tests_waitForResize(Controller *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual KDDW_QCORO_TASK tests_waitForDeleted(View *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual KDDW_QCORO_TASK tests_waitForDeleted(Controller *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForResize(View *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForResize(Controller *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForDeleted(View *, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForDeleted(Controller *, int timeout = DEFAULT_TIMEOUT) const = 0;

/// @brief Waits for the specified window to be active (have the keyboard focus)
/// Window::isActive() should return true
/// @sa Window::isActive()
virtual KDDW_QCORO_TASK tests_waitForWindowActive(std::shared_ptr<Core::Window>, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForWindowActive(std::shared_ptr<Core::Window>, int timeout = DEFAULT_TIMEOUT) const = 0;

/// @brief Waits for the specified view to receive the specified event
/// Returns true if the view received said event until timeout was reached
virtual KDDW_QCORO_TASK tests_waitForEvent(Core::Object *w, Event::Type type, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual KDDW_QCORO_TASK tests_waitForEvent(View *, Event::Type type, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual KDDW_QCORO_TASK tests_waitForEvent(std::shared_ptr<Core::Window>, Event::Type type,
int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForEvent(Core::Object *w, Event::Type type, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForEvent(View *, Event::Type type, int timeout = DEFAULT_TIMEOUT) const = 0;
virtual bool tests_waitForEvent(std::shared_ptr<Core::Window>, Event::Type type,
int timeout = DEFAULT_TIMEOUT) const = 0;

virtual void tests_doubleClickOn(Point globalPos, View *receiver) = 0;
virtual void tests_doubleClickOn(Point globalPos, std::shared_ptr<Core::Window> receiver) = 0;
virtual void tests_pressOn(Point globalPos, View *receiver) = 0;
virtual void tests_pressOn(Point globalPos, std::shared_ptr<Core::Window> receiver) = 0;
virtual KDDW_QCORO_TASK tests_releaseOn(Point globalPos, View *receiver) = 0;
virtual KDDW_QCORO_TASK tests_mouseMove(Point globalPos, View *receiver) = 0;
virtual bool tests_releaseOn(Point globalPos, View *receiver) = 0;
virtual bool tests_mouseMove(Point globalPos, View *receiver) = 0;

/// @brief Creates a Window. For the sole purpose of unit-testing Window.
/// The created window should be visible.
Expand Down
8 changes: 2 additions & 6 deletions tests/clang_format18_workaround.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@
#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);
/// - Platform::instance()->tests_wait(1);
/// + 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)
16 changes: 8 additions & 8 deletions tests/core/tst_dockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;

KDDW_QCORO_TASK tst_dockWidgetCtor()
bool tst_dockWidgetCtor()
{
Tests::EnsureTopLevelsDeleted e;

Expand All @@ -38,7 +38,7 @@ KDDW_QCORO_TASK tst_dockWidgetCtor()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_setGuestView()
bool tst_setGuestView()
{
Tests::EnsureTopLevelsDeleted e;

Expand Down Expand Up @@ -74,7 +74,7 @@ KDDW_QCORO_TASK tst_setGuestView()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_toggleAction()
bool tst_toggleAction()
{
Tests::EnsureTopLevelsDeleted e;

Expand All @@ -88,7 +88,7 @@ KDDW_QCORO_TASK tst_toggleAction()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_isOpen()
bool tst_isOpen()
{
Tests::EnsureTopLevelsDeleted e;

Expand Down Expand Up @@ -126,7 +126,7 @@ KDDW_QCORO_TASK tst_isOpen()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_setAsCurrentTab()
bool tst_setAsCurrentTab()
{
Tests::EnsureTopLevelsDeleted e;

Expand Down Expand Up @@ -159,7 +159,7 @@ KDDW_QCORO_TASK tst_setAsCurrentTab()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_dwCloseAndReopen()
bool tst_dwCloseAndReopen()
{
{
Tests::EnsureTopLevelsDeleted e;
Expand All @@ -176,7 +176,7 @@ KDDW_QCORO_TASK tst_dwCloseAndReopen()
CHECK(titleBar->isVisible());
titleBar->onCloseClicked();
CHECK(!dw->isOpen());
CHECK(KDDW_CO_AWAIT Platform::instance()->tests_waitForDeleted(fw));
CHECK(Platform::instance()->tests_waitForDeleted(fw));
CHECK(!fw);

CHECK(!dw->floatingWindow());
Expand All @@ -192,7 +192,7 @@ KDDW_QCORO_TASK tst_dwCloseAndReopen()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_setSize()
bool tst_setSize()
{
{
Tests::EnsureTopLevelsDeleted e;
Expand Down
6 changes: 3 additions & 3 deletions tests/core/tst_droparea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

using namespace KDDockWidgets;

KDDW_QCORO_TASK tst_dropAreaCtor()
bool tst_dropAreaCtor()
{
// Tests that ctor runs and doesn't leak
Core::DropArea da(nullptr, {});

KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_addWidget()
bool tst_addWidget()
{
auto group = new Core::Group();
Core::DropArea da(nullptr, {});
Expand All @@ -38,7 +38,7 @@ KDDW_QCORO_TASK tst_addWidget()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_addWidgetHidden()
bool tst_addWidgetHidden()
{
// Test adding a widget that starts hidden

Expand Down
6 changes: 3 additions & 3 deletions tests/core/tst_floatingwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;

KDDW_QCORO_TASK tst_floatingWindowCtor()
bool tst_floatingWindowCtor()
{
Tests::EnsureTopLevelsDeleted ensure;

Expand Down Expand Up @@ -55,7 +55,7 @@ KDDW_QCORO_TASK tst_floatingWindowCtor()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_floatingWindowClose()
bool tst_floatingWindowClose()
{
// Tests that a floating window is deleted after being closed

Expand All @@ -71,7 +71,7 @@ KDDW_QCORO_TASK tst_floatingWindowClose()
CHECK(!fw->groups().first()->titleBar()->isVisible());
titleBar->onCloseClicked();
CHECK(!dw->isOpen());
CHECK(KDDW_CO_AWAIT Platform::instance()->tests_waitForDeleted(fw));
CHECK(Platform::instance()->tests_waitForDeleted(fw));
CHECK(!fw);

delete dw;
Expand Down
4 changes: 2 additions & 2 deletions tests/core/tst_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using namespace KDDockWidgets;

KDDW_QCORO_TASK tst_groupCtor()
bool tst_groupCtor()
{
auto group = new Core::Group(nullptr, {});
CHECK(group->view()->is(Core::ViewType::Group));
Expand All @@ -26,7 +26,7 @@ KDDW_QCORO_TASK tst_groupCtor()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_dragRect()
bool tst_dragRect()
{
auto group = new Core::Group(nullptr, {});
// This used to crash. Test that it doesn't.
Expand Down
2 changes: 1 addition & 1 deletion tests/core/tst_separator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using namespace KDDockWidgets;

KDDW_QCORO_TASK tst_separatorCtor()
bool tst_separatorCtor()
{
Core::DropArea dropArea(nullptr, MainWindowOption_None);
Core::Separator separator(dropArea.asLayoutingHost(), Qt::Vertical, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion tests/core/tst_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

using namespace KDDockWidgets;

KDDW_QCORO_TASK tst_stackCtor()
bool tst_stackCtor()
{
Core::Group group(nullptr, {});
Core::Stack stack(&group, {});
Expand Down
8 changes: 4 additions & 4 deletions tests/core/tst_tabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;

KDDW_QCORO_TASK tst_tabBarCtor()
bool tst_tabBarCtor()
{
Core::Group group(nullptr, {});
Core::Stack stack(&group, {});
Expand All @@ -33,7 +33,7 @@ KDDW_QCORO_TASK tst_tabBarCtor()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_tabBarIndexes()
bool tst_tabBarIndexes()
{
Core::Group group(nullptr, {});
Core::TabBar *tabBar = group.tabBar();
Expand Down Expand Up @@ -122,7 +122,7 @@ KDDW_QCORO_TASK tst_tabBarIndexes()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_tabBarDWDestroyed()
bool tst_tabBarDWDestroyed()
{
/// Tests if indexes are correct if dock widget destroyed itself
Core::Group group(nullptr, {});
Expand Down Expand Up @@ -161,7 +161,7 @@ KDDW_QCORO_TASK tst_tabBarDWDestroyed()
KDDW_TEST_RETURN(true);
}

KDDW_QCORO_TASK tst_tabBarDWClosed()
bool tst_tabBarDWClosed()
{
{
/// Tests if indexes are correct if dock widget are closed (but not destroyed)
Expand Down
2 changes: 1 addition & 1 deletion tests/core/tst_titlebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using namespace KDDockWidgets;

KDDW_QCORO_TASK tst_titleBarCtor()
bool tst_titleBarCtor()
{
auto group = new Core::Group(nullptr, {});
auto tb = new Core::TitleBar(group);
Expand Down
3 changes: 1 addition & 2 deletions tests/qtquick/tst_qtquick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void TestQtQuick::tst_shutdownCrash()
// delete group;

// // 1 event loop for DelayedDelete. Avoids LSAN warnings.
// KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
// Platform::instance()->tests_wait(1);
}

void TestQtQuick::tst_childQmlContext()
Expand Down Expand Up @@ -407,7 +407,6 @@ void TestQtQuick::tst_focusBetweenTabs()
QVERIFY(floatingDockField->hasActiveFocus());

// 1 event loop for DelayedDelete. Avoids LSAN warnings.
KDDW_CO_AWAIT
Platform::instance()
->tests_wait(1);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/simple_test_framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@
#define KDDW_TEST_RETURN(res) \
if (!res) \
KDDW_WARN("FAILED: at={} ; line={}", KDDW_FUNC_INFO, __LINE__); \
KDDW_CO_RETURN res;
return res;

#define CHECK assert
#define CHECK_EQ(a, b) assert((a) == (b))

struct KDDWTest
{
std::string name;
std::function<KDDW_QCORO_TASK()> func;
std::function<bool()> func;

KDDW_QCORO_TASK run()
bool run()
{
std::cout << "Running " << name << std::endl;
auto result = KDDW_CO_AWAIT func();
auto result = func();
if (!result)
std::cerr << "FAILED! " << name << std::endl;
KDDW_TEST_RETURN(result);
}

static KDDW_QCORO_TASK run(const std::vector<KDDWTest> &tests)
static bool run(const std::vector<KDDWTest> &tests)
{
std::cout << "Running tests for Platform " << KDDockWidgets::Core::Platform::instance()->name() << "\n";
for (KDDWTest test : tests) {
auto result = KDDW_CO_AWAIT test.run();
auto result = test.run();
if (!result) {
KDDW_TEST_RETURN(result);
}
Expand Down
Loading

0 comments on commit da2847c

Please sign in to comment.