wxruby3 0.9.0.pre.rc.1-x64-mingw-ucrt → 0.9.0.pre.rc.2-x64-mingw-ucrt

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +51 -22
  3. data/README.md +38 -6
  4. data/assets/hello_button-macos.png +0 -0
  5. data/assets/hello_button-msw.png +0 -0
  6. data/assets/hello_button_clicked-macos.png +0 -0
  7. data/assets/hello_button_clicked-msw.png +0 -0
  8. data/assets/hello_button_clicked_combi.png +0 -0
  9. data/assets/hello_world-macos.png +0 -0
  10. data/assets/hello_world-msw.png +0 -0
  11. data/assets/hello_world_combi.png +0 -0
  12. data/ext/wxbase32u_gcc_custom.dll +0 -0
  13. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  14. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  15. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  16. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  17. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  18. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  19. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  20. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  21. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  22. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  23. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  24. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  25. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  26. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  27. data/lib/wx/core/brush.rb +6 -0
  28. data/lib/wx/core/events/evt_list.rb +7 -0
  29. data/lib/wx/core/evthandler.rb +12 -2
  30. data/lib/wx/core/font.rb +22 -14
  31. data/lib/wx/core/helpprovider.rb +2 -2
  32. data/lib/wx/core/menu.rb +5 -0
  33. data/lib/wx/core/pen.rb +6 -0
  34. data/lib/wx/core/window.rb +28 -1
  35. data/lib/wx/doc/app.rb +40 -0
  36. data/lib/wx/doc/brush.rb +17 -0
  37. data/lib/wx/doc/font.rb +27 -0
  38. data/lib/wx/doc/gen/activity_indicator.rb +65 -0
  39. data/lib/wx/doc/gen/aui/aui_tool_bar.rb +2 -2
  40. data/lib/wx/doc/gen/context_help_button.rb +48 -0
  41. data/lib/wx/doc/gen/core.rb +2 -2
  42. data/lib/wx/doc/gen/event_blocker.rb +18 -16
  43. data/lib/wx/doc/gen/event_filter.rb +38 -45
  44. data/lib/wx/doc/gen/event_list.rb +7 -0
  45. data/lib/wx/doc/gen/file_dialog.rb +48 -49
  46. data/lib/wx/doc/gen/font.rb +9 -0
  47. data/lib/wx/doc/gen/hyperlink_ctrl.rb +147 -0
  48. data/lib/wx/doc/gen/hyperlink_event.rb +43 -0
  49. data/lib/wx/doc/gen/menu_bar.rb +0 -6
  50. data/lib/wx/doc/gen/radio_box.rb +0 -8
  51. data/lib/wx/doc/pen.rb +17 -0
  52. data/lib/wx/doc/radio_box.rb +20 -0
  53. data/lib/wx/doc/window.rb +27 -0
  54. data/lib/wx/keyword_defs.rb +77 -76
  55. data/lib/wx/prt/keyword_defs.rb +5 -1
  56. data/lib/wx/version.rb +1 -1
  57. data/lib/wxruby_aui.so +0 -0
  58. data/lib/wxruby_core.so +0 -0
  59. data/lib/wxruby_grid.so +0 -0
  60. data/lib/wxruby_html.so +0 -0
  61. data/lib/wxruby_pg.so +0 -0
  62. data/lib/wxruby_prt.so +0 -0
  63. data/lib/wxruby_rbn.so +0 -0
  64. data/lib/wxruby_rtc.so +0 -0
  65. data/lib/wxruby_stc.so +0 -0
  66. data/rakelib/install.rb +17 -6
  67. data/rakelib/lib/config/linux.rb +4 -2
  68. data/rakelib/lib/config/macosx.rb +120 -1
  69. data/rakelib/lib/config/mingw.rb +6 -1
  70. data/rakelib/lib/config/unixish.rb +26 -11
  71. data/rakelib/lib/config.rb +15 -6
  72. data/samples/aui/aui.rb +432 -363
  73. data/samples/propgrid/propgrid.rb +3 -0
  74. data/samples/sampler/editor.rb +33 -25
  75. data/samples/sampler/sample.rb +2 -2
  76. data/samples/sampler/stc_editor.rb +4 -2
  77. data/tests/lib/item_container_tests.rb +82 -0
  78. data/tests/lib/text_entry_tests.rb +80 -0
  79. data/tests/lib/wxapp_runner.rb +12 -0
  80. data/tests/lib/wxframe_runner.rb +89 -4
  81. data/tests/test_ext_controls.rb +28 -0
  82. data/tests/test_font.rb +239 -0
  83. data/tests/test_intl.rb +5 -1
  84. data/tests/test_std_controls.rb +263 -37
  85. data/tests/test_window.rb +340 -0
  86. metadata +25 -2
@@ -0,0 +1,239 @@
1
+
2
+ require_relative './lib/wxapp_runner'
3
+
4
+ class FontTests < Test::Unit::TestCase
5
+
6
+ def get_test_fonts
7
+ [
8
+ Wx::Font.new(Wx::NORMAL_FONT),
9
+ Wx::Font.new(Wx::SMALL_FONT),
10
+ Wx::Font.new(Wx::ITALIC_FONT),
11
+ Wx::Font.new(Wx::SWISS_FONT),
12
+ Wx::Font.new(5, Wx::FontFamily::FONTFAMILY_TELETYPE, Wx::FontStyle::FONTSTYLE_NORMAL, Wx::FontWeight::FONTWEIGHT_NORMAL)
13
+ ]
14
+ end
15
+
16
+ def test_size
17
+ sz_klass = Struct.new(:specified, # Size in points specified in the ctor.
18
+ :expected) # Expected GetPointSize() return value,
19
+ # -1 here means "same as wxNORMAL_FONT".
20
+ sizes = [
21
+ sz_klass.new(9,9),
22
+ sz_klass.new(10, 10),
23
+ sz_klass.new(11, 11),
24
+ sz_klass.new(-1, -1),
25
+ sz_klass.new(70, -1),
26
+ sz_klass.new(90, 90),
27
+ ]
28
+
29
+ size_default = Wx::Font.new(Wx::FontInfo.new).get_point_size
30
+
31
+ sizes.each do |size|
32
+ # Note: use the old-style wxFont ctor as wxFontInfo doesn't implement
33
+ # any compatibility hacks.
34
+ font = Wx::Font.new(size.specified,
35
+ Wx::FONTFAMILY_DEFAULT,
36
+ Wx::FONTSTYLE_NORMAL,
37
+ Wx::FONTWEIGHT_NORMAL)
38
+
39
+ expected = size.expected
40
+ expected = size_default if expected == -1
41
+
42
+ puts "specified = #{size.specified}, expected = #{size.expected}" unless is_ci_build?
43
+ assert_equal(expected, font.get_point_size)
44
+ end
45
+
46
+ # Note that the compatibility hacks only apply to the old ctors, the newer
47
+ # one, taking wxFontInfo, doesn't support them.
48
+ assert_equal(70, Wx::Font.new(Wx::FontInfo.new(70)).get_point_size)
49
+ assert_equal(90, Wx::Font.new(Wx::FontInfo.new(90)).get_point_size)
50
+
51
+ # assert_equal fractional point sizes as well.
52
+ font = Wx::Font.new(Wx::FontInfo.new(12.25))
53
+ assert_equal(12.25, font.get_fractional_point_size)
54
+ assert_equal(12, font.get_point_size)
55
+
56
+ font = Wx::NORMAL_FONT
57
+ font.set_fractional_point_size(9.5)
58
+ assert_equal(9.5, font.get_fractional_point_size)
59
+ assert_equal(10, font.get_point_size)
60
+ end
61
+
62
+ def test_weight
63
+ font = Wx::Font.new
64
+ font.set_numeric_weight(123)
65
+
66
+ assert_equal(123, font.get_numeric_weight) unless Wx::PLATFORM == 'WXOSX'
67
+
68
+ assert_equal(Wx::FontWeight::FONTWEIGHT_THIN, font.get_weight)
69
+
70
+ font.set_numeric_weight(Wx::FontWeight::FONTWEIGHT_SEMIBOLD)
71
+ assert_equal(Wx::FontWeight::FONTWEIGHT_SEMIBOLD, font.get_numeric_weight)
72
+ assert_equal(Wx::FontWeight::FONTWEIGHT_SEMIBOLD, font.get_weight)
73
+ end
74
+
75
+ def test_get_set
76
+
77
+ get_test_fonts.each_with_index do |test, n|
78
+
79
+ assert(test.ok?)
80
+
81
+ # test Get/SetFaceName()
82
+ assert( !test.set_face_name("a dummy face name") )
83
+ assert( !test.ok? )
84
+
85
+ # if the call to set_face_name() below fails on your system/port,
86
+ # consider adding another branch to this if
87
+ known_good_face_name = if Wx::PLATFORM == 'WXMSW' || Wx::PLATFORM == 'WXOSX'
88
+ "Arial"
89
+ else
90
+ "Monospace"
91
+ end
92
+
93
+ puts("Testing font ##{n}") unless is_ci_build?
94
+
95
+ puts("setting face name to #{known_good_face_name}") unless is_ci_build?
96
+ assert( test.set_face_name(known_good_face_name) )
97
+ assert( test.ok? )
98
+
99
+
100
+ # test get/set_family()
101
+
102
+ test.set_family(Wx::FontFamily::FONTFAMILY_ROMAN )
103
+ assert( test.ok? )
104
+
105
+ # note that there is always the possibility that get_family() returns
106
+ # Wx::FONTFAMILY_DEFAULT (meaning "unknown" in this case) so that we
107
+ # consider it as a valid return value
108
+ family = test.get_family
109
+ if family != Wx::FONTFAMILY_DEFAULT
110
+ assert_equal(Wx::FONTFAMILY_ROMAN, family )
111
+ end
112
+
113
+
114
+ # test get/set_point_size()
115
+
116
+ test.set_point_size(30)
117
+ assert( test.ok? )
118
+ assert_equal( 30, test.get_point_size )
119
+
120
+
121
+ # test get/set_pixel_size()
122
+
123
+ test.set_pixel_size(Wx::Size.new(0,30))
124
+ assert( test.ok? )
125
+ assert( test.get_pixel_size.get_height <= 30 )
126
+ # NOTE: the match found by set_pixel_size() may be not 100% precise it
127
+ # only grants that a font smaller than the required height will
128
+ # be selected
129
+
130
+
131
+ # test get/set_style()
132
+
133
+ test.set_style(Wx::FONTSTYLE_SLANT)
134
+ assert( test.ok? )
135
+ # on wxMSW Wx::FONTSTYLE_SLANT==Wx::FONTSTYLE_ITALIC, so accept the latter
136
+ # as a valid value too.
137
+ if ( test.get_style != Wx::FONTSTYLE_SLANT )
138
+ assert( Wx::PLATFORM == 'WXMSW' && Wx::FONTSTYLE_ITALIC == test.get_style )
139
+ end
140
+
141
+ # test get/set_underlined()
142
+
143
+ test.set_underlined(true)
144
+ assert( test.ok? )
145
+ assert( test.get_underlined )
146
+
147
+ fontBase = test.get_base_font
148
+ assert( fontBase.ok? )
149
+ assert( !fontBase.get_underlined )
150
+ assert( !fontBase.get_strikethrough )
151
+ assert_equal( Wx::FONTWEIGHT_NORMAL, fontBase.get_weight )
152
+ assert_equal( Wx::FONTSTYLE_NORMAL, fontBase.get_style )
153
+
154
+ # test get/set_strikethrough()
155
+
156
+ test.set_strikethrough(true)
157
+ assert( test.ok? )
158
+ assert( test.get_strikethrough )
159
+
160
+
161
+ # test get/set_weight()
162
+
163
+ test.set_weight(Wx::FONTWEIGHT_BOLD)
164
+ assert( test.ok? )
165
+ assert_equal( Wx::FONTWEIGHT_BOLD, test.get_weight )
166
+ end
167
+
168
+ end
169
+
170
+ def test_native_font_info
171
+ get_test_fonts.each_with_index do |test, n|
172
+ nid = test.get_native_font_info_desc
173
+ assert( !nid.empty? )
174
+ # documented to be never empty
175
+
176
+ temp = Wx::Font.new
177
+ assert( temp.set_native_font_info(nid) )
178
+ assert( temp.ok? )
179
+
180
+ puts("Testing font ##{n}") unless is_ci_build?
181
+ puts("original font user description: #{test.get_native_font_info_user_desc}") unless is_ci_build?
182
+ puts("the other font description: #{temp.get_native_font_info_user_desc}") unless is_ci_build?
183
+
184
+ assert_equal( temp, test ) unless Wx::PLATFORM == 'WXOSX'
185
+ end
186
+
187
+ # test that clearly invalid font info strings do not work
188
+ font = Wx::Font.new
189
+ assert( !font.set_native_font_info('') )
190
+
191
+ # pango_font_description_from_string() used by Wx::Font in wxGTK and wxX11
192
+ # never returns an error at all so this assertion fails there -- and as it
193
+ # doesn't seem to be possible to do anything about it maybe we should
194
+ # change wxMSW and other ports to also accept any strings?
195
+ unless %w[WXGTK WXX11 WXQT].include?(Wx::PLATFORM)
196
+ assert( !font.set_native_font_info("bloordyblop") )
197
+ end
198
+
199
+ font.set_underlined(true)
200
+ font.set_strikethrough(true)
201
+ assert(font == Wx::Font.new(font))
202
+ assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless Wx::PLATFORM == 'WXOSX'
203
+ assert(Wx::Font.new(font.get_native_font_info_desc).get_underlined)
204
+ assert(Wx::Font.new(font.get_native_font_info_desc).get_strikethrough)
205
+ font.set_underlined(false)
206
+ assert(font == Wx::Font.new(font))
207
+ assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless Wx::PLATFORM == 'WXOSX'
208
+ assert(!Wx::Font.new(font.get_native_font_info_desc).get_underlined)
209
+ font.set_underlined(true)
210
+ font.set_strikethrough(false)
211
+ assert(font == Wx::Font.new(font))
212
+ assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless Wx::PLATFORM == 'WXOSX'
213
+ assert(Wx::Font.new(font.get_native_font_info_desc).get_underlined)
214
+ assert(!Wx::Font.new(font.get_native_font_info_desc).get_strikethrough)
215
+ end
216
+
217
+ def test_find_or_create
218
+ [10.5, Wx::Size.new(0, 32)].each do |pt_sz|
219
+ info = Wx::FontInfo.new(pt_sz)
220
+
221
+ font1 = Wx::Font.find_or_create_font(info)
222
+ assert(font1)
223
+ assert(font1.ok?)
224
+
225
+ puts "Font from font list: #{font1.get_native_font_info_user_desc}" unless is_ci_build?
226
+
227
+ if pt_sz.is_a?(Wx::Size)
228
+ assert(pt_sz.y >= font1.get_pixel_size.y)
229
+ else
230
+ assert_equal(pt_sz, font1.get_fractional_point_size) unless is_ci_build?
231
+ end
232
+
233
+ # font 2 should be font1 from the font list "cache"
234
+ font2 = Wx::TheFontList.find_or_create_font(info)
235
+ assert_equal(font1, font2)
236
+ end
237
+ end
238
+
239
+ end
data/tests/test_intl.rb CHANGED
@@ -86,6 +86,10 @@ class TestInternationalisation < Test::Unit::TestCase
86
86
  end
87
87
 
88
88
  assert_raises(ArgumentError) { Wx::Locale.set_locale('bad') }
89
- locale = Wx::Locale.new(Wx::LANGUAGE_DEFAULT)
89
+ # this causes problems on MacOSX if the language / region combination is unusual
90
+ # like on my system (US English language / NL region)
91
+ unless Wx::PLATFORM == 'WXOSX'
92
+ locale = Wx::Locale.new(Wx::LANGUAGE_DEFAULT)
93
+ end
90
94
  end
91
95
  end
@@ -1,31 +1,31 @@
1
1
 
2
2
  require_relative './lib/wxframe_runner'
3
+ require_relative './lib/text_entry_tests'
4
+ require_relative './lib/item_container_tests'
3
5
 
4
6
  class ButtonTests < WxRuby::Test::GUITests
5
7
 
6
8
  def setup
7
9
  super
8
- @button = Wx::Button.new(test_frame, name: 'Button')
9
- Wx.get_app.yield
10
+ @button = Wx::Button.new(test_frame, label: 'Button')
10
11
  end
11
12
 
12
13
  def cleanup
13
14
  @button.destroy
14
- Wx.get_app.yield
15
15
  super
16
16
  end
17
17
 
18
18
  attr_reader :button
19
19
 
20
- if Wx.has_feature?(:USE_UIACTIONSIMULATOR)
20
+ if has_ui_simulator?
21
21
 
22
22
  def test_click
23
23
  count = count_events(button, :evt_button) do
24
24
  sim = Wx::UIActionSimulator.new
25
25
 
26
- # We move in slightly to account for window decorations, we need to yield
26
+ # We move in to the middle of the widget, we need to yield
27
27
  # after every Wx::UIActionSimulator action to keep everything working in GTK
28
- sim.mouse_move(button.get_screen_position + Wx::Point.new(10, 10))
28
+ sim.mouse_move(button.get_screen_position + (button.size / 2))
29
29
  Wx.get_app.yield
30
30
 
31
31
  sim.mouse_click
@@ -40,9 +40,9 @@ class ButtonTests < WxRuby::Test::GUITests
40
40
  count = count_events(button, :evt_button) do
41
41
  sim = Wx::UIActionSimulator.new
42
42
 
43
- # We move in slightly to account for window decorations, we need to yield
43
+ # We move in to the middle of the widget, we need to yield
44
44
  # after every Wx::UIActionSimulator action to keep everything working in GTK
45
- sim.mouse_move(button.get_screen_position + Wx::Point.new(10, 10))
45
+ sim.mouse_move(button.get_screen_position + (button.size / 2))
46
46
  Wx.get_app.yield
47
47
 
48
48
  sim.mouse_click
@@ -52,7 +52,7 @@ class ButtonTests < WxRuby::Test::GUITests
52
52
  assert_equal(0, count)
53
53
  end
54
54
 
55
- end # wxUSE_UIACTIONSIMULATOR
55
+ end # has_ui_simulator?
56
56
 
57
57
  def test_bitmap
58
58
  # We start with no bitmaps
@@ -91,57 +91,283 @@ end
91
91
 
92
92
  class TextCtrlTests < WxRuby::Test::GUITests
93
93
 
94
+ include TextEntryTests
95
+
94
96
  def setup
95
97
  super
96
98
  @text = Wx::TextCtrl.new(test_frame, name: 'Text')
97
- Wx.get_app.yield
98
99
  end
99
100
 
100
101
  def cleanup
101
102
  @text.destroy
102
- Wx.get_app.yield
103
103
  super
104
104
  end
105
105
 
106
106
  attr_reader :text
107
+ alias :text_entry :text
107
108
 
109
+ def test_text
110
+ assert_equal('', text.get_value)
111
+ end
108
112
 
109
- if Wx.has_feature?(:USE_UIACTIONSIMULATOR)
110
-
111
- def test_text
112
- assert_equal('', text.get_value)
113
- sim = Wx::UIActionSimulator.new
113
+ if has_ui_simulator?
114
+ def test_max_length
115
+ sim = Wx::UIActionSimulator.new
114
116
 
115
- updates = count_events(text, :evt_text) do |c_upd|
116
- maxlen_count = count_events(text, :evt_text_maxlen) do |c_maxlen|
117
- # set focus to text control
118
- text.set_focus
119
- Wx.get_app.yield
117
+ updates = count_events(text_entry, :evt_text) do |c_upd|
118
+ maxlen_count = count_events(text_entry, :evt_text_maxlen) do |c_maxlen|
119
+ # set focus to text_entry text_entry
120
+ text_entry.set_focus
121
+ Wx.get_app.yield
120
122
 
121
- sim.text('Hello')
122
- Wx.get_app.yield
123
+ sim.text('Hello')
124
+ Wx.get_app.yield
123
125
 
124
- assert_equal('Hello', text.get_value)
125
- assert_equal(5, c_upd.count)
126
+ assert_equal('Hello', text_entry.get_value)
127
+ assert_equal(5, c_upd.count)
126
128
 
127
- text.set_max_length(10)
128
- sim.text('World')
129
- Wx.get_app.yield
129
+ text_entry.set_max_length(10)
130
+ sim.text('World')
131
+ Wx.get_app.yield
130
132
 
131
- assert_equal('HelloWorld', text.get_value)
132
- assert_equal(10, c_upd.count)
133
- assert_equal(0, c_maxlen.count)
133
+ assert_equal('HelloWorld', text_entry.get_value)
134
+ assert_equal(10, c_upd.count)
135
+ assert_equal(0, c_maxlen.count)
134
136
 
135
- sim.text('!')
136
- Wx.get_app.yield
137
+ sim.text('!')
138
+ Wx.get_app.yield
137
139
 
138
- assert_equal('HelloWorld', text.get_value)
139
- assert_equal(10, c_upd.count)
140
- assert_equal(1, c_maxlen.count)
141
- end
140
+ assert_equal('HelloWorld', text_entry.get_value)
141
+ assert_equal(10, c_upd.count)
142
+ assert_equal(1, c_maxlen.count)
142
143
  end
143
144
  end
145
+ end
146
+
147
+ end # has_ui_simulator?
148
+
149
+ end
150
+
151
+ class ComboBoxTests < WxRuby::Test::GUITests
152
+
153
+ include TextEntryTests
154
+
155
+ def setup
156
+ super
157
+ @combo = Wx::ComboBox.new(test_frame, name: 'ComboBox', choices: %w[One Two Three])
158
+ @combo.clear
159
+ end
160
+
161
+ def cleanup
162
+ @combo.destroy
163
+ super
164
+ end
165
+
166
+ attr_reader :combo
167
+ alias :text_entry :combo
168
+
169
+ def test_combo
170
+ assert_equal('', combo.get_value)
171
+ end
172
+
173
+ end
174
+
175
+ class CheckBoxTests < WxRuby::Test::GUITests
176
+
177
+ def setup
178
+ super
179
+ @check = Wx::CheckBox.new(test_frame, label: 'Check Box')
180
+ end
181
+
182
+ def cleanup
183
+ @check.destroy
184
+ super
185
+ end
186
+
187
+ def create_checkbox(style)
188
+ @check.destroy
189
+ @check = nil
190
+ @check = Wx::CheckBox.new(test_frame, label: 'Check Box', style: style)
191
+ end
192
+
193
+ attr_reader :check
194
+
195
+ def test_check
196
+ count = count_events(check, :evt_checkbox) do
197
+ assert(!check.checked?)
198
+
199
+ check.set_value(true)
200
+
201
+ assert(check.checked?)
202
+
203
+ check.set_value(false)
204
+
205
+ assert(!check.checked?)
206
+
207
+ check.set3state_value(Wx::CheckBoxState::CHK_CHECKED)
208
+
209
+ assert(check.checked?)
210
+
211
+ check.set3state_value(Wx::CheckBoxState::CHK_UNCHECKED)
212
+
213
+ assert(!check.checked?)
214
+
215
+ end
216
+
217
+ assert_equal(0, count) # should not have emitted any events
218
+ end
219
+
220
+ def test_third_state
221
+
222
+ create_checkbox(Wx::CHK_3STATE)
223
+
224
+ assert_equal(Wx::CheckBoxState::CHK_UNCHECKED, check.get3state_value)
225
+ assert(check.is3state)
226
+ assert(!check.is3rd_state_allowed_for_user)
227
+
228
+ check.value = true
229
+
230
+ assert_equal(Wx::CheckBoxState::CHK_CHECKED, check.get3state_value)
231
+
232
+ check.set3state_value(Wx::CheckBoxState::CHK_UNDETERMINED)
233
+
234
+ assert_equal(Wx::CheckBoxState::CHK_UNDETERMINED, check.get3state_value)
235
+ end
236
+
237
+ def test_third_state_user
238
+
239
+ create_checkbox(Wx::CHK_3STATE | Wx::CHK_ALLOW_3RD_STATE_FOR_USER)
240
+
241
+ assert_equal(Wx::CheckBoxState::CHK_UNCHECKED, check.get3state_value)
242
+ assert(check.is3state)
243
+ assert(check.is3rd_state_allowed_for_user)
244
+
245
+ check.value = true
246
+
247
+ assert_equal(Wx::CheckBoxState::CHK_CHECKED, check.get3state_value)
248
+
249
+ check.set3state_value(Wx::CheckBoxState::CHK_UNDETERMINED)
250
+
251
+ assert_equal(Wx::CheckBoxState::CHK_UNDETERMINED, check.get3state_value)
252
+ end
253
+
254
+ def test_invalid_style
255
+
256
+ # prints assertion warning and creates default checkbox
257
+ assert_with_assertion_failure { create_checkbox(Wx::CHK_3STATE | Wx::CHK_2STATE) }
258
+
259
+ end
260
+
261
+ end
262
+
263
+
264
+ class RadioBoxTests < WxRuby::Test::GUITests
265
+
266
+ def setup
267
+ super
268
+ @radiobox = Wx::RadioBox.new(test_frame, label: 'Radio Box', choices: ['item 0', 'item 1', 'item 2'])
269
+ end
270
+
271
+ def cleanup
272
+ @radiobox.destroy
273
+ super
274
+ end
275
+
276
+ attr_reader :radiobox
277
+
278
+ def test_find_string
279
+ assert_equal(Wx::NOT_FOUND, radiobox.find_string('Not An Item'))
280
+ assert_equal(1, radiobox.find_string('item 1'))
281
+ assert_equal(2, radiobox.find_string('ITEM 2'))
282
+ assert_equal(Wx::NOT_FOUND, radiobox.find_string('ITEM 2', true))
283
+ end
284
+
285
+ def test_show
286
+ radiobox.show(false)
287
+
288
+ assert(!radiobox.is_item_shown(0))
289
+
290
+ radiobox.show_item(1, true)
291
+
292
+ assert(!radiobox.is_item_shown(0))
293
+ assert(radiobox.is_item_shown(1))
294
+ assert(!radiobox.is_item_shown(2))
295
+
296
+ radiobox.show(true)
297
+
298
+ assert(radiobox.is_item_shown(0))
299
+ assert(radiobox.is_item_shown(1))
300
+ assert(radiobox.is_item_shown(2))
301
+
302
+ radiobox.show_item(0, false)
303
+
304
+ assert(!radiobox.is_item_shown(0))
305
+ assert(radiobox.is_item_shown(1))
306
+ assert(radiobox.is_item_shown(2))
307
+ end
308
+
309
+ def test_selection
310
+ # by default first item selected
311
+ assert_equal(0, radiobox.get_selection)
312
+ assert_equal('item 0', radiobox.get_string_selection)
313
+
314
+ radiobox.set_selection(1)
315
+
316
+ assert_equal(1, radiobox.get_selection)
317
+ assert_equal('item 1', radiobox.get_string_selection)
318
+
319
+ radiobox.string_selection = 'item 2'
320
+
321
+ assert_equal(2, radiobox.selection)
322
+ assert_equal('item 2', radiobox.string_selection)
323
+ end
324
+
325
+ def test_set_string
326
+ radiobox.set_string(0, 'new item 0')
327
+ radiobox.set_string(2, '')
328
+
329
+ assert_equal('new item 0', radiobox.get_string(0))
330
+ assert_equal('', radiobox.string(2))
331
+ end
332
+
333
+ def test_count
334
+ assert_equal(3, radiobox.get_count)
335
+ assert(!radiobox.empty?)
336
+ end
337
+
338
+ def test_help_text
339
+ assert(radiobox.get_item_help_text(1).empty?)
340
+
341
+ radiobox.set_item_help_text(1, 'Item 1 Help')
342
+
343
+ assert_equal('Item 1 Help', radiobox.get_item_help_text(1))
344
+
345
+ radiobox.set_item_help_text(1, '')
346
+
347
+ assert(radiobox.get_item_help_text(1).empty?)
348
+ end
349
+
350
+ end
351
+
352
+ class ChoiceTests < WxRuby::Test::GUITests
353
+
354
+ include ItemContainerTests
355
+
356
+ def setup
357
+ super
358
+ @choice = Wx::Choice.new(test_frame, name: 'Choice')
359
+ end
360
+
361
+ def cleanup
362
+ @choice.destroy
363
+ super
364
+ end
365
+
366
+ attr_reader :choice
367
+ alias :container :choice
144
368
 
369
+ def test_choice
370
+ assert_equal(Wx::NOT_FOUND, choice.get_selection)
145
371
  end
146
372
 
147
373
  end