summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 04:06:12 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 04:06:12 +0000
commit11dbedfaad4a9a9521ece2198a8dc491678b1902 (patch)
tree4806dc0ff0c3827ecc40921838c4507340cfdb3a /ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb
parent29e8d8b439b34c2a394407dc598fc01d14be0c20 (diff)
add tag v1_8_6_5001v1_8_6_5001
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_5001@13304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb')
-rw-r--r--ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb96
1 files changed, 96 insertions, 0 deletions
diff --git a/ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb b/ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb
new file mode 100644
index 0000000000..d4eb1146e1
--- /dev/null
+++ b/ruby_1_8_6/ext/win32ole/tests/testOLETYPE.rb
@@ -0,0 +1,96 @@
+# 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
+end