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

« back to all changes in this revision

Viewing changes to test/win32ole/test_win32ole_typelib.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_TYPELIB)
 
9
  class TestWIN32OLE_TYPELIB < Test::Unit::TestCase
 
10
    def test_s_typelibs
 
11
      tlibs = WIN32OLE_TYPELIB.typelibs
 
12
      assert_instance_of(Array, tlibs)
 
13
      assert(tlibs.size > 0)
 
14
      tlib = tlibs.find {|tlib| tlib.name == "Microsoft Shell Controls And Automation"}
 
15
      assert(tlib)
 
16
    end
 
17
 
 
18
    def test_initialize
 
19
      assert_raise(ArgumentError) {
 
20
        WIN32OLE_TYPELIB.new(1,2,3,4)
 
21
      }
 
22
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
23
      assert_instance_of(WIN32OLE_TYPELIB, tlib)
 
24
 
 
25
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1.0)
 
26
      assert_instance_of(WIN32OLE_TYPELIB, tlib)
 
27
 
 
28
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1, 0)
 
29
      assert_instance_of(WIN32OLE_TYPELIB, tlib)
 
30
      guid = tlib.guid
 
31
 
 
32
      tlib_by_guid = WIN32OLE_TYPELIB.new(guid, 1, 0)
 
33
      assert_instance_of(WIN32OLE_TYPELIB, tlib_by_guid)
 
34
      assert_equal("Microsoft Shell Controls And Automation" , tlib_by_guid.name)
 
35
 
 
36
      path = tlib.path
 
37
      tlib_by_path =  WIN32OLE_TYPELIB.new(path)
 
38
      assert_equal("Microsoft Shell Controls And Automation" , tlib_by_path.name)
 
39
 
 
40
      assert_raise(WIN32OLERuntimeError) {
 
41
        WIN32OLE_TYPELIB.new("Non Exist Type Library")
 
42
      }
 
43
    end
 
44
 
 
45
    def test_guid
 
46
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
47
      assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid)
 
48
    end
 
49
 
 
50
    def test_name
 
51
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
52
      assert_equal("Microsoft Shell Controls And Automation", tlib.name)
 
53
      tlib = WIN32OLE_TYPELIB.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}")
 
54
      assert_equal("Microsoft Shell Controls And Automation", tlib.name)
 
55
    end
 
56
 
 
57
    def test_version
 
58
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
59
      assert_equal(1.0, tlib.version)
 
60
    end
 
61
 
 
62
    def test_major_version
 
63
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
64
      assert_equal(1, tlib.major_version)
 
65
    end
 
66
 
 
67
    def test_minor_version
 
68
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
69
      assert_equal(0, tlib.minor_version)
 
70
    end
 
71
 
 
72
    def test_path
 
73
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
74
      assert_match(/shell32\.dll$/i, tlib.path)
 
75
    end
 
76
 
 
77
    def test_to_s
 
78
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
79
      assert_equal("Microsoft Shell Controls And Automation", tlib.to_s)
 
80
    end
 
81
 
 
82
    def test_ole_classes
 
83
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
84
      ole_classes = tlib.ole_classes
 
85
      assert_instance_of(Array, ole_classes)
 
86
      assert(ole_classes.size > 0)
 
87
      assert_instance_of(WIN32OLE_TYPE, ole_classes[0])
 
88
    end
 
89
 
 
90
    def test_inspect
 
91
      tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
 
92
      assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect)
 
93
    end
 
94
 
 
95
  end
 
96
end