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 'animation_field'
12 class TestAnimationField < Test::Unit::TestCase
14 # remove connection with timer
15 Qt::Timer.stubs(:every) {}
17 # create a field with an accessor for actions
18 @field = AnimationField.new(10)
19 @field.metaclass_eval do
24 def test_initialization
25 assert_equal [], @field.actions
30 assert_equal [], @field.actions
34 action = mock("action") {|x| x.expects(:[]).with(1.0).returns(true) }
37 assert_equal [], @field.actions
41 @field.run create_action(10)
43 assert_equal 1, @field.actions.size
47 assert_equal [], @field.actions
50 def test_multiple_actions
51 @field.run create_action(3)
52 @field.run create_action(2)
54 assert_equal 2, @field.actions.size
56 assert_equal 2, @field.actions.size
58 assert_equal 1, @field.actions.size
60 assert_equal [], @field.actions
64 def create_action(length)
66 lambda { x -= 1; x <= 0 }