-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_radio_button.rb
More file actions
64 lines (47 loc) · 1.33 KB
/
test_radio_button.rb
File metadata and controls
64 lines (47 loc) · 1.33 KB
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
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require 'ui'
class RadioButtonTest < Test::Unit::TestCase
include UI::Builder
def test_basics
dialog = main_dialog {
radio_button_group(:id => :group) {
vbox {
radio_button "Option 1", :id => :opt1
radio_button "Option 2", :id => :opt2
radio_button "Option 3", :id => :opt3
}
}
}
group = dialog.find(:group)
assert_kind_of UI::RadioButtonGroup, group
opt1 = dialog.find(:opt1)
opt2 = dialog.find(:opt2)
opt3 = dialog.find(:opt3)
assert_kind_of UI::RadioButton, opt1
assert_equal group, opt1.button_group
assert !opt1.value
assert !opt2.value
assert !opt3.value
opt1.value = true
assert opt1.value
assert !opt2.value
assert !opt3.value
# as it is a member of a group, changing
# the 3rd one should disable the first
opt3.value = true
assert !opt1.value
assert !opt2.value
assert opt3.value
# Convertions to Boolean
opt2.value = String.new
assert opt2.value
opt2.value = nil
assert !opt2.value
assert_equal "Option 1", opt1.label
opt1.label = "Changed"
assert_equal "Changed", opt1.label
assert !opt1.use_bold_font?
opt1.use_bold_font = true
assert opt1.use_bold_font?
end
end