git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2006-04-01 06:25:41 +00:00
Родитель 3ff87cc53f
Коммит 63fa2de637
3 изменённых файлов: 0 добавлений и 296 удалений

Просмотреть файл

@ -1,111 +0,0 @@
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
require 'oleserver'
class TestOLETYPE < RUNIT::TestCase
include OLESERVER
def test_s_new
type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
assert_instance_of(WIN32OLE_TYPE, type)
end
def test_s_ole_classes
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
assert(classes.size > 0)
end
def test_s_typelibs
libs = WIN32OLE_TYPE.typelibs
assert(libs.include?(MS_EXCEL_TYPELIB))
assert(libs.include?(MS_XML_TYPELIB))
end
def test_s_progids
progids = WIN32OLE_TYPE.progids
assert(progids.include?('Excel.Application'))
end
def test_name
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
class_names = classes.collect{|c|
c.name
}
assert(class_names.include?('Application'))
end
def test_class_to_s
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
class_names = classes.collect{|c|
"#{c}"
}
assert(class_names.include?('Application'))
end
def test_ole_type
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
app = classes.find {|c| c.name == 'Application'}
assert_equal('Class', app.ole_type)
app = classes.find {|c| c.name == '_Application'}
assert_equal('Dispatch', app.ole_type)
end
def test_typekind
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
app = classes.find {|c| c.name == 'Application'}
assert_equal(5, app.typekind)
end
def test_visible
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
app = classes.find {|c| c.name == 'Application'}
assert(app.visible?)
app = classes.find {|c| c.name == 'IAppEvents'}
assert(!app.visible?)
end
def test_src_type
classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
domnode = classes.find {|c| c.name == 'DOMNodeType'}
assert_equal('tagDOMNodeType', domnode.src_type)
end
def test_helpstring
classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
domdoc = classes.find {|c| c.name == 'DOMDocument'}
assert_equal('W3C-DOM XML Document', domdoc.helpstring)
end
def test_variables
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
xlchart = classes.find {|c| c.name == 'XlChartType'}
assert(xlchart.variables.size > 0)
end
def test_ole_methods
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
worksheet = classes.find {|c| c.name == 'Worksheet'}
assert(worksheet.ole_methods.size > 0)
end
def test_helpfile
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
worksheet = classes.find {|c| c.name == 'Worksheet'}
assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile)
end
def test_helpcontext
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
worksheet = classes.find {|c| c.name == 'Worksheet'}
assert_equal(131088, worksheet.helpcontext)
end
def test_to_s
type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
assert_equal("Application", "#{type}");
end
def test_ole_typelib
type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
tlib = type.ole_typelib
assert_instance_of(WIN32OLE_TYPELIB, tlib);
assert_equal(MS_EXCEL_TYPELIB, tlib.name);
end
def test_implemented_ole_types
type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
impltypes = type.implemented_ole_types
assert_instance_of(Array, impltypes);
assert_equal('_Application', impltypes[0].name)
assert_equal('AppEvents', impltypes[1].name)
end
end

Просмотреть файл

@ -1,134 +0,0 @@
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

Просмотреть файл

@ -1,51 +0,0 @@
# You need RubyUnit and MS Excel and MSI to run this test script
require 'rubyunit'
require 'win32ole'
require 'oleserver'
class TestOLEVARIABLE < RUNIT::TestCase
include OLESERVER
def test_name
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
chart = classes.find {|c| c.name == 'XlChartType'}
var_names = chart.variables.collect {|m| m.name}
assert(var_names.size > 0)
assert(var_names.include?('xl3DColumn'))
end
def test_to_s
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
chart = classes.find {|c| c.name == 'XlChartType'}
var_names = chart.variables.collect {|m| "#{m}"}
assert(var_names.size > 0)
assert(var_names.include?('xl3DColumn'))
end
def test_ole_type
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'}
var = chart.variables.find {|m| m.name == 'xl3DColumn'}
assert_equal('INT', var.ole_type)
end
def test_ole_type_detail
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
chart = classes.find {|c| c.name == 'XlChartType'}
var = chart.variables.find {|m| m.name == 'xl3DColumn'}
assert_equal(['INT'], var.ole_type_detail)
end
def test_value
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
chart = classes.find {|c| c.name == 'XlChartType'}
var = chart.variables.find {|m| m.name == 'xl3DColumn'}
assert_equal(-4100, var.value)
end
def test_visible
classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
chart = classes.find {|c| c.name == 'XlChartType'}
var = chart.variables.find {|m| m.name == 'xl3DColumn'}
assert(var.visible?)
end
end