| 1 |
|
| 2 |
|
| 3 |
class Plugin |
| 4 |
module GUI; end end |
| 5 |
|
| 6 |
require 'test/unit' |
| 7 |
require File.expand_path(__dir__ + '/../../../lib/test_unit_extensions') |
| 8 |
require File.expand_path(__dir__ + '/../hierarchy_parent') |
| 9 |
require File.expand_path(__dir__ + '/../hierarchy_child') |
| 10 |
require File.expand_path(__dir__ + '/../../../utils') |
| 11 |
|
| 12 |
class TC_PluginGUIHierarchyParent < Test::Unit::TestCase |
| 13 |
|
| 14 |
def setup |
| 15 |
@kparent = Class.new{ |
| 16 |
include Plugin::GUI::HierarchyParent |
| 17 |
class << self |
| 18 |
attr_accessor :active end } |
| 19 |
|
| 20 |
@kchild = Class.new{ |
| 21 |
include Plugin::GUI::HierarchyParent |
| 22 |
include Plugin::GUI::HierarchyChild } |
| 23 |
@kchild.set_parent_class @kparent |
| 24 |
|
| 25 |
@kgrandchild = Class.new{ |
| 26 |
include Plugin::GUI::HierarchyChild } |
| 27 |
@kgrandchild.set_parent_class @kchild |
| 28 |
end |
| 29 |
|
| 30 |
must "set child" do |
| 31 |
parent = @kparent.new |
| 32 |
child = @kchild.new |
| 33 |
parent << child |
| 34 |
assert_equal(true, parent.children.first == child) |
| 35 |
assert_equal(true, child.parent == parent) |
| 36 |
end |
| 37 |
|
| 38 |
must "child activation" do |
| 39 |
parent = @kparent.new |
| 40 |
@kparent.active = parent |
| 41 |
children = [@kchild.new, @kchild.new] |
| 42 |
grandchildren = [@kgrandchild.new] |
| 43 |
parent << children[0] << children[1] |
| 44 |
children[0] << grandchildren[0] |
| 45 |
assert_equal(children[0], parent.active_child) |
| 46 |
assert_equal([children[0], grandchildren[0]], parent.active_chain) |
| 47 |
assert_equal(grandchildren[0], parent.active_class_of(@kgrandchild)) |
| 48 |
assert_equal(grandchildren[0], @kgrandchild.active) |
| 49 |
end |
| 50 |
|
| 51 |
end |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|