[AHK_IrfanView_4.23]

Add prepare.ahk and test to open image file (bug 7089).

svn path=/trunk/ahk_tests/; revision=1501
This commit is contained in:
Edijs Kolesnikovičs 2012-08-15 15:11:30 +00:00
parent 627452daf4
commit 9c9887616c
3 changed files with 230 additions and 4 deletions

View File

@ -0,0 +1,131 @@
/*
* 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 = 2.GoToPage
szDocument = %A_WorkingDir%\Media\BookPage29Img.jpg ; Case sensitive!
; Test if can open picture using File -> Open dialog and close application successfully
TestsTotal++
RunApplication("")
SplitPath, szDocument, NameExt
WinWaitActive, IrfanView,,7
if not ErrorLevel
{
IfExist, %szDocument%
{
WinMenuSelectItem, IrfanView, , File, Open
if not ErrorLevel
{
WinWaitActive, Open, Look &in,7
if not ErrorLevel
{
Sleep, 1500
ControlSetText, Edit1, %szDocument%, Open, Look &in
if not ErrorLevel
{
Sleep, 1500
ControlClick, Button2, Open, Look &in
if not ErrorLevel
{
Sleep, 1500
WinWaitActive, %NameExt% - IrfanView,,7
if not ErrorLevel
{
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *14 %szDocument%
if ErrorLevel = 2
{
TestsFailed()
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Could not conduct the ImageSearch ('%szDocument%' exist).`n
}
else if ErrorLevel = 1
{
TestsFailed()
OutputDebug, %TestName%:%A_LineNumber%: Test failed: The search image '%szDocument%' could NOT be found on the screen. Color depth not 32bit?.`n
}
else
{
WinClose, %NameExt% - IrfanView
WinWaitClose, %NameExt% - IrfanView,,7
if not ErrorLevel
{
TestsOK()
OutputDebug, OK: %TestName%:%A_LineNumber%: Opened '%szDocument%' using 'File -> Open' and closed application successfully.`n
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to close '%NameExt% - IrfanView' window. Active window caption: '%title%'`n
}
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window '%NameExt% - IrfanView' failed to appear. Active window caption: '%title%'`n
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to click 'Open' button in 'Open (Look in)' window. Active window caption: '%title%'`n
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to change 'File name' control text to '%szDocument%' in 'Open (Look in)' window, bug 7089?. Active window caption: '%title%'`n
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'Open (Look in)' failed to appear. Active window caption: '%title%'`n
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to hit 'File -> Open' in 'IrfanView' window. Active window caption: '%title%'`n
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: File '%szDocument%' was NOT found. Active window caption: '%title%'`n
}
}
else
{
TestsFailed()
WinGetTitle, title, A
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'IrfanView' failed to appear. Active window caption: '%title%'`n
}

View File

@ -0,0 +1,92 @@
/*
* 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
}
}

View File

@ -36,6 +36,13 @@ else if 1 = 1.install
}
else
{
#include prepare.ahk
if 1 = 2.OpenDocument
{
#include OpenDocument.ahk ; Open picture using File -> Open dialog and close app
}
else
OutputDebug, Bad parameters!`r`n
}
@ -46,10 +53,6 @@ if 1 != --list
SplitPath, ModuleExe, fName ; Extract filename from given path
WindowCleanUp(fName)
}
; Delete saved settings
Sleep, 1500
FileRemoveDir, %A_AppData%\IrfanView, 1
TestsSkipped := TestsTotal - TestsOK - TestsFailed
TestsExecuted := TestsOK + TestsFailed