Sha256: b85f3f1a711d76571f4879c297536f53ca0496cd450bab6f2655d3bcc0d68acb
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
require 'test/unit' require 'thread' require 'fox12' include Fox class TC_stress2 < Test::Unit::TestCase def set_up_main_window(theApp) theMainWindow = FXMainWindow.new(theApp, "TC_stress2", nil, nil, DECOR_ALL, 0, 0, 200, 100) @countLabel = FXLabel.new(theMainWindow, "0", nil, LAYOUT_FILL_X|LAYOUT_FILL_Y) theMainWindow end def on_timeout(sender, sel, ptr) safeToQuit = false $lock.synchronize { if $count > 1000000 # if it were going to crash, it probably would have done # so by now, so it's safe to quit. safeToQuit = true end @countLabel.setText($count.to_s) } if safeToQuit @theApp.handle(@theMainWindow, MKUINT(FXApp::ID_QUIT, SEL_COMMAND), nil) else @theApp.addTimeout(100, method(:on_timeout)) end end def test_run # Set up the counter thread $count = 0 $lock = Mutex.new w = Thread.new do loop do $lock.synchronize { $count += 1 } sleep 0 end end # Start the app @theApp = FXApp.new("TC_stress2", "FXRuby") @theMainWindow = set_up_main_window(@theApp) @theApp.create @theMainWindow.show(PLACEMENT_SCREEN) @theApp.addTimeout(100, method(:on_timeout)) @theApp.run end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
fxruby-1.2.2 | tests/stress2.rb |
fxruby-1.2.3 | tests/stress2.rb |
fxruby-1.2.4 | tests/stress2.rb |
fxruby-1.2.5 | tests/stress2.rb |
fxruby-1.4.0 | tests/stress2.rb |
fxruby-1.2.6 | tests/stress2.rb |