Implement ActionList::Entry#clear.
[kaya.git] / test / interaction / test_undo_manager.rb
blob2370d159dd54102236346a6c0c52bb9e2ef261cc
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
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.
8 require "test/unit"
10 require "interaction/undo_manager"
12 class TestUndoManager < Test::Unit::TestCase
13   def setup
14     @manager = UndoManager.new([:a, :b, :c])
15     @manager.metaclass_eval do
16       public :find_common
17     end
18   end
19   
20         def test_find_common
21                 @manager.undo(:a, 2)
22     @manager.undo(:b, 3)
23     assert_nil @manager.find_common
24         end
25   
26   def test_find_common2
27     @manager.undo(:a, 2, :allow_more => true)
28     @manager.undo(:b, 3)
29     assert_equal 3, @manager.find_common
30   end
31   
32   def test_find_common3
33     @manager.undo(:a, 3, :allow_more => true)
34     @manager.undo(:b, nil)
35     assert_equal nil, @manager.find_common
36   end
37   
38   def test_find_common4
39     @manager.undo(:a, 1, :allow_more => true)
40     @manager.undo(:b, 2)
41     @manager.undo(:c, 3)
42     assert_equal nil, @manager.find_common
43   end
44   
45   def test_find_common5
46     @manager.undo(:a, 3)
47     @manager.undo(:b, 1, :allow_more => true)
48     assert_equal 3, @manager.find_common
49   end
50 end