detached ab6686c

consumer_external_test.go RawHistoryFolder

1package graphics_test
2
3import (
4	"errors"
5	"testing"
6
7	"github.com/bnema/vev-vt/graphics"
8)
9
10func TestExternalConsumerCanBuildAndReadImmutableScene(t *testing.T) {
11	scene := graphics.NewScene(graphics.Config{
12		MaxAssets:        4,
13		MaxPlacements:    4,
14		MaxEncodedBytes:  32,
15		MaxDecodedPixels: 64,
16	})
17	data := []byte("encoded")
18	assetID, err := scene.RegisterAsset(graphics.AssetInput{Encoded: data, Width: 8, Height: 4})
19	if err != nil {
20		t.Fatal(err)
21	}
22	data[0] = 'X'
23
24	placementID, err := scene.AddPlacement(graphics.PlacementSpec{
25		Asset:       assetID,
26		Destination: graphics.PixelRect{X: -2, Y: 3, Width: 16, Height: 8},
27	})
28	if err != nil {
29		t.Fatal(err)
30	}
31	snapshot := scene.Snapshot()
32	asset, ok := snapshot.GetAsset(assetID)
33	if !ok || string(asset.Bytes()) != "encoded" {
34		t.Fatalf("asset = %#v, ok=%v", asset, ok)
35	}
36	placement, ok := snapshot.GetPlacement(placementID)
37	if !ok || placement.AssetID() != assetID {
38		t.Fatalf("placement = %#v, ok=%v", placement, ok)
39	}
40	fragments := snapshot.VisiblePixelFragments(graphics.PixelRect{X: 0, Y: 3, Width: 4, Height: 8})
41	if len(fragments) != 1 || fragments[0].AssetID != assetID || fragments[0].PlacementID != placementID {
42		t.Fatalf("fragments = %#v", fragments)
43	}
44
45	if err := scene.RemoveAsset(assetID); !errors.Is(err, graphics.ErrAssetInUse) {
46		t.Fatalf("remove in-use asset error = %v", err)
47	}
48	if err := scene.RemoveAssetCascade(assetID); err != nil {
49		t.Fatal(err)
50	}
51	if _, ok := snapshot.GetAsset(assetID); !ok {
52		t.Fatal("immutable snapshot changed after scene mutation")
53	}
54}

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 2

Tags 13

↑↓ moveenter openesc close