7 if defined?(WIN32OLE_METHOD)
8 class TestWIN32OLE_METHOD < Test::Unit::TestCase
11 ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
12 @m_open = WIN32OLE_METHOD.new(ole_type, "open")
13 @m_namespace = WIN32OLE_METHOD.new(ole_type, "namespace")
14 @m_parent = WIN32OLE_METHOD.new(ole_type, "parent")
15 @m_invoke = WIN32OLE_METHOD.new(ole_type, "invoke")
16 @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder")
18 ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File")
19 @m_file_name = WIN32OLE_METHOD.new(ole_type, "name")
21 ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser")
22 @m_navigate_complete = WIN32OLE_METHOD.new(ole_type, "NavigateComplete")
26 ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
27 assert_raise(ArgumentError) {
28 method = WIN32OLE_METHOD.new("foo")
30 assert_raise(ArgumentError) {
31 method = WIN32OLE_METHOD.new(ole_type)
33 assert_raise(WIN32OLERuntimeError) {
34 method = WIN32OLE_METHOD.new(ole_type, "NonExistMethod")
36 assert_raise(TypeError) {
37 method = WIN32OLE_METHOD.new(ole_type, 1)
39 method = WIN32OLE_METHOD.new(ole_type, "Open")
40 assert_instance_of(WIN32OLE_METHOD, method)
41 method = WIN32OLE_METHOD.new(ole_type, "open")
42 assert_instance_of(WIN32OLE_METHOD, method)
46 assert_equal("Open", @m_open.name)
50 assert_equal("VOID", @m_open.return_type)
51 assert_equal("Folder", @m_namespace.return_type)
55 assert_equal(24, @m_open.return_vtype)
56 assert_equal(26, @m_namespace.return_vtype)
59 def test_return_type_detail
60 assert_equal(['VOID'], @m_open.return_type_detail)
61 assert_equal(['PTR', 'USERDEFINED', 'Folder'], @m_namespace.return_type_detail)
65 assert_equal('FUNC', @m_open.invoke_kind)
66 assert_equal('FUNC', @m_namespace.invoke_kind)
67 assert_equal('PROPERTYGET', @m_parent.invoke_kind)
71 assert_equal(1, @m_namespace.invkind)
72 assert_equal(2, @m_parent.invkind)
76 assert(@m_namespace.visible?)
77 assert(!@m_invoke.visible?)
81 assert(@m_navigate_complete.event?)
82 assert(!@m_namespace.event?)
85 def test_event_interface
86 assert_equal("DWebBrowserEvents", @m_navigate_complete.event_interface)
87 assert_equal(nil, @m_namespace.event_interface)
91 assert_equal("Get special folder from ShellSpecialFolderConstants", @m_namespace.helpstring)
95 assert_equal("", @m_namespace.helpfile)
96 assert_match(/VBENLR.*\.CHM$/i, @m_file_name.helpfile)
100 assert_equal(0, @m_namespace.helpcontext)
101 assert_equal(2181996, @m_file_name.helpcontext)
105 assert_equal(1610743810, @m_namespace.dispid)
109 assert_equal(24, @m_invoke.offset_vtbl)
113 assert_equal(1, @m_open.size_params)
114 assert_equal(4, @m_browse_for_folder.size_params)
117 def test_size_opt_params
118 assert_equal(0, @m_open.size_opt_params)
119 assert_equal(1, @m_browse_for_folder.size_opt_params)
123 params = @m_browse_for_folder.params
124 assert_instance_of(Array, params)
125 assert_equal(4, params.size)
126 assert_instance_of(WIN32OLE_PARAM, params[0])
130 assert_equal(@m_namespace.name, @m_namespace.to_s)
134 assert_equal("#<WIN32OLE_METHOD:NameSpace>", @m_namespace.inspect)