Skip to content

Commit

Permalink
test ignore_window_ms. #164
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Apr 14, 2016
1 parent 6f21627 commit 2b9e4e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mpf/tests/machine_files/switch_controller/config/config.yaml
Expand Up @@ -6,4 +6,7 @@ switches:
s_test_events:
number: 2
events_when_activated: test_active|100ms, test_active2
events_when_deactivated: test_inactive, test_inactive2|2s
events_when_deactivated: test_inactive, test_inactive2|2s
s_test_window_ms:
number: 3
ignore_window_ms: 100ms
22 changes: 21 additions & 1 deletion mpf/tests/test_SwitchController.py
Expand Up @@ -94,4 +94,24 @@ def test_activation_and_deactivation_events(self):
self.assertEqual(1, self._events['test_active'])
self.assertEqual(1, self._events['test_active2'])
self.assertEqual(1, self._events['test_inactive'])
self.assertEqual(1, self._events['test_inactive2'])
self.assertEqual(1, self._events['test_inactive2'])

def test_ignore_window_ms(self):
# first hit. switch gets active
self.machine.switch_controller.process_switch("s_test_window_ms", 1)
self.advance_time_and_run(.001)
self.assertTrue(self.machine.switch_controller.is_active("s_test_window_ms"))

# an disables instantly
self.machine.switch_controller.process_switch("s_test_window_ms", 0)
self.advance_time_and_run(.001)
self.assertFalse(self.machine.switch_controller.is_active("s_test_window_ms"))

# and enables again
self.machine.switch_controller.process_switch("s_test_window_ms", 1)
self.advance_time_and_run(.01)
self.assertFalse(self.machine.switch_controller.is_active("s_test_window_ms"))
self.advance_time_and_run(.05)
self.assertFalse(self.machine.switch_controller.is_active("s_test_window_ms"))
self.advance_time_and_run(.05)
self.assertTrue(self.machine.switch_controller.is_active("s_test_window_ms"))

0 comments on commit 2b9e4e8

Please sign in to comment.