+External_Function WinAPI_GetCurrentProcessId "GetCurrentProcessId" Kernel32.Dll Returns Integer
+External_Function WinAPI_EnumProcessModules "EnumProcessModules" Psapi.Dll Handle hProcess Address lphModule Integer cb Pointer lpcbNeeded Returns Integer
+External_Function WinAPI_CloseHandle "CloseHandle" Kernel32.Dll Handle hObject Returns Integer
+External_Function WinAPI_OpenProcess "OpenProcess" Kernel32.Dll DWord dwDesiredAccess Boolean bInheritHandle DWord dwProcessId Returns Handle
+Define PROCESS_TERMINATE for |CI$0001
+Define PROCESS_CREATE_THREAD for |CI$0002
+Define PROCESS_SET_SESSIONID for |CI$0004
+Define PROCESS_VM_OPERATION for |CI$0008
+Define PROCESS_VM_READ for |CI$0010
+Define PROCESS_VM_WRITE for |CI$0020
+Define PROCESS_DUP_HANDLE for |CI$0040
+Define PROCESS_CREATE_PROCESS for |CI$0080
+Define PROCESS_SET_QUOTA for |CI$0100
+Define PROCESS_SET_INFORMATION for |CI$0200
+Define PROCESS_QUERY_INFORMATION for |CI$0400
+Define PROCESS_ALL_ACCESS for (STANDARD_RIGHTS_REQUIRED ior SYNCHRONIZE ior |CI$FFFF)
+External_Function FindWindowEx "FindWindowExA" user32.dll ;
+ Handle hWndChildAfter ;
+Function HandleFor Global String sSearch Returns Handle
+ Move (lowercase(sSearch)) to sSearch
+ Move (FindWindowEx(0, 0, "", "")) to hwnd
+ ZeroString 100 to sData
+ Move (GetWindowText(hwnd,(AddressOf(sData)),100)) to ivoid
+ Move (Lowercase(Trim(cString(sData)))) to sData
+ If (pos(sSearch,sData)) Begin
+ Move (FindWindowEx(0, hWnd, "", "")) to hwnd
+Global_Variable Integer ghlogfile
+Object oSimpleLog is a cObject
+ Property String psPrivate.LogName
+ Property Boolean pisShow True
+ Property Boolean pisColored True
+ Property String psError "\e[0;31m"
+ Property String psMessage "\e[1;33m"
+ Property String psWarning "\e[0;35m"
+ Property String psOK "\e[0;32m"
+ Property String psWhite "\e[1;37m"
+ Procedure Set logfile String sName
+ Get psHome of (phoWorkspace(oApplication)) to sFolder
+ If ((Right(sFolder,1))<>"\") Append sFolder "\"
+ Set psPrivate.LogName to sFolder
+ Function logfile Returns String
+ Function_Return ( psPrivate.LogName (Self))
+ Procedure BaseLog String sColor String sText
+ Move (CurrentDateTime()) to dtNow
+ Move ("["+(String(dtNow)) +"] "+ sText) to sText
+ If ((pisColored(Self)) and (sColor<>"")) Move (sColor+sText+(psWhite(Self))) to sText
+ Move (Replaces("\e",sText,Character(27))) to sText
+ Get Seq_New_Channel to iCH
+ Append_Output channel iCH (logfile(Self))
+ Writeln channel iCH sText
+ Close_Output channel iCH
+ Send Seq_Release_Channel iCH
+ Procedure log String sText
+ Procedure log_error String sText
+ Send BaseLog (psError(Self)) sText
+ Procedure log_ok String sText
+ Send BaseLog (psOK(Self)) sText
+ Procedure log_yellow String stext
+ Send BaseLog (psMessage(Self)) sText
+ Move (Self) to ghlogfile
+Global_Variable Integer ghTest
+Object oTailTest is a cObject
+ Property Integer piErrorCount
+ Procedure DisplayError String sMessage
+ Set piErrorCount to ( (piErrorCount (Self))+1)
+ Send log_error to ghlogfile sMessage
+ Procedure DisplayOK String sMessage
+ Send log_OK to ghlogfile sMessage
+ Procedure DisplayMessage String sMessage
+ Send log_yellow to ghlogfile sMessage
+ Procedure doAssertEqual String sTest String sValue String sMessage
+ If (sTest<>sValue) Send DisplayError (SFormat("FAIL: "+sMessage,sValue,sTest))
+ If (sTest=sValue) Send DisplayOK (SFormat(sMessage,sValue,sTest))
+ Procedure doAssertContains String sTest String sValue String sMessage
+ Move ((Character(13))+(character(10))) to sCRLF
+ Move (Replaces(sCRLF,sValue," ")) to sValue
+ Move (Lowercase(sTest)) to sTest
+ Move (Lowercase(sValue)) to sValue
+ If ((Length(sValue))>30) Begin
+ Move (Pos(sTest,sValue)) to iPos
+ If (iPos<1) Move 1 to iPos
+ Move (Mid(sValue,30,iPos)) to sreport
+ If (iPos>1) Move ( "..."+sReport) to sReport
+ If ((iPos+30) < (Length(sValue)) ) Move (sReport+"...") to sReport
+ If (Pos(sTest,sValue)) Send DisplayOK (SFormat(sMessage,sReport,sTest))
+ Else Send DisplayError (SFormat("FAIL: "+sMessage,sReport,sTest))
+ Procedure doAssertNotEqual String sTest String sValue String sMessage
+ If (sTest=sValue) Send DisplayError (SFormat("NE-FAIL: "+sMessage,sValue,sTest))
+ If (sTest<>sValue) Send DisplayOK (SFormat(sMessage,sValue,sTest))
+ Procedure DisplayLogFile
+ Get psHome of (phoWorkspace(ghoApplication)) to sProgramPath
+ If ((Right(sProgramPath,1))<>"\") Append sProgramPath "\"
+ Move (GetApplicationName(ghoApplication)) to sProgName
+ Move (sProgName+".log") to sLogFile
+ Set logfile of ghLogFile to sLogFile
+ Send log_yellow to ghLogFile ""
+ Send log_yellow to ghLogFile sLogFile
+ Send log_yellow to ghLogFile "----------------------------"
+ If ((HandleFor("tail.exe"))=0) Begin
+ Move ("tail.exe "+'"'+(logfile(ghLogfile))+'"'+" -f") to sRunProg
+ Runprogram Background (sRunProg)
+Procedure AssertEqual Global String sTest String sValue String sMessage
+ Send doAssertEqual to ghTest sTest sValue sMessage
+Procedure AssertContains Global String sTest String sValue String sMessage
+ Send doAssertContains to ghTest sTest sValue sMessage
+Procedure AssertNotEqual Global String sTest String sValue String sMessage
+ Send doAssertNotEqual to ghTest sTest sValue sMessage
+Procedure TestMessage Global String sMessage
+ Send DisplayMessage to ghTest sMessage
+Procedure OKMessage Global String sMessage
+ Send log_ok to ghLogFile sMessage
+Procedure ErrorMessage Global String sMessage
+ Send log_error to ghLogFile sMessage