File: test_widget.rb

package info (click to toggle)
mikutter 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,780 kB
  • sloc: ruby: 22,912; sh: 186; makefile: 21
file content (44 lines) | stat: -rw-r--r-- 1,246 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-

class Plugin
  module GUI; end end

require 'test/unit'
require File.expand_path(__dir__ + '/../../../lib/test_unit_extensions')
require File.expand_path(__dir__ + '/../widget')
require File.expand_path(__dir__ + '/../hierarchy_parent')
require File.expand_path(__dir__ + '/../hierarchy_child')
require File.expand_path(__dir__ + '/../../../utils')

class TC_PluginGUIWidget < Test::Unit::TestCase

  def setup
    @kparent = Class.new{
      include Plugin::GUI::HierarchyParent
      include Plugin::GUI::Widget
      role :kparent
      attr_accessor :slug
      class << self
        attr_accessor :active end }

    @kchild = Class.new{
      include Plugin::GUI::HierarchyParent
      include Plugin::GUI::HierarchyChild
      include Plugin::GUI::Widget
      role :kchild }
    @kchild.set_parent_class @kparent
  end

  must "get role" do
    assert_equal(:kparent, @kparent.role)
    assert_equal(:kchild, @kchild.role)
  end

  must "role ancestor" do
    assert_equal(@kparent, @kchild.find_role_ancestor(:kparent))
    assert_equal(@kchild, @kchild.find_role_ancestor(:kchild))
    assert_equal(@kparent, @kparent.find_role_ancestor(:kparent))
    assert_nil(@kparent.find_role_ancestor(:kchild))
  end

end