Skip to content

Test the widgets and the Editor's undo and redo - #2

Merged
schikani merged 2 commits into
tinydesk-project:mainfrom
TharunBabu-05:tests/widgets-and-editor
Oct 4, 2026
Merged

schikani merged 2 commits into
tinydesk-project:mainfrom
TharunBabu-05:tests/widgets-and-editor

Conversation

@TharunBabu-05

Copy link
Copy Markdown
Contributor

What this adds

Two new CTest programs. Nothing in the library or the apps changes.

  • test_widgets (links tinydesk_core): text box editing, horizontal
    scrolling, td_textbox_set_buffer() and bracketed paste; list keys, wheel,
    clicks, double click and shrinking; the scrollbar's arrows, track and drag;
    checkbox, button (fires on release, only over the button) and progress bar;
    Tab / Shift+Tab focus order with hidden widgets; message box answers (Enter,
    Tab, click, Esc, [x]) and modality; input box and password box (stars on
    screen); the window slot and widgets kept free for a message box.
  • test_editor (links tinydesk_apps): undo a word at a time; runs of
    Backspace and Delete, typing over a selection, cut, paste and a terminal
    paste (CR / CRLF to LF) as single steps; Ctrl+Y and Ctrl+Shift+Z redo; a new
    edit ending redo; the * in the title following the save point; the
    history dropping its oldest steps and still undoing and redoing to the right
    text; a paste larger than the history; Esc with unsaved changes (Cancel,
    Discard, Save).

Both use synthetic events through td_wm_dispatch(), like test_wm. The
Editor test gives the port a td_fs_ops_t that keeps one file in memory and
reads the text and the status bar back from the composed screen, so it tests
what the user sees rather than the Editor's internals.

One check depends on a default size: the history test pastes 10,000 bytes to
go past TD_EDITOR_UNDO (6 KB).

Tested

  • Windows (MinGW GCC 15.2), with and without MQTT over TLS (mbedTLS v3.6.7):
    no warnings with -Werror, 9/9 CTest programs pass.
  • To check that the tests can fail, I made one deliberate bug at a time.
    Each was caught: no new undo step per word; history offsets not adjusted
    when old steps are dropped; a run of Delete undone one key at a time; CRLF
    pasted as two line breaks; no widgets kept for dialogs; the password drawn
    in clear; the list view not following the selection; Ctrl/Alt keys typed
    into a text box; a button firing on press.
  • Not run on Linux here; CI covers it.

test_widgets: text box editing, scrolling, own buffer and paste; list
keys, wheel, clicks and shrinking; the scrollbar; checkbox, button and
progress bar; focus order; message and input boxes; the window and
widget slots kept for a message box.

test_editor: undo by word, runs of Backspace and Delete, typing over a
selection, cut / copy / paste and a terminal paste as single steps, the
'*' following the save point, a new edit ending redo, the history
limits, and closing with unsaved changes. The file is in memory and the
text is read back from the screen.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

save() passes E.path to save_to(), which copied it onto itself with
snprintf. That is undefined: glibc empties the string, so on Linux the
title turned "untitled" after the first Ctrl+S and the next one asked for
a name (Save as). Found by the new Editor test on the Linux CI runner;
test_save_twice now checks it directly.
@schikani

schikani commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks, nice work! Reading the Editor back from the screen is a smart way to test it, and the save-twice bug was a real catch. It showed up with glibc, so I'd never have hit it on Windows. Good thing the Linux CI runner caught it.

Tested here on MinGW, with and without MQTT TLS: builds clean, all 9 tests pass. Merging.

Heads-up: I'll be moving the C sources to clang-format soon (braces on their own lines, no single-line bodies) and adding a .clang-format to the root. Once that's in, please run clang-format -i on the files you touch.

@schikani
schikani merged commit 096e84c into tinydesk-project:main Oct 4, 2026
6 checks passed
@TharunBabu-05
TharunBabu-05 deleted the tests/widgets-and-editor branch October 5, 2026 03:49
@TharunBabu-05

TharunBabu-05 commented Oct 5, 2026 via email

Copy link
Copy Markdown
Contributor Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants