ahk_tests/IrfanView/4.23/prepare.ahk
Edijs Kolesnikovičs 9c9887616c [AHK_IrfanView_4.23]
Add prepare.ahk and test to open image file (bug 7089).

svn path=/trunk/ahk_tests/; revision=1501
2012-08-15 15:11:30 +00:00

93 lines
2.8 KiB
AutoHotkey

/*
* Designed for Foxit IrfanView 4.23
* Copyright (C) 2012 Edijs Kolesnikovics
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
bContinue := false
TestsTotal := 0
TestsSkipped := 0
TestsFailed := 0
TestsOK := 0
TestsExecuted := 0
TestName = prepare
Process, Close, i_view32.exe
Sleep, 1500
RegRead, UninstallerPath, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView, UninstallString
if not ErrorLevel
{
StringReplace, UninstallerPath, UninstallerPath, `",, All ; String contains quotes, replace em
SplitPath, UninstallerPath,, InstalledDir
ModuleExe = %InstalledDir%\i_view32.exe
}
else
{
ModuleExe = %A_ProgramFiles%\IrfanView\i_view32.exe
OutputDebug, %TestName%:%A_LineNumber%: Can NOT read data from registry. Key might not exist. Using hardcoded path.`n
}
; Test if can start application
RunApplication(PathToFile)
{
global ModuleExe
global TestName
Sleep, 500
FileRemoveDir, %A_AppData%\IrfanView, 1
Sleep, 500
IfExist, %ModuleExe%
{
if PathToFile =
{
Run, %ModuleExe%,, Max ; Start maximized
WinWaitActive, IrfanView,,7
if not ErrorLevel
{
Sleep, 1000
}
else
{
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'IrfanView' failed to appear. Active window caption: '%title%'`n
}
}
else
{
Run, %ModuleExe% "%PathToFile%",, Max
Sleep, 1000
SplitPath, PathToFile, NameExt
WinWaitActive, %NameExt% - IrfanView,,7
if not ErrorLevel
{
Sleep, 1000
}
else
{
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window '%NameExt% - IrfanView' failed to appear. Active window caption: '%title%'`n
}
}
}
else
{
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT find '%ModuleExe%'.`n
}
}