diff options
author | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-04-01 06:23:07 +0000 |
---|---|---|
committer | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-04-01 06:23:07 +0000 |
commit | 3ff87cc53f6705959db82c8a4270bbdd5b8eabbd (patch) | |
tree | e4f39a05c33bf2a4f332eac6591d5b7f78349cb8 /test/win32ole | |
parent | 53efc383503c42a5c19d947c53f6caad25ee9de8 (diff) | |
download | ruby-3ff87cc53f6705959db82c8a4270bbdd5b8eabbd.tar.gz |
add WIN32OLE_TYPE#inspect, WIN32OLE_VARIABLE#inspect
add test/win32ole and remove some test script from ext/win32ole/tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/win32ole')
-rw-r--r-- | test/win32ole/test_win32ole_type.rb | 143 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_typelib.rb | 92 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_variable.rb | 62 |
3 files changed, 297 insertions, 0 deletions
diff --git a/test/win32ole/test_win32ole_type.rb b/test/win32ole/test_win32ole_type.rb new file mode 100644 index 0000000000..3acf6cd59d --- /dev/null +++ b/test/win32ole/test_win32ole_type.rb @@ -0,0 +1,143 @@ +begin + require 'win32ole' +rescue LoadError +end + +require "test/unit" + +if defined?(WIN32OLE_TYPE) + class TestWIN32OLE_TYPE < Test::Unit::TestCase + + def test_s_progids + progids = WIN32OLE_TYPE.progids + assert_instance_of(Array, progids) + assert(progids.size > 0) + assert_instance_of(String, progids[0]) + assert(progids.include?("Shell.Application.1")) + end + + def test_initialize + assert_raise(ArgumentError) { + WIN32OLE_TYPE.new + } + assert_raise(ArgumentError) { + WIN32OLE_TYPE.new("foo") + } + assert_raise(WIN32OLERuntimeError) { + WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "foo") + } + assert_raise(WIN32OLERuntimeError) { + WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Application") + } + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + assert_instance_of(WIN32OLE_TYPE, ole_type) + end + + def setup + @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + end + + def test_name + assert_equal("Shell", @ole_type.name) + end + + def test_ole_type + assert_equal("Class", @ole_type.ole_type) + end + + def test_guid + assert_equal("{13709620-C279-11CE-A49E-444553540000}", @ole_type.guid) + end + + def test_progid + assert_equal("Shell.Application.1", @ole_type.progid) + end + + def test_visible? + assert(@ole_type.visible?) + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "IShellDispatch") + assert(!ole_type.visible?) + end + + def test_to_s + assert_equal(@ole_type.to_s, @ole_type.name) + end + + def test_major_version + assert_equal(0, @ole_type.major_version) + # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents") + # assert_equal(8, ole_type.major_version) + end + + def test_minor_version + assert_equal(0, @ole_type.minor_version) + # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents") + # assert_equal(3, ole_type.minor_version) + end + + def test_typekind + assert_equal(5, @ole_type.typekind) + end + + def test_helpstring + assert_equal("Shell Object Type Information", @ole_type.helpstring) + end + + def test_src_type + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "DriveTypeConst") + assert_match(/__MIDL___MIDL_itf_scrrun_/, ole_type.src_type) + assert_equal(nil, @ole_type.src_type) + end + + def test_helpfile + assert_equal("", @ole_type.helpfile) + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders") + assert_match(/VBENLR98\.CHM$/i, ole_type.helpfile) + end + + def test_helpcontext + assert_equal(0, @ole_type.helpcontext) + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders") + assert_equal(2181929, ole_type.helpcontext) + end + + def test_variables + variables = @ole_type.variables + assert_instance_of(Array, variables) + assert(variables.size == 0) + + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + variables = ole_type.variables + assert_instance_of(Array, variables) + assert(variables.size > 0) + + assert_instance_of(WIN32OLE_VARIABLE, variables[0]) + end + + def test_ole_methods + methods = @ole_type.ole_methods + assert_instance_of(Array, methods) + assert(methods.size > 0) + assert_instance_of(WIN32OLE_METHOD, methods[0]); + assert(methods.collect{|m| m.name}.include?("Application")) + end + + def test_ole_typelib + tlib = @ole_type.ole_typelib + assert_instance_of(WIN32OLE_TYPELIB, tlib) + assert_equal("Microsoft Shell Controls And Automation", tlib.name) + end + + def test_implemented_ole_types + ole_types = @ole_type.implemented_ole_types + assert_instance_of(Array, ole_types) + assert(ole_types.size > 0) + assert_equal("IShellDispatch", ole_types[0].name) + end + + def test_inspect + assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect) + end + + end +end diff --git a/test/win32ole/test_win32ole_typelib.rb b/test/win32ole/test_win32ole_typelib.rb new file mode 100644 index 0000000000..0ef805d959 --- /dev/null +++ b/test/win32ole/test_win32ole_typelib.rb @@ -0,0 +1,92 @@ +begin + require 'win32ole' +rescue LoadError +end + +require "test/unit" + +if defined?(WIN32OLE_TYPELIB) + class TestWIN32OLE_TYPELIB < Test::Unit::TestCase + def test_s_typelibs + tlibs = WIN32OLE_TYPELIB.typelibs + assert_instance_of(Array, tlibs) + assert(tlibs.size > 0) + tlib = tlibs.find {|tlib| tlib.name == "Microsoft Shell Controls And Automation"} + assert(tlib) + end + + def test_initialize + assert_raise(ArgumentError) { + WIN32OLE_TYPELIB.new(1,2,3,4) + } + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_instance_of(WIN32OLE_TYPELIB, tlib) + + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1.0) + assert_instance_of(WIN32OLE_TYPELIB, tlib) + + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1, 0) + assert_instance_of(WIN32OLE_TYPELIB, tlib) + guid = tlib.guid + + tlib_by_guid = WIN32OLE_TYPELIB.new(guid, 1, 0) + assert_instance_of(WIN32OLE_TYPELIB, tlib_by_guid) + assert_equal("Microsoft Shell Controls And Automation" , tlib_by_guid.name) + + assert_raise(WIN32OLERuntimeError) { + WIN32OLE_TYPELIB.new("Non Exist Type Library") + } + end + + def test_guid + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid) + end + + def test_name + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal("Microsoft Shell Controls And Automation", tlib.name) + tlib = WIN32OLE_TYPELIB.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}") + assert_equal("Microsoft Shell Controls And Automation", tlib.name) + end + + def test_version + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal(1.0, tlib.version) + end + + def test_major_version + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal(1, tlib.major_version) + end + + def test_minor_version + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal(0, tlib.minor_version) + end + + def test_path + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_match(/shell32\.dll$/i, tlib.path) + end + + def test_to_s + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal("Microsoft Shell Controls And Automation", tlib.to_s) + end + + def test_ole_classes + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + ole_classes = tlib.ole_classes + assert_instance_of(Array, ole_classes) + assert(ole_classes.size > 0) + assert_instance_of(WIN32OLE_TYPE, ole_classes[0]) + end + + def test_inspect + tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation") + assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect) + end + + end +end diff --git a/test/win32ole/test_win32ole_variable.rb b/test/win32ole/test_win32ole_variable.rb new file mode 100644 index 0000000000..d84e800159 --- /dev/null +++ b/test/win32ole/test_win32ole_variable.rb @@ -0,0 +1,62 @@ +begin + require 'win32ole' +rescue LoadError +end + +require "test/unit" + +if defined?(WIN32OLE_VARIABLE) + class TestWIN32OLE_VARIABLE < Test::Unit::TestCase + + def setup + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants") + @var1 = ole_type.variables.find {|v| v.name == 'ssfDESKTOP'} + + variables = WIN32OLE_TYPE.new("Microsoft Windows Installer Object Library", "Installer").variables + @var2 = variables.find {|v| v.name == 'UILevel'} + end + + def test_name + assert_equal('ssfDESKTOP', @var1.name) + end + + def test_ole_type + assert_equal('INT', @var1.ole_type) + assert_equal('MsiUILevel', @var2.ole_type) + end + + def test_ole_type_detail + assert_equal(['INT'], @var1.ole_type_detail) + assert_equal(['USERDEFINED', 'MsiUILevel'], @var2.ole_type_detail) + end + + def test_ole_type_value + assert_equal(0, @var1.value) + assert_equal(nil, @var2.value) + end + + def test_ole_type_visible? + assert(@var1.visible?) + end + + def test_ole_type_variable_kind + assert_equal("CONSTANT", @var1.variable_kind) + assert_equal("DISPATCH", @var2.variable_kind) + end + + def test_ole_type_varkind + assert_equal(2, @var1.varkind) + assert_equal(3, @var2.varkind) + end + + def test_to_s + assert_equal(@var1.name, @var1.to_s) + end + + def test_inspect + assert_equal("#<WIN32OLE_VARIABLE:ssfDESKTOP=0>", @var1.inspect) + assert_equal("#<WIN32OLE_VARIABLE:UILevel=nil>", @var2.inspect) + end + + end +end |