[AHK_mIRC_7.25]

Match new design, add few more checks.
Install test works fine in win2k3 sp2.

svn path=/trunk/ahk_tests/; revision=1617
This commit is contained in:
Edijs Kolesnikovičs 2012-09-09 05:00:25 +00:00
parent 0e9afd9804
commit 8d7a801645
2 changed files with 147 additions and 147 deletions

View File

@ -18,94 +18,112 @@
*/
ModuleExe = %A_WorkingDir%\Apps\mIRC_7.25_Setup.exe
bContinue := false
TestName = 1.install
TestsFailed := 0
TestsOK := 0
TestsTotal := 0
MainAppFile = mirc.exe ; Mostly this is going to be process we need to look for
; Test if Setup file exists, if so, delete installed files, and run Setup
IfExist, %ModuleExe%
{
; Get rid of other versions
RegRead, UninstallerPath, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\mIRC, UninstallString
if not ErrorLevel
{
Process, Close, mirc.exe ; Teminate process
Sleep, 1500
RegRead, InstallLocation, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\mIRC, InstallLocation
RunWait, %UninstallerPath% /S ; Silently uninstall it
Sleep, 2500
; Delete everything just in case
RegDelete, HKEY_CURRENT_USER, SOFTWARE\mIRC
RegDelete, HKEY_LOCAL_MACHINE, SOFTWARE\MicroSoft\Windows\CurrentVersion\Uninstall\mIRC
FileRemoveDir, %InstallLocation%, 1
Sleep, 1000
IfExist, %InstallLocation%
{
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Failed to delete '%InstallLocation%'.`n
bContinue := false
}
else
{
bContinue := true
}
}
else
{
; There was a problem (such as a nonexistent key or value).
; That probably means we have not installed this app before.
; Check in default directory to be extra sure
IfExist, %A_ProgramFiles%\mIRC\Uninstall.exe
{
Process, Close, mirc.exe ; Teminate process
Sleep, 1500
RunWait, %A_ProgramFiles%\mIRC\Uninstall.exe /S ; Silently uninstall it
Sleep, 2500
FileRemoveDir, %A_ProgramFiles%\mIRC, 1
Sleep, 1000
IfExist, %A_ProgramFiles%\mIRC
{
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Previous version detected and failed to delete '%A_ProgramFiles%\mIRC'.`n
bContinue := false
}
else
{
bContinue := true
}
}
else
{
; No previous versions detected.
bContinue := true
}
}
if bContinue
{
FileRemoveDir, %A_AppData%\mIRC, 1
Run %ModuleExe%
}
}
TestsTotal++
IfNotExist, %ModuleExe%
TestsFailed("'" ModuleExe "' not found.")
else
{
OutputDebug, %TestName%:%A_LineNumber%: Test failed: '%ModuleExe%' not found.`n
bContinue := false
Process, Close, %MainAppFile% ; Teminate process
Process, WaitClose, %MainAppFile%, 4
if ErrorLevel ; The PID still exists.
TestsFailed("Unable to terminate '" MainAppFile "' process.") ; So, process still exists
else
{
RegRead, InstallLocation, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\mIRC, InstallLocation
if ErrorLevel
{
; There was a problem (such as a nonexistent key or value).
; That probably means we have not installed this app before.
; Check in default directory to be extra sure
IfNotExist, %A_ProgramFiles%\mIRC
bContinue := true ; No previous versions detected in hardcoded path
else
{
bHardcoded := true ; To know if we got path from registry or not
IfExist, %A_ProgramFiles%\mIRC\Uninstall.exe
{
RunWait, %A_ProgramFiles%\mIRC\Uninstall.exe /S ; Silently uninstall it
Sleep, 7000
}
IfNotExist, %A_ProgramFiles%\mIRC ; Uninstaller might delete the dir
bContinue := true
{
FileRemoveDir, %A_ProgramFiles%\mIRC, 1
if ErrorLevel
TestsFailed("Unable to delete existing '" A_ProgramFiles "\mIRC' ('" MainAppFile "' process is reported as terminated).'")
else
bContinue := true
}
}
}
else
{
IfNotExist, %InstallLocation%
bContinue := true
else
{
IfExist, %InstallLocation%\Uninstall.exe
{
RunWait, %InstallLocation%\Uninstall.exe /S ; Silently uninstall it
Sleep, 7000
}
IfNotExist, %InstallLocation%
bContinue := true
else
{
FileRemoveDir, %InstallLocation%, 1 ; Delete just in case
if ErrorLevel
TestsFailed("Unable to delete existing '" InstallLocation "' ('" MainAppFile "' process is reported as terminated).")
else
bContinue := true
}
}
}
}
if bContinue
{
RegDelete, HKEY_CURRENT_USER, SOFTWARE\mIRC
RegDelete, HKEY_LOCAL_MACHINE, SOFTWARE\MicroSoft\Windows\CurrentVersion\Uninstall\mIRC
IfExist, %A_AppData%\mIRC
{
FileRemoveDir, %A_AppData%\mIRC, 1
if ErrorLevel
TestsFailed("Unable to delete '" A_AppData "\mIRC'.")
}
if bContinue
{
if bHardcoded
TestsOK("Either there was no previous versions or we succeeded removing it using hardcoded path.")
else
TestsOK("Either there was no previous versions or we succeeded removing it using data from registry.")
Run %ModuleExe%
}
}
}
; Test if 'Welcome to the mIRC' window appeared
TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Welcome to the mIRC, 15
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (Welcome to the mIRC)' window failed to appear.")
else
{
Sleep, 250
Sleep, 700
SendInput, !n ; Hit 'Next' button
TestsOK("'mIRC Setup (Welcome to the mIRC)' window appeared, Alt+N was sent.")
}
else
TestsFailed("'mIRC Setup (Welcome to the mIRC)' window failed to appear.")
}
@ -114,14 +132,14 @@ TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, License Agreement, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (License Agreement)' window failed to appear.")
else
{
Sleep, 250
Sleep, 700
SendInput, !a ; Hit 'I Agree' button
TestsOK("'mIRC Setup (License Agreement)' window appeared, Alt+A was sent.")
}
else
TestsFailed("'mIRC Setup (License Agreement)' window failed to appear.")
}
@ -130,14 +148,14 @@ TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Choose Install Location, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (Choose Install Location)' window failed to appear.")
else
{
Sleep, 250
Sleep, 700
SendInput, !n ; Hit 'Next' button
TestsOK("'mIRC Setup (Choose Install Location)' window appeared, Alt+N was sent.")
}
else
TestsFailed("'mIRC Setup (Choose Install Location)' window failed to appear.")
}
@ -146,14 +164,14 @@ TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Choose Components, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup(Choose Components)' window failed to appear")
else
{
Sleep, 250
Sleep, 700
SendInput, !n ; Hit 'Next' button
TestsOK("'mIRC Setup(Choose Components)' window appeared, Alt+N was sent.")
}
else
TestsFailed("'mIRC Setup(Choose Components)' window failed to appear")
}
@ -162,14 +180,16 @@ TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Select Additional Tasks, 7
if not ErrorLevel
{
Sleep, 250
SendInput, !n ; Hit 'Next' button
TestsOK("'mIRC Setup (Select Additional Tasks)' window appeared, Alt+N was sent.")
}
else
if ErrorLevel
TestsFailed("'mIRC Setup (Select Additional Tasks)' window failed to appear.")
else
{
Sleep, 700
SendInput, {TAB}{TAB}{SPACE}{TAB}{SPACE} ; Uncheck 'Backup Current Files' and 'Automatically Check for Updates'
Sleep, 500
SendInput, !n ; Hit 'Next' button
TestsOK("'mIRC Setup (Select Additional Tasks)' window appeared, checkboxes 'Backup Current Files' and 'Automatically Check for Updates' unchecked, Alt+N was sent.")
}
}
@ -178,14 +198,14 @@ TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Ready to Install, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (Ready to Install)' window failed to appear.")
else
{
Sleep, 250
Sleep, 700
SendInput, {ALTDOWN}i{ALTUP} ; Hit 'Install' button
TestsOK("'mIRC Setup (Ready to Install)' window appeared, Alt+I was sent.")
}
else
TestsFailed("'mIRC Setup (Ready to Install)' window failed to appear.")
}
@ -194,41 +214,42 @@ TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Installing, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (Installing)' window failed to appear.")
else
{
Sleep, 250
Sleep, 700
OutputDebug, OK: %TestName%:%A_LineNumber%: 'Installing' window appeared, waiting for it to close.`n
WinWaitClose, mIRC Setup, Installing, 25
if not ErrorLevel
TestsOK("'mIRC Setup (Installing)' window went away.")
else
if ErrorLevel
TestsFailed("'mIRC Setup (Installing)' window failed to close.")
}
else
TestsFailed("'mIRC Setup (Installing)' window failed to appear.")
else
TestsOK("'mIRC Setup (Installing)' window went away.")
}
}
; Test if 'Completing' window appeared
TestsTotal++
if bContinue
{
WinWaitActive, mIRC Setup, Completing, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (Completing)' window failed to appear.")
else
{
Sleep, 250
Sleep, 700
OutputDebug, OK: %TestName%:%A_LineNumber%: In a sec will send '{ALT DOWN}f' (note: no '{ALT UP}' event).`n
SendInput, {ALT DOWN}f ; Hit 'Finish' button
WinWaitClose, mIRC Setup, Completing, 7
if not ErrorLevel
if ErrorLevel
TestsFailed("'mIRC Setup (Completing)' window failed to close.")
else
{
TestsOK("'mIRC Setup (Completing)' window appeared, '{ALT DOWN}f' was sent (note: no '{ALT UP}' event) and window was closed (will send '{ALT UP}' in a sec).")
SendInput, {ALT UP} ; We have to send it anyway
}
else
TestsFailed("'mIRC Setup (Completing)' window failed to close.")
}
else
TestsFailed("'mIRC Setup (Completing)' window failed to appear.")
}
@ -237,15 +258,14 @@ TestsTotal++
if bContinue
{
Sleep, 2000
RegRead, InstallLocation, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\mIRC, InstallLocation
if not ErrorLevel
{
StringReplace, InstallLocation, InstallLocation, `",, All
IfExist, %InstallLocation%
TestsOK("The application has been installed, because '" InstallLocation "' was found.")
else
TestsFailed("Something went wrong, can't find '" InstallLocation "'.")
}
else
RegRead, InstalledDir, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\mIRC, InstallLocation
if ErrorLevel
TestsFailed("Either we can't read from registry or data doesn't exist.")
else
{
IfNotExist, %InstalledDir%\%MainAppFile%
TestsFailed("Something went wrong, can't find '" InstalledDir "\" MainAppFile "'.")
else
TestsOK("The application has been installed, because '" InstalledDir "\" MainAppFile "' was found.")
}
}

View File

@ -18,42 +18,22 @@
*/
#Include ..\..\helper_functions.ahk
InitalizeCounters()
if 1 = --list
{
params =
(
1.install
)
FileAppend, %params%, *
}
else if 1 = 1.install
{
#include install_test.ahk
}
else
{
OutputDebug, Bad parameters: '%1%'!`r`n
}
if 1 != --list
if CheckParam()
{
if not bContinue
; Those brackets are required!
if 1 = 1.install
{
SplitPath, ModuleExe, fName
WindowCleanUp(fName)
#include install_test.ahk
}
; Delete saved settings
Sleep, 1500
FileRemoveDir, %A_AppData%\mIRC, 1
TestsSkipped := TestsTotal - TestsOK - TestsFailed
TestsExecuted := TestsOK + TestsFailed
if (TestsSkipped < 0 or TestsExecuted < 0)
OutputDebug, %TestName%: Check TestsTotal, TestsOK and TestsFailed, because results returns less than 0.`n
OutputDebug, %TestName%: %TestsExecuted% tests executed (0 marked as todo, %TestsFailed% failures), %TestsSkipped% skipped.`n
}
ShowTestResults()