File: test-gtk-stack.rb

package info (click to toggle)
ruby-gnome 4.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 26,648 kB
  • sloc: ruby: 67,701; ansic: 67,431; xml: 350; sh: 201; cpp: 45; makefile: 42
file content (129 lines) | stat: -rw-r--r-- 3,588 bytes parent folder | download
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright (C) 2014-2022  Ruby-GNOME Project Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

class TestGtkStack < Test::Unit::TestCase
  include GtkTestUtils

  def setup
    @stack = Gtk::Stack.new
  end

  class TestAdd < self
    def setup
      super
      @child = Gtk::Box.new(:horizontal)
    end

    def test_return_value
      assert_equal(@stack, @stack.add(@child))
    end

    def test_added
      @stack.add(@child)
      assert_equal([@child], @stack.children)
    end

    def test_name
      widget_name = "set widget name"
      @stack.add(@child, widget_name)
      assert_equal(widget_name,
                   @stack.get_page(@child).name)
    end

    def test_name_add_title
      widget_name = "set widget name"
      widget_title = "set widget title"
      @stack.add(@child, widget_name, widget_title)
      assert_equal([
                     widget_name,
                     widget_title,
                   ],
                   [
                     @stack.get_page(@child).name,
                     @stack.get_page(@child).title,
                   ])
    end
  end

  def test_hhomogeneous_accessors
    @stack.hhomogeneous = false
    assert do
      not @stack.hhomogeneous?
    end
  end

  def test_vhomogeneous_accessors
    @stack.vhomogeneous = false
    assert do
      not @stack.vhomogeneous?
    end
  end

  def test_transition_duration_accessors
    duration = 500
    @stack.transition_duration = duration
    assert_equal(duration, @stack.transition_duration)
  end

  def test_transition_type_accessors
    stack_transition_type = Gtk::StackTransitionType::SLIDE_UP
    @stack.transition_type = stack_transition_type
    assert_equal(stack_transition_type, @stack.transition_type)
  end

  class TestVisibleChild < self
    def setup
      super
      @visible_widget = Gtk::Box.new(:horizontal)
      @visible_widget.show
      @visible_widget_name = "visible widget"
      @stack.add(@visible_widget, @visible_widget_name)
    end

    def test_assign
      @stack.visible_child = @visible_widget
      assert_equal(@visible_widget, @stack.visible_child)
    end

    def test_widget
      @stack.set_visible_child(@visible_widget)
      assert_equal(@visible_widget, @stack.visible_child)
    end

    def test_name
      @stack.set_visible_child(@visible_widget_name)
      assert_equal(@visible_widget_name,
                   @stack.visible_child_name)
    end

    def test_name_and_transition_type
      @stack.set_visible_child(@visible_widget_name, :crossfade)
      assert_equal(@visible_widget_name,
                   @stack.visible_child_name)
    end

    def test_child_by_name
      assert_equal(@visible_widget,
                   @stack.get_child_by_name(@visible_widget_name))
    end
  end

  class TestEnum < self
    def test_transition_type
      assert_const_defined(Gtk::StackTransitionType, :CROSSFADE)
    end
  end
end