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