#include "arena.hpp" #include "connection_handler.hpp" #include "perfetto_categories.hpp" #include #include // Perfetto static storage for tests PERFETTO_TRACK_EVENT_STATIC_STORAGE(); // Global variable needed by Connection std::atomic activeConnections{0}; // Simple test helper since Connection has complex constructor requirements struct TestConnectionData { Arena arena; std::string message_buffer; void *user_data = nullptr; void append_message(std::string_view data) { message_buffer += data; } Arena &get_arena() { return arena; } const std::string &getResponse() const { return message_buffer; } void clearResponse() { message_buffer.clear(); } void reset() { arena.reset(); message_buffer.clear(); } }; // Test helper to verify the new hook functionality struct MockConnectionHandler : public ConnectionHandler { bool write_progress_called = false; bool write_buffer_drained_called = false; void on_write_progress(Ref &) override { write_progress_called = true; } void on_write_buffer_drained(Ref &) override { write_buffer_drained_called = true; } }; TEST_CASE("ConnectionHandler hooks") { SUBCASE("on_write_buffer_drained hook exists") { MockConnectionHandler handler; // Verify hooks are available and can be overridden CHECK_FALSE(handler.write_progress_called); CHECK_FALSE(handler.write_buffer_drained_called); // Would normally be called by Server during write operations Ref null_conn; handler.on_write_progress(null_conn); handler.on_write_buffer_drained(null_conn); CHECK(handler.write_progress_called); CHECK(handler.write_buffer_drained_called); } }