Skip to content

Commit da9b2cb

Browse files
committed
Fix Window
1 parent 7553e86 commit da9b2cb

4 files changed

Lines changed: 22 additions & 18 deletions

File tree

modules/UnitTest/UnitTest.mpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace CppUtils::UnitTest
2525
bool detail = true;
2626
bool chrono = false;
2727
bool fastAbort = false;
28+
std::string filter = "";
2829
};
2930

3031
struct Test final
@@ -126,7 +127,7 @@ namespace CppUtils::UnitTest
126127
using namespace std::chrono_literals;
127128
auto testSuiteIsSuccess = std::unordered_map<std::string, bool>{};
128129

129-
const auto nbTests = std::ranges::fold_left(
130+
auto nbTests = std::ranges::fold_left(
130131
std::views::values(m_testSuites.nodes) | std::views::transform([](auto&& node) { return std::ranges::size(node.value); }),
131132
0uz,
132133
std::plus{});
@@ -160,6 +161,12 @@ namespace CppUtils::UnitTest
160161
auto allTestsPassed = true;
161162
for (const auto& test : tests)
162163
{
164+
if (not std::empty(settings.filter) and test.name.find(settings.filter) == std::string::npos)
165+
{
166+
--nbTests;
167+
continue;
168+
}
169+
163170
if (executeTest(test, settings))
164171
++nbSuccess;
165172
else

modules/Window/Window.mpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace CppUtils::Window
9494
std::uint32_t serial) -> void;
9595

9696
inline const auto surfaceListener = xdg_surface_listener{
97-
.configure = &Window::xdg_surface_configure,
97+
.configure = xdg_surface_configure,
9898
};
9999
#endif
100100

@@ -228,7 +228,7 @@ namespace CppUtils::Window
228228
// m_imageStorage = ImageStorage{size};
229229
openWindow();
230230
wl_surface_commit(surface.get());
231-
// wl_display_roundtrip(Wayland::globals.display.get());
231+
wl_display_roundtrip(Wayland::globals.display.get());
232232
// wl_display_dispatch(Wayland::globals.display.get());
233233
wl_display_flush(Wayland::globals.display.get());
234234
}
@@ -276,13 +276,13 @@ namespace CppUtils::Window
276276
{
277277
auto result = 0;
278278
while ((result = wl_display_dispatch(Wayland::globals.display.get())) != -1)
279-
std::cout << "Event received, result = " << result << std::endl;
280-
std::cout << "Wayland dispatch exited with " << result << std::endl;
279+
Logger::print<"detail">("Event received, result = {}", result);
280+
Logger::print<"warning">("Wayland dispatch exited with {}", result);
281281
}
282282

283283
inline auto update() -> void
284284
{
285-
std::cout << "update" << std::endl;
285+
Logger::print<"detail">("update");
286286
wl_surface_attach(surface.get(), m_imageStorage.buffer.get(), 0, 0);
287287
wl_surface_damage(surface.get(), 0, 0, std::numeric_limits<std::int32_t>::max(), std::numeric_limits<std::int32_t>::max());
288288
wl_surface_commit(surface.get());
@@ -306,13 +306,13 @@ namespace CppUtils::Window
306306
#endif
307307
};
308308

309-
inline auto drawFrame(Window& window) -> void
309+
export inline auto drawFrame(Window& window) -> void
310310
{
311-
std::cout << "drawFrame" << std::endl;
311+
Logger::print<"detail">("drawFrame");
312312
const auto& imageSize = window.getSize();
313313
if (not window.m_imageStorage.buffer)
314314
{
315-
std::cout << "ImageStorage" << std::endl;
315+
Logger::print<"detail">("ImageStorage");
316316
window.m_imageStorage = Window::ImageStorage{imageSize};
317317
}
318318
auto* pixels = window.getPixels();
@@ -331,7 +331,7 @@ namespace CppUtils::Window
331331
xdg_surface* xdg_surface,
332332
std::uint32_t serial) -> void
333333
{
334-
std::cout << "Surface configure !" << std::endl;
334+
Logger::print<"detail">("Surface configure !");
335335
auto& window = *static_cast<Window*>(data);
336336
xdg_surface_ack_configure(xdg_surface, serial);
337337

tests/Window/Window.mpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ export namespace CppUtils::UnitTest::Window
99
using namespace std::literals;
1010

1111
suite.addTest("Opening a window", [&] {
12-
auto window = CppUtils::Window::Window{"Title", {1'920, 1'080}};
13-
// window.runLoop();
12+
auto window = CppUtils::Window::Window{"Title", {640, 360}};
1413
std::this_thread::sleep_for(5s);
1514
suite.expectEqual(window.getTitle(), "Title"sv);
1615
});

tests/main.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import std;
22
import CppUtils;
33
import CppUtils.UnitTests;
44

5-
auto start([[maybe_unused]] std::span<const std::string_view> args) -> int
5+
auto start(std::span<const std::string_view> args) -> int
66
{
77
try
88
{
9-
/*
10-
auto& settings = CppUtils::UnitTest::executeCommands(argc, argv);
11-
if (settings.abort)
12-
return CppUtils::exitSuccess;
13-
*/
149
auto settings = CppUtils::UnitTest::TestSettings{.fastAbort = false};
10+
for (auto i = 0uz; i < std::size(args); ++i)
11+
if (args[i] == "--filter" and i + 1 < std::size(args))
12+
settings.filter = std::string{args[++i]};
1513
return CppUtils::UnitTest::executeTests(std::move(settings));
1614
}
1715
catch (const std::exception& exception)

0 commit comments

Comments
 (0)