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