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'
14 class TestAnimationField < Test::Unit::TestCase
16 # remove connection with timer
17 Qt::Timer.stubs(:every) {}
19 # create a field with an accessor for actions
20 @field = AnimationField.new(10)
21 @field.metaclass_eval do
26 def test_initialization
27 assert_equal [], @field.actions
32 assert_equal [], @field.actions
36 action = mock("action") {|x| x.expects(:[]).with(1.0).returns(true) }
39 assert_equal [], @field.actions
43 @field.run create_action(10)
45 assert_equal 1, @field.actions.size
49 assert_equal [], @field.actions
52 def test_multiple_actions
53 @field.run create_action(3)
54 @field.run create_action(2)
56 assert_equal 2, @field.actions.size
58 assert_equal 2, @field.actions.size
60 assert_equal 1, @field.actions.size
62 assert_equal [], @field.actions
66 def create_action(length)
68 lambda { x -= 1; x <= 0 }