1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
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.
9 require 'animator_helper'
10 require 'helpers/animation_test_helper'
12 class TestAnimatorHelper < Test::Unit::TestCase
13 include AnimationAssertions
17 board = FakeBoard.new(@items)
18 @animator = Object.new
19 @animator.metaclass_eval do
20 include AnimatorHelper
21 include StubbedAnimations
22 define_method(:board) { board }
27 @items[Point.new(3, 3)] = "white knight"
28 anim = @animator.disappear_on!(Point.new(3, 3))
29 assert_animation(:disappear, anim) do |args|
30 assert_equal "white knight", args.first
35 anim = @animator.appear_on!(Point.new(3, 3), "black king")
36 assert_animation(:appear, anim) do |args|
37 assert_equal "black king", args.first
41 def test_instant_disappear
42 @items[Point.new(3, 3)] = "white knight"
43 anim = @animator.disappear_on!(Point.new(3, 3), :instant => true)
44 assert_animation(:disappear, anim)
47 def test_instant_appear
48 anim = @animator.appear_on!(Point.new(3, 3), "black king", :instant => true)
49 assert_animation(:appear, anim)
53 @items[Point.new(3, 3)] = "white knight"
54 anim = @animator.move!(Point.new(3, 3), Point.new(5, 4), Path::Linear)
55 assert_animation(:movement, anim) do |args|
56 piece, src, dst = args
57 assert_equal "white knight", piece
58 assert_equal Point.new(3, 3), src
59 assert_equal Point.new(5, 4), dst
64 @items[Point.new(3, 3)] = "white knight"
65 anim = @animator.morph_on!(Point.new(3, 3), "black knight")
66 assert_animation(:group, anim) do |args|
67 appear, disappear = args.sort
68 assert_animation(:appear, appear) do |args|
69 assert_equal "black knight", args.first
71 assert_animation(:disappear, disappear) do |args|
72 assert_equal "white knight", args.first