RegressionTests__Win32OperatingSystemTest.st
author Claus Gittinger <cg@exept.de>
Fri, 29 Apr 2016 14:06:07 +0200
changeset 1407 18f5a9e9c677
parent 1392 c93700ea3e05
child 1447 2351db93aa5b
child 1499 26a16a04219b
permissions -rw-r--r--
#QUALITY by cg class: RegressionTests::StreamTests added: #test40_eolMode

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#Win32OperatingSystemTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression-RuntimeSystem'
!


!Win32OperatingSystemTest methodsFor:'release'!

tearDown
! !

!Win32OperatingSystemTest methodsFor:'tests'!

testMutex
    |handle alreadyExists lastErrorCode handleAndLastErrorCode|

    self skipIf:[OperatingSystem isMSWINDOWSlike not] description:'test skipped (OS is not WINDOWS)'.

    handleAndLastErrorCode := Win32OperatingSystem createMutexNamed: '8906f5e0-54ed-11dd-9da4-001558137da0'.
    handle := handleAndLastErrorCode first.
    handle isNil ifTrue:[^ self].
    lastErrorCode := handleAndLastErrorCode second.
    self assert: lastErrorCode == 0.
    alreadyExists := (lastErrorCode == 5 "ERROR_ACCESS_DENIED" or:[ lastErrorCode == 183 "ERROR_ALREADY_EXISTS"]).
    alreadyExists ifTrue:[
        Transcript showCR: 'Mutex already exists!!'.
        ^ self.
    ].
    Transcript showCR: 'Mutex created!!'.
    Win32OperatingSystem waitForSingleObject: handle.
    Delay waitForSeconds:0.5. "/ self halt.
    Win32OperatingSystem releaseMutex: handle.
    Win32OperatingSystem primCloseHandle: handle.
    Transcript showCR: 'Mutex closed!!'.

    "
     self new testMutex
    "
!

testRegistry
    |k hasContentType|

    self skipIf:[OperatingSystem isMSWINDOWSlike not] description:'test skipped (OS is not WINDOWS)'.

    k := OperatingSystem registryEntry key:'HKEY_CLASSES_ROOT\MIME\Database\'.
    self assert:(k notNil).

    hasContentType := false.
    k subKeyNamesAndClassesDo:[:nm :clsNm | 
        "/ Transcript showCR:nm.
        nm = 'Content Type' ifTrue:[hasContentType := true].
    ].
    self assert:hasContentType.

    "/ k subKeysDo:[:k | Transcript showCR:k].

    "
     self new testRegistry
    "
! !

!Win32OperatingSystemTest class methodsFor:'documentation'!

version
    ^ '$Header$'
! !