Test the rule that chooses the dictionary's container #6

Closed
anas wants to merge 0 commits from test/dictionary-fits-beside into main
Owner

Why

The guard merged in #3 decides whether the dictionary opens beside the poem or as a sheet over it. Nothing proved it was right.

I tried four times to verify it on the emulator at 700dp and failed every time. Reaching the rule needs a tap landing on the glyphs of one Persian word inside a SelectionContainer, and adb's synthetic taps either:

  • became a long press and opened the system selection menu, or
  • landed between words and opened the couplet's own actions (ذخیرهٔ این بیت / رونوشت / …), which my detector then mistook for the dictionary.

The verses aren't exposed to uiautomator either — only the column list is — so there is nothing to aim at by bounds.

What this does instead

The gesture can't be driven reliably; the arithmetic behind it can. The expression moves into a pure function:

internal fun dictionaryFitsBeside(pageWidth: Dp, wide: Boolean): Boolean =
    wide && pageWidth - DictionaryPanelWidth >= MinPageMeasure

and gets four cases:

Case Page Expected
Tablet, 1280dp window ~900dp panel
Foldable open in portrait, 700dp window ~450dp → 234dp left sheet
Phone (wide = false) any sheet
Boundary 616dp / 615dp panel / sheet

The boundary case is the one that matters: it pins the threshold at panel + minimum measure, so if either constant moves the test says so.

No behaviour change — same expression, named and covered. 67 tests pass (was 63).

Still true

This proves the decision, not the rendering. Nobody has yet seen the sheet appear at 700dp with their own eyes; a real device or an instrumented test would be the honest check, and the gesture is exactly what an instrumented test could drive that adb cannot.

## Why The guard merged in #3 decides whether the dictionary opens **beside** the poem or as a **sheet** over it. Nothing proved it was right. I tried four times to verify it on the emulator at 700dp and failed every time. Reaching the rule needs a tap landing on the glyphs of one Persian word inside a `SelectionContainer`, and adb's synthetic taps either: - became a long press and opened the system selection menu, or - landed between words and opened the couplet's own actions (`ذخیرهٔ این بیت` / `رونوشت` / …), which my detector then mistook for the dictionary. The verses aren't exposed to `uiautomator` either — only the column list is — so there is nothing to aim at by bounds. ## What this does instead The gesture can't be driven reliably; the arithmetic behind it can. The expression moves into a pure function: ```kotlin internal fun dictionaryFitsBeside(pageWidth: Dp, wide: Boolean): Boolean = wide && pageWidth - DictionaryPanelWidth >= MinPageMeasure ``` and gets four cases: | Case | Page | Expected | |---|---|---| | Tablet, 1280dp window | ~900dp | panel | | Foldable open in portrait, 700dp window | ~450dp → 234dp left | sheet | | Phone (`wide = false`) | any | sheet | | Boundary | 616dp / 615dp | panel / sheet | The boundary case is the one that matters: it pins the threshold at panel + minimum measure, so if either constant moves the test says so. **No behaviour change** — same expression, named and covered. 67 tests pass (was 63). ## Still true This proves the *decision*, not the *rendering*. Nobody has yet seen the sheet appear at 700dp with their own eyes; a real device or an instrumented test would be the honest check, and the gesture is exactly what an instrumented test could drive that adb cannot.
anas added 1 commit 2026-10-07 16:43:29 +00:00
The guard added in #3 decides whether the dictionary opens beside the poem or as
a sheet over it, and until now nothing proved it. I tried four times to verify it
by hand and failed every time: reaching it needs a tap landing on the glyphs of
one Persian word inside a SelectionContainer, and adb's synthetic taps either
became a long press and opened the selection menu, or landed between words and
opened the couplet's actions instead. The verses are not exposed to uiautomator
either, so there is nothing to aim at.

The arithmetic behind the rule can be tested even though the gesture cannot, so
it moves into a pure function and gets four cases: a tablet keeps the panel, a
foldable open in portrait does not, a phone never gets it however wide the page
is measured, and the boundary sits exactly at the panel plus the minimum measure
(616dp passes, 615dp does not).

No behaviour changes — this is the same expression, named and covered.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
anas closed this pull request 2026-10-07 16:53:30 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: anas/ganjoorandroid#6
No description provided.