@@ -39,7 +39,12 @@ class MultiMachineStateTest {
3939 }
4040 }
4141
42- private open class TestState : MultiMachineState <Int , String >() {
42+ private sealed class MultiGesture {
43+ data class IntGesture (val data : Int ) : MultiGesture()
44+ data class StringGesture (val data : String ) : MultiGesture()
45+ }
46+
47+ private open class TestState : MultiMachineState <MultiGesture , String >() {
4348 override val container: ProxyMachineContainer = AllTogetherMachineContainer (
4449 listOf (
4550 object : MachineInit <Int , Int > {
@@ -59,9 +64,13 @@ class MultiMachineStateTest {
5964 )
6065 )
6166
62- override fun mapGesture (parent : Int , processor : GestureProcessor ) {
63- processor.process(IntKey , parent)
64- processor.process(StringKey , parent.toString())
67+ override fun mapGesture (parent : MultiGesture , processor : GestureProcessor ) = when (parent) {
68+ is MultiGesture .IntGesture -> {
69+ processor.process(IntKey , parent.data)
70+ }
71+ is MultiGesture .StringGesture -> {
72+ processor.process(StringKey , parent.data)
73+ }
6574 }
6675
6776 override fun mapUiState (provider : UiStateProvider , changedKey : MachineKey <* , * >? ): String {
@@ -74,7 +83,7 @@ class MultiMachineStateTest {
7483 @Test
7584 fun startsContainer () {
7685 val state = TestState ()
77- val machine = MachineMock <Int , String >(" INIT" )
86+ val machine = MachineMock <MultiGesture , String >(" INIT" )
7887 state.start(machine)
7988
8089 assertEquals(
@@ -86,13 +95,13 @@ class MultiMachineStateTest {
8695 @Test
8796 fun updatesMachines () {
8897 val state = TestState ()
89- val machine = MachineMock <Int , String >(" INIT" )
98+ val machine = MachineMock <MultiGesture , String >(" INIT" )
9099 state.start(machine)
91- state.process(1 )
92- state.process(2 )
100+ state.process(MultiGesture . IntGesture ( 1 ) )
101+ state.process(MultiGesture . StringGesture ( " 2 " ) )
93102
94103 assertEquals(
95- listOf (" INIT" , " 0 - X" , " 0 - X" , " 1 - X" , " 1 - 1 " , " 2 - 1 " , " 2 - 2" ),
104+ listOf (" INIT" , " 0 - X" , " 0 - X" , " 1 - X" , " 1 - 2" ),
96105 machine.uiStates
97106 )
98107 }
@@ -111,7 +120,7 @@ class MultiMachineStateTest {
111120 }
112121 }
113122
114- val machine = MachineMock <Int , String >(" INIT" )
123+ val machine = MachineMock <MultiGesture , String >(" INIT" )
115124 state.start(machine)
116125 assertTrue { tested }
117126 }
0 commit comments