foreseen

A text-based gemini browser with prefetching
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

commit 417a0a3c157bb7849fd1562603b2d655d017245b
parent ff1badfc22b1fde35a018cf6406ec51b4a31fab1
Author: Andrew Laack <andrew@laack.co>
Date:   Tue, 29 Sep 2026 17:23:58 -0500

More coverage of keyboard inputs

Diffstat:
Mtests/puppet-test.cpp | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/tests/puppet-test.cpp b/tests/puppet-test.cpp @@ -67,3 +67,39 @@ TEST_CASE("Open page and search the web") { REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://tlgs.one/search?" + urlEncode(rnd)); } +TEST_CASE("Open page after backspacing character") { + Browser b {}; + DrawState ds {}; + REQUIRE(mainLoop(ds, b, 'o')); + REQUIRE(mainLoop(ds, b, 'l')); + REQUIRE(mainLoop(ds, b, 'a')); + REQUIRE(mainLoop(ds, b, 'a')); + REQUIRE(mainLoop(ds, b, 'a')); + REQUIRE(mainLoop(ds, b, KEY_BACKSPACE)); + REQUIRE(mainLoop(ds, b, 'c')); + REQUIRE(mainLoop(ds, b, 'k')); + REQUIRE(mainLoop(ds, b, '.')); + REQUIRE(mainLoop(ds, b, 'c')); + REQUIRE(mainLoop(ds, b, 'o')); + REQUIRE(mainLoop(ds, b, '\n')); + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://laack.co"); +} + +TEST_CASE("Cancel 'o' menu by pressing escape") { + Browser b {}; + DrawState ds {}; + REQUIRE(mainLoop(ds, b, 'o')); + REQUIRE(mainLoop(ds, b, 'l')); + REQUIRE(mainLoop(ds, b, 'a')); + REQUIRE(mainLoop(ds, b, 'a')); + REQUIRE(mainLoop(ds, b, 'a')); + REQUIRE(mainLoop(ds, b, KEY_BACKSPACE)); + REQUIRE(mainLoop(ds, b, 'c')); + REQUIRE(mainLoop(ds, b, 'k')); + REQUIRE(mainLoop(ds, b, '.')); + REQUIRE(mainLoop(ds, b, 'c')); + REQUIRE(mainLoop(ds, b, 'o')); + REQUIRE(mainLoop(ds, b, 27)); // escape + REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "about://newtab"); +} +