| 1 | package renderpage |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/runner/render" |
| 8 | "amadan.net/oficina/equipo/internal/wire" |
| 9 | ) |
| 10 | |
| 11 | // TestCapturesFitTheWire: every capture a step can write has a name the |
| 12 | // wire's capture id accepts, a size within its render_file bound and |
| 13 | // pixels within the bounds the instance decodes, so a |
| 14 | // Design step can name any of them in its options (protocol 38). |
| 15 | func TestCapturesFitTheWire(t *testing.T) { |
| 16 | if MaxCaptureBytes != wire.MaxCaptureBytes { |
| 17 | t.Fatalf("capture bound %d, the wire's %d", MaxCaptureBytes, wire.MaxCaptureBytes) |
| 18 | } |
| 19 | // The instance decodes a capture only within the wire's pixel bounds |
| 20 | // (task 19): every capture render_page writes fits them. |
| 21 | if MaxWidth != wire.MaxCaptureWidth || MaxHeight != wire.MaxCaptureHeight { |
| 22 | t.Fatalf("capture bounds %dx%d, the wire's %dx%d", MaxWidth, MaxHeight, wire.MaxCaptureWidth, wire.MaxCaptureHeight) |
| 23 | } |
| 24 | for call := 1; call <= MaxCalls; call++ { |
| 25 | for _, tree := range []string{TreeBase, TreeWork, "diff"} { |
| 26 | for n := 1; n <= render.MaxPages; n++ { |
| 27 | if id := fmt.Sprintf("%d-%s-%d.png", call, tree, n); !wire.ValidCaptureID(id) { |
| 28 | t.Fatalf("the wire refuses %s", id) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |