DEFINITIONS
This source file includes following functions.
1 # You need RubyUnit and MS Excel and MSI to run this test script
2
3 require 'rubyunit'
4
5 require 'win32ole'
6 require 'oleserver'
7
8 class TestOLETYPE < RUNIT::TestCase
9 include OLESERVER
10 def test_s_new
11 type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
12 assert_instance_of(WIN32OLE_TYPE, type)
13 end
14 def test_s_ole_classes
15 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
16 assert(classes.size > 0)
17 end
18 def test_s_typelibs
19 libs = WIN32OLE_TYPE.typelibs
20 assert(libs.include?(MS_EXCEL_TYPELIB))
21 assert(libs.include?(MS_XML_TYPELIB))
22 end
23 def test_s_progids
24 progids = WIN32OLE_TYPE.progids
25 assert(progids.include?('Excel.Application'))
26 end
27 def test_name
28 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
29 class_names = classes.collect{|c|
30 c.name
31 }
32 assert(class_names.include?('Application'))
33 end
34 def test_ole_type
35 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
36 app = classes.find {|c| c.name == 'Application'}
37 assert_equal('Class', app.ole_type)
38 app = classes.find {|c| c.name == '_Application'}
39 assert_equal('Dispatch', app.ole_type)
40 end
41 def test_typekind
42 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
43 app = classes.find {|c| c.name == 'Application'}
44 assert_equal(5, app.typekind)
45 end
46 def test_visible
47 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
48 app = classes.find {|c| c.name == 'Application'}
49 assert(app.visible?)
50 app = classes.find {|c| c.name == 'IAppEvents'}
51 assert(!app.visible?)
52 end
53 def test_src_type
54 classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
55 domnode = classes.find {|c| c.name == 'DOMNodeType'}
56 assert_equal('tagDOMNodeType', domnode.src_type)
57 end
58 def test_helpstring
59 classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
60 domdoc = classes.find {|c| c.name == 'DOMDocument'}
61 assert_equal('W3C-DOM XML Document', domdoc.helpstring)
62 end
63 def test_variables
64 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
65 xlchart = classes.find {|c| c.name == 'XlChartType'}
66 assert(xlchart.variables.size > 0)
67 end
68 def test_ole_methods
69 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
70 worksheet = classes.find {|c| c.name == 'Worksheet'}
71 assert(worksheet.ole_methods.size > 0)
72 end
73 def test_helpfile
74 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
75 worksheet = classes.find {|c| c.name == 'Worksheet'}
76 assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile)
77 end
78 def test_helpcontext
79 classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
80 worksheet = classes.find {|c| c.name == 'Worksheet'}
81 assert_equal(131088, worksheet.helpcontext)
82 end
83 end