| index 7515d19..8c88844 100644 |
| --- a/internal/slidestest/presenter_walk_browser_test.go |
| +++ b/internal/slidestest/presenter_walk_browser_test.go |
| @@ -67,35 +67,53 @@ func TestPresenterWalksTheWholeTalk(t *testing.T) { |
| open(t, ctx, mt.fr.rig.Origin, mt.presenter()) |
| var scroll struct{ Y, SH, VH float64 } |
| const scrollJS = `({ Y: window.scrollY, SH: document.documentElement.scrollHeight, VH: innerHeight })` |
| - seen := map[string]bool{} |
| - presses := 0 |
| + // The sequence every press must produce, from the deck built above. |
| + type at struct { |
| + head string |
| + step string |
| + } |
| + var want []at |
| + for i := range 105 { |
| + steps := 0 |
| + if i%3 == 0 && i/3 < 34 { |
| + steps = 4 |
| + } |
| + for k := 0; k <= steps; k++ { |
| + want = append(want, at{fmt.Sprintf("Talk %03d", i), strconv.Itoa(k)}) |
| + } |
| + } |
| + here := func(s windowState) at { |
| + head, _, _ := strings.Cut(s.Now, "\n") |
| + return at{strings.TrimSpace(head), s.Step} |
| + } |
| before := state(t, ctx) |
| if before.Mode != "core" { |
| t.Fatalf("the window starts in mode %q, want core", before.Mode) |
| } |
| - for { |
| - if !strings.HasPrefix(before.Now, "Talk") { |
| - t.Fatalf("press %d: the window shows %q, which is not a talk slide", presses, before.Now) |
| - } |
| - seen[before.Slide] = true |
| + if got := here(before); got != want[0] { |
| + t.Fatalf("the window starts at %+v, want %+v", got, want[0]) |
| + } |
| + if len(want) != 241 { |
| + t.Fatalf("the expected walk has %d positions, want 241 (240 presses)", len(want)) |
| + } |
| + for press := 1; press < len(want); press++ { |
| run(t, ctx, key(kb.ArrowRight)) |
| got := state(t, ctx) |
| - if got.Slide == before.Slide && got.Step == before.Step { |
| - break // the last press of the talk moves nothing |
| - } |
| - presses++ |
| if got.Mode != "core" { |
| - t.Fatalf("press %d: the mode became %q", presses, got.Mode) |
| + t.Fatalf("press %d: the mode became %q", press, got.Mode) |
| + } |
| + if g := here(got); g != want[press] { |
| + t.Fatalf("press %d: the window is at %+v, want %+v", press, g, want[press]) |
| } |
| run(t, ctx, chromedp.Evaluate(scrollJS, &scroll)) |
| if scroll.Y != 0 || scroll.SH > scroll.VH { |
| - t.Fatalf("press %d: the document scrolls: %+v", presses, scroll) |
| + t.Fatalf("press %d: the document scrolls: %+v", press, scroll) |
| } |
| - before = got |
| } |
| - seen[before.Slide] = true |
| - if len(seen) != 105 || presses != 240 { |
| - t.Fatalf("walked %d slides and %d presses, want 105 and 240", len(seen), presses) |
| + // One more at the end moves nothing. |
| + run(t, ctx, key(kb.ArrowRight)) |
| + if g := here(state(t, ctx)); g != want[len(want)-1] { |
| + t.Fatalf("a press past the end moved the window to %+v", g) |
| } |
| mt.waitRow(t, "t104", 0) |
| } |