-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add held back-button routing #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ TestCase { | |
| // run in microseconds, so the pending fire would land on the | ||
| // next test if we didn't reset it here. | ||
| main._stopRepeat(); | ||
| main._stopCancelHold(); | ||
| } | ||
|
|
||
| function test_initial_state_is_hub(): void { | ||
|
|
@@ -95,13 +96,15 @@ TestCase { | |
| function test_escape_on_games_returns_to_systems(): void { | ||
| main.activeScreen = main.screenGames; | ||
| main.handleKey(Qt.Key_Escape); | ||
| main.handleKeyRelease(Qt.Key_Escape); | ||
| compare(main.activeScreen, main.screenSystems); | ||
| } | ||
|
|
||
| // Escape on systems goes back to hub. | ||
| function test_escape_on_systems_returns_to_hub(): void { | ||
| main.activeScreen = main.screenSystems; | ||
| main.handleKey(Qt.Key_Escape); | ||
| main.handleKeyRelease(Qt.Key_Escape); | ||
| compare(main.activeScreen, main.screenHub); | ||
| } | ||
|
|
||
|
|
@@ -118,9 +121,36 @@ TestCase { | |
| function test_backspace_behaves_like_escape_on_games(): void { | ||
| main.activeScreen = main.screenGames; | ||
| main.handleKey(Qt.Key_Backspace); | ||
| main.handleKeyRelease(Qt.Key_Backspace); | ||
| compare(main.activeScreen, main.screenSystems); | ||
| } | ||
|
|
||
| function test_cancel_press_arms_hold_without_immediate_navigation(): void { | ||
| main.activeScreen = main.screenGames; | ||
| main.handleKey(Qt.Key_Escape); | ||
| compare(main.activeScreen, main.screenGames, "Back press must wait for release-or-hold timeout"); | ||
| compare(main._cancelHoldPending, true); | ||
| } | ||
|
|
||
| function test_cancel_hold_from_games_routes_directly_to_hub(): void { | ||
| main.activeScreen = main.screenGames; | ||
| main.handleKey(Qt.Key_Escape); | ||
| tryCompare(main, "activeScreen", main.screenHub); | ||
| compare(main._cancelHoldPending, false, "Hold timer must clear after firing"); | ||
| main.handleKeyRelease(Qt.Key_Escape); | ||
| compare(main.activeScreen, main.screenHub, "Release after long-hold must not fire a second cancel"); | ||
| } | ||
|
|
||
| function test_cancel_hold_on_hub_opens_quit_confirm(): void { | ||
| main.activeScreen = main.screenHub; | ||
| main.handleKey(Qt.Key_Escape); | ||
| tryCompare(main, "quitConfirmModalVisible", true); | ||
| compare(main.activeScreen, main.screenHub, "Long-hold Back on Hub must stay on Hub and ask for quit"); | ||
| compare(main._cancelHoldPending, false, "Hold timer must clear after opening quit confirm"); | ||
| main.handleKeyRelease(Qt.Key_Escape); | ||
| compare(main.quitConfirmModalVisible, true, "Release after long-hold must not close the quit confirm"); | ||
| } | ||
|
Comment on lines
+135
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests expect timer-triggered navigation but implementation dispatches on release. Both These tests will timeout because the screen/modal state never changes until release. If the fix is applied to Alternative test structure for release-triggered behavior function test_cancel_hold_from_games_routes_directly_to_hub(): void {
main.activeScreen = main.screenGames;
main.handleKey(Qt.Key_Escape);
+ wait(root._cancelHoldMs + 50); // Wait past hold threshold
+ compare(main.activeScreen, main.screenGames, "Must not navigate while key is still held");
+ main.handleKeyRelease(Qt.Key_Escape);
- tryCompare(main, "activeScreen", main.screenHub);
+ compare(main.activeScreen, main.screenHub);
compare(main._cancelHoldPending, false, "Hold timer must clear after firing");
- main.handleKeyRelease(Qt.Key_Escape);
- compare(main.activeScreen, main.screenHub, "Release after long-hold must not fire a second cancel");
}This comment is related to the 🤖 Prompt for AI Agents |
||
|
|
||
| // Cross-row mapping. The test harness has no live CategoriesModel | ||
| // so we can't drive the full handleAction("down") flow with real | ||
| // categories — instead we unit-test the pure arithmetic helper | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timer only sets flag—tests expect navigation on timer fire, not on release.
The timer's
onTriggeredsets_cancelHoldReady = truebut doesn't dispatch the action. The tests (test_cancel_hold_from_games_routes_directly_to_hub,test_cancel_hold_on_hub_opens_quit_confirm) usetryComparebefore callinghandleKeyRelease, expecting navigation to occur when the timer fires. With the current implementation, navigation only happens on key release.If the intended UX is "navigate when hold threshold passes (key still held)," the timer should dispatch the action:
Proposed fix for timer-triggered dispatch
Timer { id: cancelHoldTimer interval: root._cancelHoldMs repeat: false onTriggered: { if (!root._cancelPending) return; root._cancelHoldReady = true; + root._stopCancelHold(); + root.handleAction("cancel_hold"); } }Alternatively, if the intended UX is "navigate on release after holding 1 second," the tests need restructuring to call
handleKeyReleaseand use await()ortryCompareon a different property.🤖 Prompt for AI Agents