wxruby3 1.2.0 → 1.3.0

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxruby3/swig/custom/director.swg +6 -20
  3. data/lib/wx/core/animation.rb +35 -14
  4. data/lib/wx/core/choicedlg.rb +7 -10
  5. data/lib/wx/core/colour.rb +10 -0
  6. data/lib/wx/core/dialog.rb +2 -2
  7. data/lib/wx/core/enum.rb +22 -5
  8. data/lib/wx/core/event.rb +7 -0
  9. data/lib/wx/core/file_dialog.rb +25 -0
  10. data/lib/wx/core/functions.rb +4 -10
  11. data/lib/wx/core/gdi_object.rb +24 -0
  12. data/lib/wx/core/object.rb +26 -11
  13. data/lib/wx/core/variant.rb +108 -51
  14. data/lib/wx/doc/animation_ctrl.rb +18 -0
  15. data/lib/wx/doc/colour.rb +12 -0
  16. data/lib/wx/doc/enum.rb +0 -11
  17. data/lib/wx/doc/evthandler.rb +6 -0
  18. data/lib/wx/doc/functions.rb +35 -3
  19. data/lib/wx/doc/gdi_object.rb +22 -0
  20. data/lib/wx/doc/object.rb +24 -0
  21. data/lib/wx/doc/variant.rb +8 -0
  22. data/lib/wx/helpers.rb +2 -3
  23. data/lib/wx/keyword_defs.rb +14 -1
  24. data/lib/wx/version.rb +1 -1
  25. data/rakelib/lib/config.rb +1 -1
  26. data/rakelib/lib/core/include/enum.inc +0 -80
  27. data/rakelib/lib/core/include/funcall.inc +9 -24
  28. data/rakelib/lib/core/include/swigdirector.inc +29 -11
  29. data/rakelib/lib/director/animation_ctrl.rb +11 -0
  30. data/rakelib/lib/director/defs.rb +3 -0
  31. data/rakelib/lib/director/dialog.rb +15 -7
  32. data/rakelib/lib/director/file_dialog_customize_hook.rb +77 -1
  33. data/rakelib/lib/director/functions.rb +0 -12
  34. data/rakelib/lib/director/validator.rb +7 -42
  35. data/rakelib/lib/generate/doc/credential_entry_dialog.yaml +10 -0
  36. data/rakelib/lib/generate/doc/generic_about_dialog.yaml +46 -0
  37. data/rakelib/lib/specs/interfaces.rb +2 -0
  38. data/rakelib/lib/swig_runner.rb +6 -3
  39. data/rakelib/lib/util/string.rb +7 -6
  40. data/samples/animate/anitest.rb +288 -0
  41. data/samples/animate/hourglass.ani +0 -0
  42. data/samples/animate/throbber.gif +0 -0
  43. data/samples/animate/throbber_2x.gif +0 -0
  44. data/samples/animate/tn_anitest.png +0 -0
  45. data/tests/lib/leaked_overload_exception_test.rb +25 -0
  46. data/tests/lib/leaked_process_event_exception_test.rb +33 -0
  47. data/tests/lib/leaked_queued_event_exception_test.rb +34 -0
  48. data/tests/lib/overload_type_exception_test.rb +25 -0
  49. data/tests/test_exceptions.rb +24 -24
  50. metadata +17 -2
@@ -0,0 +1,46 @@
1
+ ---
2
+ :wxGenericAboutDialog:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ class MyFrame < Wx::Frame
11
+
12
+ # declare custom about dialog class
13
+ class MyAboutDlg < Wx::GenericAboutDialog
14
+
15
+ def initialize(about_info, parent=nil)
16
+ super()
17
+
18
+ create(about_info, parent)
19
+ end
20
+
21
+ def do_add_custom_controls
22
+ # add custom controls ...
23
+ end
24
+ protected :do_add_custom_controls
25
+
26
+ end
27
+
28
+ # fill in MyFrame class ...
29
+
30
+ # handler for an About menu/button
31
+ def on_about(_evt)
32
+ aboutInfo = Wx::AboutDialogInfo.new
33
+
34
+ aboutInfo.set_name('MyApp')
35
+ aboutInfo.set_version(MY_APP_VERSION_STRING)
36
+ aboutInfo.set_description('My wxWidgets-based application!')
37
+ aboutInfo.set_copyright('(C) 1992-2024')
38
+ aboutInfo.set_web_site('http://myapp.org')
39
+ aboutInfo.add_developer('My Self')
40
+
41
+ MyFrame.MyAboutDlg(aboutInfo, self) do |dlgAbout|
42
+ dlgAbout.show_modal
43
+ end
44
+ end
45
+ end
46
+ ```
@@ -237,6 +237,8 @@ module WXRuby3
237
237
  Director.Spec(pkg, 'wxDCOverlay', director: Director::DerivedDC)
238
238
  Director.Spec(pkg, 'wxGeometry', requirements: %w[USE_GEOMETRY])
239
239
  Director.Spec(pkg, 'wxAffineMatrix2D', requirements: %w[USE_GEOMETRY])
240
+ Director.Spec(pkg, 'wxCredentialEntryDialog', director: Director::Dialog, requirements: %w[USE_CREDENTIALDLG])
241
+ Director.Spec(pkg, 'wxGenericAboutDialog', director: Director::Dialog, requirements: %w[USE_ABOUTDLG])
240
242
  }
241
243
 
242
244
  Director.Package('Wx::PRT', 'USE_PRINTING_ARCHITECTURE') do |pkg|
@@ -726,20 +726,23 @@ module WXRuby3
726
726
  elsif wrapper_re =~ line
727
727
  class_nm = $1
728
728
  mtd_nm = $2
729
+ if /(\w+)__SWIG_.+/ =~ mtd_nm # in case of method overloads
730
+ mtd_nm = $1
731
+ end
729
732
  at_wrapper = true
730
733
  if (mdef = member_map[class_nm].detect { |m| Extractor::MethodDef === m && (m.rb_name || m.name) == mtd_nm })
731
734
  matched_wrapper = true
732
735
  mtd_call_re = /(\s*)\S.*arg1\)?->#{mtd_nm}(\(.*\));/
733
- line = [line, ' bool fpa_upcall = false;', ' Swig::Director *fpa_dir = 0;']
736
+ line = [line, ' bool SWIGUNUSED fpa_upcall = false;', ' Swig::Director* SWIGUNUSED fpa_dir = 0;']
734
737
  elsif (mdef = member_map[class_nm].detect { |m| Extractor::MemberVarDef === m && "#{m.rb_name || m.name}_get" == mtd_nm })
735
738
  matched_wrapper = true
736
739
  mtd_call_re = /(\s*)\S.*arg1\)?->#{mdef.name}\)?;/
737
- line = [line, ' bool fpa_upcall = false;', ' Swig::Director *fpa_dir = 0;']
740
+ line = [line, ' bool SWIGUNUSED fpa_upcall = false;', ' Swig::Director* SWIGUNUSED fpa_dir = 0;']
738
741
  elsif (mdef = member_map[class_nm].detect { |m| Extractor::MemberVarDef === m && "#{m.rb_name || m.name}_set" == mtd_nm })
739
742
  matched_wrapper = true
740
743
  at_setter = true;
741
744
  mtd_call_re = /(\s*)\S.*arg1\)?->#{mdef.name}(\s*=\s*.*);/
742
- line = [line, ' bool fpa_upcall = false;', ' Swig::Director *fpa_dir = 0;']
745
+ line = [line, ' bool SWIGUNUSED fpa_upcall = false;', ' Swig::Director* SWIGUNUSED fpa_dir = 0;']
743
746
  end
744
747
  elsif /rb_define_method\(SwigClassWx(#{cls_re_txt}).klass\s*,\s*"(\w+)(=)?"\s*,\s*VALUEFUNC/ =~ line
745
748
  class_nm = $1
@@ -107,9 +107,10 @@ module WXRuby3
107
107
  end
108
108
 
109
109
  def rb_constant_expression(exp, const_xref)
110
- exp.gsub(/(\w+(::\w+)*)(\s*\()?/) do |s|
110
+ exp.gsub(/(\w+(::\w+)*)(\s*\((\))?)?/) do |s|
111
111
  idstr = $1
112
- is_call = !!$3
112
+ call_bracket = $3
113
+ is_empty_call = !!$4
113
114
  is_scoped = false
114
115
  ids = idstr.split('::')
115
116
  if ids.size > 1
@@ -120,18 +121,18 @@ module WXRuby3
120
121
  end
121
122
  end
122
123
  idstr = ids.shift
123
- if is_call
124
+ if call_bracket
124
125
  # object ctor or static method call
125
126
  if is_scoped
126
127
  # static method
127
- "#{scoped_name}.#{rb_method_name(idstr)}("
128
+ "#{scoped_name}.#{rb_method_name(idstr)}#{call_bracket}"
128
129
  else
129
130
  # ctor
130
131
  case idstr
131
132
  when 'wxString'
132
- '('
133
+ is_empty_call ? "''" : call_bracket
133
134
  else
134
- "#{idstr.start_with?('wx') ? 'Wx::' : ''}#{rb_wx_name(idstr)}.new("
135
+ "#{idstr.start_with?('wx') ? 'Wx::' : ''}#{rb_wx_name(idstr)}.new#{call_bracket}"
135
136
  end
136
137
  end
137
138
  else
@@ -0,0 +1,288 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+ #
5
+ # Adapted for wxRuby from wxWidgets widgets sample
6
+ # Copyright (c) 2001 Julian Smart
7
+
8
+ require 'wx'
9
+
10
+ module AniTest
11
+
12
+ # Define a new frame
13
+ class MyFrame < Wx::Frame
14
+
15
+ module ID
16
+ include Wx::IDHelper
17
+
18
+ PLAY = self.next_id
19
+ SET_NULL_ANIMATION = self.next_id
20
+ SET_INACTIVE_BITMAP = self.next_id
21
+ SET_NO_AUTO_RESIZE = self.next_id
22
+ SET_BGCOLOR = self.next_id
23
+ USE_GENERIC = self.next_id
24
+
25
+ end
26
+
27
+ def initialize(title)
28
+ super(nil, :title => title, :size => [500, 400], style: Wx::DEFAULT_FRAME_STYLE)
29
+
30
+ set_icon(Wx.Icon(:sample, art_path: File.dirname(__dir__)))
31
+
32
+ # Make a menubar
33
+ file_menu = Wx::Menu.new
34
+
35
+ if Wx.has_feature?(:USE_FILEDLG)
36
+ file_menu.append(Wx::ID_OPEN, "&Open Animation...\tCtrl+O", 'Loads an animation')
37
+ end # USE_FILEDLG
38
+ file_menu.append(Wx::ID_EXIT)
39
+
40
+ play_menu = Wx::Menu.new
41
+ play_menu.append(ID::PLAY, "Play\tCtrl+P", "Play the animation")
42
+ play_menu.append(Wx::ID_STOP, "Stop\tCtrl+S", "Stop the animation")
43
+ play_menu.append_separator
44
+ play_menu.append(ID::SET_NULL_ANIMATION, "Set null animation",
45
+ "Sets the empty animation in the control")
46
+ play_menu.append_check_item(ID::SET_INACTIVE_BITMAP, "Set inactive bitmap",
47
+ "Sets an inactive bitmap for the control")
48
+ play_menu.append_check_item(ID::SET_NO_AUTO_RESIZE, "Set no autoresize",
49
+ "Tells the control not to resize automatically")
50
+ play_menu.append(ID::SET_BGCOLOR, "Set background colour...",
51
+ "Sets the background colour of the control")
52
+
53
+ if Wx::PLATFORM == 'WXGTK'
54
+ play_menu.append_separator
55
+ play_menu.append_check_item(ID::USE_GENERIC, "Use &generic animation\tCtrl+G",
56
+ "Selects whether native or generic version is used")
57
+ end
58
+
59
+ help_menu = Wx::Menu.new
60
+ help_menu.append(Wx::ID_ABOUT)
61
+
62
+ menu_bar = Wx::MenuBar.new
63
+
64
+ menu_bar.append(file_menu, "&File")
65
+ menu_bar.append(play_menu, "&Animation")
66
+ menu_bar.append(help_menu, "&Help")
67
+
68
+ # Associate the menu bar with this frame
69
+ set_menu_bar(menu_bar)
70
+
71
+ if Wx.has_feature?(:USE_STATUSBAR)
72
+ create_status_bar
73
+ end # USE_STATUSBAR
74
+
75
+ # use a Wx::BoxSizer otherwise Wx::Frame will automatically
76
+ # resize the @animation_ctrl to fill its client area on
77
+ # user resizes
78
+ sz = Wx::VBoxSizer.new
79
+ sz.add(Wx::StaticText.new(self, Wx::ID_ANY, "wxAnimationCtrl:"),
80
+ Wx::SizerFlags.new.centre.border)
81
+
82
+ @animation_ctrl = Wx::AnimationCtrl.new(self, Wx::ID_ANY)
83
+
84
+ if Wx::WXWIDGETS_VERSION >= '3.3.0'
85
+ animations = Wx::AnimationBundle.new
86
+
87
+ throbber = Wx::Animation.new(File.join(__dir__, 'throbber.gif'))
88
+ animations.add(throbber) if throbber.ok?
89
+
90
+ throbber2x = Wx::Animation.new(File.join(__dir__, 'throbber_2x.gif'))
91
+ animations.add(throbber2x) if throbber2x.ok?
92
+
93
+ if animations.ok?
94
+ @animation_ctrl.set_animation(animations)
95
+ @animation_ctrl.play
96
+ end
97
+ elsif @animation_ctrl.load('throbber.gif')
98
+ @animation_ctrl.play
99
+ end
100
+
101
+ sz.add(@animation_ctrl, Wx::SizerFlags.new.centre.border)
102
+ set_sizer(sz)
103
+
104
+ evt_menu(ID::PLAY, :on_play)
105
+ evt_menu(ID::SET_NULL_ANIMATION, :on_set_null_animation)
106
+ evt_menu(ID::SET_INACTIVE_BITMAP, :on_set_inactive_bitmap)
107
+ evt_menu(ID::SET_NO_AUTO_RESIZE, :on_set_no_auto_resize)
108
+ evt_menu(ID::SET_BGCOLOR, :on_set_bg_color)
109
+ if Wx::PLATFORM == 'WXGTK'
110
+ evt_menu(ID::USE_GENERIC, :on_use_generic)
111
+ end
112
+
113
+ evt_menu(Wx::ID_STOP, :on_stop)
114
+ evt_menu(Wx::ID_ABOUT, :on_about)
115
+ evt_menu(Wx::ID_EXIT, :on_quit)
116
+ if Wx.has_feature?(:USE_FILEDLG)
117
+ evt_menu(Wx::ID_OPEN, :on_open)
118
+ end # USE_FILEDLG
119
+
120
+ evt_size { self.layout }
121
+ evt_update_ui(Wx::ID_ANY, :on_update_ui)
122
+ end
123
+
124
+ def on_about(_event)
125
+ info = Wx::AboutDialogInfo.new
126
+ info.set_name("Wx::AnimationCtrl and Wx::Animation sample")
127
+ info.set_description("This sample program demonstrates the usage of Wx::AnimationCtrl")
128
+ info.set_copyright("(C) 2024 Martin Corino (original (C) 2006 Julian Smart)")
129
+
130
+ info.add_developer("Martin Corino")
131
+
132
+ Wx.about_box(info, self)
133
+ end
134
+
135
+ def on_quit(_event)
136
+ close
137
+ end
138
+
139
+ def on_play(_event)
140
+ Wx.log_error('Invalid animation') unless @animation_ctrl.play
141
+ end
142
+
143
+ def on_set_null_animation(_event)
144
+ @animation_ctrl.set_animation(Wx::NULL_ANIMATION)
145
+ end
146
+
147
+ def on_set_inactive_bitmap(event)
148
+ if event.checked?
149
+ # set a dummy bitmap as the inactive bitmap
150
+ bmp = Wx::ArtProvider.get_bitmap(Wx::ART_MISSING_IMAGE)
151
+ @animation_ctrl.set_inactive_bitmap(bmp)
152
+ else
153
+ @animation_ctrl.set_inactive_bitmap(Wx::NULL_BITMAP)
154
+ end
155
+ end
156
+
157
+ def on_set_no_auto_resize(event)
158
+ # recreate the control with the new flag if necessary
159
+ style = Wx::AC_DEFAULT_STYLE | (event.checked? ? Wx::AC_NO_AUTORESIZE : 0)
160
+
161
+ recreate_animation(style) if style != @animation_ctrl.get_window_style
162
+ end
163
+
164
+ def on_set_bg_color(_event)
165
+ clr = Wx.get_colour_from_user(self, @animation_ctrl.get_background_colour,
166
+ 'Choose the background colour')
167
+
168
+ @animation_ctrl.set_background_colour(clr) if clr.ok?
169
+ end
170
+
171
+ def on_stop(_event)
172
+ @animation_ctrl.stop
173
+ end
174
+
175
+ if Wx::PLATFORM == 'WXGTK'
176
+
177
+ def on_use_generic(_event)
178
+ recreate_animation(@animation_ctrl.get_window_style)
179
+ end
180
+
181
+ end
182
+
183
+ def on_update_ui(_event)
184
+ get_menu_bar.find_item(Wx::ID_STOP).first.enable(@animation_ctrl.playing?)
185
+ get_menu_bar.find_item(ID::PLAY).first.enable(!@animation_ctrl.playing?)
186
+ get_menu_bar.find_item(ID::SET_NO_AUTO_RESIZE).first.enable(!@animation_ctrl.playing?)
187
+ end
188
+
189
+ if Wx.has_feature?(:USE_FILEDLG)
190
+
191
+ def on_open(_event)
192
+ Wx.FileDialog(self, "Please choose an animation", '', '', '*.gif;*.ani', Wx::FD_OPEN) do |dialog|
193
+ if dialog.show_modal == Wx::ID_OK
194
+ filename = dialog.get_path
195
+
196
+ temp = @animation_ctrl.create_animation
197
+ unless temp.load_file(filename)
198
+ Wx.log_error("Sorry, this animation is not a valid format for Wx::Animation.")
199
+ return
200
+ end
201
+
202
+ @animation_ctrl.set_animation(temp)
203
+ @animation_ctrl.play
204
+
205
+ get_sizer.layout
206
+ end
207
+ end
208
+ end
209
+
210
+ end # USE_FILEDLG
211
+
212
+ private
213
+
214
+ def recreate_animation(style)
215
+ # save status of the control before destroying it
216
+
217
+ # We can't reuse the existing animation if we're switching from native to
218
+ # generic control or vice versa (as indicated by the absence of change in
219
+ # the style, which is the only other reason we can get called). We could
220
+ # save the file name we loaded it from and recreate it, of course, but for
221
+ # now, for simplicity, just start without any animation in this case.
222
+ curr = Wx::Animation.new
223
+ if Wx::PLATFORM == 'WXGTK'
224
+ curr = @animation_ctrl.get_animation if style != @animation_ctrl.get_window_style
225
+ end
226
+
227
+ inactive = @animation_ctrl.get_inactive_bitmap
228
+ bg = @animation_ctrl.get_background_colour
229
+
230
+ # destroy & rebuild
231
+ old = @animation_ctrl
232
+
233
+ if Wx::PLATFORM == 'WXGTK' && get_menu_bar.is_checked(ID::USE_GENERIC)
234
+ @animation_ctrl = Wx::GenericAnimationCtrl.new(self, Wx::ID_ANY, curr, style: style)
235
+ else
236
+ @animation_ctrl = Wx::AnimationCtrl.new(self, Wx::ID_ANY, curr, style: style)
237
+ end
238
+
239
+ get_sizer.replace(old, @animation_ctrl)
240
+
241
+ # load old status in new control
242
+ @animation_ctrl.set_inactive_bitmap(inactive)
243
+ @animation_ctrl.set_background_colour(bg)
244
+
245
+ get_sizer.layout
246
+ end
247
+
248
+ end
249
+
250
+
251
+ class App < Wx::App
252
+
253
+ # this one is called on application startup and is a good place for the app
254
+ # initialization (doing it here and not in the ctor allows to have an error
255
+ # return: if OnInit() returns false, the application terminates)
256
+ def on_init
257
+ # Create the main frame window
258
+ frame = MyFrame.new('Animation Demo')
259
+ frame.show
260
+ end
261
+
262
+ end
263
+
264
+ end
265
+
266
+ module AniTestSample
267
+
268
+ include WxRuby::Sample if defined? WxRuby::Sample
269
+
270
+ def self.describe
271
+ { file: __FILE__,
272
+ summary: 'wxRuby AnimationCtrl example.',
273
+ description: <<~__DESC
274
+ A Ruby port of the wxWidgets anitest sample which showcases
275
+ animation controls.
276
+ __DESC
277
+ }
278
+ end
279
+
280
+ def self.run
281
+ execute(__FILE__)
282
+ end
283
+
284
+ if $0 == __FILE__
285
+ AniTest::App.run
286
+ end
287
+
288
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './wxframe_runner'
6
+
7
+ class DirectorOverloadExceptionTests < WxRuby::Test::GUITests
8
+
9
+ class ExceptionSizer < Wx::BoxSizer
10
+
11
+ def calc_min
12
+ raise RuntimeError, 'AnyThing'
13
+ end
14
+
15
+ end
16
+
17
+ def test_exception_in_overload
18
+ szr = ExceptionSizer.new(Wx::Orientation::VERTICAL)
19
+ szr.add(Wx::Button.new(frame_win, name: 'button'), Wx::Direction::TOP)
20
+ frame_win.sizer = szr
21
+ frame_win.layout
22
+ frame_win.sizer = nil
23
+ end
24
+
25
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './wxapp_runner'
6
+
7
+ class ProcessEventHandlingExceptionTests < Test::Unit::TestCase
8
+
9
+ class TestEvent < Wx::Event
10
+ EVT_TEST_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_event', 0)
11
+ def initialize(id=0)
12
+ super(EVT_TEST_EVENT, id)
13
+ end
14
+ end
15
+
16
+ class TestFrame < Wx::Frame
17
+
18
+ def initialize
19
+ super(nil, size: [300,300])
20
+
21
+ evt_test_event { |_evt| raise RuntimeError, 'Whatever' }
22
+ end
23
+
24
+ end
25
+
26
+ def test_process_event
27
+ win = TestFrame.new
28
+ win.process_event(TestEvent.new)
29
+ win.destroy
30
+ 10.times { Wx.get_app.yield }
31
+ end
32
+
33
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './wxapp_runner'
6
+
7
+ class QueuedEventHandlingExceptionTests < Test::Unit::TestCase
8
+
9
+ class TestEvent < Wx::Event
10
+ EVT_TEST_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_event', 0)
11
+ def initialize(id=0)
12
+ super(EVT_TEST_EVENT, id)
13
+ end
14
+ end
15
+
16
+ class TestFrame < Wx::Frame
17
+
18
+ def initialize
19
+ super(nil, size: [300,300])
20
+
21
+ evt_test_event { |_evt| raise RuntimeError, 'Whatever' }
22
+ end
23
+
24
+ end
25
+
26
+ def test_queue_event
27
+ win = TestFrame.new
28
+ win.queue_event(TestEvent.new)
29
+ Wx.get_app.yield
30
+ win.destroy
31
+ 10.times { Wx.get_app.yield }
32
+ end
33
+
34
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './wxframe_runner'
6
+
7
+ class DirectorTypeExceptionTests < WxRuby::Test::GUITests
8
+
9
+ class InvalidOutputSizer < Wx::BoxSizer
10
+
11
+ def calc_min
12
+ nil #Wx::Point.new(1,1) # expects Wx::Size
13
+ end
14
+
15
+ end
16
+
17
+ def test_invalid_output
18
+ szr = InvalidOutputSizer.new(Wx::Orientation::VERTICAL)
19
+ szr.add(Wx::Button.new(frame_win, name: 'button'), Wx::Direction::TOP)
20
+ frame_win.sizer = szr
21
+ frame_win.layout
22
+ frame_win.sizer = nil
23
+ end
24
+
25
+ end
@@ -2,40 +2,40 @@
2
2
  #
3
3
  # This software is released under the MIT license.
4
4
 
5
- require_relative './lib/wxframe_runner'
5
+ require 'test/unit'
6
+ require 'plat4m'
7
+ require 'open3'
6
8
 
7
- class DirectorExceptionTests < WxRuby::Test::GUITests
9
+ class DirectorExceptionTests < Test::Unit::TestCase
8
10
 
9
- class InvalidOutputSizer < Wx::BoxSizer
11
+ # Path to the currently running Ruby program
12
+ RUBY = ENV["RUBY"] || File.join(
13
+ RbConfig::CONFIG["bindir"],
14
+ RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).
15
+ sub(/.*\s.*/m, '"\&"')
10
16
 
11
- def calc_min
12
- Wx::Point.new(1,1) # expects Wx::Size
13
- end
17
+ OPTS = {
18
+ :err => (Plat4m.current.windows? ? 'NULL' : '/dev/null'), :out => (Plat4m.current.windows? ? 'NULL' : '/dev/null'),
19
+ }
14
20
 
21
+ def test_invalid_overload_type
22
+ assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/overload_type_exception_test.rb'), **OPTS))
23
+ assert_equal(254, $?.exitstatus)
15
24
  end
16
25
 
17
- def test_invalid_output
18
- szr = InvalidOutputSizer.new(Wx::Orientation::VERTICAL)
19
- szr.add(Wx::Button.new(frame_win, name: 'button'), Wx::Direction::TOP)
20
- frame_win.sizer = szr
21
- assert_raise_kind_of(TypeError) { frame_win.layout }
22
- frame_win.sizer = nil
26
+ def test_leaked_exception_in_overload
27
+ assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/leaked_overload_exception_test.rb'), **OPTS))
28
+ assert_equal(255, $?.exitstatus)
23
29
  end
24
30
 
25
- class ExceptionSizer < Wx::BoxSizer
26
-
27
- def calc_min
28
- raise RuntimeError, 'AnyThing'
29
- end
30
-
31
+ def test_leaked_process_event_handling_exception
32
+ assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/leaked_process_event_exception_test.rb'), **OPTS))
33
+ assert_equal(1, $?.exitstatus)
31
34
  end
32
35
 
33
- def test_exception_in_overload
34
- szr = ExceptionSizer.new(Wx::Orientation::VERTICAL)
35
- szr.add(Wx::Button.new(frame_win, name: 'button'), Wx::Direction::TOP)
36
- frame_win.sizer = szr
37
- assert_raise_kind_of(RuntimeError) { frame_win.layout }
38
- frame_win.sizer = nil
36
+ def test_leaked_queued_event_handling_exception
37
+ assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/leaked_queued_event_exception_test.rb'), **OPTS))
38
+ assert_equal(1, $?.exitstatus)
39
39
  end
40
40
 
41
41
  end