main 602baa7

replies_test.go RawHistoryFolder

1package main
2
3import "testing"
4
5// TestReplyLayouts checks reply containers against the independent packet-size
6// walker and pins list-view classification for representative replies.
7func TestReplyLayouts(t *testing.T) {
8	kinds := map[string]map[string]string{
9		"xproto.GetPropertyReply":           {"Value": "bytes"},
10		"xproto.QueryTreeReply":             {"Children": "scalar"},
11		"xproto.ListExtensionsReply":        {"Names": "iter"},
12		"xproto.QueryFontReply":             {"Properties": "struct", "CharInfos": "struct"},
13		"xproto.ListHostsReply":             {"Hosts": "iter"},
14		"render.QueryPictFormatsReply":      {"Formats": "struct", "Screens": "iter", "Subpixels": "scalar"},
15		"xfixes.GetCursorImageAndNameReply": {"CursorImage": "scalar", "Name": "bytes"},
16	}
17	for _, m := range testModules(t) {
18		replies, _, err := resolveReplies(m)
19		if err != nil {
20			t.Fatal(err)
21		}
22		for _, r := range replies {
23			var node *Node
24			for _, n := range m.Root.Children {
25				if n.Kind == "request" && goName(n.Attr["name"]) == r.Req {
26					for _, c := range n.Children {
27						if c.Kind == "reply" {
28							node = c
29						}
30					}
31				}
32			}
33			want, err := packetFixed(m, node, true)
34			if err != nil {
35				t.Fatal(err)
36			}
37			if got := max(r.C.Fixed, 32); got != want {
38				t.Errorf("%s.%s fixed %d, packet walker %d", m.Pkg, r.C.Name, got, want)
39			}
40			for _, mem := range r.C.Members {
41				if exp, ok := kinds[m.Pkg+"."+r.C.Name]; ok && mem.Kind == "list" {
42					if exp[mem.Method] != mem.ListKind {
43						t.Errorf("%s.%s.%s kind %s want %s", m.Pkg, r.C.Name, mem.Method, mem.ListKind, exp[mem.Method])
44					}
45					delete(exp, mem.Method)
46				}
47			}
48		}
49	}
50	for name, rest := range kinds {
51		if len(rest) != 0 {
52			t.Errorf("%s: unchecked lists %v", name, rest)
53		}
54	}
55}
56
57func TestReplyReservedGetter(t *testing.T) {
58	m := &Module{Pkg: "x", Symbols: map[string]*Type{}, Names: map[string]*Node{}}
59	nodes := []*Node{
60		{Kind: "pad", Attr: map[string]string{"bytes": "1"}},
61		{Kind: "field", Attr: map[string]string{"name": "raw", "type": "CARD32"}},
62	}
63	c, err := buildContainer(m, "XReply", "r", nodes, layoutReply, "Raw")
64	if err != nil {
65		t.Fatal(err)
66	}
67	if c.Members[1].Method != "Raw_" || c.Members[1].Static != 8 || c.Fixed != 12 {
68		t.Fatalf("%+v", c.Members[1])
69	}
70}

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