Skip to content

dynamic_tapping_term: add unit tests#26338

Draft
arcaartem wants to merge 3 commits into
qmk:developfrom
arcaartem:dynamic-tapping-term-tests
Draft

dynamic_tapping_term: add unit tests#26338
arcaartem wants to merge 3 commits into
qmk:developfrom
arcaartem:dynamic-tapping-term-tests

Conversation

@arcaartem

@arcaartem arcaartem commented Jul 16, 2026

Copy link
Copy Markdown

Description

There is currently no unit-test coverage for quantum/process_keycode/process_dynamic_tapping_term.c. This adds a small tests/dynamic_tapping_term suite covering the feature's baseline behavior:

  • the initial g_tapping_term matches the configured TAPPING_TERM
  • DT_UP raises g_tapping_term by DYNAMIC_TAPPING_TERM_INCREMENT per press
  • DT_DOWN lowers it by the same amount per press

The fixture restores g_tapping_term to TAPPING_TERM after every test, so the suite does not depend on test execution order (verified with --gtest_shuffle across repeated runs).

All tests pass on current develop (make test:dynamic_tapping_term, 3 tests). This is groundwork for the fix in the follow-up PR, which adds an underflow regression test to this suite alongside its one-line guard.

Types of Changes

  • Core
  • Bug fix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: qmk format-c clean; test boilerplate matches the existing suites (tests/tri_layer, tests/auto_shift).
  • I have read the CONTRIBUTING document.
  • My change targets the develop branch.
  • My change is restricted to one logical change (a single new test suite, no production code touched).
  • make test:dynamic_tapping_term passes locally (3/3).

Add a test suite under tests/dynamic_tapping_term covering the
DYNAMIC_TAPPING_TERM_ENABLE feature: the initial value of
g_tapping_term matches the configured TAPPING_TERM, DT_UP raises it
by DYNAMIC_TAPPING_TERM_INCREMENT per press, and DT_DOWN lowers it by
the same amount per press. No prior test coverage existed for this
feature.

Give the fixture a destructor that restores g_tapping_term to
TAPPING_TERM after every test, so InitialTappingTermMatchesConfiguredDefault
does not depend on running before the other tests mutate the global
tapping term. Verified order-independence by running the suite with
--gtest_shuffle across many seeds.
@arcaartem
arcaartem force-pushed the dynamic-tapping-term-tests branch from 907e674 to e547be4 Compare July 16, 2026 17:38
@arcaartem

Copy link
Copy Markdown
Author

Made the suite order-independent: the fixture now restores g_tapping_term to TAPPING_TERM after every test (verified with --gtest_shuffle across repeated runs), and an unused using-declaration was removed.

Comment thread tests/dynamic_tapping_term/test_dynamic_tapping_term.cpp Outdated
arcaartem and others added 2 commits July 17, 2026 09:19
Co-authored-by: Joel Challis <git@zvecr.com>
…c term

Exercise the feature end to end: the same hold duration resolves as a
tap under the default tapping term, then as a hold after DT_DOWN lowers
the term below it. This pins the GET_TAPPING_TERM -> g_tapping_term
wiring that the arithmetic-only tests do not cover.
@arcaartem

Copy link
Copy Markdown
Author

Removed the initial-value test as suggested. To keep the suite meaningful beyond increment arithmetic, added an end-to-end test (LoweredTappingTermChangesModTapResolution): the same hold duration resolves as a tap under the default tapping term and as a hold after DT_DOWN lowers the term below it, exercising tap-hold resolution through g_tapping_term at resolution time. Suite passes locally including --gtest_shuffle repeats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants