diff options
-rw-r--r-- | test/win32ole/test_folderitem2_invokeverb.rb | 3 | ||||
-rw-r--r-- | test/win32ole/test_nil2vtempty.rb | 2 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_event.rb | 3 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_method.rb | 135 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_param.rb | 84 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_type.rb | 1 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_typelib.rb | 1 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_variable.rb | 1 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_variant.rb | 1 | ||||
-rw-r--r-- | test/win32ole/test_win32ole_variant_m.rb | 3 |
10 files changed, 223 insertions, 11 deletions
diff --git a/test/win32ole/test_folderitem2_invokeverb.rb b/test/win32ole/test_folderitem2_invokeverb.rb index 070768468..974c50077 100644 --- a/test/win32ole/test_folderitem2_invokeverb.rb +++ b/test/win32ole/test_folderitem2_invokeverb.rb @@ -4,9 +4,8 @@ begin require 'win32ole' -rescue +rescue LoadError end - require 'test/unit' if defined?(WIN32OLE) diff --git a/test/win32ole/test_nil2vtempty.rb b/test/win32ole/test_nil2vtempty.rb index 2576415a8..6eb9333f0 100644 --- a/test/win32ole/test_nil2vtempty.rb +++ b/test/win32ole/test_nil2vtempty.rb @@ -4,8 +4,8 @@ begin require 'win32ole' rescue LoadError end - require 'test/unit' + if defined?(WIN32OLE) class TestNIL2VT_EMPTY < Test::Unit::TestCase def setup diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb index 1b0285cb5..ca6d4bed7 100644 --- a/test/win32ole/test_win32ole_event.rb +++ b/test/win32ole/test_win32ole_event.rb @@ -1,8 +1,9 @@ begin require 'win32ole' -rescue +rescue LoadError end require 'test/unit' + if defined?(WIN32OLE_EVENT) class TestWIN32OLE_EVENT < Test::Unit::TestCase def setup diff --git a/test/win32ole/test_win32ole_method.rb b/test/win32ole/test_win32ole_method.rb new file mode 100644 index 000000000..31eff8793 --- /dev/null +++ b/test/win32ole/test_win32ole_method.rb @@ -0,0 +1,135 @@ +begin + require 'win32ole' +rescue LoadError +end +require "test/unit" + +if defined?(WIN32OLE_METHOD) + class TestWIN32OLE_METHOD < Test::Unit::TestCase + + def setup + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + @m_open = WIN32OLE_METHOD.new(ole_type, "open") + @m_namespace = WIN32OLE_METHOD.new(ole_type, "namespace") + @m_parent = WIN32OLE_METHOD.new(ole_type, "parent") + @m_invoke = WIN32OLE_METHOD.new(ole_type, "invoke") + @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder") + + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File") + @m_file_name = WIN32OLE_METHOD.new(ole_type, "name") + + ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser") + @m_navigate_complete = WIN32OLE_METHOD.new(ole_type, "NavigateComplete") + end + + def test_initialize + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell") + assert_raise(ArgumentError) { + method = WIN32OLE_METHOD.new("foo") + } + assert_raise(ArgumentError) { + method = WIN32OLE_METHOD.new(ole_type) + } + assert_raise(WIN32OLERuntimeError) { + method = WIN32OLE_METHOD.new(ole_type, "NonExistMethod") + } + method = WIN32OLE_METHOD.new(ole_type, "Open") + assert_instance_of(WIN32OLE_METHOD, method) + method = WIN32OLE_METHOD.new(ole_type, "open") + assert_instance_of(WIN32OLE_METHOD, method) + end + + def test_name + assert_equal("Open", @m_open.name) + end + + def test_return_type + assert_equal("VOID", @m_open.return_type) + assert_equal("Folder", @m_namespace.return_type) + end + + def test_return_vtype + assert_equal(24, @m_open.return_vtype) + assert_equal(26, @m_namespace.return_vtype) + end + + def test_return_type_detail + assert_equal(['VOID'], @m_open.return_type_detail) + assert_equal(['PTR', 'USERDEFINED', 'Folder'], @m_namespace.return_type_detail) + end + + def test_invoke_kind + assert_equal('FUNC', @m_open.invoke_kind) + assert_equal('FUNC', @m_namespace.invoke_kind) + assert_equal('PROPERTYGET', @m_parent.invoke_kind) + end + + def test_invkind + assert_equal(1, @m_namespace.invkind) + assert_equal(2, @m_parent.invkind) + end + + def test_visible? + assert(@m_namespace.visible?) + assert(!@m_invoke.visible?) + end + + def test_event? + assert(@m_navigate_complete.event?) + assert(!@m_namespace.event?) + end + + def test_event_interface + assert_equal("DWebBrowserEvents", @m_navigate_complete.event_interface) + assert_equal(nil, @m_namespace.event_interface) + end + + def test_helpstring + assert_equal("Get special folder from ShellSpecialFolderConstants", @m_namespace.helpstring) + end + + def test_helpfile + assert_equal("", @m_namespace.helpfile) + assert_match(/VBENLR.*\.CHM$/i, @m_file_name.helpfile) + end + + def test_helpcontext + assert_equal(0, @m_namespace.helpcontext) + assert_equal(2181996, @m_file_name.helpcontext) + end + + def test_dispid + assert_equal(1610743810, @m_namespace.dispid) + end + + def test_offset_vtbl + assert_equal(24, @m_invoke.offset_vtbl) + end + + def test_size_params + assert_equal(1, @m_open.size_params) + assert_equal(4, @m_browse_for_folder.size_params) + end + + def test_size_opt_params + assert_equal(0, @m_open.size_opt_params) + assert_equal(1, @m_browse_for_folder.size_opt_params) + end + + def test_params + params = @m_browse_for_folder.params + assert_instance_of(Array, params) + assert_equal(4, params.size) + assert_instance_of(WIN32OLE_PARAM, params[0]) + end + + def test_to_s + assert_equal(@m_namespace.name, @m_namespace.to_s) + end + + def test_inspect + assert_equal("#<WIN32OLE_METHOD:NameSpace>", @m_namespace.inspect) + end + + end +end diff --git a/test/win32ole/test_win32ole_param.rb b/test/win32ole/test_win32ole_param.rb new file mode 100644 index 000000000..4374f9a42 --- /dev/null +++ b/test/win32ole/test_win32ole_param.rb @@ -0,0 +1,84 @@ +begin + require 'win32ole' +rescue LoadError +end +require "test/unit" + +if defined?(WIN32OLE_PARAM) + class TestWIN32OLE_PARAM < Test::Unit::TestCase + + def setup + ole_type = WIN32OLE_TYPE.new("Microsoft Internet Controls", "WebBrowser") + m_navigate = WIN32OLE_METHOD.new(ole_type, "Navigate") + m_before_navigate = WIN32OLE_METHOD.new(ole_type, "BeforeNavigate") + params = m_navigate.params + @param_url = params[0] + @param_flags = params[1] + @param_cancel = m_before_navigate.params[5] + + ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellLinkObject") + m_geticonlocation = WIN32OLE_METHOD.new(ole_type, "GetIconLocation") + @param_pbs = m_geticonlocation.params[0] + + ole_type = WIN32OLE_TYPE.new("Microsoft HTML Object Library", "FontNames") + m_count = WIN32OLE_METHOD.new(ole_type, "Count") + @param_p = m_count.params[0] + + ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject") + m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile") + @param_overwritefiles = m_copyfile.params[2] + end + + def test_name + assert_equal('URL', @param_url.name) + assert_equal('Flags', @param_flags.name) + assert_equal('Cancel', @param_cancel.name) + end + + def test_ole_type + assert_equal('BSTR', @param_url.ole_type) + assert_equal('VARIANT', @param_flags.ole_type) + end + + def test_ole_type_detail + assert_equal(['BSTR'], @param_url.ole_type_detail) + assert_equal(['PTR', 'VARIANT'], @param_flags.ole_type_detail) + end + + def test_input? + assert(@param_url.input?) + assert(@param_cancel.input?) + assert(!@param_pbs.input?) + end + + def test_output? + assert(!@param_url.output?) + assert(@param_cancel.output?) + assert(@param_pbs.output?) + end + + def test_optional? + assert(!@param_url.optional?) + assert(@param_flags.optional?) + end + + def test_retval? + assert(!@param_url.retval?) + assert(@param_p.retval?) + end + + def test_default + assert_equal(nil, @param_url.default) + assert_equal(true, @param_overwritefiles.default) + end + + def test_to_s + assert_equal(@param_url.name, @param_url.to_s) + end + + def test_inspect + assert_equal("#<WIN32OLE_PARAM:URL>", @param_url.inspect) + assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", @param_overwritefiles.inspect) + end + end +end diff --git a/test/win32ole/test_win32ole_type.rb b/test/win32ole/test_win32ole_type.rb index 3acf6cd59..895cdb0b7 100644 --- a/test/win32ole/test_win32ole_type.rb +++ b/test/win32ole/test_win32ole_type.rb @@ -2,7 +2,6 @@ begin require 'win32ole' rescue LoadError end - require "test/unit" if defined?(WIN32OLE_TYPE) diff --git a/test/win32ole/test_win32ole_typelib.rb b/test/win32ole/test_win32ole_typelib.rb index f4ece8abe..7b83bf8be 100644 --- a/test/win32ole/test_win32ole_typelib.rb +++ b/test/win32ole/test_win32ole_typelib.rb @@ -2,7 +2,6 @@ begin require 'win32ole' rescue LoadError end - require "test/unit" if defined?(WIN32OLE_TYPELIB) diff --git a/test/win32ole/test_win32ole_variable.rb b/test/win32ole/test_win32ole_variable.rb index d84e80015..43529d3ba 100644 --- a/test/win32ole/test_win32ole_variable.rb +++ b/test/win32ole/test_win32ole_variable.rb @@ -2,7 +2,6 @@ begin require 'win32ole' rescue LoadError end - require "test/unit" if defined?(WIN32OLE_VARIABLE) diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb index 175d1d53f..ad7c94fd1 100644 --- a/test/win32ole/test_win32ole_variant.rb +++ b/test/win32ole/test_win32ole_variant.rb @@ -2,7 +2,6 @@ begin require 'win32ole' rescue LoadError end - require "test/unit" if defined?(WIN32OLE_VARIANT) diff --git a/test/win32ole/test_win32ole_variant_m.rb b/test/win32ole/test_win32ole_variant_m.rb index 1271526db..1377ae94d 100644 --- a/test/win32ole/test_win32ole_variant_m.rb +++ b/test/win32ole/test_win32ole_variant_m.rb @@ -1,10 +1,7 @@ -# You need RubyUnit and MS Excel and MSI to run this test script - begin require 'win32ole' rescue LoadError end - require "test/unit" if defined?(WIN32OLE::VARIANT) |