mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
fix tests to more accurately reproduce user typing
This commit is contained in:
parent
4ad576bc6e
commit
55cdd5825f
7
input.go
7
input.go
|
|
@ -4,6 +4,8 @@ import (
|
|||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
"github.com/lestrrat-go/pdebug"
|
||||
"github.com/nsf/termbox-go"
|
||||
)
|
||||
|
||||
|
|
@ -31,6 +33,11 @@ func (i *Input) Loop(ctx context.Context, cancel func()) error {
|
|||
}
|
||||
|
||||
func (i *Input) handleInputEvent(ctx context.Context, ev termbox.Event) error {
|
||||
if pdebug.Enabled {
|
||||
g := pdebug.Marker("event received from user: %#v", ev)
|
||||
defer g.End()
|
||||
}
|
||||
|
||||
switch ev.Type {
|
||||
case termbox.EventError:
|
||||
return nil
|
||||
|
|
|
|||
13
peco_test.go
13
peco_test.go
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"context"
|
||||
|
||||
"github.com/lestrrat-go/pdebug"
|
||||
"github.com/nsf/termbox-go"
|
||||
"github.com/peco/peco/hub"
|
||||
"github.com/peco/peco/internal/util"
|
||||
|
|
@ -359,7 +360,11 @@ func TestGHIssue367(t *testing.T) {
|
|||
|
||||
l := len(src[0])
|
||||
copy(p, src[0])
|
||||
p = p[:l]
|
||||
src = src[1:]
|
||||
if pdebug.Enabled {
|
||||
pdebug.Printf("reader func returning %#v", string(p))
|
||||
}
|
||||
return l, nil
|
||||
})
|
||||
buf := bytes.Buffer{}
|
||||
|
|
@ -371,9 +376,13 @@ func TestGHIssue367(t *testing.T) {
|
|||
p.Run(ctx)
|
||||
}()
|
||||
|
||||
p.Query().Set("bar")
|
||||
|
||||
select {
|
||||
case <-time.After(100 * time.Millisecond):
|
||||
p.screen.SendEvent(termbox.Event{Ch: 'b'})
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
p.screen.SendEvent(termbox.Event{Ch: 'a'})
|
||||
case <-time.After(300 * time.Millisecond):
|
||||
p.screen.SendEvent(termbox.Event{Ch: 'r'})
|
||||
case <-time.After(900 * time.Millisecond):
|
||||
p.screen.SendEvent(termbox.Event{Key: termbox.KeyEnter})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue