2 require 'animator_helper'
3 require 'helpers/animation_test_helper'
5 class TestAnimatorHelper < Test::Unit::TestCase
6 include AnimationAssertions
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 }
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
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
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)
40 def test_instant_appear
41 anim = @animator.appear_on!(Point.new(3, 3), "black king", :instant => true)
42 assert_animation(:instant_appear, anim)
46 @items[Point.new(3, 3)] = "white knight"
47 anim = @animator.move!(Point.new(3, 3), Point.new(5, 4), Path::Linear)
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
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
64 assert_animation(:disappear, disappear) do |args|
65 assert_equal "white knight", args.first