Skip to content

Commit

Permalink
Add test units to ClockTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailof authored and tshirtman committed May 20, 2018
1 parent dafc07c commit f8194bb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions kivy/tests/test_clock.py
Expand Up @@ -80,3 +80,40 @@ def test_unschedule_draw(self):
Clock.unschedule(callback)
Clock.tick()
self.assertEqual(counter, 0)

def test_trigger_create(self):
from kivy.clock import Clock
trigger = Clock.create_trigger(callback, 0)
trigger()
self.assertEqual(counter, 0)
Clock.tick()
self.assertEqual(counter, 1)

def test_trigger_cancel(self):
from kivy.clock import Clock
trigger = Clock.create_trigger(callback, 5.)
trigger()
trigger.cancel()
Clock.tick()
self.assertEqual(counter, 0)

def test_trigger_interval(self):
from kivy.clock import Clock
trigger = Clock.create_trigger(callback, 0, interval=True)
trigger()
Clock.tick()
self.assertEqual(counter, 1)
Clock.tick()
self.assertEqual(counter, 2)

def test_trigger_decorator(self):
from kivy.clock import Clock, triggered

@triggered()
def triggered_callback():
callback(dt=0)

triggered_callback()
self.assertEqual(counter, 0)
Clock.tick()
self.assertEqual(counter, 1)

0 comments on commit f8194bb

Please sign in to comment.