upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/gameinput_test.cpp
diff options
context:
space:
mode:
authorquartz-heron-58 <245169279+quartz-heron-58@users.noreply.github.com>2026-11-26 08:28:59 +0800
committerquartz-heron-58 <245169279+quartz-heron-58@users.noreply.github.com>2026-11-26 08:28:59 +0800
commit9ea22eaf446b50f03d600bc2f5f1e6c4afb09788 (patch)
tree5a97e9c355087d9749ccbe20e4439b7dd73b8a5c /runtime/test/gameinput_test.cpp
parent61732aca16fb0d63deb5e9987f9758d4e6ce0228 (diff)
gameinput test: read the pad before expecting a scripted press to end (TEST-GAMEINPUT-SCRIPT-READS)
Since #2098 a scripted press lasts its 300 ms and then until the title has made six GetCurrentReading calls since it began. gameinput_test --input-script still expected the press to be over after 350 ms and three reads, so ctest gameinput_script failed on main in every build with SDL3 (it is disabled without SDL3, so CI did not show it). The test now checks that the press is still held at that point, reads the pad six more times and then expects the release. Test only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index b6658f51c..be9dc5398 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -1742,8 +1742,15 @@ int main(int argc, char** argv) {
1742 Sleep(350); 1742 Sleep(350);
1743 g_focus = true; 1743 g_focus = true;
1744 rt::gameinput::poll(); 1744 rt::gameinput::poll();
1745 // A scripted press lasts its 300 ms and then until the title has read the pads six times since it began
1746 // (update_keyboard_pad: kReads, at most kMaxHold seconds), so a title that polls slowly still sees it. Each
1747 // pad_state() is one GetCurrentReading, and this is the third since the X began.
1748 check(pad_state(input, nullptr).buttons == (GameInputGamepadX | GameInputGamepadB),
1749 "long script: past its 300 ms the press is still held while the title has read the pads fewer than six times");
1750 for (int i = 0; i < 6; ++i) pad_state(input, nullptr);
1751 rt::gameinput::poll();
1745 check(pad_state(input, nullptr).buttons == GameInputGamepadB, 1752 check(pad_state(input, nullptr).buttons == GameInputGamepadB,
1746 "long script: the timed press ends while the physical key stays held"); 1753 "long script: the timed press ends once the title has read it, while the physical key stays held");
1747 input->Release(); 1754 input->Release();
1748 std::printf("%d checks, %d failures\n", g_checks, g_failures); 1755 std::printf("%d checks, %d failures\n", g_checks, g_failures);
1749 return g_failures ? 1 : 0; 1756 return g_failures ? 1 : 0;