summaryrefslogtreecommitdiff
path: root/hyprtester/src/tests/main/gestures.cpp
diff options
context:
space:
mode:
authorNikolai Nechaev <nikolay_nechaev@mail.ru>2025-09-21 00:57:49 +0900
committerGitHub <noreply@github.com>2025-09-20 17:57:49 +0200
commit41dad381770300fe1015ad8cdd1f370a8fd4e5d5 (patch)
treec59fd4c20e1879d0f8e6c4ee035fc387d64a0e25 /hyprtester/src/tests/main/gestures.cpp
parent838439080a9feaac3386d694dc7f8463e41c51df (diff)
config: fix multi-argument gesture dispatcher parsing (#11721)
* config: Fix multi-argument gesture dispatchers parsing The `dispatcher` gesture handler used to only handle the first argument to the dispatcher, while some dispatchers (e.g., `sendshortcut`) want multiple arguments. This fixes `ConfigManager` to handle all the arguments provided to the dispatcher gesture handler. Fixes #11684. * test/gestures: Add a test for a gesture with a multi-argument dispatcher * test/gestures: Factor out `waitForWindowCount` Reduce code duplication in the gestures test.
Diffstat (limited to 'hyprtester/src/tests/main/gestures.cpp')
-rw-r--r--hyprtester/src/tests/main/gestures.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/hyprtester/src/tests/main/gestures.cpp b/hyprtester/src/tests/main/gestures.cpp
index 37d367d2..94ac1261 100644
--- a/hyprtester/src/tests/main/gestures.cpp
+++ b/hyprtester/src/tests/main/gestures.cpp
@@ -18,6 +18,20 @@ using namespace Hyprutils::Memory;
#define UP CUniquePointer
#define SP CSharedPointer
+static bool waitForWindowCount(int expectedWindowCnt, std::string_view expectation, int waitMillis = 100, int maxWaitCnt = 50) {
+ int counter = 0;
+ while (Tests::windowCount() != expectedWindowCnt) {
+ counter++;
+ std::this_thread::sleep_for(std::chrono::milliseconds(waitMillis));
+
+ if (counter > maxWaitCnt) {
+ NLog::log("{}Unmet expectation: {}", Colors::RED, expectation);
+ return false;
+ }
+ }
+ return true;
+}
+
static bool test() {
NLog::log("{}Testing gestures", Colors::GREEN);
@@ -27,19 +41,21 @@ static bool test() {
NLog::log("{}Switching to workspace 1", Colors::YELLOW);
getFromSocket("/dispatch workspace 1"); // no OK: we might be on 1 already
- OK(getFromSocket("/dispatch plugin:test:gesture left,3"));
+ Tests::spawnKitty();
+ EXPECT(Tests::windowCount(), 1);
- // wait while kitty spawns
- int counter = 0;
- while (Tests::windowCount() != 1) {
- counter++;
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ // Give the shell a moment to initialize
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
- if (counter > 50) {
- NLog::log("{}Gesture didnt spawn kitty", Colors::RED);
- return false;
- }
- }
+ OK(getFromSocket("/dispatch plugin:test:gesture up,4"));
+
+ EXPECT(waitForWindowCount(0, "Gesture sent ctrl+d to kitty"), true);
+
+ EXPECT(Tests::windowCount(), 0);
+
+ OK(getFromSocket("/dispatch plugin:test:gesture left,3"));
+
+ EXPECT(waitForWindowCount(1, "Gesture spawned kitty"), true);
EXPECT(Tests::windowCount(), 1);
@@ -126,16 +142,7 @@ static bool test() {
OK(getFromSocket("/dispatch plugin:test:gesture up,3"));
- counter = 0;
- while (Tests::windowCount() != 0) {
- counter++;
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
-
- if (counter > 50) {
- NLog::log("{}Gesture didnt close kitty", Colors::RED);
- return false;
- }
- }
+ EXPECT(waitForWindowCount(0, "Gesture closed kitty"), true);
EXPECT(Tests::windowCount(), 0);