|
2 | 2 |
|
3 | 3 | require "spec_helper"
|
4 | 4 | require "./lib/fusuma/plugin/parsers/parser"
|
5 |
| -require "./lib/fusuma/plugin/events/event" |
| 5 | +require "./lib/fusuma/plugin/inputs/input" |
6 | 6 |
|
7 | 7 | module Fusuma
|
8 | 8 | module Plugin
|
@@ -36,39 +36,128 @@ module Parsers
|
36 | 36 | it { expect(parser.parse(event)).to eq event }
|
37 | 37 | end
|
38 | 38 |
|
39 |
| - context "with libinput_command_input event" do |
40 |
| - let(:event) { Events::Event.new(tag: "libinput_command_input", record: record) } |
| 39 | + context "with libinput version 1.27.0 or later" do |
| 40 | + before do |
| 41 | + allow_any_instance_of(LibinputCommand).to receive(:libinput_1_27_0_or_later?).and_return(true) |
| 42 | + end |
| 43 | + |
41 | 44 | context "with swipe gestures" do
|
42 |
| - # event10 GESTURE_SWIPE_BEGIN +0.728s 3 |
43 |
| - # event10 GESTURE_SWIPE_UPDATE +0.948s 3 0.23/ 0.00 ( 0.29/ 0.00 unaccelerated) |
44 |
| - # event10 GESTURE_SWIPE_END +0.989s 3 |
45 |
| - let(:record) { "event10 GESTURE_SWIPE_BEGIN +0.728s 3" } |
46 |
| - it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord } |
47 |
| - it { expect(parser.parse(event).record.status).to eq "begin" } |
| 45 | + before do |
| 46 | + @debug_events = <<~EVENTS |
| 47 | + event4 GESTURE_SWIPE_BEGIN +19.410s 3 |
| 48 | + event4 GESTURE_SWIPE_UPDATE +19.410s 3 19.02/ 1.00 ( 4.17/ 0.22 unaccelerated) |
| 49 | + event4 GESTURE_SWIPE_UPDATE 2 +19.417s 3 21.24/ 0.00 ( 4.61/ 0.00 unaccelerated) |
| 50 | + event4 GESTURE_SWIPE_UPDATE 3 +19.424s 3 6.36/-0.22 ( 6.36/-0.22 unaccelerated) |
| 51 | + event4 GESTURE_SWIPE_END +19.614s 3 |
| 52 | + EVENTS |
| 53 | + .split("\n") |
| 54 | + end |
| 55 | + |
| 56 | + let(:event) { |
| 57 | + -> { |
| 58 | + record = @debug_events.shift |
| 59 | + Events::Event.new(tag: "libinput_command_input", record: record) |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + it "has a gesture record" do |
| 64 | + expect(parser.parse(event.call).record).to be_a Events::Records::GestureRecord |
| 65 | + end |
| 66 | + |
| 67 | + it "has a gesture record that it has a status" do |
| 68 | + expect(parser.parse(event.call).record.status).to eq "begin" |
| 69 | + expect(parser.parse(event.call).record.status).to eq "update" |
| 70 | + expect(parser.parse(event.call).record.status).to eq "update" |
| 71 | + expect(parser.parse(event.call).record.status).to eq "update" |
| 72 | + expect(parser.parse(event.call).record.status).to eq "end" |
| 73 | + end |
| 74 | + |
| 75 | + it "has a gesture record that it has finger num" do |
| 76 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 77 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 78 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 79 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 80 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 81 | + end |
48 | 82 | end
|
| 83 | + end |
49 | 84 |
|
50 |
| - context "with hold gestures" do |
51 |
| - # -event10 GESTURE_HOLD_BEGIN +2.125s 3 |
52 |
| - # event10 GESTURE_HOLD_END +3.274s 3 |
53 |
| - # event10 GESTURE_HOLD_BEGIN +5.573s 4 |
54 |
| - # event10 GESTURE_HOLD_END +6.462s 4 cancelled |
55 |
| - context "with begin" do |
56 |
| - let(:record) { "-event10 GESTURE_HOLD_BEGIN +2.125s 3" } |
57 |
| - it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord } |
58 |
| - it { expect(parser.parse(event).record.status).to eq "begin" } |
| 85 | + context "with libinput version 1.26.0 or earlier" do |
| 86 | + before do |
| 87 | + allow_any_instance_of(LibinputCommand).to receive(:libinput_1_27_0_or_later?).and_return(false) |
| 88 | + end |
| 89 | + |
| 90 | + context "with swipe gestures" do |
| 91 | + before do |
| 92 | + @debug_events = <<~EVENTS |
| 93 | + event10 GESTURE_SWIPE_BEGIN +0.728s 3 |
| 94 | + event10 GESTURE_SWIPE_UPDATE +0.948s 3 0.23/ 0.00 ( 0.29/ 0.00 unaccelerated) |
| 95 | + event10 GESTURE_SWIPE_END +0.989s 3 |
| 96 | + EVENTS |
| 97 | + .split("\n") |
59 | 98 | end
|
60 |
| - context "with end" do |
61 |
| - let(:record) { " event10 GESTURE_HOLD_END +3.274s 3" } |
62 |
| - it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord } |
63 |
| - it { expect(parser.parse(event).record.status).to eq "end" } |
| 99 | + |
| 100 | + let(:event) { |
| 101 | + -> { |
| 102 | + record = @debug_events.shift |
| 103 | + Events::Event.new(tag: "libinput_command_input", record: record) |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + it "has a gesture record" do |
| 108 | + expect(parser.parse(event.call).record).to be_a Events::Records::GestureRecord |
| 109 | + end |
| 110 | + |
| 111 | + it "has a gesture record that it has a status" do |
| 112 | + expect(parser.parse(event.call).record.status).to eq "begin" |
| 113 | + expect(parser.parse(event.call).record.status).to eq "update" |
| 114 | + expect(parser.parse(event.call).record.status).to eq "end" |
64 | 115 | end
|
65 |
| - context "with end(cancelled)" do |
66 |
| - let(:record) { " event10 GESTURE_HOLD_END +6.462s 4 cancelled" } |
67 |
| - it { expect(parser.parse(event).record).to be_a Events::Records::GestureRecord } |
68 |
| - it { expect(parser.parse(event).record.status).to eq "cancelled" } |
| 116 | + |
| 117 | + it "has a gesture record that it has finger num" do |
| 118 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 119 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 120 | + expect(parser.parse(event.call).record.finger).to eq 3 |
69 | 121 | end
|
70 | 122 | end
|
71 | 123 | end
|
| 124 | + |
| 125 | + context "with hold gestures" do |
| 126 | + before do |
| 127 | + @debug_events = <<~EVENTS |
| 128 | + -event10 GESTURE_HOLD_BEGIN +2.125s 3 |
| 129 | + event10 GESTURE_HOLD_END +3.274s 3 |
| 130 | + event10 GESTURE_HOLD_BEGIN +5.573s 4 |
| 131 | + event10 GESTURE_HOLD_END +6.462s 4 cancelled |
| 132 | + EVENTS |
| 133 | + .split("\n") |
| 134 | + end |
| 135 | + |
| 136 | + let(:event) { |
| 137 | + -> { |
| 138 | + record = @debug_events.shift |
| 139 | + Events::Event.new(tag: "libinput_command_input", record: record) |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + it "has a gesture record" do |
| 144 | + expect(parser.parse(event.call).record).to be_a Events::Records::GestureRecord |
| 145 | + end |
| 146 | + |
| 147 | + it "has a gesture record that it has a status" do |
| 148 | + expect(parser.parse(event.call).record.status).to eq "begin" |
| 149 | + expect(parser.parse(event.call).record.status).to eq "end" |
| 150 | + expect(parser.parse(event.call).record.status).to eq "begin" |
| 151 | + expect(parser.parse(event.call).record.status).to eq "cancelled" |
| 152 | + end |
| 153 | + |
| 154 | + it "has a gesture record that it has finger num" do |
| 155 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 156 | + expect(parser.parse(event.call).record.finger).to eq 3 |
| 157 | + expect(parser.parse(event.call).record.finger).to eq 4 |
| 158 | + expect(parser.parse(event.call).record.finger).to eq 4 |
| 159 | + end |
| 160 | + end |
72 | 161 | end
|
73 | 162 | end
|
74 | 163 | end
|
|
0 commit comments