feat/hint-hybrid aed7ca4

scene_rect_content_test.go RawHistoryFolder

1package vulkan
2
3import (
4	"image"
5	"testing"
6
7	"github.com/bnema/neferwl/internal/ports"
8)
9
10// A window under a presentation-only rect transition shows a rect that differs from its content
11// (the client has its final size already). These walk tests need no Vulkan
12// device: a single-pixel buffer is a solid quad.
13func TestSceneContentVsWindowRect(t *testing.T) {
14	r := &Renderer{width: 80, height: 60}
15	// A draw's rect is its corners: x0, y0, x1, y1.
16	// walk returns the content draws: the window's background fill is first.
17	walk := func(rect ports.Rect, lw, lh int, geo ports.Rect) []draw {
18		c := ports.SurfaceContent{
19			ID: 1, Width: 1, Height: 1, LogicalW: lw, LogicalH: lh, Geometry: geo,
20			Solid: &ports.SolidColor{R: 1, A: 1}, Opaque: true,
21		}
22		s := ports.Scene{Windows: []ports.SceneWindow{{ID: 1, Rect: rect}}}
23		contents := map[ports.WindowID]ports.SurfaceContent{1: c}
24		ds := r.draws(s, contents, newDamage(&target{}, s, image.Rect(0, 0, 80, 60)))
25		if len(ds) < 2 {
26			t.Fatalf("no content draw: %+v", ds)
27		}
28		return append([]draw(nil), ds[1:]...)
29	}
30
31	t.Run("rect smaller than content is clipped", func(t *testing.T) {
32		rect := ports.Rect{X: 10, Y: 10, W: 20, H: 20}
33		for _, geo := range []ports.Rect{{}, {X: 5, Y: 5, W: 30, H: 30}} {
34			ds := walk(rect, 40, 40, geo)
35			clip := image.Rect(10, 10, 30, 30)
36			for _, d := range ds {
37				got := image.Rect(int(d.pc.rect[0]), int(d.pc.rect[1]), int(d.pc.rect[2]), int(d.pc.rect[3]))
38				if !got.In(clip) {
39					t.Fatalf("geometry %+v: draw %v outside rect %v", geo, got, clip)
40				}
41			}
42			if d := ds[0].pc.rect; d != [4]int32{10, 10, 30, 30} {
43				t.Fatalf("geometry %+v: content = %v, want the whole rect", geo, d)
44			}
45		}
46	})
47
48	t.Run("rect larger than content shows only the content", func(t *testing.T) {
49		rect := ports.Rect{X: 10, Y: 10, W: 50, H: 40}
50		ds := walk(rect, 20, 16, ports.Rect{})
51		if len(ds) != 1 || ds[0].pc.rect != [4]int32{10, 10, 30, 26} {
52			t.Fatalf("content = %+v, want 20x16 at the rect origin", ds)
53		}
54		// Geometry shifts the surface so its geometry origin sits at the rect origin.
55		ds = walk(rect, 24, 20, ports.Rect{X: 4, Y: 4, W: 20, H: 16})
56		if len(ds) != 1 || ds[0].pc.rect != [4]int32{10, 10, 30, 26} {
57			t.Fatalf("content with geometry = %+v, want 20x16 at the rect origin", ds)
58		}
59	})
60}

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 23

Tags 10

↑↓ moveenter openesc close