8
if defined?(WIN32OLE_TYPE)
9
class TestWIN32OLE_TYPE < Test::Unit::TestCase
12
progids = WIN32OLE_TYPE.progids
13
assert_instance_of(Array, progids)
14
assert(progids.size > 0)
15
assert_instance_of(String, progids[0])
16
assert(progids.include?("Shell.Application.1"))
20
assert_raise(ArgumentError) {
23
assert_raise(ArgumentError) {
24
WIN32OLE_TYPE.new("foo")
26
assert_raise(WIN32OLERuntimeError) {
27
WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "foo")
29
assert_raise(WIN32OLERuntimeError) {
30
WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Application")
32
ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
33
assert_instance_of(WIN32OLE_TYPE, ole_type)
37
@ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
41
assert_equal("Shell", @ole_type.name)
45
assert_equal("Class", @ole_type.ole_type)
49
assert_equal("{13709620-C279-11CE-A49E-444553540000}", @ole_type.guid)
53
assert_equal("Shell.Application.1", @ole_type.progid)
57
assert(@ole_type.visible?)
58
ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "IShellDispatch")
59
assert(!ole_type.visible?)
63
assert_equal(@ole_type.to_s, @ole_type.name)
66
def test_major_version
67
assert_equal(0, @ole_type.major_version)
68
# ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
69
# assert_equal(8, ole_type.major_version)
72
def test_minor_version
73
assert_equal(0, @ole_type.minor_version)
74
# ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
75
# assert_equal(3, ole_type.minor_version)
79
assert_equal(5, @ole_type.typekind)
83
assert_equal("Shell Object Type Information", @ole_type.helpstring)
87
ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "DriveTypeConst")
88
assert_match(/__MIDL___MIDL_itf_scrrun_/, ole_type.src_type)
89
assert_equal(nil, @ole_type.src_type)
93
assert_equal("", @ole_type.helpfile)
94
ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
95
assert_match(/VBENLR98\.CHM$/i, ole_type.helpfile)
99
assert_equal(0, @ole_type.helpcontext)
100
ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
101
assert_equal(2181929, ole_type.helpcontext)
105
variables = @ole_type.variables
106
assert_instance_of(Array, variables)
107
assert(variables.size == 0)
109
ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
110
variables = ole_type.variables
111
assert_instance_of(Array, variables)
112
assert(variables.size > 0)
114
assert_instance_of(WIN32OLE_VARIABLE, variables[0])
118
methods = @ole_type.ole_methods
119
assert_instance_of(Array, methods)
120
assert(methods.size > 0)
121
assert_instance_of(WIN32OLE_METHOD, methods[0]);
122
assert(methods.collect{|m| m.name}.include?("Application"))
126
tlib = @ole_type.ole_typelib
127
assert_instance_of(WIN32OLE_TYPELIB, tlib)
128
assert_equal("Microsoft Shell Controls And Automation", tlib.name)
131
def test_implemented_ole_types
132
ole_types = @ole_type.implemented_ole_types
133
assert_instance_of(Array, ole_types)
134
assert(ole_types.size > 0)
135
assert_equal("IShellDispatch", ole_types[0].name)
139
assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect)