summaryrefslogtreecommitdiff
path: root/hyprtester/src/tests/main/scroll.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hyprtester/src/tests/main/scroll.cpp')
-rw-r--r--hyprtester/src/tests/main/scroll.cpp123
1 files changed, 32 insertions, 91 deletions
diff --git a/hyprtester/src/tests/main/scroll.cpp b/hyprtester/src/tests/main/scroll.cpp
index 3b73b906..bd33e345 100644
--- a/hyprtester/src/tests/main/scroll.cpp
+++ b/hyprtester/src/tests/main/scroll.cpp
@@ -3,15 +3,12 @@
#include "../../hyprctlCompat.hpp"
#include "tests.hpp"
-static int ret = 0;
+TEST_CASE(scrollFocusCycling) {
+ OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
-static void testFocusCycling() {
for (auto const& win : {"a", "b", "c", "d"}) {
if (!Tests::spawnKitty(win)) {
- NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
- ++TESTS_FAILED;
- ret = 1;
- return;
+ FAIL_TEST("Could not spawn kitty with win class `{}`", win);
}
}
@@ -21,49 +18,44 @@ static void testFocusCycling() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: b");
+ ASSERT_CONTAINS(str, "class: b");
}
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })"));
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: c");
+ ASSERT_CONTAINS(str, "class: c");
}
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'right' })"));
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: d");
+ ASSERT_CONTAINS(str, "class: d");
}
OK(getFromSocket("/dispatch hl.dsp.window.move({ direction = 'left' })"));
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: d");
+ ASSERT_CONTAINS(str, "class: d");
}
OK(getFromSocket("/dispatch hl.dsp.focus({ direction = 'up' })"));
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: c");
+ ASSERT_CONTAINS(str, "class: c");
}
-
- // clean up
- NLog::log("{}Killing all windows", Colors::YELLOW);
- Tests::killAllWindows();
}
-static void testFocusWrapping() {
+TEST_CASE(scrollFocusWrapping) {
+ OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
+
for (auto const& win : {"a", "b", "c", "d"}) {
if (!Tests::spawnKitty(win)) {
- NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
- ++TESTS_FAILED;
- ret = 1;
- return;
+ FAIL_TEST("Could not spawn kitty with win class `{}`", win);
}
}
@@ -76,14 +68,14 @@ static void testFocusWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: d");
+ ASSERT_CONTAINS(str, "class: d");
}
OK(getFromSocket("/dispatch hl.dsp.layout('focus r')"));
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: a");
+ ASSERT_CONTAINS(str, "class: a");
}
// set wrap_focus to false
@@ -95,7 +87,7 @@ static void testFocusWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: a");
+ ASSERT_CONTAINS(str, "class: a");
}
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:d' })"));
@@ -104,21 +96,16 @@ static void testFocusWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: d");
+ ASSERT_CONTAINS(str, "class: d");
}
-
- // clean up
- NLog::log("{}Killing all windows", Colors::YELLOW);
- Tests::killAllWindows();
}
-static void testSwapcolWrapping() {
+TEST_CASE(scrollSwapcolWrapping) {
+ OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
+
for (auto const& win : {"a", "b", "c", "d"}) {
if (!Tests::spawnKitty(win)) {
- NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
- ++TESTS_FAILED;
- ret = 1;
- return;
+ FAIL_TEST("Could not spawn kitty with win class `{}`", win);
}
}
@@ -132,7 +119,7 @@ static void testSwapcolWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: c");
+ ASSERT_CONTAINS(str, "class: c");
}
// clean up
@@ -141,10 +128,7 @@ static void testSwapcolWrapping() {
for (auto const& win : {"a", "b", "c", "d"}) {
if (!Tests::spawnKitty(win)) {
- NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
- ++TESTS_FAILED;
- ret = 1;
- return;
+ FAIL_TEST("Could not spawn kitty with win class `{}`", win);
}
}
@@ -154,7 +138,7 @@ static void testSwapcolWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: b");
+ ASSERT_CONTAINS(str, "class: b");
}
// clean up
@@ -163,10 +147,7 @@ static void testSwapcolWrapping() {
for (auto const& win : {"a", "b", "c", "d"}) {
if (!Tests::spawnKitty(win)) {
- NLog::log("{}Failed to spawn kitty with win class `{}`", Colors::RED, win);
- ++TESTS_FAILED;
- ret = 1;
- return;
+ FAIL_TEST("Could not spawn kitty with win class `{}`", win);
}
}
@@ -180,7 +161,7 @@ static void testSwapcolWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: b");
+ ASSERT_CONTAINS(str, "class: b");
}
OK(getFromSocket("/dispatch hl.dsp.focus({ window = 'class:d' })"));
@@ -190,15 +171,13 @@ static void testSwapcolWrapping() {
{
auto str = getFromSocket("/activewindow");
- EXPECT_CONTAINS(str, "class: c");
+ ASSERT_CONTAINS(str, "class: c");
}
-
- // clean up
- NLog::log("{}Killing all windows", Colors::YELLOW);
- Tests::killAllWindows();
}
-static bool testWindowRule() {
+TEST_CASE(scrollWindowRule) {
+ OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
+
NLog::log("{}Testing Scrolling Width", Colors::GREEN);
// inject a new rule.
@@ -206,53 +185,15 @@ static bool testWindowRule() {
OK(getFromSocket("/eval hl.window_rule({ name = 'scrolling-width', scrolling_width = 0.1 })"));
if (!Tests::spawnKitty("kitty_scroll")) {
- NLog::log("{}Failed to spawn kitty with win class `kitty_scroll`", Colors::RED);
- return false;
+ FAIL_TEST("Could not spawn kitty with win class `kitty_scroll`");
}
if (!Tests::spawnKitty("kitty_scroll")) {
- NLog::log("{}Failed to spawn kitty with win class `kitty_scroll`", Colors::RED);
- return false;
+ FAIL_TEST("Could not spawn kitty with win class `kitty_scroll`");
}
- EXPECT(Tests::windowCount(), 2);
+ ASSERT(Tests::windowCount(), 2);
// not the greatest test, but as long as res and gaps don't change, we good.
EXPECT_CONTAINS(getFromSocket("/activewindow"), "size: 174,1036");
-
- NLog::log("{}Killing all windows", Colors::YELLOW);
- Tests::killAllWindows();
- EXPECT(Tests::windowCount(), 0);
- return true;
}
-
-static bool test() {
- NLog::log("{}Testing Scroll layout", Colors::GREEN);
-
- // setup
- OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = 'name:scroll' })"));
- OK(getFromSocket("r/eval hl.config({ general = { layout = 'scrolling' } })"));
-
- // test
- NLog::log("{}Testing focus cycling", Colors::GREEN);
- testFocusCycling();
-
- // test
- NLog::log("{}Testing focus wrap", Colors::GREEN);
- testFocusWrapping();
-
- // test
- NLog::log("{}Testing swapcol wrap", Colors::GREEN);
- testSwapcolWrapping();
-
- testWindowRule();
-
- // clean up
- NLog::log("Cleaning up", Colors::YELLOW);
- OK(getFromSocket("/dispatch hl.dsp.focus({ workspace = '1' })"));
- OK(getFromSocket("/reload"));
-
- return !ret;
-}
-
-REGISTER_TEST_FN(test);