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