Sha256: 8f19c8df69e6a96c660cbd1c5757d2e7584559ca304f17d7f1a40c7d706f481f

Contents?: true

Size: 1.23 KB

Versions: 42

Compression:

Stored size: 1.23 KB

Contents

require 'test/unit'
require 'thread'
require 'fox16'

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

42 entries across 42 versions & 2 rubygems

Version Path
fxruby-1.6.22.pre2-x86-mingw32 test/stress2.rb
fxruby-1.6.22.pre2 test/stress2.rb
fxrubi-1.6.22.pre1-x86-mingw32 test/stress2.rb
fxrubi-1.6.22.pre1 test/stress2.rb
fxruby-1.6.20-x86-mingw32 test/stress2.rb
fxruby-1.6.20-x86-linux test/stress2.rb
fxruby-1.6.20 test/stress2.rb
fxruby-1.6.20-universal-darwin-10 test/stress2.rb
fxruby-1.6.19-x86-mingw32 tests/stress2.rb
fxruby-1.6.14-mswin32 tests/stress2.rb
fxruby-1.6.13-mswin32 tests/stress2.rb
fxruby-1.6.0 tests/stress2.rb
fxruby-1.6.1 tests/stress2.rb
fxruby-1.6.10 tests/stress2.rb
fxruby-1.6.11 tests/stress2.rb
fxruby-1.6.12 tests/stress2.rb
fxruby-1.6.13 tests/stress2.rb
fxruby-1.6.14-universal-darwin-9 tests/stress2.rb
fxruby-1.6.15-universal-darwin-9 tests/stress2.rb
fxruby-1.6.14 tests/stress2.rb