author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 28 Jun 2018 09:13:44 +0100 | |
branch | jv |
changeset 1977 | f53c1ec52418 |
parent 1974 | f2eaf05205d6 |
child 2078 | 9d76442a61bb |
permissions | -rwxr-xr-x |
1974 | 1 |
" |
2 |
COPYRIGHT (c) Claus Gittinger / eXept Software AG |
|
3 |
COPYRIGHT (c) 2016 Jan Vrany |
|
4 |
All Rights Reserved |
|
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
1447 | 13 |
"{ Package: 'stx:goodies/regression' }" |
344 | 14 |
|
15 |
"{ NameSpace: RegressionTests }" |
|
16 |
||
17 |
TestCase subclass:#Win32OperatingSystemTest |
|
675 | 18 |
instanceVariableNames:'' |
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
1161 | 21 |
category:'tests-Regression-RuntimeSystem' |
344 | 22 |
! |
23 |
||
1974 | 24 |
!Win32OperatingSystemTest class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) Claus Gittinger / eXept Software AG |
|
29 |
COPYRIGHT (c) 2016 Jan Vrany |
|
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:'release'! |
|
42 |
||
1566
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
43 |
setUp |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
44 |
self skipIf: OperatingSystem isMSWINDOWSlike not description: 'Windows specific tests'. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
45 |
super setUp |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
46 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
47 |
"Created: / 28-12-2016 / 22:12:14 / jv" |
344 | 48 |
! ! |
49 |
||
50 |
!Win32OperatingSystemTest methodsFor:'tests'! |
|
51 |
||
52 |
testMutex |
|
53 |
|handle alreadyExists lastErrorCode handleAndLastErrorCode| |
|
54 |
||
1977
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
55 |
handleAndLastErrorCode := Win32OperatingSystem createMutexNamed: UUID new printString. |
344 | 56 |
handle := handleAndLastErrorCode first. |
57 |
handle isNil ifTrue:[^ self]. |
|
58 |
lastErrorCode := handleAndLastErrorCode second. |
|
59 |
self assert: lastErrorCode == 0. |
|
60 |
alreadyExists := (lastErrorCode == 5 "ERROR_ACCESS_DENIED" or:[ lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]). |
|
61 |
alreadyExists ifTrue:[ |
|
1566
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
62 |
Transcript showCR: 'Mutex already exists!!'. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
63 |
^ self. |
344 | 64 |
]. |
1977
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
65 |
[ |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
66 |
Transcript showCR: 'Mutex created!!'. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
67 |
Win32OperatingSystem waitForSingleObject: handle. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
68 |
Delay waitForSeconds:0.5. "/ self halt. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
69 |
Win32OperatingSystem releaseMutex: handle. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
70 |
] ensure:[ |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
71 |
Win32OperatingSystem primCloseHandle: handle. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
72 |
Transcript showCR: 'Mutex closed!!'. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
73 |
]. |
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
74 |
|
344 | 75 |
|
76 |
" |
|
77 |
self new testMutex |
|
78 |
" |
|
1566
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
79 |
|
1977
f53c1ec52418
`Win32OperatingSystemTest`: use generated mutex name to allow tests to run in parallel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1974
diff
changeset
|
80 |
"Modified: / 28-06-2018 / 09:14:35 / jv" |
1352 | 81 |
! |
82 |
||
83 |
testRegistry |
|
84 |
|k hasContentType| |
|
85 |
||
86 |
k := OperatingSystem registryEntry key:'HKEY_CLASSES_ROOT\MIME\Database\'. |
|
87 |
self assert:(k notNil). |
|
88 |
||
89 |
hasContentType := false. |
|
1447 | 90 |
k subKeyNamesAndClassesDo:[:nm :clsNm | |
1566
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
91 |
"/ Transcript showCR:nm. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
92 |
nm = 'Content Type' ifTrue:[hasContentType := true]. |
1352 | 93 |
]. |
94 |
self assert:hasContentType. |
|
95 |
||
96 |
"/ k subKeysDo:[:k | Transcript showCR:k]. |
|
97 |
||
98 |
" |
|
99 |
self new testRegistry |
|
100 |
" |
|
1566
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
101 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
102 |
"Modified: / 28-12-2016 / 22:13:43 / jv" |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
103 |
! |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
104 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
105 |
testRegistry02a |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
106 |
| root key | |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
107 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
108 |
root :=OperatingSystem registryEntry key:'HKEY_CURRENT_USER'. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
109 |
root deleteSubKeyNamed: testSelector. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
110 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
111 |
self assert:(root subKeyNamed: testSelector) isNil. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
112 |
self deny: (root deleteSubKeyNamed: testSelector). |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
113 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
114 |
key := root createSubKeyNamed:testSelector. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
115 |
self assert: key notNil. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
116 |
self assert:(root subKeyNamed: testSelector) notNil. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
117 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
118 |
self assert: (root deleteSubKeyNamed:testSelector). |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
119 |
self assert:(root subKeyNamed: testSelector) isNil. |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
120 |
self deny: (root deleteSubKeyNamed: testSelector). |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
121 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
122 |
"Created: / 28-12-2016 / 23:14:15 / jv" |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
123 |
"Modified: / 05-01-2017 / 21:45:20 / jv" |
344 | 124 |
! ! |
125 |
||
126 |
!Win32OperatingSystemTest class methodsFor:'documentation'! |
|
127 |
||
128 |
version |
|
129 |
^ '$Header$' |
|
1566
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
130 |
! |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
131 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
132 |
version_HG |
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
133 |
|
2ca58098256d
Issue #109: Added tests for registry key creation / deletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1500
diff
changeset
|
134 |
^ '$Changeset: <not expanded> $' |
344 | 135 |
! ! |
1161 | 136 |