detached 602baa7

events_test.go RawHistoryFolder

1package main
2
3import (
4	"strings"
5	"testing"
6)
7
8// TestEventLayouts pins wire offsets that the X11 protocol defines, checked
9// against the event containers (independent of generated code).
10func TestEventLayouts(t *testing.T) {
11	want := map[string]map[string]int{
12		"xproto.MapRequest":       {"Parent": 4, "Window": 8},
13		"xproto.ConfigureRequest": {"StackMode": 1, "Parent": 4, "Window": 8, "Sibling": 12, "X": 16, "Y": 18, "Width": 20, "Height": 22, "BorderWidth": 24, "ValueMask": 26},
14		"xproto.KeymapNotify":     {"Keys": 1},
15		"xproto.ClientMessage":    {"Format": 1, "Window": 4, "Type": 8, "Data": 12},
16		"xproto.PropertyNotify":   {"Window": 4, "Atom": 8, "Time": 12, "State": 16},
17		"xfixes.SelectionNotify":  {"Subtype": 1, "Window": 4, "Owner": 8, "Selection": 12, "Timestamp": 16, "SelectionTimestamp": 20},
18		"shape.Notify":            {"ShapeKind": 1, "AffectedWindow": 4, "ServerTime": 16, "Shaped": 20},
19	}
20	copies := 0
21	for _, m := range testModules(t) {
22		events, err := resolveEvents(m)
23		if err != nil {
24			t.Fatal(err)
25		}
26		for _, e := range events {
27			if e.Copy != nil {
28				copies++
29				if e.C != e.Copy.C {
30					t.Errorf("%s: copy does not share its source layout", e.Name)
31				}
32				continue
33			}
34			exp := want[m.Pkg+"."+e.Name]
35			for _, mem := range e.C.Members {
36				if off, ok := exp[mem.Method]; ok {
37					if mem.Static != off {
38						t.Errorf("%s.%s.%s at %d want %d", m.Pkg, e.Name, mem.Method, mem.Static, off)
39					}
40					delete(exp, mem.Method)
41				}
42			}
43			if len(exp) != 0 {
44				t.Errorf("%s.%s: missing %v", m.Pkg, e.Name, exp)
45			}
46		}
47	}
48	if copies != 5 {
49		t.Errorf("xproto has 5 eventcopy, got %d", copies)
50	}
51}
52
53func TestEventGeneratorRejects(t *testing.T) {
54	for _, tc := range []struct{ body, want string }{
55		{`<event name="E" number="200" xge="true"><pad bytes="22"/></event>`, "xge evtype"},
56		{`<event name="E" number="1"><field type="CARD32" name="a"/></event>`, "header data byte"},
57		{`<eventcopy name="C" number="3" ref="Missing"/>`, "unknown event"},
58		{`<event name="E" number="2"><pad bytes="1"/><list type="CARD8" name="l"><fieldref>n</fieldref></list></event>`, "first 32 bytes"},
59	} {
60		// Some constructs are already rejected by the parser; either stage must
61		// fail with a source location.
62		n, err := parseXML("ev.xml", strings.NewReader(`<xcb header="test" extension-name="Test" extension-xname="TEST">`+tc.body+`</xcb>`))
63		if err == nil {
64			var ms []*Module
65			if ms, err = resolveModules([]*Node{n}); err != nil {
66				t.Fatal(err)
67			}
68			_, err = resolveEvents(ms[0])
69		}
70		if err == nil || !strings.Contains(err.Error(), tc.want) || !strings.Contains(err.Error(), "ev.xml:1:") {
71			t.Errorf("%s: got %v", tc.want, err)
72		}
73	}
74}
75
76func TestErrorConstNames(t *testing.T) {
77	for in, want := range map[string]string{"Window": "BadWindow", "BadRegion": "BadRegion", "PictFormat": "BadPictFormat", "IDChoice": "BadIDChoice"} {
78		if got := errorConst(in); got != want {
79			t.Errorf("%s => %s want %s", in, got, want)
80		}
81	}
82}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 1

↑↓ moveenter openesc close