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.
10 require 'board/point_converter'
11 require 'helpers/animation_test_helper'
12 require 'helpers/stubs'
19 include PointConverter
41 class TestAnimations < Test::Unit::TestCase
43 @field = FakeAnimationField.new
48 item = GeneralMock.new
49 @field.run @c.disappear(item, "disappear")
52 assert_equal [:opacity=, [1.0]], item.calls.shift
53 assert_equal [:visible=, [true]], item.calls.shift
57 method, args = item.calls.shift
58 break unless method == :opacity=
59 assert_operator args.first, :<=, old_op
63 assert_equal [:remove, []], item.calls.shift
64 assert_equal [], item.calls
68 item = GeneralMock.new
69 @field.run @c.appear(item, "appear")
72 assert_equal [:opacity=, [0.0]], item.calls.shift
73 assert_equal [:visible=, [true]], item.calls.shift
77 method, args = item.calls.shift
78 break unless method == :opacity=
79 assert_operator args.first, :>=, old_op
83 assert_equal [], item.calls
87 item = GeneralMock.new
88 @field.run @c.movement(item, Point.new(3, 4), Point.new(5, 6), Path::Linear)
92 while not item.calls.empty?
93 method, args = item.calls.shift
94 assert_equal :pos=, method
98 assert_operator old_p.x, :<=, p.x
99 assert_operator old_p.y, :<=, p.y
101 assert_in_delta 1.0, (delta.y.to_f / delta.x), 1e-5 if delta.x.abs >= 1e-5