ext/win32ole/win32ole.c: add WIN32OLE_TYPELIB class. add
WIN32OLE#ole_typelib method. ext/win32ole/tests/testOLETYPELIB.rb: add WIN32OLE_TYPELIB class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7dc3169658
commit
ad2c05f1c0
@ -1,3 +1,10 @@
|
|||||||
|
Sat Oct 30 15:24:41 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
|
* ext/win32ole/win32ole.c: add WIN32OLE_TYPELIB class. add
|
||||||
|
WIN32OLE#ole_typelib method.
|
||||||
|
|
||||||
|
* ext/win32ole/tests/testOLETYPELIB.rb: add WIN32OLE_TYPELIB class.
|
||||||
|
|
||||||
Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (rb_io_check_initialized): new function to check uninitialized
|
* io.c (rb_io_check_initialized): new function to check uninitialized
|
||||||
|
134
ext/win32ole/tests/testOLETYPELIB.rb
Normal file
134
ext/win32ole/tests/testOLETYPELIB.rb
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
require 'test/unit'
|
||||||
|
require 'win32ole'
|
||||||
|
require 'oleserver'
|
||||||
|
|
||||||
|
class TestOLETYPELIB < Test::Unit::TestCase
|
||||||
|
include OLESERVER
|
||||||
|
def test_exists_typelib
|
||||||
|
assert(Module.constants.include?("WIN32OLE_TYPELIB"))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_s_new
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_s_new_non_exist_tlib
|
||||||
|
exception_occured = false
|
||||||
|
msg = ""
|
||||||
|
begin
|
||||||
|
tlib = WIN32OLE_TYPELIB.new('NON EXIST TYPELIB')
|
||||||
|
rescue WIN32OLERuntimeError
|
||||||
|
msg = $!.to_s
|
||||||
|
exception_occured = true
|
||||||
|
end
|
||||||
|
assert_equal("Not found type library `NON EXIST TYPELIB`", msg)
|
||||||
|
assert(exception_occured)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_guid
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
assert_not_equal("", tlib.guid)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_s_new_from_guid
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB);
|
||||||
|
guid = tlib.guid
|
||||||
|
tlib2 = WIN32OLE_TYPELIB.new(guid);
|
||||||
|
assert_equal(tlib.name, tlib2.name);
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_version
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB);
|
||||||
|
assert(tlib.version > 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_major_version
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
assert(tlib.major_version > 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_minor_version
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
assert(tlib.minor_version >= 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_tlib_obj
|
||||||
|
ex = nil
|
||||||
|
begin
|
||||||
|
tlib1 = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
ex = WIN32OLE.new('Excel.Application')
|
||||||
|
tlib2 = ex.ole_typelib
|
||||||
|
assert_equal(tlib1.name, tlib2.name)
|
||||||
|
assert_equal(tlib1.major_version, tlib2.major_version)
|
||||||
|
assert_equal(tlib1.minor_version, tlib2.minor_version)
|
||||||
|
ensure
|
||||||
|
if ex
|
||||||
|
ex.quit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_tlib_obj2
|
||||||
|
ex = nil
|
||||||
|
begin
|
||||||
|
tlib1 = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
tlib2 = WIN32OLE_TYPELIB.new(tlib1.guid, tlib1.major_version, tlib1.minor_version)
|
||||||
|
assert_equal(tlib1.name, tlib2.name)
|
||||||
|
assert_equal(tlib1.major_version, tlib2.major_version)
|
||||||
|
assert_equal(tlib1.minor_version, tlib2.minor_version)
|
||||||
|
ensure
|
||||||
|
if ex
|
||||||
|
ex.quit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_create_tlib_obj3
|
||||||
|
ex = nil
|
||||||
|
begin
|
||||||
|
tlib1 = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
tlib2 = WIN32OLE_TYPELIB.new(tlib1.guid, tlib1.version)
|
||||||
|
assert_equal(tlib1.name, tlib2.name)
|
||||||
|
assert_equal(tlib1.guid, tlib2.guid)
|
||||||
|
assert_equal(tlib1.major_version, tlib2.major_version)
|
||||||
|
assert_equal(tlib1.minor_version, tlib2.minor_version)
|
||||||
|
ensure
|
||||||
|
if ex
|
||||||
|
ex.quit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_name
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
assert_equal(MS_EXCEL_TYPELIB, tlib.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_to_s
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
assert_equal(tlib.name, tlib.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_path
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
assert(/EXCEL/ =~ tlib.path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ole_classes
|
||||||
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
classes = tlib.ole_classes
|
||||||
|
assert(classes.instance_of?(Array))
|
||||||
|
assert(classes.size > 0)
|
||||||
|
assert('WIN32OLE_TYPE', classes[0].class)
|
||||||
|
assert(classes.collect{|i| i.name}.include?('Workbooks'))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_s_typelibs
|
||||||
|
tlibs = WIN32OLE_TYPELIB.typelibs
|
||||||
|
assert(tlibs.instance_of?(Array))
|
||||||
|
assert(tlibs.size > 0)
|
||||||
|
assert('WIN32OLE_TYPELIB', tlibs[0].class)
|
||||||
|
tlibnames = tlibs.collect{|i| i.name}
|
||||||
|
tlibnames.include?('Microsoft Internet Controlls')
|
||||||
|
end
|
||||||
|
end
|
@ -22,7 +22,9 @@ class TestOLEVARIABLE < RUNIT::TestCase
|
|||||||
assert(var_names.include?('xl3DColumn'))
|
assert(var_names.include?('xl3DColumn'))
|
||||||
end
|
end
|
||||||
def test_ole_type
|
def test_ole_type
|
||||||
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
tlib = WIN32OLE_TYPELIB.new(MS_EXCEL_TYPELIB)
|
||||||
|
classes = tlib.ole_classes
|
||||||
|
# classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
|
||||||
chart = classes.find {|c| c.name == 'XlChartType'}
|
chart = classes.find {|c| c.name == 'XlChartType'}
|
||||||
var = chart.variables.find {|m| m.name == 'xl3DColumn'}
|
var = chart.variables.find {|m| m.name == 'xl3DColumn'}
|
||||||
assert_equal('INT', var.ole_type)
|
assert_equal('INT', var.ole_type)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# You need RubyUnit and MS Excel and MSI to run this test script
|
# You need RubyUnit and MS Excel and MSI to run this test script
|
||||||
|
|
||||||
|
require 'test/unit'
|
||||||
require 'runit/testcase'
|
require 'runit/testcase'
|
||||||
require 'runit/cui/testrunner'
|
# require 'runit/cui/testrunner'
|
||||||
|
|
||||||
require 'win32ole'
|
require 'win32ole'
|
||||||
require 'oleserver'
|
require 'oleserver'
|
||||||
@ -40,7 +41,7 @@ class TestWin32OLE < RUNIT::TestCase
|
|||||||
exc = assert_exception(WIN32OLERuntimeError) {
|
exc = assert_exception(WIN32OLERuntimeError) {
|
||||||
WIN32OLE.new("{000}")
|
WIN32OLE.new("{000}")
|
||||||
}
|
}
|
||||||
assert_match(/Unknown OLE server : `\{000\}'/, exc.message)
|
assert_match(/Unknown OLE server `\{000\}'/, exc.message)
|
||||||
end
|
end
|
||||||
def test_s_connect
|
def test_s_connect
|
||||||
excel2 = WIN32OLE.connect('Excel.Application')
|
excel2 = WIN32OLE.connect('Excel.Application')
|
||||||
@ -220,6 +221,12 @@ class TestWin32OLE < RUNIT::TestCase
|
|||||||
assert(add_info.params[0].optional?)
|
assert(add_info.params[0].optional?)
|
||||||
assert_equal('VARIANT', add_info.params[0].ole_type)
|
assert_equal('VARIANT', add_info.params[0].ole_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ole_typelib
|
||||||
|
tlib = @excel.ole_typelib
|
||||||
|
assert_equal(tlib.name, MS_EXCEL_TYPELIB);
|
||||||
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
@excel.quit
|
@excel.quit
|
||||||
@excel = nil
|
@excel = nil
|
||||||
@ -227,7 +234,8 @@ class TestWin32OLE < RUNIT::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestWin32OLE_WITH_MSI < RUNIT::TestCase
|
# class TestWin32OLE_WITH_MSI < RUNIT::TestCase
|
||||||
|
class TestWin32OLE_WITH_MSI < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
installer = WIN32OLE.new("WindowsInstaller.Installer")
|
installer = WIN32OLE.new("WindowsInstaller.Installer")
|
||||||
@record = installer.CreateRecord(2)
|
@record = installer.CreateRecord(2)
|
||||||
@ -288,25 +296,3 @@ class TestMyExcel < TestWin32OLE
|
|||||||
#
|
#
|
||||||
private :test_s_const_load
|
private :test_s_const_load
|
||||||
end
|
end
|
||||||
|
|
||||||
if $0 == __FILE__
|
|
||||||
puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
|
|
||||||
if ARGV.size == 0
|
|
||||||
suite = RUNIT::TestSuite.new
|
|
||||||
suite.add_test(TestWin32OLE.suite)
|
|
||||||
suite.add_test(TestMyExcel.suite)
|
|
||||||
begin
|
|
||||||
installer = WIN32OLE.new("WindowsInstaller.Installer")
|
|
||||||
suite.add_test(TestWin32OLE_WITH_MSI.suite)
|
|
||||||
rescue
|
|
||||||
puts "Skip some test with MSI"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
suite = RUNIT::TestSuite.new
|
|
||||||
ARGV.each do |testmethod|
|
|
||||||
suite.add_test(TestWin32OLE.new(testmethod))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
RUNIT::CUI::TestRunner.quiet_mode = true
|
|
||||||
RUNIT::CUI::TestRunner.run(suite)
|
|
||||||
end
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
require 'rubyunit'
|
require 'test/unit'
|
||||||
require 'win32ole'
|
require 'win32ole'
|
||||||
puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
|
puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
|
||||||
# RUNIT::CUI::TestRunner.quiet_mode = true
|
|
||||||
require "testWIN32OLE"
|
require "testWIN32OLE"
|
||||||
require "testOLETYPE"
|
require "testOLETYPE"
|
||||||
require "testOLEPARAM"
|
require "testOLEPARAM"
|
||||||
require "testOLEMETHOD"
|
require "testOLEMETHOD"
|
||||||
require "testOLEVARIABLE"
|
require "testOLEVARIABLE"
|
||||||
require "testVARIANT"
|
require "testVARIANT"
|
||||||
|
require "testOLETYPELIB"
|
||||||
# require "testOLEEVENT"
|
# require "testOLEEVENT"
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user