fusuma 2.0.0.pre → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +50 -11
  3. data/fusuma.gemspec +5 -6
  4. data/lib/fusuma.rb +87 -33
  5. data/lib/fusuma/config.rb +33 -40
  6. data/lib/fusuma/config/index.rb +34 -8
  7. data/lib/fusuma/config/searcher.rb +80 -4
  8. data/lib/fusuma/custom_process.rb +13 -0
  9. data/lib/fusuma/device.rb +19 -6
  10. data/lib/fusuma/environment.rb +4 -3
  11. data/lib/fusuma/hash_support.rb +40 -0
  12. data/lib/fusuma/libinput_command.rb +10 -15
  13. data/lib/fusuma/multi_logger.rb +2 -6
  14. data/lib/fusuma/plugin/base.rb +18 -15
  15. data/lib/fusuma/plugin/buffers/buffer.rb +3 -2
  16. data/lib/fusuma/plugin/buffers/gesture_buffer.rb +34 -25
  17. data/lib/fusuma/plugin/buffers/timer_buffer.rb +3 -3
  18. data/lib/fusuma/plugin/detectors/detector.rb +26 -5
  19. data/lib/fusuma/plugin/detectors/pinch_detector.rb +109 -58
  20. data/lib/fusuma/plugin/detectors/rotate_detector.rb +91 -50
  21. data/lib/fusuma/plugin/detectors/swipe_detector.rb +93 -56
  22. data/lib/fusuma/plugin/events/event.rb +5 -4
  23. data/lib/fusuma/plugin/events/records/context_record.rb +27 -0
  24. data/lib/fusuma/plugin/events/records/gesture_record.rb +9 -6
  25. data/lib/fusuma/plugin/events/records/index_record.rb +46 -14
  26. data/lib/fusuma/plugin/events/records/record.rb +1 -1
  27. data/lib/fusuma/plugin/events/records/text_record.rb +2 -1
  28. data/lib/fusuma/plugin/executors/command_executor.rb +21 -4
  29. data/lib/fusuma/plugin/executors/executor.rb +45 -3
  30. data/lib/fusuma/plugin/filters/filter.rb +1 -1
  31. data/lib/fusuma/plugin/filters/libinput_device_filter.rb +6 -7
  32. data/lib/fusuma/plugin/filters/libinput_timeout_filter.rb +2 -2
  33. data/lib/fusuma/plugin/inputs/input.rb +20 -7
  34. data/lib/fusuma/plugin/inputs/libinput_command_input.rb +17 -5
  35. data/lib/fusuma/plugin/inputs/timer_input.rb +7 -7
  36. data/lib/fusuma/plugin/manager.rb +22 -29
  37. data/lib/fusuma/plugin/parsers/libinput_gesture_parser.rb +10 -8
  38. data/lib/fusuma/plugin/parsers/parser.rb +8 -9
  39. data/lib/fusuma/string_support.rb +16 -0
  40. data/lib/fusuma/version.rb +1 -1
  41. data/spec/helpers/config_helper.rb +20 -0
  42. data/spec/lib/config/searcher_spec.rb +97 -0
  43. data/spec/lib/config_spec.rb +112 -0
  44. data/spec/lib/custom_process_spec.rb +28 -0
  45. data/spec/lib/device_spec.rb +96 -0
  46. data/spec/lib/dummy_config.yml +31 -0
  47. data/spec/lib/fusuma_spec.rb +103 -0
  48. data/spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt +181 -0
  49. data/spec/lib/libinput-list-devices_magic_trackpad.txt +51 -0
  50. data/spec/lib/libinput-list-devices_razer_razer_blade.txt +252 -0
  51. data/spec/lib/libinput-list-devices_thejinx0r.txt +361 -0
  52. data/spec/lib/libinput-list-devices_unavailable.txt +36 -0
  53. data/spec/lib/libinput_command_spec.rb +160 -0
  54. data/spec/lib/plugin/base_spec.rb +74 -0
  55. data/spec/lib/plugin/buffers/buffer_spec.rb +80 -0
  56. data/spec/lib/plugin/buffers/dummy_buffer.rb +20 -0
  57. data/spec/lib/plugin/buffers/gesture_buffer_spec.rb +172 -0
  58. data/spec/lib/plugin/detectors/detector_spec.rb +43 -0
  59. data/spec/lib/plugin/detectors/dummy_detector.rb +24 -0
  60. data/spec/lib/plugin/detectors/pinch_detector_spec.rb +119 -0
  61. data/spec/lib/plugin/detectors/rotate_detector_spec.rb +125 -0
  62. data/spec/lib/plugin/detectors/swipe_detector_spec.rb +118 -0
  63. data/spec/lib/plugin/events/event_spec.rb +30 -0
  64. data/spec/lib/plugin/events/records/gesture_record_spec.rb +22 -0
  65. data/spec/lib/plugin/events/records/record_spec.rb +31 -0
  66. data/spec/lib/plugin/events/records/text_record_spec.rb +26 -0
  67. data/spec/lib/plugin/executors/command_executor_spec.rb +57 -0
  68. data/spec/lib/plugin/executors/executor_spec.rb +160 -0
  69. data/spec/lib/plugin/filters/filter_spec.rb +92 -0
  70. data/spec/lib/plugin/filters/libinput_filter_spec.rb +120 -0
  71. data/spec/lib/plugin/inputs/input_spec.rb +70 -0
  72. data/spec/lib/plugin/inputs/libinput_command_input_spec.rb +121 -0
  73. data/spec/lib/plugin/inputs/timer_input_spec.rb +40 -0
  74. data/spec/lib/plugin/manager_spec.rb +27 -0
  75. data/spec/lib/plugin/parsers/parser_spec.rb +45 -0
  76. data/spec/spec_helper.rb +20 -0
  77. metadata +84 -38
  78. data/.github/FUNDING.yml +0 -8
  79. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -32
  80. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  81. data/.github/pull_request_template.md +0 -9
  82. data/.github/stale.yml +0 -18
  83. data/.gitignore +0 -17
  84. data/.reek.yml +0 -96
  85. data/.rspec +0 -2
  86. data/.rubocop.yml +0 -40
  87. data/.rubocop_todo.yml +0 -40
  88. data/.travis.yml +0 -11
  89. data/CHANGELOG.md +0 -456
  90. data/CODE_OF_CONDUCT.md +0 -74
  91. data/CONTRIBUTING.md +0 -72
  92. data/Gemfile +0 -18
  93. data/Rakefile +0 -15
@@ -0,0 +1,361 @@
1
+ event7 - HTX USB HID Device HTX HID Device Touchpad: kernel bug: clickpad advertising right button
2
+ Device: Power Button
3
+ Kernel: /dev/input/event1
4
+ Group: 1
5
+ Seat: seat0, default
6
+ Capabilities: keyboard
7
+ Tap-to-click: n/a
8
+ Tap-and-drag: n/a
9
+ Tap drag lock: n/a
10
+ Left-handed: n/a
11
+ Nat.scrolling: n/a
12
+ Middle emulation: n/a
13
+ Calibration: n/a
14
+ Scroll methods: none
15
+ Click methods: none
16
+ Disable-w-typing: n/a
17
+ Accel profiles: n/a
18
+ Rotation: n/a
19
+
20
+ Device: HTX USB HID Device HTX HID Device Keyboard
21
+ Kernel: /dev/input/event4
22
+ Group: 2
23
+ Seat: seat0, default
24
+ Capabilities: keyboard
25
+ Tap-to-click: n/a
26
+ Tap-and-drag: n/a
27
+ Tap drag lock: n/a
28
+ Left-handed: n/a
29
+ Nat.scrolling: n/a
30
+ Middle emulation: n/a
31
+ Calibration: n/a
32
+ Scroll methods: none
33
+ Click methods: none
34
+ Disable-w-typing: n/a
35
+ Accel profiles: n/a
36
+ Rotation: n/a
37
+
38
+ Device: HTX USB HID Device HTX HID Device Consumer Control
39
+ Kernel: /dev/input/event5
40
+ Group: 2
41
+ Seat: seat0, default
42
+ Capabilities: keyboard pointer
43
+ Tap-to-click: n/a
44
+ Tap-and-drag: n/a
45
+ Tap drag lock: n/a
46
+ Left-handed: n/a
47
+ Nat.scrolling: disabled
48
+ Middle emulation: n/a
49
+ Calibration: n/a
50
+ Scroll methods: none
51
+ Click methods: none
52
+ Disable-w-typing: n/a
53
+ Accel profiles: n/a
54
+ Rotation: n/a
55
+
56
+ Device: HTX USB HID Device HTX HID Device Touchpad
57
+ Kernel: /dev/input/event7
58
+ Group: 2
59
+ Seat: seat0, default
60
+ Size: 114x86mm
61
+ Capabilities: pointer gesture
62
+ Tap-to-click: disabled
63
+ Tap-and-drag: enabled
64
+ Tap drag lock: disabled
65
+ Left-handed: disabled
66
+ Nat.scrolling: disabled
67
+ Middle emulation: disabled
68
+ Calibration: n/a
69
+ Scroll methods: *two-finger edge
70
+ Click methods: *button-areas clickfinger
71
+ Disable-w-typing: enabled
72
+ Accel profiles: none
73
+ Rotation: n/a
74
+
75
+ Device: SINO WEALTH Gaming KB
76
+ Kernel: /dev/input/event9
77
+ Group: 3
78
+ Seat: seat0, default
79
+ Capabilities: keyboard
80
+ Tap-to-click: n/a
81
+ Tap-and-drag: n/a
82
+ Tap drag lock: n/a
83
+ Left-handed: n/a
84
+ Nat.scrolling: n/a
85
+ Middle emulation: n/a
86
+ Calibration: n/a
87
+ Scroll methods: none
88
+ Click methods: none
89
+ Disable-w-typing: n/a
90
+ Accel profiles: n/a
91
+ Rotation: n/a
92
+
93
+ Device: SINO WEALTH Gaming KB System Control
94
+ Kernel: /dev/input/event10
95
+ Group: 3
96
+ Seat: seat0, default
97
+ Capabilities: keyboard
98
+ Tap-to-click: n/a
99
+ Tap-and-drag: n/a
100
+ Tap drag lock: n/a
101
+ Left-handed: n/a
102
+ Nat.scrolling: n/a
103
+ Middle emulation: n/a
104
+ Calibration: n/a
105
+ Scroll methods: none
106
+ Click methods: none
107
+ Disable-w-typing: n/a
108
+ Accel profiles: n/a
109
+ Rotation: n/a
110
+
111
+ Device: SINO WEALTH Gaming KB Consumer Control
112
+ Kernel: /dev/input/event11
113
+ Group: 3
114
+ Seat: seat0, default
115
+ Capabilities: keyboard pointer
116
+ Tap-to-click: n/a
117
+ Tap-and-drag: n/a
118
+ Tap drag lock: n/a
119
+ Left-handed: n/a
120
+ Nat.scrolling: disabled
121
+ Middle emulation: n/a
122
+ Calibration: n/a
123
+ Scroll methods: none
124
+ Click methods: none
125
+ Disable-w-typing: n/a
126
+ Accel profiles: n/a
127
+ Rotation: n/a
128
+
129
+ Device: SINO WEALTH Gaming KB Keyboard
130
+ Kernel: /dev/input/event12
131
+ Group: 3
132
+ Seat: seat0, default
133
+ Capabilities: keyboard
134
+ Tap-to-click: n/a
135
+ Tap-and-drag: n/a
136
+ Tap drag lock: n/a
137
+ Left-handed: n/a
138
+ Nat.scrolling: n/a
139
+ Middle emulation: n/a
140
+ Calibration: n/a
141
+ Scroll methods: none
142
+ Click methods: none
143
+ Disable-w-typing: n/a
144
+ Accel profiles: n/a
145
+ Rotation: n/a
146
+
147
+ Device: Yubico YubiKey OTP+FIDO+CCID
148
+ Kernel: /dev/input/event6
149
+ Group: 4
150
+ Seat: seat0, default
151
+ Capabilities: keyboard
152
+ Tap-to-click: n/a
153
+ Tap-and-drag: n/a
154
+ Tap drag lock: n/a
155
+ Left-handed: n/a
156
+ Nat.scrolling: n/a
157
+ Middle emulation: n/a
158
+ Calibration: n/a
159
+ Scroll methods: none
160
+ Click methods: none
161
+ Disable-w-typing: n/a
162
+ Accel profiles: n/a
163
+ Rotation: n/a
164
+
165
+ Device: HDA NVidia HDMI/DP,pcm=3
166
+ Kernel: /dev/input/event13
167
+ Group: 5
168
+ Seat: seat0, default
169
+ Capabilities:
170
+ Tap-to-click: n/a
171
+ Tap-and-drag: n/a
172
+ Tap drag lock: n/a
173
+ Left-handed: n/a
174
+ Nat.scrolling: n/a
175
+ Middle emulation: n/a
176
+ Calibration: n/a
177
+ Scroll methods: none
178
+ Click methods: none
179
+ Disable-w-typing: n/a
180
+ Accel profiles: n/a
181
+ Rotation: n/a
182
+
183
+ Device: HDA NVidia HDMI/DP,pcm=7
184
+ Kernel: /dev/input/event14
185
+ Group: 5
186
+ Seat: seat0, default
187
+ Capabilities:
188
+ Tap-to-click: n/a
189
+ Tap-and-drag: n/a
190
+ Tap drag lock: n/a
191
+ Left-handed: n/a
192
+ Nat.scrolling: n/a
193
+ Middle emulation: n/a
194
+ Calibration: n/a
195
+ Scroll methods: none
196
+ Click methods: none
197
+ Disable-w-typing: n/a
198
+ Accel profiles: n/a
199
+ Rotation: n/a
200
+
201
+ Device: HDA NVidia HDMI/DP,pcm=8
202
+ Kernel: /dev/input/event15
203
+ Group: 5
204
+ Seat: seat0, default
205
+ Capabilities:
206
+ Tap-to-click: n/a
207
+ Tap-and-drag: n/a
208
+ Tap drag lock: n/a
209
+ Left-handed: n/a
210
+ Nat.scrolling: n/a
211
+ Middle emulation: n/a
212
+ Calibration: n/a
213
+ Scroll methods: none
214
+ Click methods: none
215
+ Disable-w-typing: n/a
216
+ Accel profiles: n/a
217
+ Rotation: n/a
218
+
219
+ Device: HDA NVidia HDMI/DP,pcm=9
220
+ Kernel: /dev/input/event16
221
+ Group: 5
222
+ Seat: seat0, default
223
+ Capabilities:
224
+ Tap-to-click: n/a
225
+ Tap-and-drag: n/a
226
+ Tap drag lock: n/a
227
+ Left-handed: n/a
228
+ Nat.scrolling: n/a
229
+ Middle emulation: n/a
230
+ Calibration: n/a
231
+ Scroll methods: none
232
+ Click methods: none
233
+ Disable-w-typing: n/a
234
+ Accel profiles: n/a
235
+ Rotation: n/a
236
+
237
+ Device: HDA NVidia HDMI/DP,pcm=3
238
+ Kernel: /dev/input/event17
239
+ Group: 5
240
+ Seat: seat0, default
241
+ Capabilities:
242
+ Tap-to-click: n/a
243
+ Tap-and-drag: n/a
244
+ Tap drag lock: n/a
245
+ Left-handed: n/a
246
+ Nat.scrolling: n/a
247
+ Middle emulation: n/a
248
+ Calibration: n/a
249
+ Scroll methods: none
250
+ Click methods: none
251
+ Disable-w-typing: n/a
252
+ Accel profiles: n/a
253
+ Rotation: n/a
254
+
255
+ Device: HDA NVidia HDMI/DP,pcm=7
256
+ Kernel: /dev/input/event18
257
+ Group: 5
258
+ Seat: seat0, default
259
+ Capabilities:
260
+ Tap-to-click: n/a
261
+ Tap-and-drag: n/a
262
+ Tap drag lock: n/a
263
+ Left-handed: n/a
264
+ Nat.scrolling: n/a
265
+ Middle emulation: n/a
266
+ Calibration: n/a
267
+ Scroll methods: none
268
+ Click methods: none
269
+ Disable-w-typing: n/a
270
+ Accel profiles: n/a
271
+ Rotation: n/a
272
+
273
+ Device: HDA NVidia HDMI/DP,pcm=8
274
+ Kernel: /dev/input/event19
275
+ Group: 5
276
+ Seat: seat0, default
277
+ Capabilities:
278
+ Tap-to-click: n/a
279
+ Tap-and-drag: n/a
280
+ Tap drag lock: n/a
281
+ Left-handed: n/a
282
+ Nat.scrolling: n/a
283
+ Middle emulation: n/a
284
+ Calibration: n/a
285
+ Scroll methods: none
286
+ Click methods: none
287
+ Disable-w-typing: n/a
288
+ Accel profiles: n/a
289
+ Rotation: n/a
290
+
291
+ Device: HDA NVidia HDMI/DP,pcm=9
292
+ Kernel: /dev/input/event20
293
+ Group: 5
294
+ Seat: seat0, default
295
+ Capabilities:
296
+ Tap-to-click: n/a
297
+ Tap-and-drag: n/a
298
+ Tap drag lock: n/a
299
+ Left-handed: n/a
300
+ Nat.scrolling: n/a
301
+ Middle emulation: n/a
302
+ Calibration: n/a
303
+ Scroll methods: none
304
+ Click methods: none
305
+ Disable-w-typing: n/a
306
+ Accel profiles: n/a
307
+ Rotation: n/a
308
+
309
+ Device: QEMU QEMU USB Tablet
310
+ Kernel: /dev/input/event2
311
+ Group: 6
312
+ Seat: seat0, default
313
+ Capabilities: pointer
314
+ Tap-to-click: n/a
315
+ Tap-and-drag: n/a
316
+ Tap drag lock: n/a
317
+ Left-handed: disabled
318
+ Nat.scrolling: disabled
319
+ Middle emulation: disabled
320
+ Calibration: identity matrix
321
+ Scroll methods: none
322
+ Click methods: none
323
+ Disable-w-typing: n/a
324
+ Accel profiles: n/a
325
+ Rotation: n/a
326
+
327
+ Device: AT Translated Set 2 keyboard
328
+ Kernel: /dev/input/event0
329
+ Group: 7
330
+ Seat: seat0, default
331
+ Capabilities: keyboard
332
+ Tap-to-click: n/a
333
+ Tap-and-drag: n/a
334
+ Tap drag lock: n/a
335
+ Left-handed: n/a
336
+ Nat.scrolling: n/a
337
+ Middle emulation: n/a
338
+ Calibration: n/a
339
+ Scroll methods: none
340
+ Click methods: none
341
+ Disable-w-typing: n/a
342
+ Accel profiles: n/a
343
+ Rotation: n/a
344
+
345
+ Device: ImExPS/2 Generic Explorer Mouse
346
+ Kernel: /dev/input/event3
347
+ Group: 8
348
+ Seat: seat0, default
349
+ Capabilities: pointer
350
+ Tap-to-click: n/a
351
+ Tap-and-drag: n/a
352
+ Tap drag lock: n/a
353
+ Left-handed: disabled
354
+ Nat.scrolling: disabled
355
+ Middle emulation: disabled
356
+ Calibration: n/a
357
+ Scroll methods: button
358
+ Click methods: none
359
+ Disable-w-typing: n/a
360
+ Accel profiles: flat *adaptive
361
+ Rotation: n/a
@@ -0,0 +1,36 @@
1
+ Device: AT Translated Set 2 keyboard
2
+ Kernel: /dev/input/event4
3
+ Group: 9
4
+ Seat: seat0, default
5
+ Capabilities: keyboard
6
+ Tap-to-click: n/a
7
+ Tap-and-drag: n/a
8
+ Tap drag lock: n/a
9
+ Left-handed: n/a
10
+ Nat.scrolling: n/a
11
+ Middle emulation: n/a
12
+ Calibration: n/a
13
+ Scroll methods: none
14
+ Click methods: none
15
+ Disable-w-typing: n/a
16
+ Accel profiles: n/a
17
+ Rotation: n/a
18
+
19
+ Device: Dell WMI hotkeys
20
+ Kernel: /dev/input/event9
21
+ Group: 10
22
+ Seat: seat0, default
23
+ Capabilities: keyboard
24
+ Tap-to-click: n/a
25
+ Tap-and-drag: n/a
26
+ Tap drag lock: n/a
27
+ Left-handed: n/a
28
+ Nat.scrolling: n/a
29
+ Middle emulation: n/a
30
+ Calibration: n/a
31
+ Scroll methods: none
32
+ Click methods: none
33
+ Disable-w-typing: n/a
34
+ Accel profiles: n/a
35
+ Rotation: n/a
36
+
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require './lib/fusuma/libinput_command'
5
+
6
+ module Fusuma
7
+ RSpec.describe LibinputCommand do
8
+ let(:libinput_command) { described_class.new(libinput_options: libinput_options, commands: commands) }
9
+ let(:libinput_options) { [] }
10
+ let(:commands) { {} }
11
+ describe '#version' do
12
+ subject { libinput_command.version }
13
+
14
+ context 'when libinput-list-device is available' do
15
+ before do
16
+ allow(libinput_command).to receive('which')
17
+ .with('libinput') { false }
18
+ allow(libinput_command).to receive('which')
19
+ .with('libinput-list-devices') { true }
20
+ allow_any_instance_of(Kernel).to receive(:`)
21
+ .with('libinput-list-devices --version') { "1.6.3\n" }
22
+ end
23
+
24
+ it { is_expected.to eq '1.6.3' }
25
+ it { expect(libinput_command.new_cli_option_available?).to be false }
26
+ end
27
+
28
+ context 'when libinput is available' do
29
+ before do
30
+ allow(libinput_command).to receive('which')
31
+ .with('libinput') { true }
32
+ allow(libinput_command).to receive('which')
33
+ .with('libinput-list-devices') { false }
34
+ allow_any_instance_of(Kernel).to receive(:`)
35
+ .with('libinput --version') { "1.8\n" }
36
+ end
37
+
38
+ it { is_expected.to eq '1.8' }
39
+ it { expect(libinput_command.new_cli_option_available?).to be true }
40
+ end
41
+
42
+ context 'when libinput command is not found' do
43
+ before do
44
+ allow(libinput_command).to receive('which')
45
+ .with('libinput') { false }
46
+ allow(libinput_command).to receive('which')
47
+ .with('libinput-list-devices') { false }
48
+ end
49
+
50
+ it 'shold print error and exit 1' do
51
+ expect(MultiLogger).to receive(:error)
52
+ expect { subject }.to raise_error(SystemExit)
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#new_cli_option_available?' do
58
+ subject { libinput_command.new_cli_option_available? }
59
+ context 'with NEW_CLI_OPTION_VERSION' do
60
+ before do
61
+ allow(libinput_command).to receive(:version)
62
+ .and_return(LibinputCommand::NEW_CLI_OPTION_VERSION)
63
+ end
64
+ it { is_expected.to eq true }
65
+ end
66
+ context 'without NEW_CLI_OPTION_VERSION' do
67
+ before do
68
+ allow(libinput_command).to receive(:version)
69
+ .and_return(LibinputCommand::NEW_CLI_OPTION_VERSION - 0.1)
70
+ end
71
+ it { is_expected.to eq false }
72
+ end
73
+ end
74
+
75
+ describe 'list_devices' do
76
+ subject { libinput_command.list_devices }
77
+ after { subject }
78
+
79
+ before do
80
+ dummy_io = StringIO.new('dummy')
81
+ io = StringIO.new('dummy output')
82
+ allow(Open3).to receive(:popen3).with(anything).and_return([dummy_io, io, dummy_io, dummy_io, nil])
83
+ end
84
+
85
+ context 'with the alternative command' do
86
+ let(:commands) { { list_devices_command: 'dummy_list_devices' } }
87
+
88
+ it 'should call dummy events' do
89
+ expect(Open3).to receive(:popen3).with(/dummy_list_devices/)
90
+ end
91
+ end
92
+
93
+ context 'with new cli version' do
94
+ before do
95
+ allow(libinput_command).to receive(:new_cli_option_available?)
96
+ .and_return(true)
97
+ end
98
+
99
+ it 'call `libinput list-devices`' do
100
+ command = 'libinput list-devices'
101
+ expect(Open3).to receive(:popen3)
102
+ .with(command)
103
+ end
104
+ end
105
+ context 'with old cli version' do
106
+ before do
107
+ allow(libinput_command).to receive(:new_cli_option_available?)
108
+ .and_return(false)
109
+ end
110
+
111
+ it 'call `libinput-list-devices`' do
112
+ command = 'libinput-list-devices'
113
+ expect(Open3).to receive(:popen3)
114
+ .with(command)
115
+ end
116
+ end
117
+ end
118
+
119
+ describe 'debug_events' do
120
+ before do
121
+ @dummy_io = StringIO.new('dummy')
122
+ allow(Process).to receive(:spawn).with(anything).and_return(0)
123
+ end
124
+ subject { libinput_command.debug_events(@dummy_io) }
125
+
126
+ context 'with the alternative command' do
127
+ before do
128
+ allow(libinput_command).to receive(:debug_events_with_options).and_return 'dummy_debug_events'
129
+ end
130
+
131
+ it 'should call dummy events' do
132
+ expect(Process).to receive(:spawn).with('dummy_debug_events', { out: @dummy_io, in: '/dev/null' }).once
133
+ subject
134
+ end
135
+ end
136
+ end
137
+
138
+ describe '#debug_events_with_options' do
139
+ subject { libinput_command.debug_events_with_options }
140
+
141
+ context 'with new cli version' do
142
+ before do
143
+ allow(libinput_command)
144
+ .to receive(:new_cli_option_available?)
145
+ .and_return(true)
146
+ end
147
+ it { is_expected.to eq 'stdbuf -oL -- libinput debug-events' }
148
+ end
149
+
150
+ context 'with old cli version' do
151
+ before do
152
+ allow(libinput_command)
153
+ .to receive(:new_cli_option_available?)
154
+ .and_return(false)
155
+ end
156
+ it { is_expected.to eq 'stdbuf -oL -- libinput-debug-events' }
157
+ end
158
+ end
159
+ end
160
+ end