mirror of
https://github.com/reactos/ahk_tests.git
synced 2025-02-17 10:10:24 +00:00
[AHK_Word_Viewer_2003]
Add prepare.ahk and copy_text.ahk; 2.copy_text: open word document and copy text from it to the clipboard. Test succeeds in 23k SP1 and WinXP SP3. svn path=/trunk/ahk_tests/; revision=2011
This commit is contained in:
parent
ecda291ac3
commit
05cb02fe5f
79
Microsoft Office/Word Viewer 2003/copy_text.ahk
Normal file
79
Microsoft Office/Word Viewer 2003/copy_text.ahk
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Designed for Word Viewer 2003
|
||||
* Copyright (C) 2013 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
|
||||
*/
|
||||
|
||||
TestName = 2.copy_text
|
||||
szDocument = %A_WorkingDir%\Media\Microsoft Word 2003 Doc.doc ; Case sensitive!
|
||||
|
||||
; Test if can open Word document and copy text from it to clipboard
|
||||
TestsTotal++
|
||||
RunApplication(szDocument)
|
||||
if bContinue
|
||||
{
|
||||
|
||||
RegRead, bHideExt, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, HideFileExt
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to read 'HideFileExt' in 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'.")
|
||||
else
|
||||
{
|
||||
if bHideExt
|
||||
SplitPath, szDocument,,,, name_no_ext
|
||||
else
|
||||
SplitPath, szDocument, NameExt
|
||||
szWndCaption = %name_no_ext%%NameExt% - Microsoft Word Viewer
|
||||
WinWaitActive, %szWndCaption%,,2
|
||||
if ErrorLevel
|
||||
TestsFailed("Window '" szWndCaption "' failed to appear.")
|
||||
else
|
||||
{
|
||||
szExpected = Hello from Word document.
|
||||
clipboard = ; clean
|
||||
SendInput, ^a ; Ctrl+A aka select all
|
||||
SendInput, ^c ; Ctrl+C aka copy
|
||||
ClipWait, 2
|
||||
if ErrorLevel
|
||||
TestsFailed("Sent Ctrl+A and Ctrl+C to '" szWndCaption "' window, but copied nothing.")
|
||||
else
|
||||
{
|
||||
IfNotInString, szExpected, %clipboard%
|
||||
TestsFailed("Sent Ctrl+A and Ctrl+C to '" szWndCaption "' window, but got unexpected results. Is '" clipboard "', should be '" szExpected "'.")
|
||||
else
|
||||
TestsOK("Sent Ctrl+A and Ctrl+C to '" szWndCaption "' window and succeeded copying text to the clipboard.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
; Test if can close application successfully
|
||||
TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
WinClose, %szWndCaption%
|
||||
WinWaitClose, %szWndCaption%,,3
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to close '" szWndCaption "' window.")
|
||||
else
|
||||
{
|
||||
Process, WaitClose, %ProcessExe%, 4
|
||||
if ErrorLevel
|
||||
TestsFailed("'" ProcessExe "' process failed to close despite '" szWndCaption "' window closed.")
|
||||
else
|
||||
TestsOK("Closed '" szWndCaption "' window and '" ProcessExe "' process went away.")
|
||||
}
|
||||
}
|
123
Microsoft Office/Word Viewer 2003/prepare.ahk
Normal file
123
Microsoft Office/Word Viewer 2003/prepare.ahk
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Designed for Word Viewer 2003
|
||||
* Copyright (C) 2013 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
|
||||
*/
|
||||
|
||||
TestName = prepare
|
||||
ModuleExe = %A_ProgramFiles%\Microsoft Office\OFFICE11\WORDVIEW.exe ; registry contains empty string anyway
|
||||
bContinue := true
|
||||
|
||||
|
||||
; Terminate application
|
||||
if bContinue
|
||||
{
|
||||
SplitPath, ModuleExe, ProcessExe
|
||||
bTerminateProcess(ProcessExe)
|
||||
}
|
||||
|
||||
|
||||
; Delete settings separately from RunApplication() in case we want to write our own settings
|
||||
TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
RegDelete, HKEY_CURRENT_USER, Software\Microsoft\Office
|
||||
IfExist, %A_AppData%\Microsoft\Office
|
||||
{
|
||||
FileRemoveDir, %A_AppData%\Microsoft\Office, 1
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to delete '" A_AppData "\Microsoft\Office'.")
|
||||
else
|
||||
TestsOK("")
|
||||
}
|
||||
else
|
||||
TestsOK("")
|
||||
}
|
||||
|
||||
|
||||
; Test if can start application
|
||||
RunApplication(PathToFile)
|
||||
{
|
||||
global ModuleExe
|
||||
global TestName
|
||||
global TestsTotal
|
||||
global bContinue
|
||||
global ProcessExe
|
||||
|
||||
TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
IfNotExist, %ModuleExe%
|
||||
TestsFailed("RunApplication(): Can NOT find '" ModuleExe "'.")
|
||||
else
|
||||
{
|
||||
if PathToFile =
|
||||
{
|
||||
Run, %ModuleExe%,, Max ; Start maximized
|
||||
WinWait, Microsoft Word Viewer,,3
|
||||
if ErrorLevel
|
||||
TestsFailed("'Microsoft Word Viewer' window does NOT exist.")
|
||||
else
|
||||
{
|
||||
WinWaitActive, Open,,3
|
||||
if ErrorLevel
|
||||
{
|
||||
Process, Exist, %ProcessExe%
|
||||
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
|
||||
if NewPID = 0
|
||||
TestsFailed("RunApplication(): Window 'Open' failed to appear. No '" ProcessExe "' process detected.")
|
||||
else
|
||||
TestsFailed("RunApplication(): Window 'Open' failed to appear. '" ProcessExe "' process detected.")
|
||||
}
|
||||
else
|
||||
TestsOK("There is 'Microsoft Word Viewer' window in a background and 'Open' is active one.")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IfNotExist, %PathToFile%
|
||||
TestsFailed("RunApplication(): Can NOT find '" PathToFile "'.")
|
||||
else
|
||||
{
|
||||
Run, %ModuleExe% "%PathToFile%",, Max
|
||||
RegRead, bHideExt, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, HideFileExt
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to read 'HideFileExt' in 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'.")
|
||||
else
|
||||
{
|
||||
if bHideExt
|
||||
SplitPath, PathToFile,,,, name_no_ext
|
||||
else
|
||||
SplitPath, PathToFile, NameExt
|
||||
szWndCaption = %name_no_ext%%NameExt% - Microsoft Word Viewer
|
||||
WinWaitActive, %szWndCaption%,,3
|
||||
if ErrorLevel
|
||||
{
|
||||
Process, Exist, %ProcessExe%
|
||||
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
|
||||
if NewPID = 0
|
||||
TestsFailed("RunApplication(): Window '" szWndCaption "' failed to appear. No '" ProcessExe "' process detected.")
|
||||
else
|
||||
TestsFailed("RunApplication(): Window '" szWndCaption "' failed to appear. '" ProcessExe "' process detected.")
|
||||
}
|
||||
else
|
||||
TestsOK("Seems like succeeded opening '" PathToFile "', because active window caption is '" szWndCaption "'.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ params =
|
||||
(
|
||||
|
||||
1.install
|
||||
2.copy_text
|
||||
|
||||
)
|
||||
|
||||
@ -34,6 +35,18 @@ if CheckParam()
|
||||
{
|
||||
#include install_test.ahk
|
||||
}
|
||||
else
|
||||
{
|
||||
if 1 != --list
|
||||
{
|
||||
#include prepare.ahk
|
||||
|
||||
if 1 = 2.copy_text
|
||||
{
|
||||
#include copy_text.ahk
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShowTestResults()
|
||||
|
Loading…
x
Reference in New Issue
Block a user