| 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__ + '/../widget') |
| 9 |
require File.expand_path(__dir__ + '/../hierarchy_parent') |
| 10 |
require File.expand_path(__dir__ + '/../hierarchy_child') |
| 11 |
require File.expand_path(__dir__ + '/../../../utils') |
| 12 |
|
| 13 |
class TC_PluginGUIWidget < Test::Unit::TestCase |
| 14 |
|
| 15 |
def setup |
| 16 |
@kparent = Class.new{ |
| 17 |
include Plugin::GUI::HierarchyParent |
| 18 |
include Plugin::GUI::Widget |
| 19 |
role :kparent |
| 20 |
attr_accessor :slug |
| 21 |
class << self |
| 22 |
attr_accessor :active end } |
| 23 |
|
| 24 |
@kchild = Class.new{ |
| 25 |
include Plugin::GUI::HierarchyParent |
| 26 |
include Plugin::GUI::HierarchyChild |
| 27 |
include Plugin::GUI::Widget |
| 28 |
role :kchild } |
| 29 |
@kchild.set_parent_class @kparent |
| 30 |
end |
| 31 |
|
| 32 |
must "get role" do |
| 33 |
assert_equal(:kparent, @kparent.role) |
| 34 |
assert_equal(:kchild, @kchild.role) |
| 35 |
end |
| 36 |
|
| 37 |
must "role ancestor" do |
| 38 |
assert_equal(@kparent, @kchild.find_role_ancestor(:kparent)) |
| 39 |
assert_equal(@kchild, @kchild.find_role_ancestor(:kchild)) |
| 40 |
assert_equal(@kparent, @kparent.find_role_ancestor(:kparent)) |
| 41 |
assert_nil(@kparent.find_role_ancestor(:kchild)) |
| 42 |
end |
| 43 |
|
| 44 |
end |