From 78463b143f11e507067d2ec5b54f068e77d91d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edijs=20Kolesnikovi=C4=8Ds?= Date: Wed, 8 Aug 2012 19:30:49 +0000 Subject: [PATCH] [AHK_7-Zip_4.65] Add archive extract test. svn path=/trunk/ahk_tests/; revision=1489 --- 7-Zip/4.65/ExtractArchive.ahk | 124 +++++++++++++++++++++++++++++++ 7-Zip/4.65/prepare.ahk | 88 ++++++++++++++++++++++ 7-Zip/4.65/zz_7zip_4.65_test.ahk | 7 ++ 3 files changed, 219 insertions(+) create mode 100644 7-Zip/4.65/ExtractArchive.ahk create mode 100644 7-Zip/4.65/prepare.ahk diff --git a/7-Zip/4.65/ExtractArchive.ahk b/7-Zip/4.65/ExtractArchive.ahk new file mode 100644 index 0000000..9185db6 --- /dev/null +++ b/7-Zip/4.65/ExtractArchive.ahk @@ -0,0 +1,124 @@ +/* + * Designed for 7-Zip 4.65 + * 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.ExtractArchive +szDocument = %A_WorkingDir%\Media\7Zip_TestFile.7z + +; Test if can extract file to the folder in desktop +TestsTotal++ +IfExist, %szDocument% +{ + FileRemoveDir, %A_Desktop%\7-Zip, 1 + FileCreateDir, %A_Desktop%\7-Zip + if not ErrorLevel + { + RunApplication(szDocument) + WinWaitActive, %szDocument%\,,7 + if not ErrorLevel + { + SendInput, {F5} ; Shortcut to 'Extract' + WinWaitActive, Copy, Copy to, 7 + if not ErrorLevel + { + ControlSetText, Edit1, %A_Desktop%\7-Zip, Copy, Copy to ; Path + if not ErrorLevel + { + ControlClick, Button2, Copy, Copy to ; Hit 'OK' button + if not ErrorLevel + { + Sleep, 4000 ; Give it some time to extract + IfExist, %A_Desktop%\7-Zip\TestFile.txt + { + FileReadLine, OutputVar, %A_Desktop%\7-Zip\TestFile.txt, 1 + if not ErrorLevel + { + TestText = If you can read this, then test works. + if OutputVar = %TestText% + { + TestsOK() + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Line 1 of '%A_Desktop%\7-Zip\TestFile.txt' is not the same as expected (%OutputVar%). Active window caption: '%title%'.`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT read contents of '%A_Desktop%\7-Zip\TestFile.txt'. Active window caption: '%title%'.`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT find '%A_Desktop%\7-Zip\TestFile.txt'. Active window caption: '%title%'.`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to click 'OK' in 'Copy (Copy to)' window. Active window caption: '%title%'.`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to change 'Edit1' control text to '%A_Desktop%\7-Zip'. Active window caption: '%title%'.`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'Copy (Copy to)' failed to appear. Shortcuts (F5) not working? Active window caption: '%title%'`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window '%PathToFile%\' failed to appear. Active window caption: '%title%'`n + } + } + else + { + TestsFailed() + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Failed to create '%A_Desktop%\7-Zip'. Active window caption: '%title%'`n + } +} +else +{ + TestsFailed() + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT find '%szDocument%'.`n +} + +Process, Close, 7zFM.exe \ No newline at end of file diff --git a/7-Zip/4.65/prepare.ahk b/7-Zip/4.65/prepare.ahk new file mode 100644 index 0000000..081f462 --- /dev/null +++ b/7-Zip/4.65/prepare.ahk @@ -0,0 +1,88 @@ +/* + * Designed for 7-Zip 4.65 + * 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 + + +RegRead, UninstallerPath, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip, UninstallString +if not ErrorLevel +{ + StringReplace, UninstallerPath, UninstallerPath, `",, All ; String contains quotes, replace em + SplitPath, UninstallerPath,, InstalledDir + ModuleExe = %InstalledDir%\7zFM.exe +} +else +{ + ModuleExe = %A_ProgramFiles%\7-Zip\7zFM.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 + RegDelete, HKEY_LOCAL_MACHINE, SOFTWARE\7-Zip + RegDelete, HKEY_CURRENT_USER, SOFTWARE\7-Zip + IfExist, %ModuleExe% + { + if PathToFile = + { + Run, %ModuleExe%,, Max ; Start maximized + Sleep, 1000 + WinWaitActive, 7-Zip File Manager,,7 + if not ErrorLevel + { + ; TestsOK() + } + else + { + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window '7-Zip File Manager' failed to appear. Active window caption: '%title%'`n + } + } + else + { + Run, %ModuleExe% "%PathToFile%",, Max + Sleep, 1000 + WinWaitActive, %PathToFile%\,,7 + if not ErrorLevel + { + ; TestsOK() + } + else + { + WinGetTitle, title, A + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window '%PathToFile%\' failed to appear. Active window caption: '%title%'`n + } + } + } + else + { + OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT find '%ModuleExe%'.`n + } +} diff --git a/7-Zip/4.65/zz_7zip_4.65_test.ahk b/7-Zip/4.65/zz_7zip_4.65_test.ahk index db30bb6..0a5117d 100644 --- a/7-Zip/4.65/zz_7zip_4.65_test.ahk +++ b/7-Zip/4.65/zz_7zip_4.65_test.ahk @@ -36,6 +36,13 @@ else if 1 = 1.install } else { + #include prepare.ahk + + if 1 = 2.ExtractArchive + { + #include ExtractArchive.ahk + } + else OutputDebug, Bad parameters!`r`n }