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