Moved main -> lib.
[kaya/ydirson.git] / test / simple_animation_test.rb
bloba59fbf3c7850f174ec9d88eda3fb82eb55a1b0ed
1 require 'test/unit'
2 require 'animation_field'
3 require 'mocha'
5 class SimpleAnimationTest < Test::Unit::TestCase
6   def test_init
7     anim = SimpleAnimation.new "test", 10,
8       mock("init") {|x| x.expects(:[]).once.with },
9       mock("step") {|x| x.expects(:[]).once.with(0.0) },
10       mock("post") {|x| x.expects(:[]).never }
11     
12     anim[34.43]
13   end
14   
15   def test_phases
16     phase = :not_started
17     step_mock = mock("step") do |x|
18       x.expects(:[]).once.with(0.0)
19       x.expects(:[]).once.with(1.0)
20     end
21     
22     anim = SimpleAnimation.new "test", 10, 
23       mock("init") {|x| x.expects(:[]).once.with },
24       step_mock,
25       mock("post") {|x| x.expects(:[]).once.with }
26     
27     anim[10.0]
28     anim[20.0]
29   end
30   
31   def test_steps
32     steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
33     step_mock = mock("step") do |x|
34       steps.each do |s|
35         x.expects(:[]).once.with(s)
36       end
37     end
38     anim = SimpleAnimation.new "test", 10, nil, step_mock
39     start = 42.0
40     steps.each do |s|
41       anim[start + s * 10.0]
42     end
43   end
44   
45   def test_to_s
46     anim = SimpleAnimation.new "hello", 10, nil, lambda {}
47     assert_match /hello/, anim.to_s
48   end
49 end