Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add new tests for animations, fix the existing tests, fix a bug with …

…cancel
  • Loading branch information...
commit 84b769afc3ec77447dc3888024d80c49c9157e99 1 parent b08ea1b
@tshirtman tshirtman authored
Showing with 31 additions and 7 deletions.
  1. +2 −2 kivy/animation.py
  2. +29 −5 kivy/tests/test_animations.py
View
4 kivy/animation.py
@@ -126,7 +126,7 @@ def transition(self):
return self._transition
@property
- def animated_animated_properties(self):
+ def animated_properties(self):
'''Return the properties used to animate
'''
return self._animated_properties
@@ -231,7 +231,7 @@ def cancel_property(self, widget, prop):
# no more properties to animation ? kill the animation.
if not props['properties']:
- self.stop(widget)
+ self.cancel(widget)
#
# Private
View
34 kivy/tests/test_animations.py
@@ -4,12 +4,19 @@
'''
import unittest
-from time import sleep
-from kivy.animation import Animation
+from time import time, sleep
+from kivy.animation import Animation, AnimationTransition
from kivy.uix.widget import Widget
+from functools import partial
+from kivy.clock import Clock
class AnimationTestCase(unittest.TestCase):
+ def sleep(self, t):
+ start = time()
+ while time() < start + t:
+ sleep(.01)
+ Clock.tick()
def setUp(self):
self.a = Animation(x=100, d=1, t='out_bounce')
@@ -17,14 +24,31 @@ def setUp(self):
def test_start_animation(self):
self.a.start(self.w)
- sleep(1)
+ self.sleep(1)
+ self.assertAlmostEqual(self.w.x, 100)
def test_stop_animation(self):
self.a.start(self.w)
- sleep(.5)
+ self.sleep(.5)
self.a.stop(self.w)
+ self.assertNotAlmostEqual(self.w.x, 100)
+ self.assertNotAlmostEqual(self.w.x, 0)
def test_stop_all(self):
self.a.start(self.w)
- sleep(.5)
+ self.sleep(.5)
Animation.stop_all(self.w)
+
+ def test_stop_all_2(self):
+ self.a.start(self.w)
+ self.sleep(.5)
+ Animation.stop_all(self.w, 'x')
+
+ def test_duration(self):
+ self.assertEqual(self.a.duration, 1)
+
+ def test_transition(self):
+ self.assertEqual(self.a.transition, AnimationTransition.out_bounce)
+
+ def test_animated_properties(self):
+ self.assertEqual(self.a.animated_properties['x'], 100)

0 comments on commit 84b769a

Please sign in to comment.
Something went wrong with that request. Please try again.