[AHK_Helper_Functions]

TestsFailed(): Check if internet connection is present before taking any screenshots.

svn path=/trunk/ahk_tests/; revision=1958
This commit is contained in:
Edijs Kolesnikovičs 2013-02-08 18:32:26 +00:00
parent ac8d64773c
commit 9c2377da3f

View File

@ -279,51 +279,56 @@ TestsFailed(DebugText)
}
}
szApp = %A_WorkingDir%\Apps\Cap.exe ; Screenshot capture utility by Mysoft (Grégori Macário Harbs)
IfNotExist, %szApp%
TestsInfo("Can NOT find '" szApp "'.")
if not bIsConnectedToInternet()
TestsFailed("TestsFailed(): No internet connection detected.")
else
{
clipboard = ; emptry clipboard
szFileName := SubStr(A_ScriptName, 1, -4) ; remove '.exe' part from our executable name
szUploadURL = mysoft.zapto.org:8000/Uploads/Captures/%szFileName%_%TestName%.jpg
Run, %szApp% /full /jpg 40 /silent /revision /nobelt /clipboard /hfs %szUploadURL%
SplitPath, szApp, ProcessName
Process, wait, %ProcessName%, 3
NewPID = %ErrorLevel%
if NewPID = 0
TestsInfo("Process '" ProcessName "' failed to appear.")
szApp = %A_WorkingDir%\Apps\Cap.exe ; Screenshot capture utility by Mysoft (Grégori Macário Harbs)
IfNotExist, %szApp%
TestsInfo("Can NOT find '" szApp "'.")
else
{
iTimeOut := 30
while iTimeOut > 0
{
Process, Exist, %ProcessName%
NewPID = %ErrorLevel%
if NewPID = 0
break ; process is closed
else
{
Sleep, 1000
iTimeOut--
}
}
Process, Exist, %ProcessName%
clipboard = ; emptry clipboard
szFileName := SubStr(A_ScriptName, 1, -4) ; remove '.exe' part from our executable name
szUploadURL = mysoft.zapto.org:8000/Uploads/Captures/%szFileName%_%TestName%.jpg
Run, %szApp% /full /jpg 40 /silent /revision /nobelt /clipboard /hfs %szUploadURL%
SplitPath, szApp, ProcessName
Process, wait, %ProcessName%, 3
NewPID = %ErrorLevel%
if NewPID != 0
{
Process, Close, %ProcessName%
Process, WaitClose, %ProcessName%, 5
if ErrorLevel
TestsInfo("Unable to terminate '" ProcessName "' process.")
}
if NewPID = 0
TestsInfo("Process '" ProcessName "' failed to appear.")
else
{
if A_LastError = 0 ; szApp returns 0 in case of success and puts URL in clipboard
TestsInfo("Successfully uploaded to: " clipboard ".")
iTimeOut := 30
while iTimeOut > 0
{
Process, Exist, %ProcessName%
NewPID = %ErrorLevel%
if NewPID = 0
break ; process is closed
else
{
Sleep, 1000
iTimeOut--
}
}
Process, Exist, %ProcessName%
NewPID = %ErrorLevel%
if NewPID != 0
{
Process, Close, %ProcessName%
Process, WaitClose, %ProcessName%, 5
if ErrorLevel
TestsInfo("Unable to terminate '" ProcessName "' process.")
}
else
TestsInfo("There were something wrong while running '" szApp "'.")
{
if A_LastError = 0 ; szApp returns 0 in case of success and puts URL in clipboard
TestsInfo("Successfully uploaded to: " clipboard ".")
else
TestsInfo("There were something wrong while running '" szApp "'.")
}
}
}
}