diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 15:06:22 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 15:06:22 +0200 |
| commit | 1530bf2856bbb32a6e0457596b55c07f3836a0ec (patch) | |
| tree | d699766a2607042de0f8278652b9b7cde2426b84 /internal/tui/flamegraph/renderer_test.go | |
| parent | 4737786fd4a417ff94e22e4f72a1e924d4e033dd (diff) | |
flamegraph: use full viewport with capped bar height and preserve footer/status
Diffstat (limited to 'internal/tui/flamegraph/renderer_test.go')
| -rw-r--r-- | internal/tui/flamegraph/renderer_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/renderer_test.go b/internal/tui/flamegraph/renderer_test.go index b85bceb..091aeec 100644 --- a/internal/tui/flamegraph/renderer_test.go +++ b/internal/tui/flamegraph/renderer_test.go @@ -158,6 +158,15 @@ func TestRenderTerminalViewShowsNarrowMessage(t *testing.T) { } } +func TestComputeBarHeightCappedAtThree(t *testing.T) { + if got := computeBarHeight(30, 4, 3); got != 3 { + t.Fatalf("expected bar height cap at 3, got %d", got) + } + if got := computeBarHeight(5, 10, 3); got != 1 { + t.Fatalf("expected bar height minimum 1 when depth exceeds rows, got %d", got) + } +} + func TestRenderTerminalViewIncludesToolbarAndStatus(t *testing.T) { snapshot := &snapshotNode{ Name: "root", @@ -177,6 +186,23 @@ func TestRenderTerminalViewIncludesToolbarAndStatus(t *testing.T) { } } +func TestRenderTerminalViewFillsAvailableHeightForShallowTree(t *testing.T) { + snapshot := &snapshotNode{ + Name: "root", + Total: 10, + Children: []*snapshotNode{ + {Name: "child", Total: 10}, + }, + } + frames := BuildTerminalLayout(snapshot, 100, 20) + + out := RenderTerminalView(frames, 100, 20, 1, nil, nil, nil, 0, true, false, "") + lines := strings.Split(out, "\n") + if got, want := len(lines), 20; got != want { + t.Fatalf("expected render to fill viewport height (%d lines), got %d", want, got) + } +} + func TestFrameLabelAddsSelectionAndMatchMarkers(t *testing.T) { if got := frameLabel("child", 7, true, false); got != ">child<" { t.Fatalf("expected selected marker label, got %q", got) |
