MCPcopy
hub / github.com/gdamore/tcell / TestFiniPreventsSetStyleMutation

Function TestFiniPreventsSetStyleMutation

tscreen_test.go:115–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func TestFiniPreventsSetStyleMutation(t *testing.T) {
116 mt := vt.NewMockTerm(vt.MockOptSize{X: 8, Y: 2})
117 scr, err := NewTerminfoScreenFromTty(mt)
118 if err != nil {
119 t.Fatalf("failed to get screen: %v", err)
120 }
121 bs, ok := scr.(*baseScreen)
122 if !ok {
123 t.Fatalf("expected *baseScreen, got %T", scr)
124 }
125 ts, ok := bs.screenImpl.(*tScreen)
126 if !ok {
127 t.Fatalf("expected *tScreen, got %T", bs.screenImpl)
128 }
129 if err := scr.Init(); err != nil {
130 t.Fatalf("failed to initialize screen: %v", err)
131 }
132
133 before := StyleDefault.Foreground(ColorRed)
134 after := StyleDefault.Foreground(ColorBlue)
135 scr.SetStyle(before)
136 scr.Fini()
137 scr.SetStyle(after)
138
139 ts.Lock()
140 defer ts.Unlock()
141 if !ts.fini {
142 t.Fatal("screen was not marked finished")
143 }
144 if ts.style != before {
145 t.Fatal("SetStyle mutated the screen after Fini")
146 }
147}
148
149func TestFiniPreventsFurtherTerminalMutation(t *testing.T) {
150 tty := &spyTty{MockTerm: vt.NewMockTerm(vt.MockOptSize{X: 8, Y: 2})}

Callers

nothing calls this directly

Calls 6

NewMockTermFunction · 0.92
NewTerminfoScreenFromTtyFunction · 0.85
ForegroundMethod · 0.80
InitMethod · 0.65
SetStyleMethod · 0.65
FiniMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…