summaryrefslogtreecommitdiff
path: root/hyprtester/src/tests/shared.cpp
diff options
context:
space:
mode:
authorrfresh2 <89827146+rfresh2@users.noreply.github.com>2025-10-06 12:10:56 -0700
committerGitHub <noreply@github.com>2025-10-06 21:10:56 +0200
commit73f06434a43c75b3a81e31a6ed7586a14a9c7a48 (patch)
tree0bb1a5ace48f8f17859583f59eb39b9787283273 /hyprtester/src/tests/shared.cpp
parent17e77e0407bebd5d24521012ee1d04b156d6b9f4 (diff)
keybinds: fix repeat and long press keybinds release (#11863)
Diffstat (limited to 'hyprtester/src/tests/shared.cpp')
-rw-r--r--hyprtester/src/tests/shared.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/hyprtester/src/tests/shared.cpp b/hyprtester/src/tests/shared.cpp
index b7aa325c..8cdd648e 100644
--- a/hyprtester/src/tests/shared.cpp
+++ b/hyprtester/src/tests/shared.cpp
@@ -9,10 +9,15 @@
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
-CUniquePointer<CProcess> Tests::spawnKitty(const std::string& class_) {
+CUniquePointer<CProcess> Tests::spawnKitty(const std::string& class_, const std::vector<std::string> args) {
const auto COUNT_BEFORE = windowCount();
- CUniquePointer<CProcess> kitty = makeUnique<CProcess>("kitty", class_.empty() ? std::vector<std::string>{} : std::vector<std::string>{"--class", class_});
+ std::vector<std::string> programArgs = args;
+ if (!class_.empty()) {
+ programArgs.insert(programArgs.begin(), "--class");
+ programArgs.insert(programArgs.begin() + 1, class_);
+ }
+ CUniquePointer<CProcess> kitty = makeUnique<CProcess>("kitty", programArgs);
kitty->addEnv("WAYLAND_DISPLAY", WLDISPLAY);
kitty->runAsync();
@@ -49,7 +54,7 @@ int Tests::countOccurrences(const std::string& in, const std::string& what) {
auto pos = in.find(what);
while (pos != std::string::npos) {
cnt++;
- pos = in.find(what, pos + what.length() - 1);
+ pos = in.find(what, pos + what.length());
}
return cnt;
@@ -90,3 +95,13 @@ void Tests::waitUntilWindowsN(int n) {
}
}
}
+
+std::string Tests::execAndGet(const std::string& cmd) {
+ CProcess proc("/bin/sh", {"-c", cmd});
+
+ if (!proc.runSync()) {
+ return "error";
+ }
+
+ return proc.stdOut();
+}