~ubuntu-branches/ubuntu/dapper/ruby1.9/dapper

« back to all changes in this revision

Viewing changes to ext/win32ole/tests/testOLETYPE.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2006-05-08 22:23:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060508222312-w2wqeaz030ifi59j
Tags: 1.9.0+20060423-3ubuntu1
* Resynchronized with Debian.
* Only change from Debian is the addition of
  debian/patches/903_sparc_fix_define.patch to fix illegal instructions
  at runtime on sparc. (change from 1.9.0+20050921-1ubuntu1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
35
 
  def test_class_to_s
36
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
37
 
    class_names = classes.collect{|c|
38
 
      "#{c}"
39
 
    }
40
 
    assert(class_names.include?('Application'))
41
 
  end
42
 
 
43
 
  def test_ole_type
44
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
45
 
    app = classes.find {|c| c.name == 'Application'}
46
 
    assert_equal('Class', app.ole_type)
47
 
    app = classes.find {|c| c.name == '_Application'}
48
 
    assert_equal('Dispatch', app.ole_type)
49
 
  end
50
 
  def test_typekind
51
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
52
 
    app = classes.find {|c| c.name == 'Application'}
53
 
    assert_equal(5, app.typekind)
54
 
  end
55
 
  def test_visible
56
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
57
 
    app = classes.find {|c| c.name == 'Application'}
58
 
    assert(app.visible?)
59
 
    app = classes.find {|c| c.name == 'IAppEvents'}
60
 
    assert(!app.visible?)
61
 
  end
62
 
  def test_src_type
63
 
    classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
64
 
    domnode = classes.find {|c| c.name == 'DOMNodeType'}
65
 
    assert_equal('tagDOMNodeType', domnode.src_type)
66
 
  end
67
 
  def test_helpstring
68
 
    classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
69
 
    domdoc = classes.find {|c| c.name == 'DOMDocument'}
70
 
    assert_equal('W3C-DOM XML Document', domdoc.helpstring)
71
 
  end
72
 
  def test_variables
73
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
74
 
    xlchart = classes.find {|c| c.name == 'XlChartType'}
75
 
    assert(xlchart.variables.size > 0)
76
 
  end
77
 
  def test_ole_methods
78
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
79
 
    worksheet = classes.find {|c| c.name == 'Worksheet'}
80
 
    assert(worksheet.ole_methods.size > 0)
81
 
  end
82
 
  def test_helpfile
83
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
84
 
    worksheet = classes.find {|c| c.name == 'Worksheet'}
85
 
    assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile)
86
 
  end
87
 
  def test_helpcontext
88
 
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
89
 
    worksheet = classes.find {|c| c.name == 'Worksheet'}
90
 
    assert_equal(131088, worksheet.helpcontext)
91
 
  end
92
 
  def test_to_s
93
 
    type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
94
 
    assert_equal("Application", "#{type}");
95
 
  end
96
 
  def test_ole_typelib
97
 
    type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
98
 
    tlib = type.ole_typelib
99
 
    assert_instance_of(WIN32OLE_TYPELIB, tlib);
100
 
    assert_equal(MS_EXCEL_TYPELIB, tlib.name);
101
 
  end
102
 
 
103
 
  def test_implemented_ole_types
104
 
    type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
105
 
    impltypes = type.implemented_ole_types
106
 
    assert_instance_of(Array, impltypes);
107
 
    assert_equal('_Application', impltypes[0].name)
108
 
    assert_equal('AppEvents', impltypes[1].name)
109
 
  end
110
 
 
111
 
end