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

« back to all changes in this revision

Viewing changes to test/win32ole/test_win32ole_type.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
begin
 
2
  require 'win32ole'
 
3
rescue LoadError
 
4
end
 
5
 
 
6
require "test/unit"
 
7
 
 
8
if defined?(WIN32OLE_TYPE)
 
9
  class TestWIN32OLE_TYPE < Test::Unit::TestCase
 
10
 
 
11
    def test_s_progids
 
12
      progids = WIN32OLE_TYPE.progids
 
13
      assert_instance_of(Array, progids)
 
14
      assert(progids.size > 0)
 
15
      assert_instance_of(String, progids[0])
 
16
      assert(progids.include?("Shell.Application.1"))
 
17
    end
 
18
 
 
19
    def test_initialize
 
20
      assert_raise(ArgumentError) {
 
21
        WIN32OLE_TYPE.new
 
22
      }
 
23
      assert_raise(ArgumentError) {
 
24
        WIN32OLE_TYPE.new("foo")
 
25
      }
 
26
      assert_raise(WIN32OLERuntimeError) {
 
27
        WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "foo")
 
28
      }
 
29
      assert_raise(WIN32OLERuntimeError) {
 
30
        WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Application")
 
31
      }
 
32
      ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
 
33
      assert_instance_of(WIN32OLE_TYPE, ole_type)
 
34
    end
 
35
 
 
36
    def setup
 
37
      @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
 
38
    end
 
39
 
 
40
    def test_name
 
41
      assert_equal("Shell", @ole_type.name)
 
42
    end
 
43
 
 
44
    def test_ole_type
 
45
      assert_equal("Class", @ole_type.ole_type)
 
46
    end
 
47
 
 
48
    def test_guid
 
49
      assert_equal("{13709620-C279-11CE-A49E-444553540000}", @ole_type.guid)
 
50
    end
 
51
 
 
52
    def test_progid
 
53
      assert_equal("Shell.Application.1", @ole_type.progid)
 
54
    end
 
55
 
 
56
    def test_visible?
 
57
      assert(@ole_type.visible?)
 
58
      ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "IShellDispatch")
 
59
      assert(!ole_type.visible?)
 
60
    end
 
61
 
 
62
    def test_to_s
 
63
      assert_equal(@ole_type.to_s, @ole_type.name)
 
64
    end
 
65
 
 
66
    def test_major_version
 
67
      assert_equal(0, @ole_type.major_version)
 
68
      # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
 
69
      # assert_equal(8, ole_type.major_version)
 
70
    end
 
71
 
 
72
    def test_minor_version
 
73
      assert_equal(0, @ole_type.minor_version)
 
74
      # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
 
75
      # assert_equal(3, ole_type.minor_version)
 
76
    end
 
77
 
 
78
    def test_typekind
 
79
      assert_equal(5, @ole_type.typekind)
 
80
    end
 
81
 
 
82
    def test_helpstring
 
83
      assert_equal("Shell Object Type Information", @ole_type.helpstring)
 
84
    end
 
85
 
 
86
    def test_src_type
 
87
      ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "DriveTypeConst")
 
88
      assert_match(/__MIDL___MIDL_itf_scrrun_/, ole_type.src_type)
 
89
      assert_equal(nil, @ole_type.src_type)
 
90
    end
 
91
 
 
92
    def test_helpfile
 
93
      assert_equal("", @ole_type.helpfile)
 
94
      ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
 
95
      assert_match(/VBENLR98\.CHM$/i, ole_type.helpfile)
 
96
    end
 
97
 
 
98
    def test_helpcontext
 
99
      assert_equal(0, @ole_type.helpcontext)
 
100
      ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
 
101
      assert_equal(2181929, ole_type.helpcontext)
 
102
    end
 
103
 
 
104
    def test_variables
 
105
      variables = @ole_type.variables
 
106
      assert_instance_of(Array, variables)
 
107
      assert(variables.size == 0)
 
108
 
 
109
      ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
 
110
      variables = ole_type.variables
 
111
      assert_instance_of(Array, variables)
 
112
      assert(variables.size > 0)
 
113
 
 
114
      assert_instance_of(WIN32OLE_VARIABLE, variables[0])
 
115
    end
 
116
 
 
117
    def test_ole_methods
 
118
      methods = @ole_type.ole_methods
 
119
      assert_instance_of(Array, methods)
 
120
      assert(methods.size > 0)
 
121
      assert_instance_of(WIN32OLE_METHOD, methods[0]);
 
122
      assert(methods.collect{|m| m.name}.include?("Application"))
 
123
    end
 
124
 
 
125
    def test_ole_typelib
 
126
      tlib = @ole_type.ole_typelib
 
127
      assert_instance_of(WIN32OLE_TYPELIB, tlib)
 
128
      assert_equal("Microsoft Shell Controls And Automation", tlib.name)
 
129
    end
 
130
 
 
131
    def test_implemented_ole_types
 
132
      ole_types = @ole_type.implemented_ole_types
 
133
      assert_instance_of(Array, ole_types)
 
134
      assert(ole_types.size > 0)
 
135
      assert_equal("IShellDispatch", ole_types[0].name)
 
136
    end
 
137
 
 
138
    def test_inspect
 
139
      assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect)
 
140
    end
 
141
 
 
142
  end
 
143
end