summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/model_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-05 22:51:51 +0200
committerPaul Buetow <paul@buetow.org>2026-03-05 22:51:51 +0200
commit58267b80526c0faba0ff528fe768e92dd21e0b6f (patch)
tree1dac5a6389483fcbf6b4ed8e212ca6b518d95504 /internal/tui/flamegraph/model_test.go
parent4d69b8bf11b563d8ec6693447c09f35dec13b148 (diff)
task 365: animate flamegraph layout on resize
Diffstat (limited to 'internal/tui/flamegraph/model_test.go')
-rw-r--r--internal/tui/flamegraph/model_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/model_test.go b/internal/tui/flamegraph/model_test.go
index 326c2d8..51ce96d 100644
--- a/internal/tui/flamegraph/model_test.go
+++ b/internal/tui/flamegraph/model_test.go
@@ -356,6 +356,49 @@ func TestDataRefreshAnimationConvergesOverTicks(t *testing.T) {
}
}
+func TestResizeRecalculatesLayoutAndCullsNarrowFrames(t *testing.T) {
+ m := NewModel(nil)
+ m.width = 120
+ m.height = 40
+ m.snapshot = &snapshotNode{
+ Name: "root",
+ Total: 100,
+ Children: []*snapshotNode{
+ {
+ Name: "big",
+ Total: 99,
+ Children: []*snapshotNode{
+ {Name: "deep", Total: 99},
+ },
+ },
+ {Name: "tiny", Total: 1},
+ },
+ }
+ m.rebuildFrames(false)
+ _ = mustFrameIndex(t, m.frames, "root"+pathSeparator+"tiny")
+
+ next, _ := m.Update(tea.WindowSizeMsg{Width: 80, Height: 24})
+ m = next.(Model)
+ for i := 0; i < 180 && m.animating; i++ {
+ next, _ = m.Update(animTickMsg{})
+ m = next.(Model)
+ }
+
+ for _, frame := range m.frames {
+ if frame.Col+frame.Width > 80 {
+ t.Fatalf("frame exceeds resized width: %+v", frame)
+ }
+ if frame.Row >= 24 {
+ t.Fatalf("frame row exceeds resized height: %+v", frame)
+ }
+ }
+ for _, frame := range m.frames {
+ if frame.Path == "root"+pathSeparator+"tiny" {
+ t.Fatalf("expected tiny frame to be culled at width 80")
+ }
+ }
+}
+
func newZoomModel() Model {
m := NewModel(nil)
m.width = 120