1647
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
2481
|
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' }"
|
344
|
15 |
|
|
16 |
"{ NameSpace: RegressionTests }"
|
|
17 |
|
|
18 |
TestCase subclass:#Win32OperatingSystemTest
|
675
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
1161
|
22 |
category:'tests-Regression-RuntimeSystem'
|
344
|
23 |
!
|
|
24 |
|
2481
|
25 |
!Win32OperatingSystemTest 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 |
! !
|
344
|
40 |
|
|
41 |
!Win32OperatingSystemTest methodsFor:'tests'!
|
|
42 |
|
1647
|
43 |
test01_Registry
|
|
44 |
|k hasContentType|
|
|
45 |
|
|
46 |
self
|
|
47 |
skipIf:[OperatingSystem isMSWINDOWSlike not]
|
|
48 |
description:'test skipped (OS is not WINDOWS)'.
|
|
49 |
|
|
50 |
k := OperatingSystem registryEntry key:'HKEY_CLASSES_ROOT\MIME\Database\'.
|
|
51 |
self assert:(k notNil).
|
|
52 |
|
|
53 |
hasContentType := false.
|
|
54 |
k subKeyNamesAndClassesDo:[:nm :clsNm |
|
|
55 |
"/ Transcript showCR:nm.
|
|
56 |
nm = 'Content Type' ifTrue:[hasContentType := true].
|
|
57 |
].
|
|
58 |
self assert:hasContentType.
|
|
59 |
|
|
60 |
"/ k subKeysDo:[:k | Transcript showCR:k].
|
|
61 |
|
|
62 |
"
|
|
63 |
self new test01_Registry
|
|
64 |
"
|
|
65 |
!
|
|
66 |
|
|
67 |
test02_RegistryStore_and_Retrieve
|
|
68 |
|k s20 s40 s200 s800 s1600 s3200 s6400|
|
|
69 |
|
|
70 |
self
|
|
71 |
skipIf:[OperatingSystem isMSWINDOWSlike not]
|
|
72 |
description:'test skipped (OS is not WINDOWS)'.
|
|
73 |
|
|
74 |
(OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\ExeptTest') isNil ifTrue:[
|
|
75 |
(OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software') createSubKeyNamed:'ExeptTest'.
|
|
76 |
].
|
|
77 |
k := OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\ExeptTest'.
|
|
78 |
self assert:k notNil.
|
|
79 |
|
|
80 |
(k valueNamed:'BLA10') isNil ifTrue:[
|
|
81 |
k valueNamed:'BLA10' put:'1234567890'
|
|
82 |
].
|
|
83 |
|
|
84 |
s20 := '12345678901234567890'.
|
|
85 |
s40 := s20,s20.
|
|
86 |
s200 := s40,s40,s40,s40,s40.
|
|
87 |
s800 := s200,s200,s200,s200.
|
|
88 |
s1600 := s800,s800.
|
|
89 |
s3200 := s1600,s1600.
|
|
90 |
s6400 := s3200,s3200.
|
|
91 |
|
|
92 |
(k valueNamed:'BLA1600') isNil ifTrue:[
|
|
93 |
k valueNamed:'BLA1600' put:s1600
|
|
94 |
].
|
|
95 |
(k valueNamed:'BLA3200') isNil ifTrue:[
|
|
96 |
k valueNamed:'BLA3200' put:s3200
|
|
97 |
].
|
|
98 |
(k valueNamed:'BLA6400') isNil ifTrue:[
|
|
99 |
k valueNamed:'BLA6400' put:s6400
|
|
100 |
].
|
|
101 |
|
|
102 |
self assert:(k valueNames includesAll:#('BLA10' 'BLA1600' 'BLA3200')).
|
|
103 |
self assert:(k valueNamed:'BLA10') = '1234567890'.
|
|
104 |
self assert:(k valueNamed:'BLA1600') = s1600.
|
|
105 |
self assert:(k valueNamed:'BLA3200') = s3200.
|
|
106 |
self assert:(k valueNamed:'BLA6400') = s6400.
|
|
107 |
|
|
108 |
"
|
|
109 |
self new test02_RegistryStore_and_Retrieve
|
|
110 |
"
|
|
111 |
!
|
|
112 |
|
|
113 |
test03_RegistryStore_and_Retrieve_Unicode
|
|
114 |
"with unicode keys and values"
|
|
115 |
|
|
116 |
|k s20 s40 s200 s800 s1600 s3200 s6400|
|
|
117 |
|
|
118 |
self
|
|
119 |
skipIf:[OperatingSystem isMSWINDOWSlike not]
|
|
120 |
description:'test skipped (OS is not WINDOWS)'.
|
|
121 |
|
|
122 |
self
|
|
123 |
skip:'Unicode not yet supported in Registry code'.
|
|
124 |
|
|
125 |
(OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\ExeptTest') isNil ifTrue:[
|
|
126 |
(OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software') createSubKeyNamed:'ExeptTest'.
|
|
127 |
].
|
|
128 |
k := OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\ExeptTest'.
|
|
129 |
self assert:k notNil.
|
|
130 |
|
|
131 |
(k valueNamed:'BLA10_u') isNil ifTrue:[
|
|
132 |
k valueNamed:'BLA10_u' put:'αβγ4567890'
|
|
133 |
].
|
|
134 |
|
|
135 |
s20 := 'αβγ45678901234567890'.
|
|
136 |
s40 := s20,s20.
|
|
137 |
s200 := s40,s40,s40,s40,s40.
|
|
138 |
s800 := s200,s200,s200,s200.
|
|
139 |
s1600 := s800,s800.
|
|
140 |
s3200 := s1600,s1600.
|
|
141 |
s6400 := s3200,s3200.
|
|
142 |
|
|
143 |
(k valueNamed:'BLA1600_u') isNil ifTrue:[
|
|
144 |
k valueNamed:'BLA1600_u' put:s1600
|
|
145 |
].
|
|
146 |
(k valueNamed:'BLA3200_u') isNil ifTrue:[
|
|
147 |
k valueNamed:'BLA3200_u' put:s3200
|
|
148 |
].
|
|
149 |
(k valueNamed:'BLA6400_u') isNil ifTrue:[
|
|
150 |
k valueNamed:'BLA6400_u' put:s6400
|
|
151 |
].
|
|
152 |
|
|
153 |
self assert:(k valueNames includesAll:#('BLA10_u' 'BLA1600_u' 'BLA3200_u')).
|
|
154 |
self assert:(k valueNamed:'BLA10_u') = 'αβγ4567890'.
|
|
155 |
self assert:(k valueNamed:'BLA1600_u') = s1600.
|
|
156 |
self assert:(k valueNamed:'BLA3200_u') = s3200.
|
|
157 |
self assert:(k valueNamed:'BLA6400_u') = s6400.
|
|
158 |
|
|
159 |
"
|
|
160 |
self new test03_RegistryStore_and_Retrieve_Unicode
|
|
161 |
"
|
|
162 |
!
|
|
163 |
|
|
164 |
test10_Mutex
|
344
|
165 |
|handle alreadyExists lastErrorCode handleAndLastErrorCode|
|
|
166 |
|
1647
|
167 |
self
|
|
168 |
skipIf:[OperatingSystem isMSWINDOWSlike not]
|
|
169 |
description:'test skipped (OS is not WINDOWS)'.
|
675
|
170 |
|
344
|
171 |
handleAndLastErrorCode := Win32OperatingSystem createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'.
|
|
172 |
handle := handleAndLastErrorCode first.
|
|
173 |
handle isNil ifTrue:[^ self].
|
|
174 |
lastErrorCode := handleAndLastErrorCode second.
|
|
175 |
self assert: lastErrorCode == 0.
|
|
176 |
alreadyExists := (lastErrorCode == 5 "ERROR_ACCESS_DENIED" or:[ lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]).
|
|
177 |
alreadyExists ifTrue:[
|
1647
|
178 |
Transcript showCR: 'Mutex already exists!!'.
|
|
179 |
^ self.
|
344
|
180 |
].
|
354
|
181 |
Transcript showCR: 'Mutex created!!'.
|
344
|
182 |
Win32OperatingSystem waitForSingleObject: handle.
|
355
|
183 |
Delay waitForSeconds:0.5. "/ self halt.
|
344
|
184 |
Win32OperatingSystem releaseMutex: handle.
|
|
185 |
Win32OperatingSystem primCloseHandle: handle.
|
354
|
186 |
Transcript showCR: 'Mutex closed!!'.
|
344
|
187 |
|
|
188 |
"
|
1647
|
189 |
self new test10_Mutex
|
1352
|
190 |
"
|
344
|
191 |
! !
|
|
192 |
|
|
193 |
!Win32OperatingSystemTest class methodsFor:'documentation'!
|
|
194 |
|
|
195 |
version
|
|
196 |
^ '$Header$'
|
1648
|
197 |
!
|
|
198 |
|
|
199 |
version_CVS
|
|
200 |
^ '$Header$'
|
344
|
201 |
! !
|
1161
|
202 |
|