ruby-changes:52841
From: suke <ko1@a...>
Date: Sat, 13 Oct 2018 12:18:48 +0900 (JST)
Subject: [ruby-changes:52841] suke:r65053 (trunk): use ADODB.Connection instead of Microsoft Internet Controls.
suke 2018-10-13 12:18:42 +0900 (Sat, 13 Oct 2018) New Revision: 65053 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65053 Log: use ADODB.Connection instead of Microsoft Internet Controls. * test/win32ole/test_win32ole_type.rb: remove test using Microsoft Internet Controls. * test/win32ole/test_win32ole_type_event.rb: some test uses ADODB.Connection. Added files: trunk/test/win32ole/test_win32ole_type_event.rb Modified files: trunk/test/win32ole/test_win32ole_type.rb Index: test/win32ole/test_win32ole_type.rb =================================================================== --- test/win32ole/test_win32ole_type.rb (revision 65052) +++ test/win32ole/test_win32ole_type.rb (revision 65053) @@ -175,62 +175,12 @@ if defined?(WIN32OLE_TYPE) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole_type.rb#L175 assert_instance_of(Array, ole_types) assert_equal(1, ole_types.size) assert_match(/^IShellDispatch\d{0,1}$/, ole_types[0].name) - - ie_otype = WIN32OLE_TYPE.new("Microsoft Internet Controls", "InternetExplorer") - ole_types = ie_otype.implemented_ole_types - assert_equal(4, ole_types.size) - otype = ole_types.select{|t| t.name == "IWebBrowser2"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "IWebBrowserApp"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents2"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents"} - assert_equal(1, otype.size) - end - - def test_default_ole_types - ie_otype = WIN32OLE_TYPE.new("Microsoft Internet Controls", "InternetExplorer") - ole_types = ie_otype.default_ole_types - otype = ole_types.select{|t| t.name == "IWebBrowser2"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "IWebBrowserApp"} - assert_equal(0, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents2"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents"} - assert_equal(0, otype.size) - end - - def test_source_ole_types - ie_otype = WIN32OLE_TYPE.new("Microsoft Internet Controls", "InternetExplorer") - ole_types = ie_otype.source_ole_types - otype = ole_types.select{|t| t.name == "IWebBrowser2"} - assert_equal(0, otype.size) - otype = ole_types.select{|t| t.name == "IWebBrowserApp"} - assert_equal(0, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents2"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents"} - assert_equal(1, otype.size) - end - - def test_default_event_sources - ie_otype = WIN32OLE_TYPE.new("Microsoft Internet Controls", "InternetExplorer") - ole_types = ie_otype.default_event_sources - otype = ole_types.select{|t| t.name == "IWebBrowser2"} - assert_equal(0, otype.size) - otype = ole_types.select{|t| t.name == "IWebBrowserApp"} - assert_equal(0, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents2"} - assert_equal(1, otype.size) - otype = ole_types.select{|t| t.name == "DWebBrowserEvents"} - assert_equal(0, otype.size) end def test_inspect assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect) end + # WIN32OLE_TYPE.typelibs will be obsoleted. def test_s_typelibs tlibs = WIN32OLE_TYPE.typelibs.sort Index: test/win32ole/test_win32ole_type_event.rb =================================================================== --- test/win32ole/test_win32ole_type_event.rb (nonexistent) +++ test/win32ole/test_win32ole_type_event.rb (revision 65053) @@ -0,0 +1,54 @@ https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole_type_event.rb#L1 +# frozen_string_literal: false +begin + require 'win32ole' +rescue LoadError +end +require "test/unit" + +if defined?(WIN32OLE_TYPE) + def ado_installed? + installed = false + if defined?(WIN32OLE) + begin + WIN32OLE.new('ADODB.Connection') + installed = true + rescue + end + end + installed + end + + class TestWIN32OLE_TYPE_EVENT < Test::Unit::TestCase + unless ado_installed? + def test_dummy_for_skip_message + skip 'ActiveX Data Object Library not found' + end + else + + def setup + typelib = WIN32OLE.new('ADODB.Connection').ole_typelib + @ole_type = WIN32OLE_TYPE.new(typelib.name, 'Connection') + end + + def test_implemented_ole_types + ole_types = @ole_type.implemented_ole_types.map(&:name).sort + assert_equal(['ConnectionEvents', '_Connection'], ole_types) + end + + def test_default_ole_types + ole_types = @ole_type.default_ole_types.map(&:name).sort + assert_equal(['ConnectionEvents', '_Connection'], ole_types) + end + + def test_source_ole_types + ole_types = @ole_type.source_ole_types.map(&:name) + assert_equal(['ConnectionEvents'], ole_types) + end + + def test_default_event_sources + event_sources = @ole_type.default_event_sources.map(&:name) + assert_equal(['ConnectionEvents'], event_sources) + end + end + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/