mirror of
https://github.com/reactos/ahk_tests.git
synced 2024-11-26 21:10:40 +00:00
[AHK_Diablo_II_1.4]
Add prepare.ahk and player_walk.ahk; 2.player_walk: make player to explore the map. Test succeeds in WinXP SP3 (not without a lot of 'FIXMEs'). svn path=/trunk/ahk_tests/; revision=2020
This commit is contained in:
parent
014b248946
commit
ae142ad026
45
Diablo II/1.4/player_walk.ahk
Normal file
45
Diablo II/1.4/player_walk.ahk
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Designed for Diablo II 1.4
|
||||
* 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.player_walk
|
||||
|
||||
; Test if can load game and walk player on the map
|
||||
TestsTotal++
|
||||
RunApplication()
|
||||
if bContinue
|
||||
{
|
||||
IfWinNotActive, Diablo II
|
||||
TestsFailed("'Diablo II' is NOT active window.")
|
||||
else
|
||||
{
|
||||
; FIXME
|
||||
Click, 50, 50 ; Walk
|
||||
Sleep, 1500
|
||||
SendInput, {ESC} ; Bring up the menu
|
||||
Sleep, 500
|
||||
SendInput, {UP}{ENTER} ; Select 'Save and exit game'
|
||||
Sleep, 500
|
||||
SendInput, {ESC} ; Close game completely
|
||||
Process, WaitClose, %ProcessExe%, 4
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to exit the game, because '" ProcessExe "' process still exists.")
|
||||
else
|
||||
TestsOK("Made player to walk and closed game using its menu.")
|
||||
}
|
||||
}
|
160
Diablo II/1.4/prepare.ahk
Normal file
160
Diablo II/1.4/prepare.ahk
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Designed for Diablo II 1.4
|
||||
* 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
|
||||
|
||||
; Test if the app is installed
|
||||
TestsTotal++
|
||||
RegRead, InstalledDir, HKEY_LOCAL_MACHINE, SOFTWARE\Blizzard Entertainment\Diablo II Shareware, InstallPath
|
||||
if ErrorLevel
|
||||
TestsFailed("Either registry key does not exist or we failed to read it.")
|
||||
else
|
||||
{
|
||||
if (InstalledDir = "")
|
||||
TestsFailed("Either registry contains empty string or we failed to read it.")
|
||||
else
|
||||
{
|
||||
ModuleExe = %InstalledDir%\Diablo II.exe
|
||||
TestsOK("")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
; 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
|
||||
{
|
||||
IfExist, %InstalledDir%\Save
|
||||
{
|
||||
FileRemoveDir, %InstalledDir%\Save, 1
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to delete '" InstalledDir "\Save'.")
|
||||
else
|
||||
TestsOK("")
|
||||
}
|
||||
else
|
||||
TestsOK("")
|
||||
}
|
||||
|
||||
|
||||
; Test if can start application
|
||||
RunApplication()
|
||||
{
|
||||
global ModuleExe
|
||||
global TestName
|
||||
global TestsTotal
|
||||
global bContinue
|
||||
global ProcessExe
|
||||
|
||||
TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
IfNotExist, %ModuleExe%
|
||||
TestsFailed("RunApplication(): Can NOT find '" ModuleExe "'.")
|
||||
else
|
||||
{
|
||||
Run, %ModuleExe%
|
||||
WinWaitActive, Diablo II,, 3
|
||||
if ErrorLevel
|
||||
{
|
||||
Process, Exist, %ProcessExe%
|
||||
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
|
||||
if NewPID = 0
|
||||
TestsFailed("RunApplication(): Window 'Diablo II' failed to appear. No '" ProcessExe "' process detected.")
|
||||
else
|
||||
TestsFailed("RunApplication(): Window 'Diablo II' failed to appear. '" ProcessExe "' process detected.")
|
||||
}
|
||||
else
|
||||
{
|
||||
WinGetPos, X, Y, Width, Height, Diablo II
|
||||
iTimeOut := 60
|
||||
while (iTimeOut > 0)
|
||||
{
|
||||
WinGetPos, X, Y, Width, Height, Diablo II
|
||||
if (Width != A_ScreenWidth) OR (Height != A_ScreenHeight)
|
||||
{
|
||||
Sleep, 100
|
||||
iTimeOut--
|
||||
}
|
||||
else
|
||||
break
|
||||
}
|
||||
|
||||
if (Width != A_ScreenWidth) OR (Height != A_ScreenHeight)
|
||||
TestsFailed("RunApplication(): Window size is not equal to screen size. Is '" Width "x" Height "', should be '" A_ScreenWidth "x" A_ScreenHeight "'. iTimeOut=" iTimeOut ".")
|
||||
else
|
||||
{
|
||||
; FIME
|
||||
Sleep, 1500
|
||||
Click, 395, 205 ; Close splash
|
||||
Sleep, 1500
|
||||
Click, 395, 205 ; Close splash
|
||||
Sleep, 1500
|
||||
Click, 395, 205 ; Single player
|
||||
Sleep, 1500
|
||||
Click, 395, 205 ; Select player
|
||||
Sleep, 1500
|
||||
PlayerName = DiabloPlayer
|
||||
SendInput, %PlayerName% ; Fill 'Character Name' field
|
||||
clipboard = ; Clean the clipboard
|
||||
SendInput, ^a ; Ctrl+A aka Select All. Select all text from 'Character Name' field
|
||||
SendInput, ^c ; Ctrl+C aka Copy
|
||||
ClipWait, 2
|
||||
if ErrorLevel
|
||||
TestsFailed("RunApplication(): The attempt to copy text onto the clipboard failed.")
|
||||
else
|
||||
{
|
||||
IfNotInString, PlayerName, %clipboard%
|
||||
TestsFailed("Unexpected clipboard content. Is '" clipboard "', should be '" PlayerName "'.")
|
||||
else
|
||||
{
|
||||
TestsInfo("RunApplication(): Entered player name successfully. Sending ENTER to start the actuall game.")
|
||||
SendInput, {ENTER}
|
||||
iTimeOut := 15
|
||||
while (iTimeOut > 0)
|
||||
{
|
||||
WinGetPos, X, Y, Width, Height, Diablo II
|
||||
if ((Width = 640) AND (Height = 480))
|
||||
break
|
||||
else
|
||||
{
|
||||
Sleep, 1000
|
||||
iTimeOut--
|
||||
}
|
||||
}
|
||||
|
||||
if not ((Width = 640) AND (Height = 480))
|
||||
TestsFailed("RunApplication(): unexpected 'Diablo II' window size. Is '" Width "x" Height "', should be '640x480' (iTimeOut=" iTimeOut ").")
|
||||
else
|
||||
TestsOK("RunApplication(): Game is up and running (iTimeOut=" iTimeOut ").")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ params =
|
||||
(
|
||||
|
||||
1.install
|
||||
2.player_walk
|
||||
|
||||
)
|
||||
|
||||
@ -34,6 +35,18 @@ if CheckParam()
|
||||
{
|
||||
#include install_test.ahk
|
||||
}
|
||||
else
|
||||
{
|
||||
if 1 != --list
|
||||
{
|
||||
#include prepare.ahk
|
||||
|
||||
if 1 = 2.player_walk
|
||||
{
|
||||
#include player_walk.ahk
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShowTestResults()
|
||||
|
Loading…
Reference in New Issue
Block a user