test(hyprland): expose dispatch internals for unit tests

Move buildLuaDispatch and isLuaProtocol from private to
protected/public so IPCTestHelper can access them.

Add 7 tests covering all buildLuaDispatch branches, dispatch
error path, and isLuaProtocol cache behavior.
This commit is contained in:
Higor Prado
2026-05-02 20:25:43 -03:00
parent e17c0d9f0a
commit 97917db593
2 changed files with 86 additions and 7 deletions
+7 -7
View File
@@ -40,22 +40,22 @@ class IPC {
/// (legacy text or Lua-based) depending on the running Hyprland version.
static std::string dispatch(const std::string& dispatcher, const std::string& arg);
/// Build a Lua-format dispatch command string.
static std::string buildLuaDispatch(const std::string& dispatcher, const std::string& arg);
protected:
static std::filesystem::path socketFolder_;
private:
void socketListener();
void parseIPC(const std::string&);
/// Detect whether the running Hyprland uses the Lua-based IPC protocol.
/// Returns true for Hyprland >= 0.54 (Lua config), false for older versions.
static bool isLuaProtocol();
/// Build a Lua-format dispatch command string.
static std::string buildLuaDispatch(const std::string& dispatcher, const std::string& arg);
static std::optional<bool> s_luaProtocolDetected_; // cached detection result
private:
void socketListener();
void parseIPC(const std::string&);
std::thread ipcThread_;
std::mutex callbackMutex_;
std::mutex socketMutex_;