oficina / estilo Public

Clone
git clone https://amadan.net/oficina/estilo

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3// The compact bar (Bar.Compact) and the touch sizes, in real engines:
4// a stacked, compact bar as Docs draws it on a document, at phone,
5// tablet and desktop widths, with a coarse pointer where a phone or a
6// tablet has one. Not part of `make test`: it needs Node 22+ and
7// Playwright (ESTILO_PLAYWRIGHT, ESTILO_BROWSERS as for the title
8// check). ESTILO_SHOTS=<dir> saves a screenshot of every case there,
9// light and dark, in English, Arabic and Russian.
10package chrome
11
12import (
13 "bytes"
14 "encoding/json"
15 "fmt"
16 "html/template"
17 "net/http"
18 "net/http/httptest"
19 "os"
20 "os/exec"
21 "strings"
22 "testing"
23
24 "amadan.net/oficina/estilo.git/base"
25 "amadan.net/oficina/estilo.git/brand"
26 "amadan.net/oficina/estilo.git/menu"
27 "amadan.net/oficina/estilo.git/theme"
28 "github.com/carlosframework/rastrillo/ui"
29)
30
31const compactPage = `<!doctype html>
32<html lang="%s" dir="%s"%s>
33<head>
34<meta charset="utf-8">
35<meta name="viewport" content="width=device-width, initial-scale=1">
36<link rel="stylesheet" href="/tokens.css">
37<link rel="stylesheet" href="/theme.css">
38<link rel="stylesheet" href="/base.css">
39<link rel="stylesheet" href="/menu.css">
40<link rel="stylesheet" href="/chrome.css">
41<script defer src="/chrome.js"></script>
42<style>
43 body { margin: 0; }
44 [demo-title] { margin: 0; padding: var(--rst-sp-2) 20px var(--rst-sp-3); }
45 [demo-title] h1 { margin: 0 0 var(--rst-sp-1); font-size: 28px; line-height: 1.15; }
46 [demo-title] p { margin: 0; color: var(--rst-text-muted); font-size: 13px; }
47 [demo-inline] b, [demo-inline] small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
48 [demo-inline] b { font-size: 15px; font-weight: 600; }
49 [demo-inline] small { font-size: 12px; color: var(--rst-text-muted); }
50 [demo-paper] { color-scheme: light; background: #fff; color: #1d1f24; padding: var(--rst-sp-1) 20px 60vh; }
51</style>
52</head>
53<body>
54<div estilo-shell>
55%s
56<main id="main"><div demo-title><h1 dir="auto">%s</h1><p>%s</p></div><div demo-paper><p>%s</p></div></main>
57</div>
58</body>
59</html>
60`
61
62// compactLabels are the demo's words per locale: Arabic to see the bar
63// mirrored, Russian for long labels.
64var compactLabels = map[string]map[string]string{
65 "en": {"app": "Docs", "title": "A History of the Millbrook Waterworks", "sub": "Oficina · Saved", "file": "File", "edit": "Edit", "view": "View", "share": "Share…", "rename": "Rename", "pdf": "Download as PDF", "paged": "Paged", "infinite": "Infinite", "delete": "Delete…", "format": "Format", "more": "More", "undo": "Undo", "redo": "Redo", "body": "Before 1887, Millbrook drew its water the way most small towns did: from private wells and a handful of shared pumps."},
66 "ar": {"app": "المستندات", "title": "ملاحظات الاجتماع الأسبوعي حول مشروع المكتبة الجديدة", "sub": "أوفيسينا · تم الحفظ", "file": "ملف", "edit": "تحرير", "view": "عرض", "share": "مشاركة…", "rename": "إعادة التسمية", "pdf": "تنزيل بصيغة PDF", "paged": "صفحات", "infinite": "متواصل", "delete": "حذف…", "format": "تنسيق", "more": "المزيد", "undo": "تراجع", "redo": "إعادة", "body": "اجتمع الفريق يوم الثلاثاء لمناقشة الجدول الزمني لمشروع المكتبة."},
67 "ru": {"app": "Документы", "title": "Очень длинное название документа, которое кто-то набрал целиком", "sub": "Oficina · Сохранено", "file": "Файл", "edit": "Правка", "view": "Вид", "share": "Поделиться…", "rename": "Переименовать", "pdf": "Скачать как PDF", "paged": "Постранично", "infinite": "Непрерывно", "delete": "Удалить…", "format": "Формат", "more": "Ещё", "undo": "Отменить", "redo": "Повторить", "body": "До 1887 года Миллбрук брал воду так же, как большинство маленьких городов."},
68}
69
70const glyph = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="8"/></svg>`
71
72func compactBar(L map[string]string) Bar {
73 item := func(label, key string) template.HTML {
74 var b bytes.Buffer
75 _ = template.Must(template.New("").ParseFS(menu.Templates(), "templates/*.html")).ExecuteTemplate(&b, "estilo-menu-item", menu.Item{Href: "#", Label: label, Key: key, Icon: glyph})
76 return template.HTML(b.String())
77 }
78 menubar := template.HTML(`<nav estilo-menubar aria-label="Menus">`)
79 for _, m := range []string{"file", "edit", "view"} {
80 menubar += template.HTML(`<details estilo-menubar-menu name="estilo-menus"><summary estilo-menubar-title data-demo="`+m+`">`+template.HTMLEscapeString(L[m])+`</summary><div estilo-menu>`) + item(L["pdf"], "⌘P") + item(L["rename"], "⇧⌘R") + `</div></details>`
81 }
82 menubar += `</nav>`
83 lead := template.HTML(`<button type="button" estilo-bar-tool aria-label="` + template.HTMLEscapeString(L["undo"]) + `">` + glyph + `</button><button type="button" estilo-bar-tool disabled aria-label="` + template.HTMLEscapeString(L["redo"]) + `">` + glyph + `</button>`)
84 more := template.HTML(`<details name="estilo-menus" data-demo="more"><summary estilo-bar-tool aria-label="`+template.HTMLEscapeString(L["more"])+`">`+glyph+`</summary><div estilo-menu>`) +
85 item(L["share"], "") + item(L["rename"], "") + `<hr>` + item(L["pdf"], "⌘P") +
86 template.HTML(`<button estilo-menu-item type="button" aria-pressed="true"><span estilo-menu-check>`+glyph+`</span><span estilo-menu-label>`+template.HTMLEscapeString(L["paged"])+`</span></button>`) +
87 `<hr>` + template.HTML(`<a estilo-menu-item="danger" href="#"><span estilo-menu-label>`+template.HTMLEscapeString(L["delete"])+`</span></a>`) + `</div></details>`
88 trail := template.HTML(`<button type="button" estilo-bar-tool aria-label="`+template.HTMLEscapeString(L["format"])+`"><b>Aa</b></button>`) + more
89 b := signedIn("x")
90 b.App = App{Name: L["app"], Slug: "docs", Home: "/", Icon: brand.Path("docs")}
91 b.ContextEdit = &TitleEdit{Action: "/t", Name: "title", Value: L["title"], Label: "Title", Submit: L["rename"]}
92 b.Nav = nil
93 b.Actions = []Action{{Item: menu.Item{Controls: "inspector", Label: L["format"]}, WideOnly: true}, {Item: menu.Item{Href: "#", Label: L["share"]}, Primary: true}}
94 b.Menubar, b.Lead, b.Sticky = menubar, lead, true
95 b.Compact = &Compact{Trail: trail}
96 return b
97}
98
99// standIn is a stacked bar that is not compact, shaped as Mapa's and
100// Fichas' are (frame.go in each): Menubar, Lead and Nav, with page
101// actions, one of them WideOnly (Mapa's Links). Below 800px their nav and
102// actions are only in the Menu sheet, and their own layouts change at
103// 800px, so nothing about them may move to 704px (Fable on c56314e).
104func standIn(kind string, L map[string]string) Bar {
105 b := compactBar(L)
106 b.Compact = nil
107 b.Lead = `<span>Saved</span>`
108 switch kind {
109 case "mapa":
110 b.App.Name = "Mapa"
111 b.Nav = []Link{{Href: "#home", Label: "Home", Current: true}, {Href: "#pages", Label: "Pages"}, {Href: "#recent", Label: "Recent"}, {Href: "#starred", Label: "Starred"}}
112 b.Actions = []Action{{Item: menu.Item{Href: "#history", Label: "History"}, Icon: glyph},
113 {Item: menu.Item{Controls: "mapa-links", Label: "Links"}, WideOnly: true, Icon: glyph}}
114 default:
115 b.App.Name = "Fichas"
116 b.ContextEdit, b.Context, b.Switcher = nil, "People", nil
117 b.Nav = []Link{{Href: "#search", Label: "Search"}, {Href: "#people", Label: "People", Current: true}, {Href: "#companies", Label: "Companies"}}
118 b.Actions = []Action{{Item: menu.Item{Href: "#history", Label: "History"}, Icon: glyph},
119 {Item: menu.Item{Href: "#new", Label: "New person"}, Primary: true, Icon: glyph}}
120 }
121 return b
122}
123
124// standInCase is what the driver measured on a stand-in: every nav link
125// and every action that is not WideOnly, and those a person can reach:
126// shown in the bar, or a row in the open Menu sheet.
127type standInCase struct {
128 Name string `json:"name"`
129 Error string `json:"error"`
130 Width int `json:"width"`
131 Header float64 `json:"header"`
132 Var float64 `json:"var"`
133 Overflow bool `json:"overflow"`
134 Wanted []string `json:"wanted"`
135 Reached []string `json:"reached"`
136}
137
138type compactCase struct {
139 Engine string `json:"engine"`
140 Version string `json:"version"`
141 Error string `json:"error"`
142 Cases []struct {
143 Name string `json:"name"`
144 Error string `json:"error"`
145 Width int `json:"width"`
146 Touch bool `json:"touch"`
147 Coarse bool `json:"coarse"`
148 Header float64 `json:"header"`
149 Var float64 `json:"var"`
150 Overflow bool `json:"overflow"`
151 Shown map[string]bool `json:"shown"`
152 Boxes map[string][]float64 `json:"boxes"` // x, y, w, h
153 Panel []float64 `json:"panel"`
154 Rows []float64 `json:"rows"`
155 Keys int `json:"keys"`
156 Ellipsis string `json:"ellipsis"`
157 // The large-title idiom (Compact.Title), at rest and folded.
158 Rest largeTitle `json:"rest"`
159 Folded largeTitle `json:"folded"`
160 // A public page's brand (App.Home empty): its colour and the
161 // accent's.
162 Public struct {
163 Brand string `json:"brand"`
164 Accent string `json:"accent"`
165 } `json:"public"`
166 } `json:"cases"`
167 StandIns []standInCase `json:"standIns"`
168 Extra struct {
169 Resized struct {
170 From, Header, Var float64
171 } `json:"resized"`
172 ResizedError string `json:"resizedError"`
173 Forced map[string]struct {
174 Border float64 `json:"border"`
175 Forced bool `json:"forced"`
176 Error string `json:"error"`
177 } `json:"forced"`
178 } `json:"extra"`
179}
180
181type largeTitle struct {
182 Title bool `json:"title"` // the compact title is visible
183 Name float64 `json:"name"` // Back's name, its drawn width
184 Label string `json:"label"` // Back's text, its accessible name
185 Border string `json:"border"` // the bar's bottom border colour
186 Box []float64 `json:"box"` // the compact title
187 Back []float64 `json:"back"`
188 End []float64 `json:"end"`
189}
190
191func TestTheCompactBarInRealEngines(t *testing.T) {
192 if _, err := exec.LookPath("node"); err != nil {
193 t.Fatal("node is required (Node 22+)")
194 }
195 view := parse(t)
196 mux := http.NewServeMux()
197 mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
198 lang := r.URL.Query().Get("lang")
199 L, ok := compactLabels[lang]
200 if !ok {
201 lang, L = "en", compactLabels["en"]
202 }
203 // Light is named, not left to the system: this Mac is in dark
204 // mode and headless engines follow it.
205 dir, scheme := "ltr", ` data-theme="light"`
206 if lang == "ar" {
207 dir = "rtl"
208 }
209 if r.URL.Query().Get("scheme") == "dark" {
210 scheme = ` data-theme="dark"`
211 }
212 var bar bytes.Buffer
213 b := compactBar(L)
214 if kind := r.URL.Query().Get("kind"); kind != "" {
215 b = standIn(kind, L)
216 }
217 if r.URL.Query().Get("public") != "" {
218 b.App.Home = ""
219 }
220 if r.URL.Query().Get("inline") != "" {
221 b.Compact.Title = template.HTML(`<div demo-inline><b dir="auto">` + template.HTMLEscapeString(L["title"]) + `</b><small>` + template.HTMLEscapeString(L["sub"]) + `</small></div>`)
222 }
223 if err := view.ExecuteTemplate(&bar, "estilo-bar", b); err != nil {
224 t.Error(err)
225 }
226 w.Header().Set("Content-Type", "text/html; charset=utf-8")
227 fmt.Fprintf(w, compactPage, lang, dir, scheme, bar.String(), template.HTMLEscapeString(L["title"]), template.HTMLEscapeString(L["sub"]), template.HTMLEscapeString(L["body"]))
228 })
229 assets := map[string][]byte{"/tokens.css": ui.TokensCSS(), "/theme.css": theme.CSS(), "/base.css": base.CSS(), "/menu.css": menu.CSS(), "/chrome.css": CSS(), "/chrome.js": JS()}
230 for path, body := range assets {
231 mux.HandleFunc("GET "+path, func(w http.ResponseWriter, r *http.Request) {
232 ct := "text/css; charset=utf-8"
233 if strings.HasSuffix(path, ".js") {
234 ct = "text/javascript; charset=utf-8"
235 }
236 w.Header().Set("Content-Type", ct)
237 _, _ = w.Write(body)
238 })
239 }
240 mux.Handle("GET "+brand.Prefix, brand.Handler())
241 srv := httptest.NewServer(mux)
242 t.Cleanup(srv.Close)
243
244 engines := strings.Split(os.Getenv("ESTILO_BROWSERS"), ",")
245 if engines[0] == "" {
246 engines = []string{"chromium", "webkit"}
247 }
248 job, _ := json.Marshal(map[string]any{"origin": srv.URL, "engines": engines, "shots": os.Getenv("ESTILO_SHOTS")})
249 cmd := exec.Command("node", "compact.browser.mjs", string(job))
250 cmd.Stderr = os.Stderr
251 raw, err := cmd.Output()
252 if err != nil {
253 t.Fatalf("node compact.browser.mjs: %v", err)
254 }
255 var results []compactCase
256 if err := json.Unmarshal(raw, &results); err != nil {
257 t.Fatalf("driver output: %v\n%s", err, raw)
258 }
259 if len(results) != len(engines) {
260 t.Fatalf("%d engines asked for, %d reported", len(engines), len(results))
261 }
262 for _, r := range results {
263 if r.Error != "" {
264 t.Errorf("%s did not launch: %s", r.Engine, r.Error)
265 continue
266 }
267 if len(r.Cases) == 0 {
268 t.Errorf("%s measured nothing", r.Engine)
269 }
270 for _, c := range r.Cases {
271 where := fmt.Sprintf("%s %s, %s", r.Engine, r.Version, c.Name)
272 if c.Error != "" {
273 t.Errorf("%s: could not be driven: %s", where, c.Error)
274 continue
275 }
276 t.Logf("%s: header %.1f (var %.1f), shown %v, panel %v, rows %v, keys %d", where, c.Header, c.Var, c.Shown, c.Panel, c.Rows, c.Keys)
277 if c.Touch != c.Coarse {
278 t.Errorf("%s: (pointer: coarse) is %v with touch %v; the emulation is not what the case says", where, c.Coarse, c.Touch)
279 }
280 if c.Overflow {
281 t.Errorf("%s: the page scrolls sideways", where)
282 }
283 compact := strings.HasPrefix(c.Name, "phone") || strings.HasPrefix(c.Name, "landscape")
284 if compact {
285 if c.Header < 51.5 || c.Header > 52.5 || c.Var != 52 {
286 t.Errorf("%s: the compact bar is %.1fpx tall, published %.1f; want one 52px row", where, c.Header, c.Var)
287 }
288 for _, hidden := range []string{"menubar", "actions", "switcher", "account", "more", "icon"} {
289 if c.Shown[hidden] {
290 t.Errorf("%s: %s is shown in a compact bar", where, hidden)
291 }
292 }
293 for _, shown := range []string{"back", "name", "title", "lead", "trail"} {
294 if !c.Shown[shown] {
295 t.Errorf("%s: %s is not shown in a compact bar", where, shown)
296 }
297 }
298 // Back, then the title, then the end group, left to right
299 // (right to left in Arabic), none on top of another.
300 back, title, end := c.Boxes["back"], c.Boxes["title"], c.Boxes["end"]
301 rtl := strings.Contains(c.Name, " ar")
302 if !rtl && !(back[0]+back[2] <= title[0]+0.5 && title[0]+title[2] <= end[0]+0.5) {
303 t.Errorf("%s: Back %v, title %v and end %v overlap or are out of order", where, back, title, end)
304 }
305 if rtl && !(end[0]+end[2] <= title[0]+0.5 && title[0]+title[2] <= back[0]+0.5) {
306 t.Errorf("%s: in Arabic, end %v, title %v and Back %v overlap or are out of order", where, end, title, back)
307 }
308 // The large-title idiom: hidden at rest, then folded into
309 // the bar between the chevron and the end group, Back still
310 // named, the hairline drawn.
311 if c.Rest.Title || c.Rest.Name < 10 || c.Rest.Border == c.Folded.Border {
312 t.Errorf("%s: at rest the compact title shows %v, Back's name is %.1fpx, the border %q (folded %q)", where, c.Rest.Title, c.Rest.Name, c.Rest.Border, c.Folded.Border)
313 }
314 if len(c.Folded.Back) == 4 && (c.Folded.Back[2] < 43.5 || c.Folded.Back[3] < 43.5) {
315 t.Errorf("%s: folded, Back is %.1fx%.1fpx, under 44", where, c.Folded.Back[2], c.Folded.Back[3])
316 }
317 if c.Public.Brand == "" || c.Public.Brand == c.Public.Accent {
318 t.Errorf("%s: a public page's plain-text brand is %q, the accent %q: it looks like a link", where, c.Public.Brand, c.Public.Accent)
319 }
320 if !c.Folded.Title || c.Folded.Name > 1 || strings.TrimSpace(c.Folded.Label) == "" {
321 t.Errorf("%s: folded, the compact title shows %v, Back's name is %.1fpx wide and Back reads %q", where, c.Folded.Title, c.Folded.Name, c.Folded.Label)
322 }
323 if f := c.Folded; len(f.Box) == 4 && len(f.Back) == 4 && len(f.End) == 4 {
324 rtl := strings.Contains(c.Name, " ar")
325 if !rtl && !(f.Back[0]+f.Back[2] <= f.Box[0]+0.5 && f.Box[0]+f.Box[2] <= f.End[0]+0.5) || rtl && !(f.End[0]+f.End[2] <= f.Box[0]+0.5 && f.Box[0]+f.Box[2] <= f.Back[0]+0.5) {
326 t.Errorf("%s: folded, Back %v, the compact title %v and the end %v overlap", where, f.Back, f.Box, f.End)
327 }
328 if f.Box[2] < 100 {
329 t.Errorf("%s: folded, the compact title has %.1fpx", where, f.Box[2])
330 }
331 }
332 if c.Ellipsis != "ellipsis" {
333 t.Errorf("%s: the title field's overflow is %q, not an ellipsis", where, c.Ellipsis)
334 }
335 for _, tool := range []string{"tool-0", "tool-1", "tool-2", "tool-3"} {
336 if b := c.Boxes[tool]; len(b) != 4 || b[2] < 43.5 || b[3] < 43.5 {
337 t.Errorf("%s: %s is %v, under 44px", where, tool, b)
338 }
339 }
340 // The ••• panel drops from the inline end, inside the
341 // viewport, rows 44px, no shortcut hints.
342 p := c.Panel
343 if len(p) != 4 || p[0] < 0 || p[0]+p[2] > float64(c.Width)+0.5 || p[1] < c.Header-0.5 {
344 t.Errorf("%s: the ••• panel %v is not under the bar inside a %dpx viewport", where, p, c.Width)
345 } else if !rtl && float64(c.Width)-(p[0]+p[2]) > 9 || rtl && p[0] > 9 {
346 t.Errorf("%s: the ••• panel %v does not hang from the inline end", where, p)
347 }
348 for _, h := range c.Rows {
349 if h < 43.5 {
350 t.Errorf("%s: a ••• row is %.1fpx, under 44", where, h)
351 }
352 }
353 if c.Keys != 0 {
354 t.Errorf("%s: %d shortcut hints show in the ••• panel", where, c.Keys)
355 }
356 continue
357 }
358 // Wide: the stacked header, as without Compact.
359 if c.Header < 55.5 || c.Header > 56.5 {
360 t.Errorf("%s: the stacked header is %.1fpx, want 56", where, c.Header)
361 }
362 for _, hidden := range []string{"trail", "back", "more"} {
363 if c.Shown[hidden] {
364 t.Errorf("%s: %s is shown from 44rem", where, hidden)
365 }
366 }
367 // The stack is the title over the menu row, never one row.
368 if ti, mb := c.Boxes["title"], c.Boxes["menubar"]; len(ti) != 4 || len(mb) != 4 || mb[1] < ti[1]+ti[3]/2 { // the title row sits 2.5px low by design
369 t.Errorf("%s: the title %v is not over the menu row %v", where, ti, mb)
370 }
371 for _, shown := range []string{"menubar", "actions", "account", "switcher", "icon"} {
372 if !c.Shown[shown] {
373 t.Errorf("%s: %s is not shown from 44rem", where, shown)
374 }
375 }
376 want := 28.0
377 if c.Coarse {
378 want = 44
379 }
380 for _, h := range c.Rows {
381 if h < want-0.5 || (!c.Coarse && h > want+0.5) {
382 t.Errorf("%s: a File row is %.1fpx, want %v", where, h, want)
383 }
384 }
385 if c.Coarse && c.Keys != 0 {
386 t.Errorf("%s: %d shortcut hints show on a touch screen", where, c.Keys)
387 }
388 if !c.Coarse && c.Keys == 0 {
389 t.Errorf("%s: no shortcut hints with a mouse", where)
390 }
391 }
392 }
393 // Mapa and Fichas, as their bars are: everything in reach at every
394 // width, the header the height it publishes, and 56px only from 800px.
395 for _, r := range results {
396 if r.Error != "" {
397 continue
398 }
399 if len(r.StandIns) == 0 {
400 t.Errorf("%s measured no stand-in", r.Engine)
401 }
402 for _, c := range r.StandIns {
403 where := fmt.Sprintf("%s %s, %s", r.Engine, r.Version, c.Name)
404 t.Logf("%s: header %.1f (var %.1f), reached %v of %v", where, c.Header, c.Var, c.Reached, c.Wanted)
405 if c.Error != "" {
406 t.Errorf("%s: could not be driven: %s", where, c.Error)
407 continue
408 }
409 if c.Overflow {
410 t.Errorf("%s: the page scrolls sideways", where)
411 }
412 reached := map[string]bool{}
413 for _, l := range c.Reached {
414 reached[strings.TrimSpace(l)] = true
415 }
416 if len(c.Wanted) < 3 {
417 t.Errorf("%s: only %v to reach; the check is not reading the bar", where, c.Wanted)
418 }
419 for _, w := range c.Wanted {
420 if !reached[strings.TrimSpace(w)] {
421 t.Errorf("%s: %q is out of reach: not in the bar and not in an open Menu sheet", where, w)
422 }
423 }
424 if d := c.Header - c.Var; d > 0.5 || d < -0.5 {
425 t.Errorf("%s: the header is %.1fpx and publishes %.1f", where, c.Header, c.Var)
426 }
427 wide := c.Width >= 800
428 if wide != (c.Header > 55.5 && c.Header < 56.5) {
429 t.Errorf("%s: the header is %.1fpx at %dpx; a stacked bar that is not compact is the 56px header exactly from 800px", where, c.Header, c.Width)
430 }
431 }
432 }
433 // A compact bar loaded below 704px and widened to 768px is the 56px
434 // header: the script must not hold it at the 52px it measured (Fable's
435 // delta review, item 1). And in forced colours the band's controls
436 // keep their border, as from 800px (item 2).
437 for _, r := range results {
438 if r.Error != "" {
439 continue
440 }
441 x := r.Extra
442 if x.ResizedError != "" {
443 t.Errorf("%s: the resize could not be driven: %s", r.Engine, x.ResizedError)
444 } else if x.Resized.From < 51.5 || x.Resized.From > 52.5 || x.Resized.Header < 55.5 || x.Resized.Header > 56.5 || x.Resized.Var < 55.5 || x.Resized.Var > 56.5 {
445 t.Errorf("%s: 650px then 768px: the bar went from %.1fpx to %.1fpx (publishing %.1f); want 52 then 56", r.Engine, x.Resized.From, x.Resized.Header, x.Resized.Var)
446 }
447 for _, w := range []string{"768", "1280"} {
448 f := x.Forced[w]
449 switch {
450 case f.Error != "":
451 t.Errorf("%s: forced colours at %s could not be driven: %s", r.Engine, w, f.Error)
452 case !f.Forced:
453 t.Errorf("%s: forced colours at %s were not emulated; the check is blind", r.Engine, w)
454 case f.Border < 1:
455 t.Errorf("%s: in forced colours at %spx the primary control's border is %.1fpx: it has no edge", r.Engine, w, f.Border)
456 }
457 }
458 }
459}
460