Fix minishogi notation, enabling play against gnuminishogi.
[kaya/ydirson.git] / test / test_simple_animation.rb
blobed774ed3fcd84cb74f5ff700ff8c2220d8bb9191
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 require 'test/unit'
9 require 'animation_field'
10 require 'rubygems'
11 require 'mocha'
13 class TestSimpleAnimation < Test::Unit::TestCase
14   def test_init
15     anim = SimpleAnimation.new "test", 10,
16       mock("init") {|x| x.expects(:[]).once.with },
17       mock("step") {|x| x.expects(:[]).once.with(0.0) },
18       mock("post") {|x| x.expects(:[]).never }
19     
20     anim[34.43]
21   end
22   
23   def test_phases
24     phase = :not_started
25     step_mock = mock("step") do |x|
26       x.expects(:[]).once.with(0.0)
27       x.expects(:[]).once.with(1.0)
28     end
29     
30     anim = SimpleAnimation.new "test", 10, 
31       mock("init") {|x| x.expects(:[]).once.with },
32       step_mock,
33       mock("post") {|x| x.expects(:[]).once.with }
34     
35     anim[10.0]
36     anim[20.0]
37   end
38   
39   def test_steps
40     steps = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
41     step_mock = mock("step") do |x|
42       steps.each do |s|
43         x.expects(:[]).once.with(s)
44       end
45     end
46     anim = SimpleAnimation.new "test", 10, nil, step_mock
47     start = 42.0
48     steps.each do |s|
49       anim[start + s * 10.0]
50     end
51   end
52   
53   def test_to_s
54     anim = SimpleAnimation.new "hello", 10, nil, lambda {}
55     assert_match /hello/, anim.to_s
56   end
57 end