1707
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
1353
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#Win32OLETests
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'tests-Regression-RuntimeSystem'
|
|
12 |
!
|
|
13 |
|
|
14 |
|
1355
|
15 |
!Win32OLETests class methodsFor:'queries'!
|
|
16 |
|
|
17 |
coveredPackageNames
|
|
18 |
^ #('exept:ole')
|
|
19 |
! !
|
|
20 |
|
1353
|
21 |
!Win32OLETests methodsFor:'tests'!
|
|
22 |
|
|
23 |
test00_loadOLE
|
|
24 |
|iid_IEnum|
|
|
25 |
|
1393
|
26 |
self skipIf:[OperatingSystem isMSWINDOWSlike not] description:'test skipped (OS is not WINDOWS)'.
|
1353
|
27 |
|
|
28 |
Smalltalk at:#ExternalLibraryFunction:Verbose put:true.
|
|
29 |
Smalltalk at:#ObjectFileLoader:Verbose put:true.
|
|
30 |
"/
|
|
31 |
"/ this will already perform a number of calls into OLE,
|
|
32 |
"/ to get the CLSIDs of various wellknown interfaces
|
|
33 |
"/ (see OLEInterfaceConstants initialize)
|
|
34 |
Smalltalk loadPackage:'exept:ole'.
|
|
35 |
|
1447
|
36 |
"/ so when we arrive here without error, some is already known to work..
|
1353
|
37 |
self assert:(OLEInterfaceConstants notNil).
|
|
38 |
|
|
39 |
iid_IEnum := OLEInterfaceConstants classVarAt:#'IID_IEnum'.
|
|
40 |
self assert:(iid_IEnum notNil).
|
|
41 |
self assert:(iid_IEnum class == GUID).
|
|
42 |
self assert:(iid_IEnum printString = '{2AE64960-CDDD-101C-9029-040224007802}').
|
|
43 |
|
|
44 |
"
|
|
45 |
self new test00_loadOLE
|
|
46 |
"
|
1356
|
47 |
!
|
|
48 |
|
|
49 |
test01_SysAllocString
|
|
50 |
|ole rslt bstr|
|
|
51 |
|
1707
|
52 |
self skipIf:[OperatingSystem isMSWINDOWSlike not] description:'test skipped (OS is not WINDOWS)'.
|
|
53 |
|
1356
|
54 |
ole := OLEAutomationDLL current.
|
|
55 |
rslt := ole SysAllocString: 'hello World'.
|
|
56 |
|
|
57 |
self assert:(rslt notNil).
|
1372
|
58 |
self assert:(rslt sizeInBytes == (4 + ('hello World' size * 2) "+ 2")).
|
|
59 |
self assert:(rslt sizeInCharacters == 'hello World' size).
|
|
60 |
self assert:(rslt characterAt:1) == $h.
|
|
61 |
self assert:(rslt characterAt:2) == $e.
|
1356
|
62 |
|
|
63 |
"
|
|
64 |
self new test01_SysAllocString
|
|
65 |
"
|
1374
|
66 |
!
|
|
67 |
|
|
68 |
test02_GuidFromProgID
|
1722
|
69 |
|guid appToId|
|
1374
|
70 |
|
1722
|
71 |
self
|
|
72 |
skipIf:[OperatingSystem isMSWINDOWSlike not]
|
|
73 |
description:'test skipped (OS is not WINDOWS)'.
|
1707
|
74 |
|
1447
|
75 |
self
|
1707
|
76 |
should:[
|
1722
|
77 |
guid := GUID clsidFromProgID:'Foo.Bar'.
|
|
78 |
]
|
|
79 |
raise:OLEError.
|
1376
|
80 |
|
1722
|
81 |
appToId := Dictionary new.
|
|
82 |
appToId at:'AcroPDF.PDF' put:nil.
|
|
83 |
appToId at:'InternetExplorer.Application' put:'{0002DF01-0000-0000-C000-000000000046}'.
|
|
84 |
appToId at:'Msxml2.DOMDocument.4.0' put:'{88D969C0-F192-11D4-A65F-0040963251E5}'.
|
|
85 |
appToId at:'Microsoft.JScript.Vsa.VsaEngine' put:'{B71E484D-93ED-4B56-BFB9-CEED5134822B}'.
|
|
86 |
|
|
87 |
appToId keysAndValuesDo:[:app :id |
|
|
88 |
OLEError handle:[:ex |
|
|
89 |
ex hresult = (OLEStatusCodeConstants at:#CO_E_CLASSSTRING) ifTrue:[
|
|
90 |
"/ kind of expected - your machine has app not installed...
|
|
91 |
Transcript showCR:'OLE: class not found: ', app
|
|
92 |
] ifFalse:[
|
|
93 |
self assert:false description:'unexpected error code'.
|
|
94 |
]
|
|
95 |
] do:[
|
|
96 |
guid := GUID clsidFromProgID:app.
|
|
97 |
self assert:guid notNil.
|
|
98 |
|
|
99 |
id notNil ifTrue:[
|
|
100 |
self assert:guid printString = id.
|
|
101 |
].
|
|
102 |
].
|
1375
|
103 |
].
|
1374
|
104 |
|
|
105 |
"
|
|
106 |
self new test02_GuidFromProgID
|
|
107 |
"
|
1377
|
108 |
|
|
109 |
"Modified: / 30-03-2016 / 02:28:15 / cg"
|
1378
|
110 |
!
|
|
111 |
|
1381
|
112 |
test03_verbsEnumerator
|
|
113 |
|clsID enumerator nextVerb|
|
|
114 |
|
1707
|
115 |
self skipIf:[OperatingSystem isMSWINDOWSlike not] description:'test skipped (OS is not WINDOWS)'.
|
1722
|
116 |
self skipIf:true description:'tests unfinished code'.
|
1707
|
117 |
|
1381
|
118 |
clsID := GUID clsidFromProgID:'InternetExplorer.Application'.
|
|
119 |
self assert:clsID notNil.
|
|
120 |
self assert:(clsID printString = '{0002DF01-0000-0000-C000-000000000046}').
|
|
121 |
|
|
122 |
enumerator := OLERegistryInterface verbsEnumerator:clsID.
|
|
123 |
self assert:(enumerator notNil).
|
|
124 |
|
|
125 |
nextVerb := enumerator next.
|
|
126 |
self assert:nextVerb notNil.
|
|
127 |
enumerator release.
|
|
128 |
|
|
129 |
"
|
|
130 |
self new test03_verbsEnumerator
|
|
131 |
"
|
|
132 |
|
|
133 |
"Created: / 30-03-2016 / 11:29:03 / cg"
|
|
134 |
!
|
|
135 |
|
|
136 |
test20_CreateInstance
|
1380
|
137 |
|guid iDispatch iWebBrowser iWebBrowserApp iWebBrowser2
|
1382
|
138 |
ids visibleID params result specTable|
|
1378
|
139 |
|
1707
|
140 |
self skipIf:[OperatingSystem isMSWINDOWSlike not] description:'test skipped (OS is not WINDOWS)'.
|
1722
|
141 |
self skipIf:true description:'tests unfinished code'.
|
1707
|
142 |
|
1447
|
143 |
guid := (GUID clsidFromProgID:'InternetExplorer.Application').
|
1378
|
144 |
self assert:(guid notNil).
|
|
145 |
self assert:(guid printString = '{0002DF01-0000-0000-C000-000000000046}').
|
|
146 |
|
1447
|
147 |
iDispatch := IClassFactory
|
1707
|
148 |
createInstance:guid
|
|
149 |
iid: (OLEInterface oleConstantAt:'IID_IDispatch')
|
|
150 |
controllingUnknown:nil
|
|
151 |
context:(OLEInterface oleConstantAt:'CLSCTX_ALL').
|
1378
|
152 |
self assert:(iDispatch notNil).
|
|
153 |
|
|
154 |
self assert:(iDispatch hasTypeInfo).
|
|
155 |
iWebBrowser := iDispatch queryInterface: IWebBrowser iid.
|
|
156 |
self assert:(iWebBrowser notNil).
|
1382
|
157 |
specTable := OLEDispatchSpecificationTable constructSpecificationTable: iDispatch getTypeInfo.
|
1378
|
158 |
iDispatch release.
|
|
159 |
|
|
160 |
iWebBrowserApp := iWebBrowser queryInterface: IWebBrowserApp iid.
|
|
161 |
self assert:(iWebBrowserApp notNil).
|
|
162 |
iWebBrowser release.
|
|
163 |
|
|
164 |
iWebBrowser2 := iWebBrowserApp queryInterface: IWebBrowser2 iid.
|
|
165 |
self assert:(iWebBrowser2 notNil).
|
|
166 |
iWebBrowserApp release.
|
|
167 |
|
1380
|
168 |
"/ iWebBrowser2 setProperty:'Visible' value:true.
|
|
169 |
ids := iWebBrowser2 getIDsOfNames:(Array with:'Visible').
|
|
170 |
visibleID := ids first.
|
|
171 |
|
|
172 |
params := OLE_DISPPARAMS new.
|
|
173 |
params cArgs: 0.
|
1382
|
174 |
result := iWebBrowser2 invokePropertyGet: visibleID with:params.
|
|
175 |
self assert:(result == false).
|
|
176 |
|
|
177 |
"/ params := OLEDispatchValueAdaptor new
|
|
178 |
"/ parametersForPropertySet: aIDispatchSpecification arguments: valueArray
|
|
179 |
"/ parameters parametersForPropertySet: aDispatchSpecification arguments: valueArray
|
|
180 |
|
|
181 |
params := OLE_DISPPARAMS new.
|
|
182 |
params cArgs: 1.
|
1722
|
183 |
params arguments:(Array with:true asOLEVariant).
|
1382
|
184 |
result := iWebBrowser2 invokePropertyPut: visibleID with:params.
|
|
185 |
self assert:(result == false).
|
1379
|
186 |
|
1378
|
187 |
iWebBrowser2 release.
|
|
188 |
|
1447
|
189 |
|
1378
|
190 |
"
|
1381
|
191 |
self new test20_CreateInstance
|
1378
|
192 |
"
|
|
193 |
|
1381
|
194 |
"Created: / 30-03-2016 / 11:26:36 / cg"
|
1382
|
195 |
"Modified: / 30-03-2016 / 20:08:04 / cg"
|
1353
|
196 |
! !
|
|
197 |
|
|
198 |
!Win32OLETests class methodsFor:'documentation'!
|
|
199 |
|
|
200 |
version
|
|
201 |
^ '$Header$'
|
|
202 |
!
|
|
203 |
|
|
204 |
version_CVS
|
|
205 |
^ '$Header$'
|
|
206 |
! !
|
|
207 |
|