| index 995d92a..c098151 100644 |
| --- a/internal/slidestest/browser_editor_tidy_test.go |
| +++ b/internal/slidestest/browser_editor_tidy_test.go |
| @@ -2344,3 +2344,110 @@ func TestTidyLastSlideRemovedFromTheNotes(t *testing.T) { |
| t.Errorf("the last slide removed by a colleague while the caret was in its notes: the card is %+v with %d marks drawn; want data-inspect=slide, the Deck section alone, no marks", s, drawn) |
| } |
| } |
| + |
| +// fitJS is the desktop slide against the room it has: the slide's own |
| +// rect, the stage's (the visible stage area), the notes card's top (or |
| +// null when it is not drawn) and the inspector card's left (null when |
| +// hidden), the stage's scroll and client heights, and its width over |
| +// its height. |
| +const fitJS = `(() => { |
| + const q = s => document.querySelector(s) |
| + const drawn = el => !!el && el.checkVisibility() && el.getBoundingClientRect().height > 0 |
| + const box = el => { const r = el.getBoundingClientRect(); return {L: r.left, T: r.top, R: r.right, B: r.bottom, W: r.width, H: r.height} } |
| + const stage = q('[slides-stage]'), slide = q('[slides-stage] > [slides-slide]') |
| + const notes = q('[slides-notes-pane]'), card = q('[slides-inspector]') |
| + return { |
| + Slide: box(slide), Stage: box(stage), |
| + NotesTop: drawn(notes) ? notes.getBoundingClientRect().top : -1, |
| + CardLeft: drawn(card) ? card.getBoundingClientRect().left : -1, |
| + ScrollH: stage.scrollHeight, ClientH: stage.clientHeight, |
| + ScrollW: stage.scrollWidth, ClientW: stage.clientWidth |
| + } |
| +})()` |
| + |
| +type fitState struct { |
| + Slide, Stage edges4 |
| + NotesTop, CardLeft float64 |
| + ScrollH, ClientH, ScrollW, ClientW float64 |
| +} |
| + |
| +// fits says how the slide fails to fit its room; "" is the pass. |
| +func (f fitState) fits() string { |
| + var out []string |
| + const e = 0.5 |
| + if f.Slide.L < f.Stage.L-e || f.Slide.T < f.Stage.T-e || f.Slide.R > f.Stage.R+e || f.Slide.B > f.Stage.B+e { |
| + out = append(out, fmt.Sprintf("the slide %+v is not inside the stage %+v", f.Slide, f.Stage)) |
| + } |
| + if f.NotesTop >= 0 && f.Slide.B > f.NotesTop+e { |
| + out = append(out, fmt.Sprintf("the slide ends at %.1f, under the notes card's top %.1f", f.Slide.B, f.NotesTop)) |
| + } |
| + if f.CardLeft >= 0 && f.Slide.R > f.CardLeft+e { |
| + out = append(out, fmt.Sprintf("the slide ends at %.1f, under the inspector card's left %.1f", f.Slide.R, f.CardLeft)) |
| + } |
| + if f.Slide.H <= 0 || math.Abs(f.Slide.W/f.Slide.H-16.0/9)/(16.0/9) > 0.01 { |
| + out = append(out, fmt.Sprintf("the slide is %.1f×%.1f, not 16:9 within 1%%", f.Slide.W, f.Slide.H)) |
| + } |
| + if f.ScrollH != f.ClientH { |
| + out = append(out, fmt.Sprintf("the stage scrolls: scrollHeight %g, clientHeight %g", f.ScrollH, f.ClientH)) |
| + } |
| + return strings.Join(out, "; ") |
| +} |
| + |
| +// TestTidyDesktopSlideFits (final review, finding 5, V1): the desktop |
| +// slide fits the room above the notes, both ways, at 16:9. At 1280×720 |
| +// and 1920×1080, in desktop view and in Both, with the notes open at |
| +// their default height, at their maximum and closed, and with the card |
| +// shown and hidden: the slide's own rect is inside the stage, above the |
| +// notes card, left of the inspector card, 16:9 within 1%, and the stage |
| +// does not scroll. |
| +func TestTidyDesktopSlideFits(t *testing.T) { |
| + te := openTidyEditor(t, 2, 1280, 720) |
| + notes := map[string]func(){ |
| + "the notes at their default height": func() { |
| + te.rig.Run( |
| + chromedp.Evaluate(`(p => { if (p.dataset.state !== 'open') document.querySelector('[data-view-toggle="notes"]').click() })(document.querySelector('[slides-notes-pane]'))`, nil), |
| + waitFor(`document.querySelector('[slides-notes-pane]').dataset.state === 'open'`), |
| + chromedp.Focus(`[slides-notes-resize]`, chromedp.ByQuery), |
| + chromedp.KeyEvent(kb.Home), |
| + ) |
| + // From the minimum up to the default, 144px, by script: the |
| + // default is not a multiple of the arrow's step. |
| + te.rig.Run(chromedp.Evaluate(`document.querySelector('[slides-notes-pane]').style.setProperty('--slides-notes-block-size', '144px')`, nil)) |
| + }, |
| + "the notes at their maximum": func() { |
| + te.rig.Run( |
| + chromedp.Focus(`[slides-notes-resize]`, chromedp.ByQuery), |
| + chromedp.KeyEvent(kb.End), |
| + ) |
| + }, |
| + "the notes closed": func() { |
| + te.rig.Run( |
| + chromedp.Evaluate(`document.querySelector('[data-view-toggle="notes"]').click()`, nil), |
| + waitFor(`document.querySelector('[slides-notes-pane]').dataset.state === 'closed'`), |
| + ) |
| + }, |
| + } |
| + for _, vp := range [][2]int64{{1280, 720}, {1920, 1080}} { |
| + te.size(vp[0], vp[1]) |
| + for _, v := range []string{"desktop", "both"} { |
| + te.view(v) |
| + for _, card := range []string{"open", "closed"} { |
| + var now string |
| + te.rig.Run(chromedp.Evaluate(`document.querySelector('[slides-inspector]').dataset.state`, &now)) |
| + if now != card { |
| + te.pressFormat(card) |
| + } |
| + for _, n := range []string{"the notes at their default height", "the notes at their maximum", "the notes closed"} { |
| + notes[n]() |
| + te.rig.Run(chromedp.Sleep(100 * time.Millisecond)) |
| + var f fitState |
| + te.rig.Run(chromedp.Evaluate(fitJS, &f)) |
| + if got := f.fits(); got != "" { |
| + t.Errorf("%dx%d, %s view, the card %s, %s: %s", vp[0], vp[1], v, card, n, got) |
| + } |
| + } |
| + } |
| + } |
| + } |
| + te.view("desktop") |
| +} |