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

« back to all changes in this revision

Viewing changes to ext/win32ole/tests/testOLEMETHOD.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 TestOLEMETHOD < RUNIT::TestCase
9
 
  include OLESERVER
10
 
  def setup
11
 
    @excel_app = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
12
 
  end
13
 
  def test_s_new
14
 
    m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
15
 
    assert_instance_of(WIN32OLE_METHOD, m)
16
 
    m =  WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
17
 
    assert_instance_of(WIN32OLE_METHOD, m)
18
 
    m =  WIN32OLE_METHOD.new(@excel_app, 'workbookopen')
19
 
    assert_instance_of(WIN32OLE_METHOD, m)
20
 
  end
21
 
  def test_name
22
 
    m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
23
 
    assert_equal('Quit', m.name)
24
 
  end
25
 
  def test_to_s
26
 
    m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
27
 
    assert_equal('Quit', "#{m}")
28
 
  end
29
 
  def test_return_type
30
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
31
 
    assert_equal('Range', m.return_type)
32
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
33
 
    assert_equal('BSTR', m.return_type)
34
 
  end
35
 
  def test_return_vtype
36
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
37
 
    assert_equal(WIN32OLE::VARIANT::VT_PTR, m.return_vtype)
38
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
39
 
    assert_equal(WIN32OLE::VARIANT::VT_BSTR, m.return_vtype)
40
 
  end
41
 
  def test_return_type_detail
42
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
43
 
    assert_equal(['PTR', 'USERDEFINED', 'Range'], m.return_type_detail)
44
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
45
 
    assert_equal(['BSTR'], m.return_type_detail)
46
 
  end
47
 
 
48
 
  def test_invoke_kind
49
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
50
 
    assert_equal('PROPERTYGET', m.invoke_kind)
51
 
  end
52
 
  def test_visible
53
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
54
 
    assert(m.visible?)
55
 
    m = WIN32OLE_METHOD.new(@excel_app, 'AddRef')
56
 
    assert(!m.visible?)
57
 
  end
58
 
  def test_event
59
 
    m =  WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
60
 
    assert(m.event?)
61
 
    m =  WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
62
 
    assert(!m.event?)
63
 
  end
64
 
  def test_event_interface
65
 
    m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
66
 
    assert_equal('AppEvents', m.event_interface)
67
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
68
 
    assert_nil(m.event_interface)
69
 
  end
70
 
  def test_helpstring
71
 
    domdoc = WIN32OLE_TYPE.new(MS_XML_TYPELIB, 'DOMDocument')
72
 
    m =  WIN32OLE_METHOD.new(domdoc, 'abort')
73
 
    assert_equal('abort an asynchronous download', m.helpstring)
74
 
  end
75
 
  def test_helpfile
76
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
77
 
    assert_match(/VBAXL.*\.(HLP|CHM)$/i, m.helpfile)
78
 
  end
79
 
  def test_helpcontext
80
 
    m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
81
 
    assert(m.helpcontext > 0)
82
 
  end
83
 
  def test_offset_vtbl
84
 
    m = WIN32OLE_METHOD.new(@excel_app, 'QueryInterface')
85
 
    assert_equal(0, m.offset_vtbl)
86
 
  end
87
 
  def test_dispid
88
 
    tobj = WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation', 'FolderItem2')
89
 
    method = WIN32OLE_METHOD.new(tobj, 'InvokeVerb')
90
 
    assert_equal(1610743824, method.dispid)
91
 
  end
92
 
end