test: replace fakeIME with Mockery mocks and add Makefile
Add same-package IME and Clipboard mocks for internal/edit, a Makefile with check, race, mocks, mocks-check, fakes-check and perf-check targets, drop unused code and make the demo stylesheet a ui testdata file.
- commit
- 90277d5c33effa9f6803fc1c8c0ab0fcbb5349ee
- author
- brice · · 2026-10-01 17:44 UTC
- parent
- 21218d9
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
8 files · +479 -37
this diff holds invisible characters (direction controls, zero-width characters). They are shown as <U+XXXX> markers, never applied.
M .mockery.yml +9 -0
| @@ -14,3 +14,12 @@ packages: | |||
| 14 | 14 | filename: '{{.InterfaceName}}_mock_test.go' | |
| 15 | 15 | interfaces: | |
| 16 | 16 | target: | |
| 17 | + | # Editor ports: same-package mocks in test files. | |
| 18 | + | github.com/bnema/nefergui/internal/edit: | |
| 19 | + | config: | |
| 20 | + | dir: internal/edit | |
| 21 | + | pkgname: edit | |
| 22 | + | filename: '{{.InterfaceName}}_mock_test.go' | |
| 23 | + | interfaces: | |
| 24 | + | IME: | |
| 25 | + | Clipboard: | |
| @@ -14,3 +14,12 @@ packages: | |||||
| 14 | filename: '{{.InterfaceName}}_mock_test.go' | 14 | filename: '{{.InterfaceName}}_mock_test.go' | ||
| 15 | interfaces: | 15 | interfaces: | ||
| 16 | target: | 16 | target: | ||
| 17 | + | # Editor ports: same-package mocks in test files. | |||
| 18 | + | github.com/bnema/nefergui/internal/edit: | |||
| 19 | + | config: | |||
| 20 | + | dir: internal/edit | |||
| 21 | + | pkgname: edit | |||
| 22 | + | filename: '{{.InterfaceName}}_mock_test.go' | |||
| 23 | + | interfaces: | |||
| 24 | + | IME: | |||
| 25 | + | Clipboard: | |||
A Makefile +23 -0
| @@ -0,0 +1,23 @@ | |||
| 1 | + | .PHONY: build test vet race mocks mocks-check fakes-check perf-check check | |
| 2 | + | ||
| 3 | + | build: | |
| 4 | + | CGO_ENABLED=0 go build ./... | |
| 5 | + | test: | |
| 6 | + | CGO_ENABLED=0 go test ./... | |
| 7 | + | vet: | |
| 8 | + | CGO_ENABLED=0 go vet ./... | |
| 9 | + | race: | |
| 10 | + | CGO_ENABLED=1 go test -race ./... | |
| 11 | + | mocks: | |
| 12 | + | mockery | |
| 13 | + | mocks-check: mocks | |
| 14 | + | git diff --exit-code -- ':(glob)internal/**/*_mock_test.go' | |
| 15 | + | @test -z "$$(git ls-files --others --exclude-standard -- ':(glob)internal/**/*_mock_test.go')" | |
| 16 | + | fakes-check: | |
| 17 | + | @rc=0; grep -rniE '^\s*type\s+\w*(fake|stub|spy|dummy|mock)\w*|^\s*\w*(fake|stub|spy|dummy|mock)\w*(\[[^]]*\])?\s+(struct|interface)\b' --include='*_test.go' --exclude='*_mock_test.go' . 2>/dev/null || rc=$$?; \ | |
| 18 | + | [ $$rc -eq 1 ] || { [ $$rc -eq 0 ] && printf '%s\n' 'handwritten test double: generate with Mockery v3' >&2; exit 1; } | |
| 19 | + | # Allocation guards (testing.AllocsPerRun). | |
| 20 | + | perf-check: | |
| 21 | + | CGO_ENABLED=0 go test -run 'TestAlloc' -count=1 ./... | |
| 22 | + | check: build vet test fakes-check perf-check | |
| 23 | + | CGO_ENABLED=0 staticcheck ./... | |
| @@ -0,0 +1,23 @@ | |||||
| 1 | + | .PHONY: build test vet race mocks mocks-check fakes-check perf-check check | |||
| 2 | + | ||||
| 3 | + | build: | |||
| 4 | + | CGO_ENABLED=0 go build ./... | |||
| 5 | + | test: | |||
| 6 | + | CGO_ENABLED=0 go test ./... | |||
| 7 | + | vet: | |||
| 8 | + | CGO_ENABLED=0 go vet ./... | |||
| 9 | + | race: | |||
| 10 | + | CGO_ENABLED=1 go test -race ./... | |||
| 11 | + | mocks: | |||
| 12 | + | mockery | |||
| 13 | + | mocks-check: mocks | |||
| 14 | + | git diff --exit-code -- ':(glob)internal/**/*_mock_test.go' | |||
| 15 | + | @test -z "$$(git ls-files --others --exclude-standard -- ':(glob)internal/**/*_mock_test.go')" | |||
| 16 | + | fakes-check: | |||
| 17 | + | @rc=0; grep -rniE '^\s*type\s+\w*(fake|stub|spy|dummy|mock)\w*|^\s*\w*(fake|stub|spy|dummy|mock)\w*(\[[^]]*\])?\s+(struct|interface)\b' --include='*_test.go' --exclude='*_mock_test.go' . 2>/dev/null || rc=$$?; \ | |||
| 18 | + | [ $$rc -eq 1 ] || { [ $$rc -eq 0 ] && printf '%s\n' 'handwritten test double: generate with Mockery v3' >&2; exit 1; } | |||
| 19 | + | # Allocation guards (testing.AllocsPerRun). | |||
| 20 | + | perf-check: | |||
| 21 | + | CGO_ENABLED=0 go test -run 'TestAlloc' -count=1 ./... | |||
| 22 | + | check: build vet test fakes-check perf-check | |||
| 23 | + | CGO_ENABLED=0 staticcheck ./... | |||
M example_test.go +12 -14
| @@ -40,19 +40,17 @@ func ExampleRenderer() { | |||
| 40 | 40 | ||
| 41 | 41 | m := &model{} | |
| 42 | 42 | var out nefergui.Output | |
| 43 | - | for { | |
| 44 | - | drawn, err := r.Render(&out, m, view) | |
| 45 | - | if err != nil { | |
| 46 | - | log.Fatal(err) | |
| 47 | - | } | |
| 48 | - | if drawn { | |
| 49 | - | // Import out.Planes as a wl_buffer when out.NewBuffer is set, attach | |
| 50 | - | // it with the Acquire/Release points, commit, and call r.Released | |
| 51 | - | // when out.ReleaseFD becomes readable. | |
| 52 | - | _ = out.Buffer | |
| 53 | - | } | |
| 54 | - | // Sleep until a Wayland event, <-r.Wake(), or a short timer when | |
| 55 | - | // r.Pending() reports a frame waiting for the GPU. | |
| 56 | - | return | |
| 43 | + | // One iteration of the client loop; real clients repeat it forever. | |
| 44 | + | drawn, err := r.Render(&out, m, view) | |
| 45 | + | if err != nil { | |
| 46 | + | log.Fatal(err) | |
| 47 | + | } | |
| 48 | + | if drawn { | |
| 49 | + | // Import out.Planes as a wl_buffer when out.NewBuffer is set, attach | |
| 50 | + | // it with the Acquire/Release points, commit, and call r.Released | |
| 51 | + | // when out.ReleaseFD becomes readable. | |
| 52 | + | _ = out.Buffer | |
| 57 | 53 | } | |
| 54 | + | // Then sleep until a Wayland event, <-r.Wake(), or a short timer when | |
| 55 | + | // r.Pending() reports a frame waiting for the GPU. | |
| 58 | 56 | } | |
| @@ -40,19 +40,17 @@ func ExampleRenderer() { | |||||
| 40 | 40 | ||||
| 41 | m := &model{} | 41 | m := &model{} | ||
| 42 | var out nefergui.Output | 42 | var out nefergui.Output | ||
| 43 | - | for { | 43 | + | // One iteration of the client loop; real clients repeat it forever. |
| 44 | - | drawn, err := r.Render(&out, m, view) | 44 | + | drawn, err := r.Render(&out, m, view) |
| 45 | - | if err != nil { | 45 | + | if err != nil { |
| 46 | - | log.Fatal(err) | 46 | + | log.Fatal(err) |
| 47 | - | } | 47 | + | } |
| 48 | - | if drawn { | 48 | + | if drawn { |
| 49 | - | // Import out.Planes as a wl_buffer when out.NewBuffer is set, attach | 49 | + | // Import out.Planes as a wl_buffer when out.NewBuffer is set, attach |
| 50 | - | // it with the Acquire/Release points, commit, and call r.Released | 50 | + | // it with the Acquire/Release points, commit, and call r.Released |
| 51 | - | // when out.ReleaseFD becomes readable. | 51 | + | // when out.ReleaseFD becomes readable. |
| 52 | - | _ = out.Buffer | 52 | + | _ = out.Buffer |
| 53 | - | } | |||
| 54 | - | // Sleep until a Wayland event, <-r.Wake(), or a short timer when | |||
| 55 | - | // r.Pending() reports a frame waiting for the GPU. | |||
| 56 | - | return | |||
| 57 | } | 53 | } | ||
| 54 | + | // Then sleep until a Wayland event, <-r.Wake(), or a short timer when | |||
| 55 | + | // r.Pending() reports a frame waiting for the GPU. | |||
| 58 | } | 56 | } | ||
A internal/edit/Clipboard_mock_test.go +158 -0
| @@ -0,0 +1,158 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package edit | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | mock "github.com/stretchr/testify/mock" | |
| 9 | + | ) | |
| 10 | + | ||
| 11 | + | // NewMockClipboard creates a new instance of MockClipboard. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 12 | + | // The first argument is typically a *testing.T value. | |
| 13 | + | func NewMockClipboard(t interface { | |
| 14 | + | mock.TestingT | |
| 15 | + | Cleanup(func()) | |
| 16 | + | }) *MockClipboard { | |
| 17 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 18 | + | helper.Helper() | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | mock := &MockClipboard{} | |
| 22 | + | mock.Mock.Test(t) | |
| 23 | + | ||
| 24 | + | t.Cleanup(func() { | |
| 25 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 26 | + | helper.Helper() | |
| 27 | + | } | |
| 28 | + | mock.AssertExpectations(t) | |
| 29 | + | }) | |
| 30 | + | ||
| 31 | + | return mock | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | // MockClipboard is an autogenerated mock type for the Clipboard type | |
| 35 | + | type MockClipboard struct { | |
| 36 | + | mock.Mock | |
| 37 | + | } | |
| 38 | + | ||
| 39 | + | type MockClipboard_Expecter struct { | |
| 40 | + | mock *mock.Mock | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | func (_m *MockClipboard) EXPECT() *MockClipboard_Expecter { | |
| 44 | + | return &MockClipboard_Expecter{mock: &_m.Mock} | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | // ReadText provides a mock function for the type MockClipboard | |
| 48 | + | func (_mock *MockClipboard) ReadText(limit int) ([]byte, error) { | |
| 49 | + | ret := _mock.Called(limit) | |
| 50 | + | ||
| 51 | + | if len(ret) == 0 { | |
| 52 | + | panic("no return value specified for ReadText") | |
| 53 | + | } | |
| 54 | + | ||
| 55 | + | var r0 []byte | |
| 56 | + | var r1 error | |
| 57 | + | if returnFunc, ok := ret.Get(0).(func(int) ([]byte, error)); ok { | |
| 58 | + | return returnFunc(limit) | |
| 59 | + | } | |
| 60 | + | if returnFunc, ok := ret.Get(0).(func(int) []byte); ok { | |
| 61 | + | r0 = returnFunc(limit) | |
| 62 | + | } else { | |
| 63 | + | if ret.Get(0) != nil { | |
| 64 | + | r0 = ret.Get(0).([]byte) | |
| 65 | + | } | |
| 66 | + | } | |
| 67 | + | if returnFunc, ok := ret.Get(1).(func(int) error); ok { | |
| 68 | + | r1 = returnFunc(limit) | |
| 69 | + | } else { | |
| 70 | + | r1 = ret.Error(1) | |
| 71 | + | } | |
| 72 | + | return r0, r1 | |
| 73 | + | } | |
| 74 | + | ||
| 75 | + | // MockClipboard_ReadText_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadText' | |
| 76 | + | type MockClipboard_ReadText_Call struct { | |
| 77 | + | *mock.Call | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | // ReadText is a helper method to define mock.On call | |
| 81 | + | // - limit int | |
| 82 | + | func (_e *MockClipboard_Expecter) ReadText(limit any) *MockClipboard_ReadText_Call { | |
| 83 | + | return &MockClipboard_ReadText_Call{Call: _e.mock.On("ReadText", limit)} | |
| 84 | + | } | |
| 85 | + | ||
| 86 | + | func (_c *MockClipboard_ReadText_Call) Run(run func(limit int)) *MockClipboard_ReadText_Call { | |
| 87 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 88 | + | var arg0 int | |
| 89 | + | if args[0] != nil { | |
| 90 | + | arg0 = args[0].(int) | |
| 91 | + | } | |
| 92 | + | run( | |
| 93 | + | arg0, | |
| 94 | + | ) | |
| 95 | + | }) | |
| 96 | + | return _c | |
| 97 | + | } | |
| 98 | + | ||
| 99 | + | func (_c *MockClipboard_ReadText_Call) Return(bytes []byte, err error) *MockClipboard_ReadText_Call { | |
| 100 | + | _c.Call.Return(bytes, err) | |
| 101 | + | return _c | |
| 102 | + | } | |
| 103 | + | ||
| 104 | + | func (_c *MockClipboard_ReadText_Call) RunAndReturn(run func(limit int) ([]byte, error)) *MockClipboard_ReadText_Call { | |
| 105 | + | _c.Call.Return(run) | |
| 106 | + | return _c | |
| 107 | + | } | |
| 108 | + | ||
| 109 | + | // WriteText provides a mock function for the type MockClipboard | |
| 110 | + | func (_mock *MockClipboard) WriteText(bytes []byte) error { | |
| 111 | + | ret := _mock.Called(bytes) | |
| 112 | + | ||
| 113 | + | if len(ret) == 0 { | |
| 114 | + | panic("no return value specified for WriteText") | |
| 115 | + | } | |
| 116 | + | ||
| 117 | + | var r0 error | |
| 118 | + | if returnFunc, ok := ret.Get(0).(func([]byte) error); ok { | |
| 119 | + | r0 = returnFunc(bytes) | |
| 120 | + | } else { | |
| 121 | + | r0 = ret.Error(0) | |
| 122 | + | } | |
| 123 | + | return r0 | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | // MockClipboard_WriteText_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteText' | |
| 127 | + | type MockClipboard_WriteText_Call struct { | |
| 128 | + | *mock.Call | |
| 129 | + | } | |
| 130 | + | ||
| 131 | + | // WriteText is a helper method to define mock.On call | |
| 132 | + | // - bytes []byte | |
| 133 | + | func (_e *MockClipboard_Expecter) WriteText(bytes any) *MockClipboard_WriteText_Call { | |
| 134 | + | return &MockClipboard_WriteText_Call{Call: _e.mock.On("WriteText", bytes)} | |
| 135 | + | } | |
| 136 | + | ||
| 137 | + | func (_c *MockClipboard_WriteText_Call) Run(run func(bytes []byte)) *MockClipboard_WriteText_Call { | |
| 138 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 139 | + | var arg0 []byte | |
| 140 | + | if args[0] != nil { | |
| 141 | + | arg0 = args[0].([]byte) | |
| 142 | + | } | |
| 143 | + | run( | |
| 144 | + | arg0, | |
| 145 | + | ) | |
| 146 | + | }) | |
| 147 | + | return _c | |
| 148 | + | } | |
| 149 | + | ||
| 150 | + | func (_c *MockClipboard_WriteText_Call) Return(err error) *MockClipboard_WriteText_Call { | |
| 151 | + | _c.Call.Return(err) | |
| 152 | + | return _c | |
| 153 | + | } | |
| 154 | + | ||
| 155 | + | func (_c *MockClipboard_WriteText_Call) RunAndReturn(run func(bytes []byte) error) *MockClipboard_WriteText_Call { | |
| 156 | + | _c.Call.Return(run) | |
| 157 | + | return _c | |
| 158 | + | } | |
| @@ -0,0 +1,158 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package edit | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | mock "github.com/stretchr/testify/mock" | |||
| 9 | + | ) | |||
| 10 | + | ||||
| 11 | + | // NewMockClipboard creates a new instance of MockClipboard. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 12 | + | // The first argument is typically a *testing.T value. | |||
| 13 | + | func NewMockClipboard(t interface { | |||
| 14 | + | mock.TestingT | |||
| 15 | + | Cleanup(func()) | |||
| 16 | + | }) *MockClipboard { | |||
| 17 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 18 | + | helper.Helper() | |||
| 19 | + | } | |||
| 20 | + | ||||
| 21 | + | mock := &MockClipboard{} | |||
| 22 | + | mock.Mock.Test(t) | |||
| 23 | + | ||||
| 24 | + | t.Cleanup(func() { | |||
| 25 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 26 | + | helper.Helper() | |||
| 27 | + | } | |||
| 28 | + | mock.AssertExpectations(t) | |||
| 29 | + | }) | |||
| 30 | + | ||||
| 31 | + | return mock | |||
| 32 | + | } | |||
| 33 | + | ||||
| 34 | + | // MockClipboard is an autogenerated mock type for the Clipboard type | |||
| 35 | + | type MockClipboard struct { | |||
| 36 | + | mock.Mock | |||
| 37 | + | } | |||
| 38 | + | ||||
| 39 | + | type MockClipboard_Expecter struct { | |||
| 40 | + | mock *mock.Mock | |||
| 41 | + | } | |||
| 42 | + | ||||
| 43 | + | func (_m *MockClipboard) EXPECT() *MockClipboard_Expecter { | |||
| 44 | + | return &MockClipboard_Expecter{mock: &_m.Mock} | |||
| 45 | + | } | |||
| 46 | + | ||||
| 47 | + | // ReadText provides a mock function for the type MockClipboard | |||
| 48 | + | func (_mock *MockClipboard) ReadText(limit int) ([]byte, error) { | |||
| 49 | + | ret := _mock.Called(limit) | |||
| 50 | + | ||||
| 51 | + | if len(ret) == 0 { | |||
| 52 | + | panic("no return value specified for ReadText") | |||
| 53 | + | } | |||
| 54 | + | ||||
| 55 | + | var r0 []byte | |||
| 56 | + | var r1 error | |||
| 57 | + | if returnFunc, ok := ret.Get(0).(func(int) ([]byte, error)); ok { | |||
| 58 | + | return returnFunc(limit) | |||
| 59 | + | } | |||
| 60 | + | if returnFunc, ok := ret.Get(0).(func(int) []byte); ok { | |||
| 61 | + | r0 = returnFunc(limit) | |||
| 62 | + | } else { | |||
| 63 | + | if ret.Get(0) != nil { | |||
| 64 | + | r0 = ret.Get(0).([]byte) | |||
| 65 | + | } | |||
| 66 | + | } | |||
| 67 | + | if returnFunc, ok := ret.Get(1).(func(int) error); ok { | |||
| 68 | + | r1 = returnFunc(limit) | |||
| 69 | + | } else { | |||
| 70 | + | r1 = ret.Error(1) | |||
| 71 | + | } | |||
| 72 | + | return r0, r1 | |||
| 73 | + | } | |||
| 74 | + | ||||
| 75 | + | // MockClipboard_ReadText_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadText' | |||
| 76 | + | type MockClipboard_ReadText_Call struct { | |||
| 77 | + | *mock.Call | |||
| 78 | + | } | |||
| 79 | + | ||||
| 80 | + | // ReadText is a helper method to define mock.On call | |||
| 81 | + | // - limit int | |||
| 82 | + | func (_e *MockClipboard_Expecter) ReadText(limit any) *MockClipboard_ReadText_Call { | |||
| 83 | + | return &MockClipboard_ReadText_Call{Call: _e.mock.On("ReadText", limit)} | |||
| 84 | + | } | |||
| 85 | + | ||||
| 86 | + | func (_c *MockClipboard_ReadText_Call) Run(run func(limit int)) *MockClipboard_ReadText_Call { | |||
| 87 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 88 | + | var arg0 int | |||
| 89 | + | if args[0] != nil { | |||
| 90 | + | arg0 = args[0].(int) | |||
| 91 | + | } | |||
| 92 | + | run( | |||
| 93 | + | arg0, | |||
| 94 | + | ) | |||
| 95 | + | }) | |||
| 96 | + | return _c | |||
| 97 | + | } | |||
| 98 | + | ||||
| 99 | + | func (_c *MockClipboard_ReadText_Call) Return(bytes []byte, err error) *MockClipboard_ReadText_Call { | |||
| 100 | + | _c.Call.Return(bytes, err) | |||
| 101 | + | return _c | |||
| 102 | + | } | |||
| 103 | + | ||||
| 104 | + | func (_c *MockClipboard_ReadText_Call) RunAndReturn(run func(limit int) ([]byte, error)) *MockClipboard_ReadText_Call { | |||
| 105 | + | _c.Call.Return(run) | |||
| 106 | + | return _c | |||
| 107 | + | } | |||
| 108 | + | ||||
| 109 | + | // WriteText provides a mock function for the type MockClipboard | |||
| 110 | + | func (_mock *MockClipboard) WriteText(bytes []byte) error { | |||
| 111 | + | ret := _mock.Called(bytes) | |||
| 112 | + | ||||
| 113 | + | if len(ret) == 0 { | |||
| 114 | + | panic("no return value specified for WriteText") | |||
| 115 | + | } | |||
| 116 | + | ||||
| 117 | + | var r0 error | |||
| 118 | + | if returnFunc, ok := ret.Get(0).(func([]byte) error); ok { | |||
| 119 | + | r0 = returnFunc(bytes) | |||
| 120 | + | } else { | |||
| 121 | + | r0 = ret.Error(0) | |||
| 122 | + | } | |||
| 123 | + | return r0 | |||
| 124 | + | } | |||
| 125 | + | ||||
| 126 | + | // MockClipboard_WriteText_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteText' | |||
| 127 | + | type MockClipboard_WriteText_Call struct { | |||
| 128 | + | *mock.Call | |||
| 129 | + | } | |||
| 130 | + | ||||
| 131 | + | // WriteText is a helper method to define mock.On call | |||
| 132 | + | // - bytes []byte | |||
| 133 | + | func (_e *MockClipboard_Expecter) WriteText(bytes any) *MockClipboard_WriteText_Call { | |||
| 134 | + | return &MockClipboard_WriteText_Call{Call: _e.mock.On("WriteText", bytes)} | |||
| 135 | + | } | |||
| 136 | + | ||||
| 137 | + | func (_c *MockClipboard_WriteText_Call) Run(run func(bytes []byte)) *MockClipboard_WriteText_Call { | |||
| 138 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 139 | + | var arg0 []byte | |||
| 140 | + | if args[0] != nil { | |||
| 141 | + | arg0 = args[0].([]byte) | |||
| 142 | + | } | |||
| 143 | + | run( | |||
| 144 | + | arg0, | |||
| 145 | + | ) | |||
| 146 | + | }) | |||
| 147 | + | return _c | |||
| 148 | + | } | |||
| 149 | + | ||||
| 150 | + | func (_c *MockClipboard_WriteText_Call) Return(err error) *MockClipboard_WriteText_Call { | |||
| 151 | + | _c.Call.Return(err) | |||
| 152 | + | return _c | |||
| 153 | + | } | |||
| 154 | + | ||||
| 155 | + | func (_c *MockClipboard_WriteText_Call) RunAndReturn(run func(bytes []byte) error) *MockClipboard_WriteText_Call { | |||
| 156 | + | _c.Call.Return(run) | |||
| 157 | + | return _c | |||
| 158 | + | } | |||
A internal/edit/IME_mock_test.go +267 -0
| @@ -0,0 +1,267 @@ | |||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |
| 2 | + | // github.com/vektra/mockery | |
| 3 | + | // template: testify | |
| 4 | + | ||
| 5 | + | package edit | |
| 6 | + | ||
| 7 | + | import ( | |
| 8 | + | mock "github.com/stretchr/testify/mock" | |
| 9 | + | ) | |
| 10 | + | ||
| 11 | + | // NewMockIME creates a new instance of MockIME. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |
| 12 | + | // The first argument is typically a *testing.T value. | |
| 13 | + | func NewMockIME(t interface { | |
| 14 | + | mock.TestingT | |
| 15 | + | Cleanup(func()) | |
| 16 | + | }) *MockIME { | |
| 17 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 18 | + | helper.Helper() | |
| 19 | + | } | |
| 20 | + | ||
| 21 | + | mock := &MockIME{} | |
| 22 | + | mock.Mock.Test(t) | |
| 23 | + | ||
| 24 | + | t.Cleanup(func() { | |
| 25 | + | if helper, ok := t.(interface{ Helper() }); ok { | |
| 26 | + | helper.Helper() | |
| 27 | + | } | |
| 28 | + | mock.AssertExpectations(t) | |
| 29 | + | }) | |
| 30 | + | ||
| 31 | + | return mock | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | // MockIME is an autogenerated mock type for the IME type | |
| 35 | + | type MockIME struct { | |
| 36 | + | mock.Mock | |
| 37 | + | } | |
| 38 | + | ||
| 39 | + | type MockIME_Expecter struct { | |
| 40 | + | mock *mock.Mock | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | func (_m *MockIME) EXPECT() *MockIME_Expecter { | |
| 44 | + | return &MockIME_Expecter{mock: &_m.Mock} | |
| 45 | + | } | |
| 46 | + | ||
| 47 | + | // ContentType provides a mock function for the type MockIME | |
| 48 | + | func (_mock *MockIME) ContentType(password bool, multiline bool) { | |
| 49 | + | _mock.Called(password, multiline) | |
| 50 | + | return | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | // MockIME_ContentType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ContentType' | |
| 54 | + | type MockIME_ContentType_Call struct { | |
| 55 | + | *mock.Call | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | // ContentType is a helper method to define mock.On call | |
| 59 | + | // - password bool | |
| 60 | + | // - multiline bool | |
| 61 | + | func (_e *MockIME_Expecter) ContentType(password any, multiline any) *MockIME_ContentType_Call { | |
| 62 | + | return &MockIME_ContentType_Call{Call: _e.mock.On("ContentType", password, multiline)} | |
| 63 | + | } | |
| 64 | + | ||
| 65 | + | func (_c *MockIME_ContentType_Call) Run(run func(password bool, multiline bool)) *MockIME_ContentType_Call { | |
| 66 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 67 | + | var arg0 bool | |
| 68 | + | if args[0] != nil { | |
| 69 | + | arg0 = args[0].(bool) | |
| 70 | + | } | |
| 71 | + | var arg1 bool | |
| 72 | + | if args[1] != nil { | |
| 73 | + | arg1 = args[1].(bool) | |
| 74 | + | } | |
| 75 | + | run( | |
| 76 | + | arg0, | |
| 77 | + | arg1, | |
| 78 | + | ) | |
| 79 | + | }) | |
| 80 | + | return _c | |
| 81 | + | } | |
| 82 | + | ||
| 83 | + | func (_c *MockIME_ContentType_Call) Return() *MockIME_ContentType_Call { | |
| 84 | + | _c.Call.Return() | |
| 85 | + | return _c | |
| 86 | + | } | |
| 87 | + | ||
| 88 | + | func (_c *MockIME_ContentType_Call) RunAndReturn(run func(password bool, multiline bool)) *MockIME_ContentType_Call { | |
| 89 | + | _c.Run(run) | |
| 90 | + | return _c | |
| 91 | + | } | |
| 92 | + | ||
| 93 | + | // CursorRect provides a mock function for the type MockIME | |
| 94 | + | func (_mock *MockIME) CursorRect(x float64, y float64, w float64, h float64) { | |
| 95 | + | _mock.Called(x, y, w, h) | |
| 96 | + | return | |
| 97 | + | } | |
| 98 | + | ||
| 99 | + | // MockIME_CursorRect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CursorRect' | |
| 100 | + | type MockIME_CursorRect_Call struct { | |
| 101 | + | *mock.Call | |
| 102 | + | } | |
| 103 | + | ||
| 104 | + | // CursorRect is a helper method to define mock.On call | |
| 105 | + | // - x float64 | |
| 106 | + | // - y float64 | |
| 107 | + | // - w float64 | |
| 108 | + | // - h float64 | |
| 109 | + | func (_e *MockIME_Expecter) CursorRect(x any, y any, w any, h any) *MockIME_CursorRect_Call { | |
| 110 | + | return &MockIME_CursorRect_Call{Call: _e.mock.On("CursorRect", x, y, w, h)} | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | func (_c *MockIME_CursorRect_Call) Run(run func(x float64, y float64, w float64, h float64)) *MockIME_CursorRect_Call { | |
| 114 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 115 | + | var arg0 float64 | |
| 116 | + | if args[0] != nil { | |
| 117 | + | arg0 = args[0].(float64) | |
| 118 | + | } | |
| 119 | + | var arg1 float64 | |
| 120 | + | if args[1] != nil { | |
| 121 | + | arg1 = args[1].(float64) | |
| 122 | + | } | |
| 123 | + | var arg2 float64 | |
| 124 | + | if args[2] != nil { | |
| 125 | + | arg2 = args[2].(float64) | |
| 126 | + | } | |
| 127 | + | var arg3 float64 | |
| 128 | + | if args[3] != nil { | |
| 129 | + | arg3 = args[3].(float64) | |
| 130 | + | } | |
| 131 | + | run( | |
| 132 | + | arg0, | |
| 133 | + | arg1, | |
| 134 | + | arg2, | |
| 135 | + | arg3, | |
| 136 | + | ) | |
| 137 | + | }) | |
| 138 | + | return _c | |
| 139 | + | } | |
| 140 | + | ||
| 141 | + | func (_c *MockIME_CursorRect_Call) Return() *MockIME_CursorRect_Call { | |
| 142 | + | _c.Call.Return() | |
| 143 | + | return _c | |
| 144 | + | } | |
| 145 | + | ||
| 146 | + | func (_c *MockIME_CursorRect_Call) RunAndReturn(run func(x float64, y float64, w float64, h float64)) *MockIME_CursorRect_Call { | |
| 147 | + | _c.Run(run) | |
| 148 | + | return _c | |
| 149 | + | } | |
| 150 | + | ||
| 151 | + | // Disable provides a mock function for the type MockIME | |
| 152 | + | func (_mock *MockIME) Disable() { | |
| 153 | + | _mock.Called() | |
| 154 | + | return | |
| 155 | + | } | |
| 156 | + | ||
| 157 | + | // MockIME_Disable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Disable' | |
| 158 | + | type MockIME_Disable_Call struct { | |
| 159 | + | *mock.Call | |
| 160 | + | } | |
| 161 | + | ||
| 162 | + | // Disable is a helper method to define mock.On call | |
| 163 | + | func (_e *MockIME_Expecter) Disable() *MockIME_Disable_Call { | |
| 164 | + | return &MockIME_Disable_Call{Call: _e.mock.On("Disable")} | |
| 165 | + | } | |
| 166 | + | ||
| 167 | + | func (_c *MockIME_Disable_Call) Run(run func()) *MockIME_Disable_Call { | |
| 168 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 169 | + | run() | |
| 170 | + | }) | |
| 171 | + | return _c | |
| 172 | + | } | |
| 173 | + | ||
| 174 | + | func (_c *MockIME_Disable_Call) Return() *MockIME_Disable_Call { | |
| 175 | + | _c.Call.Return() | |
| 176 | + | return _c | |
| 177 | + | } | |
| 178 | + | ||
| 179 | + | func (_c *MockIME_Disable_Call) RunAndReturn(run func()) *MockIME_Disable_Call { | |
| 180 | + | _c.Run(run) | |
| 181 | + | return _c | |
| 182 | + | } | |
| 183 | + | ||
| 184 | + | // Enable provides a mock function for the type MockIME | |
| 185 | + | func (_mock *MockIME) Enable() { | |
| 186 | + | _mock.Called() | |
| 187 | + | return | |
| 188 | + | } | |
| 189 | + | ||
| 190 | + | // MockIME_Enable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Enable' | |
| 191 | + | type MockIME_Enable_Call struct { | |
| 192 | + | *mock.Call | |
| 193 | + | } | |
| 194 | + | ||
| 195 | + | // Enable is a helper method to define mock.On call | |
| 196 | + | func (_e *MockIME_Expecter) Enable() *MockIME_Enable_Call { | |
| 197 | + | return &MockIME_Enable_Call{Call: _e.mock.On("Enable")} | |
| 198 | + | } | |
| 199 | + | ||
| 200 | + | func (_c *MockIME_Enable_Call) Run(run func()) *MockIME_Enable_Call { | |
| 201 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 202 | + | run() | |
| 203 | + | }) | |
| 204 | + | return _c | |
| 205 | + | } | |
| 206 | + | ||
| 207 | + | func (_c *MockIME_Enable_Call) Return() *MockIME_Enable_Call { | |
| 208 | + | _c.Call.Return() | |
| 209 | + | return _c | |
| 210 | + | } | |
| 211 | + | ||
| 212 | + | func (_c *MockIME_Enable_Call) RunAndReturn(run func()) *MockIME_Enable_Call { | |
| 213 | + | _c.Run(run) | |
| 214 | + | return _c | |
| 215 | + | } | |
| 216 | + | ||
| 217 | + | // Surrounding provides a mock function for the type MockIME | |
| 218 | + | func (_mock *MockIME) Surrounding(text string, cursor int, anchor int) { | |
| 219 | + | _mock.Called(text, cursor, anchor) | |
| 220 | + | return | |
| 221 | + | } | |
| 222 | + | ||
| 223 | + | // MockIME_Surrounding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Surrounding' | |
| 224 | + | type MockIME_Surrounding_Call struct { | |
| 225 | + | *mock.Call | |
| 226 | + | } | |
| 227 | + | ||
| 228 | + | // Surrounding is a helper method to define mock.On call | |
| 229 | + | // - text string | |
| 230 | + | // - cursor int | |
| 231 | + | // - anchor int | |
| 232 | + | func (_e *MockIME_Expecter) Surrounding(text any, cursor any, anchor any) *MockIME_Surrounding_Call { | |
| 233 | + | return &MockIME_Surrounding_Call{Call: _e.mock.On("Surrounding", text, cursor, anchor)} | |
| 234 | + | } | |
| 235 | + | ||
| 236 | + | func (_c *MockIME_Surrounding_Call) Run(run func(text string, cursor int, anchor int)) *MockIME_Surrounding_Call { | |
| 237 | + | _c.Call.Run(func(args mock.Arguments) { | |
| 238 | + | var arg0 string | |
| 239 | + | if args[0] != nil { | |
| 240 | + | arg0 = args[0].(string) | |
| 241 | + | } | |
| 242 | + | var arg1 int | |
| 243 | + | if args[1] != nil { | |
| 244 | + | arg1 = args[1].(int) | |
| 245 | + | } | |
| 246 | + | var arg2 int | |
| 247 | + | if args[2] != nil { | |
| 248 | + | arg2 = args[2].(int) | |
| 249 | + | } | |
| 250 | + | run( | |
| 251 | + | arg0, | |
| 252 | + | arg1, | |
| 253 | + | arg2, | |
| 254 | + | ) | |
| 255 | + | }) | |
| 256 | + | return _c | |
| 257 | + | } | |
| 258 | + | ||
| 259 | + | func (_c *MockIME_Surrounding_Call) Return() *MockIME_Surrounding_Call { | |
| 260 | + | _c.Call.Return() | |
| 261 | + | return _c | |
| 262 | + | } | |
| 263 | + | ||
| 264 | + | func (_c *MockIME_Surrounding_Call) RunAndReturn(run func(text string, cursor int, anchor int)) *MockIME_Surrounding_Call { | |
| 265 | + | _c.Run(run) | |
| 266 | + | return _c | |
| 267 | + | } | |
| @@ -0,0 +1,267 @@ | |||||
| 1 | + | // Code generated by mockery; DO NOT EDIT. | |||
| 2 | + | // github.com/vektra/mockery | |||
| 3 | + | // template: testify | |||
| 4 | + | ||||
| 5 | + | package edit | |||
| 6 | + | ||||
| 7 | + | import ( | |||
| 8 | + | mock "github.com/stretchr/testify/mock" | |||
| 9 | + | ) | |||
| 10 | + | ||||
| 11 | + | // NewMockIME creates a new instance of MockIME. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. | |||
| 12 | + | // The first argument is typically a *testing.T value. | |||
| 13 | + | func NewMockIME(t interface { | |||
| 14 | + | mock.TestingT | |||
| 15 | + | Cleanup(func()) | |||
| 16 | + | }) *MockIME { | |||
| 17 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 18 | + | helper.Helper() | |||
| 19 | + | } | |||
| 20 | + | ||||
| 21 | + | mock := &MockIME{} | |||
| 22 | + | mock.Mock.Test(t) | |||
| 23 | + | ||||
| 24 | + | t.Cleanup(func() { | |||
| 25 | + | if helper, ok := t.(interface{ Helper() }); ok { | |||
| 26 | + | helper.Helper() | |||
| 27 | + | } | |||
| 28 | + | mock.AssertExpectations(t) | |||
| 29 | + | }) | |||
| 30 | + | ||||
| 31 | + | return mock | |||
| 32 | + | } | |||
| 33 | + | ||||
| 34 | + | // MockIME is an autogenerated mock type for the IME type | |||
| 35 | + | type MockIME struct { | |||
| 36 | + | mock.Mock | |||
| 37 | + | } | |||
| 38 | + | ||||
| 39 | + | type MockIME_Expecter struct { | |||
| 40 | + | mock *mock.Mock | |||
| 41 | + | } | |||
| 42 | + | ||||
| 43 | + | func (_m *MockIME) EXPECT() *MockIME_Expecter { | |||
| 44 | + | return &MockIME_Expecter{mock: &_m.Mock} | |||
| 45 | + | } | |||
| 46 | + | ||||
| 47 | + | // ContentType provides a mock function for the type MockIME | |||
| 48 | + | func (_mock *MockIME) ContentType(password bool, multiline bool) { | |||
| 49 | + | _mock.Called(password, multiline) | |||
| 50 | + | return | |||
| 51 | + | } | |||
| 52 | + | ||||
| 53 | + | // MockIME_ContentType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ContentType' | |||
| 54 | + | type MockIME_ContentType_Call struct { | |||
| 55 | + | *mock.Call | |||
| 56 | + | } | |||
| 57 | + | ||||
| 58 | + | // ContentType is a helper method to define mock.On call | |||
| 59 | + | // - password bool | |||
| 60 | + | // - multiline bool | |||
| 61 | + | func (_e *MockIME_Expecter) ContentType(password any, multiline any) *MockIME_ContentType_Call { | |||
| 62 | + | return &MockIME_ContentType_Call{Call: _e.mock.On("ContentType", password, multiline)} | |||
| 63 | + | } | |||
| 64 | + | ||||
| 65 | + | func (_c *MockIME_ContentType_Call) Run(run func(password bool, multiline bool)) *MockIME_ContentType_Call { | |||
| 66 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 67 | + | var arg0 bool | |||
| 68 | + | if args[0] != nil { | |||
| 69 | + | arg0 = args[0].(bool) | |||
| 70 | + | } | |||
| 71 | + | var arg1 bool | |||
| 72 | + | if args[1] != nil { | |||
| 73 | + | arg1 = args[1].(bool) | |||
| 74 | + | } | |||
| 75 | + | run( | |||
| 76 | + | arg0, | |||
| 77 | + | arg1, | |||
| 78 | + | ) | |||
| 79 | + | }) | |||
| 80 | + | return _c | |||
| 81 | + | } | |||
| 82 | + | ||||
| 83 | + | func (_c *MockIME_ContentType_Call) Return() *MockIME_ContentType_Call { | |||
| 84 | + | _c.Call.Return() | |||
| 85 | + | return _c | |||
| 86 | + | } | |||
| 87 | + | ||||
| 88 | + | func (_c *MockIME_ContentType_Call) RunAndReturn(run func(password bool, multiline bool)) *MockIME_ContentType_Call { | |||
| 89 | + | _c.Run(run) | |||
| 90 | + | return _c | |||
| 91 | + | } | |||
| 92 | + | ||||
| 93 | + | // CursorRect provides a mock function for the type MockIME | |||
| 94 | + | func (_mock *MockIME) CursorRect(x float64, y float64, w float64, h float64) { | |||
| 95 | + | _mock.Called(x, y, w, h) | |||
| 96 | + | return | |||
| 97 | + | } | |||
| 98 | + | ||||
| 99 | + | // MockIME_CursorRect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CursorRect' | |||
| 100 | + | type MockIME_CursorRect_Call struct { | |||
| 101 | + | *mock.Call | |||
| 102 | + | } | |||
| 103 | + | ||||
| 104 | + | // CursorRect is a helper method to define mock.On call | |||
| 105 | + | // - x float64 | |||
| 106 | + | // - y float64 | |||
| 107 | + | // - w float64 | |||
| 108 | + | // - h float64 | |||
| 109 | + | func (_e *MockIME_Expecter) CursorRect(x any, y any, w any, h any) *MockIME_CursorRect_Call { | |||
| 110 | + | return &MockIME_CursorRect_Call{Call: _e.mock.On("CursorRect", x, y, w, h)} | |||
| 111 | + | } | |||
| 112 | + | ||||
| 113 | + | func (_c *MockIME_CursorRect_Call) Run(run func(x float64, y float64, w float64, h float64)) *MockIME_CursorRect_Call { | |||
| 114 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 115 | + | var arg0 float64 | |||
| 116 | + | if args[0] != nil { | |||
| 117 | + | arg0 = args[0].(float64) | |||
| 118 | + | } | |||
| 119 | + | var arg1 float64 | |||
| 120 | + | if args[1] != nil { | |||
| 121 | + | arg1 = args[1].(float64) | |||
| 122 | + | } | |||
| 123 | + | var arg2 float64 | |||
| 124 | + | if args[2] != nil { | |||
| 125 | + | arg2 = args[2].(float64) | |||
| 126 | + | } | |||
| 127 | + | var arg3 float64 | |||
| 128 | + | if args[3] != nil { | |||
| 129 | + | arg3 = args[3].(float64) | |||
| 130 | + | } | |||
| 131 | + | run( | |||
| 132 | + | arg0, | |||
| 133 | + | arg1, | |||
| 134 | + | arg2, | |||
| 135 | + | arg3, | |||
| 136 | + | ) | |||
| 137 | + | }) | |||
| 138 | + | return _c | |||
| 139 | + | } | |||
| 140 | + | ||||
| 141 | + | func (_c *MockIME_CursorRect_Call) Return() *MockIME_CursorRect_Call { | |||
| 142 | + | _c.Call.Return() | |||
| 143 | + | return _c | |||
| 144 | + | } | |||
| 145 | + | ||||
| 146 | + | func (_c *MockIME_CursorRect_Call) RunAndReturn(run func(x float64, y float64, w float64, h float64)) *MockIME_CursorRect_Call { | |||
| 147 | + | _c.Run(run) | |||
| 148 | + | return _c | |||
| 149 | + | } | |||
| 150 | + | ||||
| 151 | + | // Disable provides a mock function for the type MockIME | |||
| 152 | + | func (_mock *MockIME) Disable() { | |||
| 153 | + | _mock.Called() | |||
| 154 | + | return | |||
| 155 | + | } | |||
| 156 | + | ||||
| 157 | + | // MockIME_Disable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Disable' | |||
| 158 | + | type MockIME_Disable_Call struct { | |||
| 159 | + | *mock.Call | |||
| 160 | + | } | |||
| 161 | + | ||||
| 162 | + | // Disable is a helper method to define mock.On call | |||
| 163 | + | func (_e *MockIME_Expecter) Disable() *MockIME_Disable_Call { | |||
| 164 | + | return &MockIME_Disable_Call{Call: _e.mock.On("Disable")} | |||
| 165 | + | } | |||
| 166 | + | ||||
| 167 | + | func (_c *MockIME_Disable_Call) Run(run func()) *MockIME_Disable_Call { | |||
| 168 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 169 | + | run() | |||
| 170 | + | }) | |||
| 171 | + | return _c | |||
| 172 | + | } | |||
| 173 | + | ||||
| 174 | + | func (_c *MockIME_Disable_Call) Return() *MockIME_Disable_Call { | |||
| 175 | + | _c.Call.Return() | |||
| 176 | + | return _c | |||
| 177 | + | } | |||
| 178 | + | ||||
| 179 | + | func (_c *MockIME_Disable_Call) RunAndReturn(run func()) *MockIME_Disable_Call { | |||
| 180 | + | _c.Run(run) | |||
| 181 | + | return _c | |||
| 182 | + | } | |||
| 183 | + | ||||
| 184 | + | // Enable provides a mock function for the type MockIME | |||
| 185 | + | func (_mock *MockIME) Enable() { | |||
| 186 | + | _mock.Called() | |||
| 187 | + | return | |||
| 188 | + | } | |||
| 189 | + | ||||
| 190 | + | // MockIME_Enable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Enable' | |||
| 191 | + | type MockIME_Enable_Call struct { | |||
| 192 | + | *mock.Call | |||
| 193 | + | } | |||
| 194 | + | ||||
| 195 | + | // Enable is a helper method to define mock.On call | |||
| 196 | + | func (_e *MockIME_Expecter) Enable() *MockIME_Enable_Call { | |||
| 197 | + | return &MockIME_Enable_Call{Call: _e.mock.On("Enable")} | |||
| 198 | + | } | |||
| 199 | + | ||||
| 200 | + | func (_c *MockIME_Enable_Call) Run(run func()) *MockIME_Enable_Call { | |||
| 201 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 202 | + | run() | |||
| 203 | + | }) | |||
| 204 | + | return _c | |||
| 205 | + | } | |||
| 206 | + | ||||
| 207 | + | func (_c *MockIME_Enable_Call) Return() *MockIME_Enable_Call { | |||
| 208 | + | _c.Call.Return() | |||
| 209 | + | return _c | |||
| 210 | + | } | |||
| 211 | + | ||||
| 212 | + | func (_c *MockIME_Enable_Call) RunAndReturn(run func()) *MockIME_Enable_Call { | |||
| 213 | + | _c.Run(run) | |||
| 214 | + | return _c | |||
| 215 | + | } | |||
| 216 | + | ||||
| 217 | + | // Surrounding provides a mock function for the type MockIME | |||
| 218 | + | func (_mock *MockIME) Surrounding(text string, cursor int, anchor int) { | |||
| 219 | + | _mock.Called(text, cursor, anchor) | |||
| 220 | + | return | |||
| 221 | + | } | |||
| 222 | + | ||||
| 223 | + | // MockIME_Surrounding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Surrounding' | |||
| 224 | + | type MockIME_Surrounding_Call struct { | |||
| 225 | + | *mock.Call | |||
| 226 | + | } | |||
| 227 | + | ||||
| 228 | + | // Surrounding is a helper method to define mock.On call | |||
| 229 | + | // - text string | |||
| 230 | + | // - cursor int | |||
| 231 | + | // - anchor int | |||
| 232 | + | func (_e *MockIME_Expecter) Surrounding(text any, cursor any, anchor any) *MockIME_Surrounding_Call { | |||
| 233 | + | return &MockIME_Surrounding_Call{Call: _e.mock.On("Surrounding", text, cursor, anchor)} | |||
| 234 | + | } | |||
| 235 | + | ||||
| 236 | + | func (_c *MockIME_Surrounding_Call) Run(run func(text string, cursor int, anchor int)) *MockIME_Surrounding_Call { | |||
| 237 | + | _c.Call.Run(func(args mock.Arguments) { | |||
| 238 | + | var arg0 string | |||
| 239 | + | if args[0] != nil { | |||
| 240 | + | arg0 = args[0].(string) | |||
| 241 | + | } | |||
| 242 | + | var arg1 int | |||
| 243 | + | if args[1] != nil { | |||
| 244 | + | arg1 = args[1].(int) | |||
| 245 | + | } | |||
| 246 | + | var arg2 int | |||
| 247 | + | if args[2] != nil { | |||
| 248 | + | arg2 = args[2].(int) | |||
| 249 | + | } | |||
| 250 | + | run( | |||
| 251 | + | arg0, | |||
| 252 | + | arg1, | |||
| 253 | + | arg2, | |||
| 254 | + | ) | |||
| 255 | + | }) | |||
| 256 | + | return _c | |||
| 257 | + | } | |||
| 258 | + | ||||
| 259 | + | func (_c *MockIME_Surrounding_Call) Return() *MockIME_Surrounding_Call { | |||
| 260 | + | _c.Call.Return() | |||
| 261 | + | return _c | |||
| 262 | + | } | |||
| 263 | + | ||||
| 264 | + | func (_c *MockIME_Surrounding_Call) RunAndReturn(run func(text string, cursor int, anchor int)) *MockIME_Surrounding_Call { | |||
| 265 | + | _c.Run(run) | |||
| 266 | + | return _c | |||
| 267 | + | } | |||
M internal/edit/edit_test.go +10 -14
| @@ -4,6 +4,8 @@ import ( | |||
| 4 | 4 | "strings" | |
| 5 | 5 | "testing" | |
| 6 | 6 | "unicode/utf8" | |
| 7 | + | ||
| 8 | + | "github.com/stretchr/testify/mock" | |
| 7 | 9 | ) | |
| 8 | 10 | ||
| 9 | 11 | type memoryClipboard struct{ data []byte } | |
| @@ -11,17 +13,6 @@ type memoryClipboard struct{ data []byte } | |||
| 11 | 13 | func (m *memoryClipboard) ReadText(limit int) ([]byte, error) { return m.data, nil } | |
| 12 | 14 | func (m *memoryClipboard) WriteText(v []byte) error { m.data = append([]byte(nil), v...); return nil } | |
| 13 | 15 | ||
| 14 | - | type fakeIME struct { | |
| 15 | - | enabled, disabled int | |
| 16 | - | surrounding string | |
| 17 | - | cursor, anchor int | |
| 18 | - | } | |
| 19 | - | ||
| 20 | - | func (f *fakeIME) Enable() { f.enabled++ } | |
| 21 | - | func (f *fakeIME) Disable() { f.disabled++ } | |
| 22 | - | func (f *fakeIME) Surrounding(v string, c, a int) { f.surrounding = v; f.cursor = c; f.anchor = a } | |
| 23 | - | func (f *fakeIME) CursorRect(x, y, w, h float64) {} | |
| 24 | - | func (f *fakeIME) ContentType(password, multiline bool) {} | |
| 25 | 16 | func TestGraphemesAndIME(t *testing.T) { | |
| 26 | 17 | s := State{} | |
| 27 | 18 | s.Sync("e\u0301👩<U+200D>💻a") | |
| @@ -46,11 +37,16 @@ func TestGraphemesAndIME(t *testing.T) { | |||
| 46 | 37 | if s.Preedit != "候補" || s.Value != "éa" { | |
| 47 | 38 | t.Fatal(s) | |
| 48 | 39 | } | |
| 49 | - | ime := &fakeIME{} | |
| 40 | + | ime := NewMockIME(t) | |
| 41 | + | ime.EXPECT().Enable().Once() | |
| 42 | + | ime.EXPECT().Surrounding("éa", mock.Anything, mock.Anything).Maybe() | |
| 43 | + | ime.EXPECT().CursorRect(mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe() | |
| 44 | + | ime.EXPECT().ContentType(false, false).Once() | |
| 45 | + | ime.EXPECT().Disable().Once() | |
| 50 | 46 | s.Focus(ime, false, false) | |
| 51 | 47 | s.Blur(ime) | |
| 52 | - | if ime.enabled != 1 || ime.disabled != 1 || s.Preedit != "" { | |
| 53 | - | t.Fatal(s, ime) | |
| 48 | + | if s.Preedit != "" { | |
| 49 | + | t.Fatal(s) | |
| 54 | 50 | } | |
| 55 | 51 | } | |
| 56 | 52 | func TestClipboardAndMask(t *testing.T) { | |
| @@ -4,6 +4,8 @@ import ( | |||||
| 4 | "strings" | 4 | "strings" | ||
| 5 | "testing" | 5 | "testing" | ||
| 6 | "unicode/utf8" | 6 | "unicode/utf8" | ||
| 7 | + | ||||
| 8 | + | "github.com/stretchr/testify/mock" | |||
| 7 | ) | 9 | ) | ||
| 8 | 10 | ||||
| 9 | type memoryClipboard struct{ data []byte } | 11 | type memoryClipboard struct{ data []byte } | ||
| @@ -11,17 +13,6 @@ type memoryClipboard struct{ data []byte } | |||||
| 11 | func (m *memoryClipboard) ReadText(limit int) ([]byte, error) { return m.data, nil } | 13 | func (m *memoryClipboard) ReadText(limit int) ([]byte, error) { return m.data, nil } | ||
| 12 | func (m *memoryClipboard) WriteText(v []byte) error { m.data = append([]byte(nil), v...); return nil } | 14 | func (m *memoryClipboard) WriteText(v []byte) error { m.data = append([]byte(nil), v...); return nil } | ||
| 13 | 15 | ||||
| 14 | - | type fakeIME struct { | |||
| 15 | - | enabled, disabled int | |||
| 16 | - | surrounding string | |||
| 17 | - | cursor, anchor int | |||
| 18 | - | } | |||
| 19 | - | ||||
| 20 | - | func (f *fakeIME) Enable() { f.enabled++ } | |||
| 21 | - | func (f *fakeIME) Disable() { f.disabled++ } | |||
| 22 | - | func (f *fakeIME) Surrounding(v string, c, a int) { f.surrounding = v; f.cursor = c; f.anchor = a } | |||
| 23 | - | func (f *fakeIME) CursorRect(x, y, w, h float64) {} | |||
| 24 | - | func (f *fakeIME) ContentType(password, multiline bool) {} | |||
| 25 | func TestGraphemesAndIME(t *testing.T) { | 16 | func TestGraphemesAndIME(t *testing.T) { | ||
| 26 | s := State{} | 17 | s := State{} | ||
| 27 | s.Sync("e\u0301👩<U+200D>💻a") | 18 | s.Sync("e\u0301👩<U+200D>💻a") | ||
| @@ -46,11 +37,16 @@ func TestGraphemesAndIME(t *testing.T) { | |||||
| 46 | if s.Preedit != "候補" || s.Value != "éa" { | 37 | if s.Preedit != "候補" || s.Value != "éa" { | ||
| 47 | t.Fatal(s) | 38 | t.Fatal(s) | ||
| 48 | } | 39 | } | ||
| 49 | - | ime := &fakeIME{} | 40 | + | ime := NewMockIME(t) |
| 41 | + | ime.EXPECT().Enable().Once() | |||
| 42 | + | ime.EXPECT().Surrounding("éa", mock.Anything, mock.Anything).Maybe() | |||
| 43 | + | ime.EXPECT().CursorRect(mock.Anything, mock.Anything, mock.Anything, mock.Anything).Maybe() | |||
| 44 | + | ime.EXPECT().ContentType(false, false).Once() | |||
| 45 | + | ime.EXPECT().Disable().Once() | |||
| 50 | s.Focus(ime, false, false) | 46 | s.Focus(ime, false, false) | ||
| 51 | s.Blur(ime) | 47 | s.Blur(ime) | ||
| 52 | - | if ime.enabled != 1 || ime.disabled != 1 || s.Preedit != "" { | 48 | + | if s.Preedit != "" { |
| 53 | - | t.Fatal(s, ime) | 49 | + | t.Fatal(s) |
| 54 | } | 50 | } | ||
| 55 | } | 51 | } | ||
| 56 | func TestClipboardAndMask(t *testing.T) { | 52 | func TestClipboardAndMask(t *testing.T) { | ||
M internal/presentation/session/slot.go +0 -2
| @@ -26,8 +26,6 @@ type Slot struct { | |||
| 26 | 26 | Presented bool // the caller has been told to import this buffer | |
| 27 | 27 | } | |
| 28 | 28 | ||
| 29 | - | func (slot *Slot) closeImage() { slot.Image.Close() } | |
| 30 | - | ||
| 31 | 29 | // beginReady does not change Pool ownership until the previous GPU submission | |
| 32 | 30 | // has completed. An unready available buffer is retried on a bounded wakeup. | |
| 33 | 31 | func beginReady(pool *buffers.Pool, slots map[uint64]*Slot, ready func(*Slot) (bool, error)) (*buffers.Buffer, *Slot, bool, error) { | |
| @@ -26,8 +26,6 @@ type Slot struct { | |||||
| 26 | Presented bool // the caller has been told to import this buffer | 26 | Presented bool // the caller has been told to import this buffer | ||
| 27 | } | 27 | } | ||
| 28 | 28 | ||||
| 29 | - | func (slot *Slot) closeImage() { slot.Image.Close() } | |||
| 30 | - | ||||
| 31 | // beginReady does not change Pool ownership until the previous GPU submission | 29 | // beginReady does not change Pool ownership until the previous GPU submission | ||
| 32 | // has completed. An unready available buffer is retried on a bounded wakeup. | 30 | // has completed. An unready available buffer is retried on a bounded wakeup. | ||
| 33 | func beginReady(pool *buffers.Pool, slots map[uint64]*Slot, ready func(*Slot) (bool, error)) (*buffers.Buffer, *Slot, bool, error) { | 31 | func beginReady(pool *buffers.Pool, slots map[uint64]*Slot, ready func(*Slot) (bool, error)) (*buffers.Buffer, *Slot, bool, error) { | ||
M internal/ui/runtime.go +0 -7
| @@ -237,13 +237,6 @@ func (r *runtime) Build(view func(*Frame)) bool { | |||
| 237 | 237 | return true | |
| 238 | 238 | } | |
| 239 | 239 | ||
| 240 | - | // consumedInput reports whether the last committed build handled input events. | |
| 241 | - | func (r *runtime) consumedInput() bool { | |
| 242 | - | r.mu.Lock() | |
| 243 | - | defer r.mu.Unlock() | |
| 244 | - | return r.consumed | |
| 245 | - | } | |
| 246 | - | ||
| 247 | 240 | // Wait blocks until input/redraw is available or the context is cancelled. | |
| 248 | 241 | func (r *runtime) Wait(ctx context.Context) error { | |
| 249 | 242 | select { | |
| @@ -237,13 +237,6 @@ func (r *runtime) Build(view func(*Frame)) bool { | |||||
| 237 | return true | 237 | return true | ||
| 238 | } | 238 | } | ||
| 239 | 239 | ||||
| 240 | - | // consumedInput reports whether the last committed build handled input events. | |||
| 241 | - | func (r *runtime) consumedInput() bool { | |||
| 242 | - | r.mu.Lock() | |||
| 243 | - | defer r.mu.Unlock() | |||
| 244 | - | return r.consumed | |||
| 245 | - | } | |||
| 246 | - | ||||
| 247 | // Wait blocks until input/redraw is available or the context is cancelled. | 240 | // Wait blocks until input/redraw is available or the context is cancelled. | ||
| 248 | func (r *runtime) Wait(ctx context.Context) error { | 241 | func (r *runtime) Wait(ctx context.Context) error { | ||
| 249 | select { | 242 | select { | ||