(t *testing.T)
| 113 | } |
| 114 | |
| 115 | func 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 | |
| 149 | func TestFiniPreventsFurtherTerminalMutation(t *testing.T) { |
| 150 | tty := &spyTty{MockTerm: vt.NewMockTerm(vt.MockOptSize{X: 8, Y: 2})} |
nothing calls this directly
no test coverage detected
searching dependent graphs…