OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / test / win32ole / test_win32ole_typelib.rb
1 begin
2   require 'win32ole'
3 rescue LoadError
4 end
5 require "test/unit"
6
7 if defined?(WIN32OLE_TYPELIB)
8   class TestWIN32OLE_TYPELIB < Test::Unit::TestCase
9     def test_s_typelibs
10       tlibs = WIN32OLE_TYPELIB.typelibs
11       assert_instance_of(Array, tlibs)
12       assert(tlibs.size > 0)
13       tlib = tlibs.find {|t| t.name == "Microsoft Shell Controls And Automation"}
14       assert(tlib)
15     end
16
17     def test_initialize
18       assert_raise(ArgumentError) {
19         WIN32OLE_TYPELIB.new(1,2,3,4)
20       }
21
22       assert_raise(TypeError) {
23         WIN32OLE_TYPELIB.new(100)
24       }
25
26       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
27       assert_instance_of(WIN32OLE_TYPELIB, tlib)
28
29       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1.0)
30       assert_instance_of(WIN32OLE_TYPELIB, tlib)
31
32       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1, 0)
33       assert_instance_of(WIN32OLE_TYPELIB, tlib)
34       guid = tlib.guid
35
36       tlib_by_guid = WIN32OLE_TYPELIB.new(guid, 1, 0)
37       assert_instance_of(WIN32OLE_TYPELIB, tlib_by_guid)
38       assert_equal("Microsoft Shell Controls And Automation" , tlib_by_guid.name)
39
40       path = tlib.path
41       tlib_by_path =  WIN32OLE_TYPELIB.new(path)
42       assert_equal("Microsoft Shell Controls And Automation" , tlib_by_path.name)
43
44       assert_raise(WIN32OLERuntimeError) {
45         WIN32OLE_TYPELIB.new("Non Exist Type Library")
46       }
47     end
48
49     def test_guid
50       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
51       assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid)
52     end
53
54     def test_name
55       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
56       assert_equal("Microsoft Shell Controls And Automation", tlib.name)
57       tlib = WIN32OLE_TYPELIB.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}")
58       assert_equal("Microsoft Shell Controls And Automation", tlib.name)
59     end
60
61     def test_version
62       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
63       assert_equal(1.0, tlib.version)
64     end
65
66     def test_major_version
67       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
68       assert_equal(1, tlib.major_version)
69     end
70
71     def test_minor_version
72       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
73       assert_equal(0, tlib.minor_version)
74     end
75
76     def test_path
77       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
78       assert_match(/shell32\.dll$/i, tlib.path)
79     end
80
81     def test_visible?
82       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
83       assert(tlib.visible?)
84     end
85
86     def test_library_name
87       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
88       assert_equal("Shell32", tlib.library_name)
89     end
90
91     def test_to_s
92       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
93       assert_equal("Microsoft Shell Controls And Automation", tlib.to_s)
94     end
95
96     def test_ole_types
97       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
98       ole_types = tlib.ole_types
99       assert_instance_of(Array, ole_types)
100       assert(ole_types.size > 0)
101       assert_instance_of(WIN32OLE_TYPE, ole_types[0])
102     end
103
104     def test_inspect
105       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
106       assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect)
107     end
108
109   end
110 end