(t *testing.T)
| 229 | } |
| 230 | |
| 231 | func TestPtyResize(t *testing.T) { |
| 232 | t.Parallel() |
| 233 | winch0 := Window{40, 80} |
| 234 | winch1 := Window{80, 160} |
| 235 | winch2 := Window{20, 40} |
| 236 | winches := make(chan Window) |
| 237 | done := make(chan bool) |
| 238 | session, _, cleanup := newTestSession(t, &Server{ |
| 239 | Handler: func(s Session) { |
| 240 | ptyReq, winCh, isPty := s.Pty() |
| 241 | if !isPty { |
| 242 | t.Fatalf("expected pty but none requested") |
| 243 | } |
| 244 | if ptyReq.Window != winch0 { |
| 245 | t.Fatalf("expected window %#v but got %#v", winch0, ptyReq.Window) |
| 246 | } |
| 247 | for win := range winCh { |
| 248 | winches <- win |
| 249 | } |
| 250 | close(done) |
| 251 | }, |
| 252 | }, nil) |
| 253 | defer cleanup() |
| 254 | // winch0 |
| 255 | if err := session.RequestPty("xterm", winch0.Height, winch0.Width, gossh.TerminalModes{}); err != nil { |
| 256 | t.Fatalf("expected nil but got %v", err) |
| 257 | } |
| 258 | if err := session.Shell(); err != nil { |
| 259 | t.Fatalf("expected nil but got %v", err) |
| 260 | } |
| 261 | gotWinch := <-winches |
| 262 | if gotWinch != winch0 { |
| 263 | t.Fatalf("expected window %#v but got %#v", winch0, gotWinch) |
| 264 | } |
| 265 | // winch1 |
| 266 | winchMsg := struct{ w, h uint32 }{uint32(winch1.Width), uint32(winch1.Height)} |
| 267 | ok, err := session.SendRequest("window-change", true, gossh.Marshal(&winchMsg)) |
| 268 | if err == nil && !ok { |
| 269 | t.Fatalf("unexpected error or bad reply on send request") |
| 270 | } |
| 271 | gotWinch = <-winches |
| 272 | if gotWinch != winch1 { |
| 273 | t.Fatalf("expected window %#v but got %#v", winch1, gotWinch) |
| 274 | } |
| 275 | // winch2 |
| 276 | winchMsg = struct{ w, h uint32 }{uint32(winch2.Width), uint32(winch2.Height)} |
| 277 | ok, err = session.SendRequest("window-change", true, gossh.Marshal(&winchMsg)) |
| 278 | if err == nil && !ok { |
| 279 | t.Fatalf("unexpected error or bad reply on send request") |
| 280 | } |
| 281 | gotWinch = <-winches |
| 282 | if gotWinch != winch2 { |
| 283 | t.Fatalf("expected window %#v but got %#v", winch2, gotWinch) |
| 284 | } |
| 285 | session.Close() |
| 286 | <-done |
| 287 | } |
| 288 |
nothing calls this directly
no test coverage detected
searching dependent graphs…