Add some additional tests for AxisToButton.
This commit is contained in:
parent
ed2627e113
commit
8bbb84da85
1 changed files with 31 additions and 3 deletions
|
@ -1,6 +1,9 @@
|
||||||
package mappingrules
|
package mappingrules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/holoplot/go-evdev"
|
"github.com/holoplot/go-evdev"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
@ -51,9 +54,34 @@ func (t *MappingRuleAxisToButtonTests) TestMatchEvent() {
|
||||||
}, t.mode)
|
}, t.mode)
|
||||||
t.Equal(NoNextEvent, testRule.nextEvent)
|
t.Equal(NoNextEvent, testRule.nextEvent)
|
||||||
|
|
||||||
// TODO: more tests here... check repeats
|
testRule = NewMappingRuleAxisToButton(t.base, t.inputRule, t.outputRule, 750, 250)
|
||||||
|
testRule.MatchEvent(t.inputDevice, &evdev.InputEvent{
|
||||||
|
Type: evdev.EV_ABS,
|
||||||
|
Code: evdev.ABS_X,
|
||||||
|
Value: 10000,
|
||||||
|
}, t.mode)
|
||||||
|
t.Equal(time.Duration(250*time.Millisecond), testRule.nextEvent)
|
||||||
|
|
||||||
|
testRule.MatchEvent(t.inputDevice, &evdev.InputEvent{
|
||||||
|
Type: evdev.EV_ABS,
|
||||||
|
Code: evdev.ABS_X,
|
||||||
|
Value: 1001,
|
||||||
|
}, t.mode)
|
||||||
|
t.True(testRule.nextEvent > time.Duration(700*time.Millisecond))
|
||||||
|
|
||||||
|
testRule.MatchEvent(t.inputDevice, &evdev.InputEvent{
|
||||||
|
Type: evdev.EV_ABS,
|
||||||
|
Code: evdev.ABS_X,
|
||||||
|
Value: 5500,
|
||||||
|
}, t.mode)
|
||||||
|
t.Equal(time.Duration(500*time.Millisecond), testRule.nextEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *MappingRuleAxisToButtonTests) TestTimerEvent() {
|
// TODO: to add TimerEvent tests we need to use an interface to mock time.
|
||||||
// STUB
|
// func (t *MappingRuleAxisToButtonTests) TestTimerEvent() {
|
||||||
|
// // STUB
|
||||||
|
// }
|
||||||
|
|
||||||
|
func TestRunnerMappingRuleAxisToButtonTests(t *testing.T) {
|
||||||
|
suite.Run(t, new(MappingRuleAxisToButtonTests))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue