fusuma 2.4.1 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -0
  3. data/bin/console +2 -2
  4. data/fusuma.gemspec +17 -18
  5. data/lib/fusuma/config/index.rb +17 -17
  6. data/lib/fusuma/config/searcher.rb +1 -1
  7. data/lib/fusuma/config/yaml_duplication_checker.rb +7 -7
  8. data/lib/fusuma/config.rb +17 -13
  9. data/lib/fusuma/device.rb +12 -12
  10. data/lib/fusuma/environment.rb +10 -10
  11. data/lib/fusuma/hash_support.rb +1 -1
  12. data/lib/fusuma/libinput_command.rb +18 -19
  13. data/lib/fusuma/multi_logger.rb +4 -4
  14. data/lib/fusuma/plugin/base.rb +6 -6
  15. data/lib/fusuma/plugin/buffers/buffer.rb +5 -4
  16. data/lib/fusuma/plugin/buffers/gesture_buffer.rb +6 -6
  17. data/lib/fusuma/plugin/buffers/timer_buffer.rb +2 -2
  18. data/lib/fusuma/plugin/detectors/detector.rb +5 -5
  19. data/lib/fusuma/plugin/detectors/hold_detector.rb +29 -29
  20. data/lib/fusuma/plugin/detectors/pinch_detector.rb +47 -47
  21. data/lib/fusuma/plugin/detectors/rotate_detector.rb +40 -40
  22. data/lib/fusuma/plugin/detectors/swipe_detector.rb +43 -43
  23. data/lib/fusuma/plugin/events/event.rb +11 -11
  24. data/lib/fusuma/plugin/events/records/gesture_record.rb +5 -5
  25. data/lib/fusuma/plugin/events/records/index_record.rb +5 -5
  26. data/lib/fusuma/plugin/events/records/record.rb +2 -2
  27. data/lib/fusuma/plugin/events/records/text_record.rb +1 -1
  28. data/lib/fusuma/plugin/executors/command_executor.rb +4 -4
  29. data/lib/fusuma/plugin/executors/executor.rb +3 -3
  30. data/lib/fusuma/plugin/filters/filter.rb +3 -3
  31. data/lib/fusuma/plugin/filters/libinput_device_filter.rb +12 -12
  32. data/lib/fusuma/plugin/inputs/input.rb +8 -8
  33. data/lib/fusuma/plugin/inputs/libinput_command_input.rb +13 -13
  34. data/lib/fusuma/plugin/inputs/timer_input.rb +3 -3
  35. data/lib/fusuma/plugin/manager.rb +58 -31
  36. data/lib/fusuma/plugin/parsers/libinput_gesture_parser.rb +10 -10
  37. data/lib/fusuma/plugin/parsers/parser.rb +3 -3
  38. data/lib/fusuma/string_support.rb +3 -3
  39. data/lib/fusuma/version.rb +1 -1
  40. data/lib/fusuma.rb +10 -10
  41. metadata +3 -79
  42. data/spec/helpers/config_helper.rb +0 -20
  43. data/spec/lib/config/searcher_spec.rb +0 -179
  44. data/spec/lib/config_spec.rb +0 -104
  45. data/spec/lib/custom_process_spec.rb +0 -29
  46. data/spec/lib/device_spec.rb +0 -96
  47. data/spec/lib/dummy_config.yml +0 -31
  48. data/spec/lib/fusuma_spec.rb +0 -103
  49. data/spec/lib/libinput-list-devices_iberianpig-XPS-9360.txt +0 -181
  50. data/spec/lib/libinput-list-devices_magic_trackpad.txt +0 -51
  51. data/spec/lib/libinput-list-devices_razer_razer_blade.txt +0 -252
  52. data/spec/lib/libinput-list-devices_thejinx0r.txt +0 -361
  53. data/spec/lib/libinput-list-devices_unavailable.txt +0 -36
  54. data/spec/lib/libinput_command_spec.rb +0 -164
  55. data/spec/lib/plugin/base_spec.rb +0 -74
  56. data/spec/lib/plugin/buffers/buffer_spec.rb +0 -80
  57. data/spec/lib/plugin/buffers/dummy_buffer.rb +0 -20
  58. data/spec/lib/plugin/buffers/gesture_buffer_spec.rb +0 -192
  59. data/spec/lib/plugin/detectors/detector_spec.rb +0 -43
  60. data/spec/lib/plugin/detectors/dummy_detector.rb +0 -24
  61. data/spec/lib/plugin/detectors/hold_detector_spec.rb +0 -145
  62. data/spec/lib/plugin/detectors/pinch_detector_spec.rb +0 -119
  63. data/spec/lib/plugin/detectors/rotate_detector_spec.rb +0 -125
  64. data/spec/lib/plugin/detectors/swipe_detector_spec.rb +0 -118
  65. data/spec/lib/plugin/events/event_spec.rb +0 -30
  66. data/spec/lib/plugin/events/records/gesture_record_spec.rb +0 -22
  67. data/spec/lib/plugin/events/records/record_spec.rb +0 -31
  68. data/spec/lib/plugin/events/records/text_record_spec.rb +0 -26
  69. data/spec/lib/plugin/executors/command_executor_spec.rb +0 -57
  70. data/spec/lib/plugin/executors/executor_spec.rb +0 -164
  71. data/spec/lib/plugin/filters/filter_spec.rb +0 -92
  72. data/spec/lib/plugin/filters/libinput_filter_spec.rb +0 -120
  73. data/spec/lib/plugin/inputs/input_spec.rb +0 -70
  74. data/spec/lib/plugin/inputs/libinput_command_input_spec.rb +0 -121
  75. data/spec/lib/plugin/inputs/timer_input_spec.rb +0 -40
  76. data/spec/lib/plugin/manager_spec.rb +0 -27
  77. data/spec/lib/plugin/parsers/libinput_gesture_parser_spec.rb +0 -76
  78. data/spec/lib/plugin/parsers/parser_spec.rb +0 -45
  79. data/spec/spec_helper.rb +0 -23
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- require './lib/fusuma/plugin/detectors/swipe_detector'
6
- require './lib/fusuma/plugin/buffers/gesture_buffer'
7
- require './lib/fusuma/plugin/events/records/gesture_record'
8
- require './lib/fusuma/config'
9
-
10
- module Fusuma
11
- module Plugin
12
- module Detectors
13
- RSpec.describe SwipeDetector do
14
- before do
15
- @detector = SwipeDetector.new
16
- @buffer = Buffers::GestureBuffer.new
17
- end
18
-
19
- around do |example|
20
- ConfigHelper.load_config_yml = <<~CONFIG
21
- threshold:
22
- swipe: 1
23
- CONFIG
24
-
25
- example.run
26
-
27
- Config.custom_path = nil
28
- end
29
-
30
- describe '#detect' do
31
- context 'with no swipe event in buffer' do
32
- before do
33
- @buffer.clear
34
- end
35
- it { expect(@detector.detect([@buffer])).to eq nil }
36
- end
37
-
38
- context 'with not enough swipe events in buffer' do
39
- before do
40
- deltas = [
41
- Events::Records::GestureRecord::Delta.new(0, 0, 0, 0, 0, 0), # begin
42
- Events::Records::GestureRecord::Delta.new(20, 0, 0, 0, 0, 0) # update
43
- ]
44
- events = create_events(deltas: deltas)
45
-
46
- events.each { |event| @buffer.buffer(event) }
47
- end
48
- it 'should have repeat record' do
49
- event = @detector.detect([@buffer])
50
- expect(event.record.trigger).to eq :repeat
51
- end
52
- end
53
-
54
- context 'with enough swipe RIGHT event' do
55
- before do
56
- deltas = [
57
- Events::Records::GestureRecord::Delta.new(0, 0, 0, 0, 0, 0), # begin
58
- Events::Records::GestureRecord::Delta.new(0, 0, 0, 0, 0, 0), # update
59
- Events::Records::GestureRecord::Delta.new(31, 0, 0, 0, 0, 0) # update
60
- ]
61
- events = create_events(deltas: deltas)
62
-
63
- events.each { |event| @buffer.buffer(event) }
64
- end
65
- it { expect(@detector.detect([@buffer])).to all be_a Events::Event }
66
- it { expect(@detector.detect([@buffer]).map(&:record)).to all be_a Events::Records::IndexRecord }
67
- it { expect(@detector.detect([@buffer]).map(&:record).map(&:index)).to all be_a Config::Index }
68
- it 'should detect 3 fingers swipe-right' do
69
- events = @detector.detect([@buffer])
70
- expect(events[0].record.index.keys.map(&:symbol))
71
- .to eq([:swipe, 3, :right])
72
- expect(events[1].record.index.keys.map(&:symbol))
73
- .to eq([:swipe, 3, :right, :update])
74
- end
75
- end
76
-
77
- context 'with enough swipe DOWN event' do
78
- before do
79
- deltas = [
80
- Events::Records::GestureRecord::Delta.new(0, 0, 0, 0),
81
- Events::Records::GestureRecord::Delta.new(0, 0, 0, 0),
82
- Events::Records::GestureRecord::Delta.new(0, 31, 0, 0)
83
- ]
84
- events = create_events(deltas: deltas)
85
-
86
- events.each { |event| @buffer.buffer(event) }
87
- end
88
- it 'should detect 3 fingers swipe-down' do
89
- events = @detector.detect([@buffer])
90
- expect(events[0].record.index.keys.map(&:symbol))
91
- .to eq([:swipe, 3, :down])
92
- expect(events[1].record.index.keys.map(&:symbol))
93
- .to eq([:swipe, 3, :down, :update])
94
- end
95
- end
96
- end
97
-
98
- private
99
-
100
- def create_events(deltas: [])
101
- record_type = SwipeDetector::GESTURE_RECORD_TYPE
102
- deltas.map do |delta|
103
- status = if deltas[0].equal? delta
104
- 'begin'
105
- else
106
- 'update'
107
- end
108
- gesture_record = Events::Records::GestureRecord.new(status: status,
109
- gesture: record_type,
110
- finger: 3,
111
- delta: delta)
112
- Events::Event.new(tag: 'libinput_gesture_parser', record: gesture_record)
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/events/event'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Events
9
- RSpec.describe Event do
10
- let(:event) { Event.new(**args) }
11
- let(:args) { { tag: 'text', record: 'dummy_text' } }
12
-
13
- class DummyRecord < Records::Record
14
- end
15
-
16
- describe '#record' do
17
- context 'with text' do
18
- it { expect(event.record).to be_a Records::Record }
19
- end
20
-
21
- context 'with Record' do
22
- let(:args) { { tag: 'dummy_record', record: DummyRecord.new } }
23
-
24
- it { expect(event.record).to be_a Records::Record }
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/events/records/gesture_record'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Events
9
- module Records
10
- RSpec.describe GestureRecord do
11
- let(:record) do
12
- described_class.new(status: 'updating',
13
- gesture: 'swipe',
14
- finger: 3,
15
- direction: direction)
16
- end
17
- let(:direction) { GestureRecord::Delta.new(0, 0, 1, 0) }
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/events/records/record'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Events
9
- module Records
10
- RSpec.describe Record do
11
- class DummyRecord < Records::Record
12
- def type
13
- :dummy
14
- end
15
- end
16
- let(:record) { described_class.new }
17
-
18
- describe '#type' do
19
- it { expect { record.type }.to raise_error(NotImplementedError) }
20
-
21
- context 'override #type' do
22
- let(:record) { DummyRecord.new }
23
- it { expect { record.type }.not_to raise_error(NotImplementedError) }
24
- it { expect(record.type).to eq :dummy }
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/events/records/text_record'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Events
9
- module Records
10
- RSpec.describe TextRecord do
11
- let(:record) { described_class.new('this is dummy') }
12
-
13
- describe '#type' do
14
- subject { record.type }
15
- it { is_expected.to eq :text }
16
- end
17
-
18
- describe '#to_s' do
19
- subject { record.to_s }
20
- it { is_expected.to eq 'this is dummy' }
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/executors/command_executor'
5
- require './lib/fusuma/plugin/events/event'
6
-
7
- module Fusuma
8
- module Plugin
9
- module Executors
10
- RSpec.describe CommandExecutor do
11
- before do
12
- index = Config::Index.new([:dummy, 1, :direction])
13
- record = Events::Records::IndexRecord.new(index: index)
14
- @event = Events::Event.new(tag: 'dummy_detector', record: record)
15
- @executor = CommandExecutor.new
16
- end
17
-
18
- around do |example|
19
- ConfigHelper.load_config_yml = <<~CONFIG
20
- dummy:
21
- 1:
22
- direction:
23
- command: 'echo dummy'
24
- interval: 1
25
- CONFIG
26
-
27
- example.run
28
-
29
- Config.custom_path = nil
30
- end
31
-
32
- describe '#execute' do
33
- it 'spawn' do
34
- command = 'echo dummy'
35
- env = {}
36
- expect(Process).to receive(:spawn).with(env, command)
37
- expect(Process).to receive(:detach).with(anything)
38
- @executor.execute(@event)
39
- end
40
- end
41
-
42
- describe '#executable?' do
43
- context 'detector is matched with config file' do
44
- it { expect(@executor.executable?(@event)).to be_truthy }
45
- end
46
-
47
- context 'detector is NOT matched with config file' do
48
- before do
49
- @event.tag = 'invalid'
50
- end
51
- it { expect(@executor.executable?(@event)).to be_falsey }
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- require './lib/fusuma/config'
6
- require './lib/fusuma/plugin/executors/executor'
7
- require './lib/fusuma/plugin/detectors/detector'
8
- require './lib/fusuma/plugin/events/event'
9
-
10
- module Fusuma
11
- module Plugin
12
- module Executors
13
- RSpec.describe Executor do
14
- before { @executor = Executor.new }
15
-
16
- describe '#execute_key' do
17
- it { expect { @executor.execute_keys }.to raise_error(NotImplementedError) }
18
- end
19
-
20
- describe '#execute' do
21
- it { expect { @executor.execute('dummy') }.to raise_error(NotImplementedError) }
22
- end
23
-
24
- describe '#executable?' do
25
- it { expect { @executor.executable?('dummy') }.to raise_error(NotImplementedError) }
26
- end
27
- end
28
-
29
- class DummyExecutor < Executor
30
- def execute_keys
31
- [:dummy]
32
- end
33
-
34
- def execute(event)
35
- index = Config::Index.new([*event.record.index.keys, :dummy])
36
- content = Config.search(index)
37
-
38
- # stdout
39
- puts content if executable?(event)
40
- end
41
-
42
- def executable?(event)
43
- event.tag == 'dummy'
44
- end
45
- end
46
-
47
- RSpec.describe DummyExecutor do
48
- before do
49
- index = Config::Index.new([:dummy_gesture,
50
- Config::Index::Key.new(:dummy_direction, skippable: true)])
51
- record = Events::Records::IndexRecord.new(index: index)
52
- @event = Events::Event.new(tag: 'dummy', record: record)
53
- @executor = DummyExecutor.new
54
- end
55
-
56
- around do |example|
57
- ConfigHelper.load_config_yml = <<~CONFIG
58
- dummy_gesture:
59
- dummy_direction:
60
- dummy: 'echo dummy'
61
- interval: 0.3
62
-
63
- plugin:
64
- executors:
65
- dummy_executor:
66
- dummy: dummy
67
- CONFIG
68
-
69
- example.run
70
-
71
- Config.custom_path = nil
72
- end
73
-
74
- describe '#execute' do
75
- it { expect { @executor.execute(@event) }.to output("echo dummy\n").to_stdout }
76
- context 'without executable' do
77
- before do
78
- allow(@executor).to receive(:executable?).and_return false
79
- end
80
- it { expect { @executor.execute(@event) }.not_to output("echo dummy\n").to_stdout }
81
- end
82
- end
83
-
84
- describe '#executable?' do
85
- it { expect(@executor.executable?(@event)).to be_truthy }
86
- end
87
-
88
- describe 'interval' do
89
- it 'should return interval from Config' do
90
- interval_time = 0.3 * DummyExecutor::BASE_ONESHOT_INTERVAL
91
- expect(@executor.interval(@event)).to eq interval_time
92
- end
93
-
94
- context 'without skippable direction' do
95
- around do |example|
96
- ConfigHelper.load_config_yml = <<~CONFIG
97
- dummy_gesture:
98
- interval: 0.1
99
- dummy_direction:
100
- dummy: 'echo dummy'
101
-
102
- plugin:
103
- executors:
104
- dummy_executor:
105
- dummy: dummy
106
- CONFIG
107
-
108
- example.run
109
-
110
- Config.custom_path = nil
111
- end
112
- it 'should not return parent interval' do
113
- expect(@executor.interval(@event)).to eq DummyExecutor::BASE_ONESHOT_INTERVAL
114
- expect(@executor.interval(@event)).not_to eq 0.1 * DummyExecutor::BASE_ONESHOT_INTERVAL
115
- end
116
-
117
- context 'with Config::Searcher.skip' do
118
- it 'should return parent interval' do
119
- Config::Searcher.skip do
120
- expect(@executor.interval(@event)).to eq 0.1 * DummyExecutor::BASE_ONESHOT_INTERVAL
121
- end
122
- end
123
- end
124
- end
125
- end
126
-
127
- describe 'enough_interval?' do
128
- it 'should return true at first time' do
129
- expect(@executor.enough_interval?(@event)).to eq true
130
- end
131
-
132
- context 'after update_interval' do
133
- before do
134
- @executor.update_interval(@event)
135
- end
136
- it 'should return false' do
137
- expect(@executor.enough_interval?(@event)).to eq false
138
- end
139
-
140
- context 'after wait interval time' do
141
- before do
142
- # dummy_gesture/dummy_direction/interval => 0.3
143
- interval_time = 0.3 * DummyExecutor::BASE_ONESHOT_INTERVAL
144
-
145
- @event2 = Events::Event.new(
146
- time: @event.time + interval_time,
147
- tag: 'dummy',
148
- record: @event.record
149
- )
150
- end
151
- it 'should return true after wait' do
152
- expect(@executor.enough_interval?(@event2)).to eq true
153
- end
154
- end
155
- end
156
- end
157
-
158
- describe '#config_params' do
159
- it { expect(@executor.config_params).to eq(dummy: 'dummy') }
160
- end
161
- end
162
- end
163
- end
164
- end
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'tempfile'
5
-
6
- require './lib/fusuma/config'
7
- require './lib/fusuma/plugin/filters/filter'
8
- require './lib/fusuma/plugin/events/event'
9
-
10
- module Fusuma
11
- module Plugin
12
- module Filters
13
- class DummyFilter < Filter
14
- DEFAULT_SOURCE = 'dummy_input'
15
-
16
- def config_param_types
17
- {
18
- source: String
19
- }
20
- end
21
- end
22
-
23
- RSpec.describe DummyFilter do
24
- let(:filter) { DummyFilter.new }
25
-
26
- describe '#source' do
27
- subject { filter.source }
28
-
29
- it { is_expected.to eq DummyFilter::DEFAULT_SOURCE }
30
-
31
- context 'with config' do
32
- around do |example|
33
- @custom_source = 'custom_input'
34
-
35
- ConfigHelper.load_config_yml = <<~CONFIG
36
- plugin:
37
- filters:
38
- dummy_filter:
39
- source: #{@custom_source}
40
- CONFIG
41
-
42
- example.run
43
-
44
- Config.custom_path = nil
45
- end
46
-
47
- it { is_expected.to eq @custom_source }
48
- end
49
- end
50
-
51
- describe '#filter' do
52
- subject { filter.filter(event) }
53
- let(:event) { Events::Event.new(tag: 'dummy_input', record: 'dummy') }
54
-
55
- context 'when filter#keep? return false' do
56
- before do
57
- allow(filter).to receive(:keep?).and_return(false)
58
- end
59
-
60
- it { is_expected.to be nil }
61
- end
62
-
63
- context 'when filter#keep? return true' do
64
- before do
65
- allow(filter).to receive(:keep?).and_return(true)
66
- end
67
-
68
- it { is_expected.to be event }
69
- end
70
- end
71
-
72
- describe '#config_params' do
73
- around do |example|
74
- ConfigHelper.load_config_yml = <<~CONFIG
75
- plugin:
76
- filters:
77
- dummy_filter:
78
- dummy: dummy
79
- CONFIG
80
-
81
- example.run
82
-
83
- Config.custom_path = nil
84
- end
85
-
86
- subject { filter.config_params }
87
- it { is_expected.to eq(dummy: 'dummy') }
88
- end
89
- end
90
- end
91
- end
92
- end
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'tempfile'
5
-
6
- require './lib/fusuma/config'
7
- require './lib/fusuma/plugin/filters/libinput_device_filter'
8
- require './lib/fusuma/plugin/events/event'
9
-
10
- module Fusuma
11
- module Plugin
12
- module Filters
13
- RSpec.describe LibinputDeviceFilter do
14
- before do
15
- @filter = LibinputDeviceFilter.new
16
- end
17
-
18
- describe '#source' do
19
- it { expect(@filter.source).to eq LibinputDeviceFilter::DEFAULT_SOURCE }
20
-
21
- context 'with config' do
22
- around do |example|
23
- @custom_source = 'custom_input'
24
-
25
- ConfigHelper.load_config_yml = <<~CONFIG
26
- plugin:
27
- filters:
28
- libinput_device_filter:
29
- source: #{@custom_source}
30
- CONFIG
31
-
32
- example.run
33
-
34
- Config.custom_path = nil
35
- end
36
-
37
- it { expect(@filter.source).to eq @custom_source }
38
- end
39
- end
40
-
41
- describe '#filter' do
42
- before do
43
- @event = Events::Event.new(tag: 'libinput_command_input', record: 'dummy')
44
- end
45
-
46
- context 'when filter#keep? return false' do
47
- before do
48
- allow(@filter).to receive(:keep?).and_return(false)
49
- end
50
-
51
- it { expect(@filter.filter(@event)).to be nil }
52
- end
53
-
54
- context 'when filter#keep? return true' do
55
- before do
56
- allow(@filter).to receive(:keep?).and_return(true)
57
- end
58
-
59
- it { expect(@filter.filter(@event)).to be @event }
60
- end
61
- end
62
-
63
- describe '#keep?' do
64
- before do
65
- device = Device.new(id: 'event18', name: 'Awesome Touchpad', available: true)
66
- allow(Device).to receive(:all).and_return([device])
67
- @keep_device = LibinputDeviceFilter::KeepDevice.new(name_patterns: [])
68
- allow(@filter).to receive(:keep_device).and_return(@keep_device)
69
- end
70
-
71
- context 'when including record generated from touchpad' do
72
- before do
73
- text = ' event18 GESTURE_SWIPE_UPDATE +1.44s 4 11.23/ 1.00 (36.91/ 3.28 unaccelerated) '
74
- @event = Events::Event.new(tag: 'libinput_command_input', record: text)
75
- end
76
- it 'should keep record' do
77
- expect(@filter.keep?(@event.record)).to be true
78
- end
79
-
80
- context 'when including -' do
81
- before do
82
- text = '-event18 GESTURE_SWIPE_UPDATE +1.44s 4 11.23/ 1.00 (36.91/ 3.28 unaccelerated) '
83
- @event = Events::Event.new(tag: 'libinput_command_input', record: text)
84
- end
85
- it 'should keep record' do
86
- expect(@filter.keep?(@event.record)).to be true
87
- end
88
- end
89
- end
90
- context 'when new device is added' do
91
- before do
92
- text = '-event18 DEVICE_ADDED Apple Wireless Trackpad seat0 default group13 cap:pg size 132x112mm tap(dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfing '
93
- @event = Events::Event.new(tag: 'libinput_command_input', record: text)
94
- end
95
- it 'should reset KeepDevice' do
96
- expect(@keep_device).to receive(:reset)
97
- @filter.keep?(@event.record)
98
- end
99
-
100
- it 'discard DEVICE_ADDED record' do
101
- expect(@filter.keep?(@event.record)).to be false
102
- end
103
-
104
- context 'when keep device is NOT matched' do
105
- before do
106
- @keep_device = LibinputDeviceFilter::KeepDevice.new(name_patterns: ['Microsoft Arc Mouse'])
107
- allow(@filter).to receive(:keep_device).and_return(@keep_device)
108
- end
109
- it 'should NOT reset KeepDevice' do
110
- expect(@keep_device).not_to receive(:reset)
111
- # NOTE: @event.record is 'Apple Wireless Touchpad'
112
- @filter.keep?(@event.record)
113
- end
114
- end
115
- end
116
- end
117
- end
118
- end
119
- end
120
- end