From 150d693fe794a01aab762a18d2d8a2c8bc54b43c Mon Sep 17 00:00:00 2001 From: Levizor Date: Tue, 9 Sep 2025 15:19:51 +0200 Subject: hyprctl: add an active layout index field in devices (#11531) --- hyprtester/src/tests/main/hyprctl.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'hyprtester/src/tests/main/hyprctl.cpp') diff --git a/hyprtester/src/tests/main/hyprctl.cpp b/hyprtester/src/tests/main/hyprctl.cpp index 2946c630..95f7caae 100644 --- a/hyprtester/src/tests/main/hyprctl.cpp +++ b/hyprtester/src/tests/main/hyprctl.cpp @@ -1,7 +1,9 @@ #include "tests.hpp" #include "../../shared.hpp" #include "../../hyprctlCompat.hpp" +#include #include +#include #include #include #include @@ -29,6 +31,24 @@ static std::string getCommandStdOut(std::string command) { return stdOut.substr(0, stdOut.length() - 1); } +static bool testDevicesActiveLayoutIndex() { + NLog::log("{}Testing hyprctl devices active_layout_index", Colors::GREEN); + + // configure layouts + getFromSocket("/keyword input:kb_layout us,pl,ua"); + + for (uint8_t i = 0; i < 3; i++) { + // set layout + getFromSocket("/switchxkblayout all " + std::to_string(i)); + std::string devicesJson = getFromSocket("j/devices"); + std::string expected = R"("active_layout_index": )" + std::to_string(i); + // check layout index + EXPECT_CONTAINS(devicesJson, expected); + } + + return true; +} + static bool testGetprop() { NLog::log("{}Testing hyprctl getprop", Colors::GREEN); if (!Tests::spawnKitty()) { @@ -154,8 +174,9 @@ static bool test() { EXPECT(jqProc.exitCode(), 0); } - if (!testGetprop()) - return false; + testGetprop(); + testDevicesActiveLayoutIndex(); + getFromSocket("/reload"); return !ret; } -- cgit v1.2.3