Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2710e700e8 |
No files matched your search
+2
-5
@@ -610,17 +610,14 @@ func (a *App) cmdWindow(args string) {
|
|||||||
|
|
||||||
_, _ = fmt.Sscanf(args, "%d", &bufIndex)
|
_, _ = fmt.Sscanf(args, "%d", &bufIndex)
|
||||||
|
|
||||||
|
a.ui.SwitchBuffer(bufIndex)
|
||||||
|
|
||||||
a.mu.Lock()
|
a.mu.Lock()
|
||||||
nick := a.nick
|
nick := a.nick
|
||||||
a.mu.Unlock()
|
a.mu.Unlock()
|
||||||
|
|
||||||
// Read the name before switching. A message from the server can
|
|
||||||
// add a buffer at any time, but only at the end, so bufIndex
|
|
||||||
// still names this buffer when SwitchBuffer runs.
|
|
||||||
name, found := a.ui.BufferName(bufIndex)
|
name, found := a.ui.BufferName(bufIndex)
|
||||||
if found {
|
if found {
|
||||||
a.ui.SwitchBuffer(bufIndex)
|
|
||||||
|
|
||||||
if name != "(status)" {
|
if name != "(status)" {
|
||||||
a.mu.Lock()
|
a.mu.Lock()
|
||||||
a.target = name
|
a.target = name
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ const (
|
|||||||
// be handled, or for the UI to stop, before it fails.
|
// be handled, or for the UI to stop, before it fails.
|
||||||
const eventLoopTimeout = 5 * time.Second
|
const eventLoopTimeout = 5 * time.Second
|
||||||
|
|
||||||
// holdTime is how long TestLinesKeepOrder holds the first line,
|
|
||||||
// which gives the second line time to start too early.
|
|
||||||
const holdTime = 200 * time.Millisecond
|
|
||||||
|
|
||||||
func TestMemberPrefix(t *testing.T) {
|
func TestMemberPrefix(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -287,8 +283,8 @@ func TestAltDigit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestEventLoopKeepsRunning sends Alt and 1, then a typed line and
|
// TestEventLoopKeepsRunning sends Alt and 1, then a typed line and
|
||||||
// Enter, to a running UI. It checks that both are handled, so the
|
// Enter, to a running UI. It checks that both are handled, in that
|
||||||
// event loop did not stop on either.
|
// order, so the event loop did not stop on either.
|
||||||
func TestEventLoopKeepsRunning(t *testing.T) {
|
func TestEventLoopKeepsRunning(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -314,40 +310,6 @@ func TestEventLoopKeepsRunning(t *testing.T) {
|
|||||||
waitHandled(t, handled, testText)
|
waitHandled(t, handled, testText)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestLinesKeepOrder holds the handling of a first line until a
|
|
||||||
// second line has been passed in. It fails if the second line is
|
|
||||||
// handled while the first is still held.
|
|
||||||
func TestLinesKeepOrder(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
const firstLine, secondLine = "one", "two"
|
|
||||||
|
|
||||||
ui := NewUI()
|
|
||||||
handled := make(chan string)
|
|
||||||
release := make(chan struct{})
|
|
||||||
|
|
||||||
ui.OnInput(func(text string) {
|
|
||||||
if text == firstLine {
|
|
||||||
<-release
|
|
||||||
}
|
|
||||||
|
|
||||||
handled <- text
|
|
||||||
})
|
|
||||||
|
|
||||||
ui.callOnInput(firstLine)
|
|
||||||
ui.callOnInput(secondLine)
|
|
||||||
|
|
||||||
select {
|
|
||||||
case got := <-handled:
|
|
||||||
t.Fatalf("handled %q while the first line was held", got)
|
|
||||||
case <-time.After(holdTime):
|
|
||||||
}
|
|
||||||
|
|
||||||
close(release)
|
|
||||||
waitHandled(t, handled, firstLine)
|
|
||||||
waitHandled(t, handled, secondLine)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestOwnEventFromOtherClient checks that a message, notice,
|
// TestOwnEventFromOtherClient checks that a message, notice,
|
||||||
// join or part that the user's session makes from another
|
// join or part that the user's session makes from another
|
||||||
// client shows as one line in the buffer it belongs to.
|
// client shows as one line in the buffer it belongs to.
|
||||||
|
|||||||
Reference in new issue
Block a user