Add program entry point and a MainWindow class.
[kaya.git] / test / test_animator_helper.rb
blobee5694dd549e9ecb6a33e076a838936d973010bf
1 require 'test/unit'
2 require 'animator_helper'
3 require 'helpers/animation_test_helper'
5 class TestAnimatorHelper < Test::Unit::TestCase
6   include AnimationAssertions
7   
8   def setup
9     @items = { }
10     board = FakeBoard.new(@items)
11     @animator = Object.new
12     @animator.metaclass_eval do
13       include AnimatorHelper
14       include StubbedAnimations
15       define_method(:board) { board }
16     end
17   end
18   
19   def test_disappear
20     @items[Point.new(3, 3)] = "white knight"
21     anim = @animator.disappear_on!(Point.new(3, 3))
22     assert_animation(:disappear, anim) do |args|
23       assert_equal "white knight", args.first
24     end
25   end
26   
27   def test_appear
28     anim = @animator.appear_on!(Point.new(3, 3), "black king")
29     assert_animation(:appear, anim) do |args|
30       assert_equal "black king", args.first
31     end
32   end
33   
34   def test_instant_disappear
35     @items[Point.new(3, 3)] = "white knight"
36     anim = @animator.disappear_on!(Point.new(3, 3), :instant => true)
37     assert_animation(:instant_disappear, anim)
38   end
39   
40   def test_instant_appear
41     anim = @animator.appear_on!(Point.new(3, 3), "black king", :instant => true)
42     assert_animation(:instant_appear, anim)
43   end
44   
45   def test_move
46     @items[Point.new(3, 3)] = "white knight"
47     anim = @animator.move!(Point.new(3, 3), Point.new(5, 4))
48     assert_animation(:movement, anim) do |args|
49       piece, src, dst = args
50       assert_equal "white knight", piece
51       assert_equal Point.new(3, 3), src
52       assert_equal Point.new(5, 4), dst
53     end
54   end
55   
56   def test_morph
57     @items[Point.new(3, 3)] = "white knight"
58     anim = @animator.morph_on!(Point.new(3, 3), "black knight")
59     assert_animation(:group, anim) do |args|
60       appear, disappear = args.sort
61       assert_animation(:appear, appear) do |args|
62         assert_equal "black knight", args.first
63       end
64       assert_animation(:disappear, disappear) do |args|
65         assert_equal "white knight", args.first
66       end
67     end
68   end
69 end