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