/
githubmirror
/
lazygit
Обзор
Документация
Войти
/
githubmirror
/
lazygit
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
pkg/gocui/double_click_test.go
34 строки
1011 B
Stefan Haller
Add test for double-click detection
31 июл 2026, 09:22
31 июл 2026, 09:22
38d2293
Код
Авторство
О чём код?
package gocui import ( "testing" "github.com/gdamore/tcell/v3" "github.com/stretchr/testify/assert" ) func TestMouseReleaseDoesNotBreakDoubleClickDetection(t *testing.T) { t.Cleanup(resetMouseState) resetMouseState() g := newTestGui(t) view, _ := g.SetView("list", 0, 0, 20, 10, 0) doubleClicks := []bool{} assert.NoError(t, g.SetViewClickBinding(&ViewMouseBinding{ ViewName: "list", Key: MouseLeft, Handler: func(opts ViewMouseBindingOpts) error { doubleClicks = append(doubleClicks, opts.IsDoubleClick) return nil }, })) for _, event := range []GocuiEvent{ gocuiEventFromTcellEvent(tcell.NewEventMouse(view.x0+1, view.y0+1, tcell.ButtonPrimary, tcell.ModNone)), gocuiEventFromTcellEvent(tcell.NewEventMouse(view.x0+1, view.y0+1, tcell.ButtonNone, tcell.ModNone)), gocuiEventFromTcellEvent(tcell.NewEventMouse(view.x0+1, view.y0+1, tcell.ButtonPrimary, tcell.ModNone)), } { assert.NoError(t, g.onKey(&event)) } assert.Equal(t, []bool{false, true}, doubleClicks) }