Sha256: 821cedfe5f576049f4e171f44bbe5552fa27498d49b29df13cb9cecd0b4d9c28
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
############################################################################ # tc_win32_api_callback.rb # # Test case for the Win32::API::Callback class. You should run this as Rake # task, i.e. 'rake test', instead of running it directly. ############################################################################ require 'win32/api' require 'test/unit' include Win32 class TC_Win32_API_Callback < Test::Unit::TestCase def setup @buffer = 0.chr * 260 @api_ew = API.new('EnumWindows', 'KP', 'L', 'user32') @api_gwt = API.new('GetWindowText', 'LPI', 'I', 'user32') @callback = nil end def test_constructor assert_respond_to(API::Callback, :new) assert_nothing_raised{ API::Callback.new('LP', 'I') } assert_nothing_raised{ API::Callback.new('LP', 'I'){} } end def test_prototype assert_nothing_raised{ @callback = API::Callback.new('LP', 'I') } assert_respond_to(@callback, :prototype) assert_equal('LP', @callback.prototype) end def test_return_value assert_nothing_raised{ @callback = API::Callback.new('LP', 'I') } assert_respond_to(@callback, :return_type) assert_equal('I', @callback.return_type) end def test_callback assert_nothing_raised{ @callback = API::Callback.new('LP', 'I'){ |handle, param| buf = "\0" * 200 @api_gwt.call(handle, buf, 200); buf.index(param).nil? ? true : false } } assert_nothing_raised{ @api_ew.call(@callback, 'UEDIT32') } end def test_constructor_expected_errors assert_raise(API::Callback::Error){ API::Callback.new('X') } end def teardown @buffer = nil @api_ew = nil @api_gwt = nil @callback = nil end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
win32-api-1.0.0-mswin32 | test/tc_win32_api_callback.rb |
win32-api-1.0.0 | test/tc_win32_api_callback.rb |