Skip to content

Commit 14193db

Browse files
committed
Add X11 mocking utilities
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
1 parent 089f9ce commit 14193db

File tree

5 files changed

+382
-30
lines changed

5 files changed

+382
-30
lines changed

tests/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ excluding_any("wayland" IF NOT BUILD_WAYLAND)
2525

2626
# Mocking works because it's linked before conky_core, so the linker uses mock
2727
# implementations instead of those that are linked later.
28-
add_library(conky-mock OBJECT ${mock_sources})
2928
add_library(Catch2 STATIC catch2/catch_amalgamated.cpp)
3029

30+
add_library(conky-mock OBJECT ${mock_sources})
31+
target_link_libraries(conky-mock Catch2)
32+
3133
add_executable(test-conky test-common.cc ${test_sources})
3234
target_include_directories(test-conky
3335
PUBLIC

tests/mock/mock.hh

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ std::string debug_format(const std::string& format, Args... args) {
3333
/// This is intended for cases where some library function is internally invoked
3434
/// but would fail if conditions only present at runtime aren't met.
3535
struct state_change {
36-
public:
3736
virtual ~state_change() = default;
37+
38+
static std::string change_name() { return "state_change"; }
39+
3840
/// Returns a string representation of this state change with information
3941
/// necessary to differentiate it from other variants of the same type.
4042
virtual std::string debug() = 0;
@@ -70,7 +72,7 @@ std::optional<T> next_state_change_t() {
7072
} // namespace mock
7173

7274
/// A variant of `mock::next_state_change_t` that integrates into Catch2.
73-
/// It's a macro because using `FAIL` outside of a test doesn't work.
75+
/// It's a macro because using `FAIL` outside of a test doesn't compile.
7476
#define EXPECT_NEXT_CHANGE(T) \
7577
[]() { \
7678
static_assert(std::is_base_of_v<mock::state_change, T>, \

0 commit comments

Comments
 (0)