Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
12 KiB

  1. 'FastTest.inc - definitions/declarations for Fast Test routines
  2. '
  3. ' Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
  4. '
  5. 'Purpose:
  6. ' This file declares the functions, constants and variables
  7. ' used by the Fast Test routines.
  8. '
  9. 'NOTES:
  10. ' A common code sequence is used throughout to catch unexpected errors
  11. ' using the ON ERROR command. The sequence is explained in this note
  12. ' but not each time that it is used.
  13. '
  14. ' gErrorType = ET_NEXT ' Global variable to indicate how to handle
  15. ' ' an unexpected error:
  16. ' ' ET_NEXT : save that error happened
  17. ' ' and continue on next statement
  18. ' ' ET_NOTHING : let driver catch unexpected
  19. ' ' errors with message
  20. ' ' ET_LOG : error happened in log routine
  21. '
  22. ' ' some code that could cause runtime errors
  23. ' fh1% = FREEFILE ' out of handles?
  24. ' OPEN stFileSpec1$ FOR INPUT AS #fh1% ' file doesn't exist?
  25. ' fh2% = FREEFILE ' out of handles?
  26. ' OPEN stFileSpec2$ FOR INPUT AS #fh2% ' file doesn't exist?
  27. '
  28. ' IF gfError THEN ' since ET_NEXT was used above, we would
  29. ' ' execute this block if an error had
  30. ' ' occurred.
  31. ' XLogFailure "Could not open files for XFileCmp" ' log a failure
  32. ' ' specific to this section of code
  33. ' ' if XSetTerminate is called to have scripts continue in event
  34. ' ' of errors, then the script will continue executing here
  35. ' gErrorType = ET_NOTHING ' reset so other unexpected errors are
  36. ' ' caught
  37. ' gfError = FALSE ' reset because we logged this already
  38. ' EXIT SUB ' can't continue with this function,
  39. ' ' something went wrong
  40. ' END IF
  41. '$DEFINE TESTCTRL
  42. '$DEFINE TESTEVNT
  43. '$INCLUDE 'MSTEST.inc'
  44. '$INCLUDE 'WNAPIDEC.INC'
  45. ' XLog constants to determine where to log information to
  46. CONST LOG_DISK = 2 'log to disk
  47. CONST LOG_SCREEN = 4 'log to screen (viewport in testdrvr)
  48. CONST LOG_COM1 = 8 'log to COM1 port
  49. CONST LOG_COM2 = 16 'log to COM2 port
  50. CONST LOG_MSGBOX = 32 'log the string in a msgbox (Pause in testdrvr)
  51. ' Mouse button constants that map to QueMouse function names, X functions
  52. ' can use either ones
  53. CONST LBUTTON% = VK_LBUTTON
  54. CONST MBUTTON% = VK_MBUTTON
  55. CONST RBUTTON% = VK_RBUTTON
  56. 'Global to be used to describe Log Options by ORing above Const's
  57. GLOBAL gfLogOptions%
  58. 'Global to be used to save above flag when logging is temporarily turned off.
  59. GLOBAL gfTmpLogOptions%
  60. gfLogOptions = LOG_SCREEN 'default to showing in viewport
  61. gfTmpLogOptions = LOG_SCREEN 'default to showing in viewport
  62. GLOBAL gsCurrentDir$
  63. gsCurrentDir$ = curdir$ ' get current directory that started execution
  64. ' Global variable to hold log file name
  65. GLOBAL gsLogFileName$
  66. gsLogFileName$ = gsCurrentDir$ + "\FASTTEST.LOG"
  67. ' Global variable to hold string to use as the keystrokes necessary
  68. ' to close the app in the case of errors
  69. GLOBAL gsCleanup$
  70. gsCleanup$ = "{esc 5}%( )c" ' five escapes, alt-space C (for close)
  71. ' Global variable to hold class name of app
  72. GLOBAL gsAppClassname$
  73. gsAppClassname$ = ""
  74. ' Global variable to hold state of whether to terminate on XLogFailure
  75. GLOBAL gfTerminate%
  76. gfTerminate% = TRUE ' default to terminate at first failure
  77. ' Global variable that indicates if failure occured
  78. GLOBAL gfFailure%
  79. gfFailure% = FALSE
  80. 'Global variable that indicates an ON ERROR occurred
  81. GLOBAL gfError%
  82. gfError% = FALSE
  83. 'Global variable that is the string value for the dialog window class
  84. GLOBAL gsDialogClass$
  85. gsDialogClass$ = "#32770"
  86. ' Error Type constants (don't use 0)
  87. CONST ET_NOTHING = 1 ' no handling, log unexpected runtime error
  88. CONST ET_NEXT = 2 ' flag error, continue next statement
  89. CONST ET_LOG = 3 ' error happened in log routines, inform user elsewise
  90. 'Global variable that shows what type of error to handle
  91. GLOBAL gErrorType%
  92. gErrorType% = ET_NOTHING
  93. 'Prototypes from FTestLog.mst
  94. DECLARE SUB XSetLogFilename(sFilename$)
  95. DECLARE SUB XSetTerminate(fTerminate%)
  96. DECLARE SUB XLog (stLog$)
  97. DECLARE SUB XLogBanner(lpszInput$)
  98. DECLARE SUB XLogWarning(lpszInput$)
  99. DECLARE SUB XLogFailure(stFailure$)
  100. DECLARE SUB XFailureCheck
  101. DECLARE SUB XSetLogOptions (wLogOptions%)
  102. DECLARE SUB XLogOff ()
  103. DECLARE SUB XLogOn ()
  104. DECLARE SUB XDialogBoxExists(s$)
  105. DECLARE SUB XDialogBoxNotExists(s$)
  106. DECLARE SUB XWaitDialogBox(s$, WaitTime%)
  107. DECLARE SUB XButtonExists(stButton$)
  108. DECLARE SUB XButtonNotExists(stButton$)
  109. DECLARE SUB XButtonEnabled(stButton$)
  110. DECLARE SUB XButtonNotEnabled(stButton$)
  111. DECLARE SUB XClickButton(stButtonName$)
  112. DECLARE SUB XListBoxExists(stListBox$)
  113. DECLARE SUB XListBoxNotExists(stListBox$)
  114. DECLARE SUB XFocusListBox(stListBox$)
  115. DECLARE SUB XListBoxItemExists (stListBox$, stListBoxItem$)
  116. DECLARE SUB XListBoxItemNotExists (stListBox$, stListBoxItem$)
  117. DECLARE SUB XClickListBoxItem (stListBox$, stListBoxItem$)
  118. DECLARE SUB XDblClickListBoxItem (stListBox$, stListBoxItem$)
  119. DECLARE SUB XComboBoxExists(stComboBox$)
  120. DECLARE SUB XComboBoxNotExists(stComboBox$)
  121. DECLARE SUB XFocusComboBox(stComboBox$)
  122. DECLARE SUB XComboBoxItemExists (stComboBox$, stComboBoxItem$)
  123. DECLARE SUB XComboBoxItemNotExists (stComboBox$, stComboBoxItem$)
  124. DECLARE SUB XClickComboBoxItem (stComboBox$, stComboBoxItem$)
  125. DECLARE SUB XDblClickComboBoxItem (stComboBox$, stComboBoxItem$)
  126. DECLARE SUB XCheckBoxExists(stCheckBox$)
  127. DECLARE SUB XCheckBoxNotExists(stCheckBox$)
  128. DECLARE SUB XCheckBoxChecked(stCheckBox$)
  129. DECLARE SUB XCheckBoxNotChecked(stCheckBox$)
  130. DECLARE SUB XCheckBoxEnabled(stCheckBox$)
  131. DECLARE SUB XCheckBoxNotEnabled(stCheckBox$)
  132. DECLARE SUB XClickCheckBox(stCheckBox$)
  133. DECLARE SUB XEditTextExists(stEditText$)
  134. DECLARE SUB XEditTextNotExists(stEditTextNot$)
  135. DECLARE SUB XSetEditText (stEditCaption$, stEditText$)
  136. DECLARE SUB XOptionButtonExists(stOptionButton$)
  137. DECLARE SUB XOptionButtonNotExists(stOptionButton$)
  138. DECLARE SUB XOptionButtonEnabled(stOptionButton$)
  139. DECLARE SUB XOptionButtonNotEnabled(stOptionButton$)
  140. DECLARE SUB XOptionButtonChecked(stOptionButton$)
  141. DECLARE SUB XOptionButtonNotChecked(stOptionButton$)
  142. DECLARE SUB XClickOptionButton(stOptionButton$)
  143. DECLARE FUNCTION BDialogBoxExists%(s$)
  144. DECLARE FUNCTION BButtonExists%(stButtonName$)
  145. DECLARE FUNCTION BButtonEnabled%(stButtonName$)
  146. DECLARE FUNCTION BListBoxExists%(stListBox$)
  147. DECLARE FUNCTION IGetListBoxItemCount%(stListBox$)
  148. DECLARE FUNCTION BListBoxItemExists%(stListBox$, stListBoxItem$)
  149. DECLARE FUNCTION SGetListBoxItemText$(stListBox$)
  150. DECLARE FUNCTION BComboBoxExists%(stComboBox$)
  151. DECLARE FUNCTION IGetComboBoxItemCount%(stComboBox$)
  152. DECLARE FUNCTION BComboBoxItemExists%(stComboBox$, stComboBoxItem$)
  153. DECLARE FUNCTION SGetComboBoxItemText$(stComboBox$)
  154. DECLARE FUNCTION BCheckBoxExists%(stCheckBox$)
  155. DECLARE FUNCTION BCheckBoxChecked%(stCheckBox$)
  156. DECLARE FUNCTION BCheckBoxEnabled%(stCheckBox$)
  157. DECLARE FUNCTION BEditTextExists%(stEditText$)
  158. DECLARE FUNCTION SGetEditText$(stEditCaption$)
  159. DECLARE FUNCTION BOptionButtonExists%(stOptionButton$)
  160. DECLARE FUNCTION BOptionButtonEnabled%(stOptionButton$)
  161. DECLARE FUNCTION BOptionButtonChecked%(stOptionButton$)
  162. 'Prototypes from FTestKey.mst
  163. DECLARE SUB XKey (s$)
  164. DECLARE SUB XAlt (s$)
  165. DECLARE SUB XCtrl (s$)
  166. DECLARE SUB XShift (s$)
  167. DECLARE SUB XCtrlAlt (s$)
  168. DECLARE SUB XAltShift (s$)
  169. DECLARE SUB XCtrlShift (s$)
  170. DECLARE SUB XCtrlAltShift (s$)
  171. DECLARE SUB XText(s$)
  172. DECLARE SUB XEnter(s$)
  173. DECLARE SUB XSelectMenuItem(stMenu$,stMenuItem$,stHMenuItem$)
  174. DECLARE SUB XMenuItemExists(stMenu$,stMenuItem$, stHMenuItem$)
  175. DECLARE SUB XMenuItemNotExists(stMenu$,stMenuItem$, stHMenuItem$)
  176. DECLARE SUB XMenuItemGrayed(stMenu$,stMenuItem$, stHMenuItem$)
  177. DECLARE SUB XMenuItemNotGrayed(stMenu$,stMenuItem$, stHMenuItem$)
  178. DECLARE SUB XMenuItemChecked(stMenu$,stMenuItem$, stHMenuItem$)
  179. DECLARE SUB XMenuItemNotChecked(stMenu$,stMenuItem$, stHMenuItem$)
  180. DECLARE SUB XMenuItemEnabled(stMenu$,stMenuItem$, stHMenuItem$)
  181. DECLARE SUB XMenuItemNotEnabled(stMenu$,stMenuItem$, stHMenuItem$)
  182. DECLARE SUB XCaptionExists(stCaption$)
  183. DECLARE SUB XCaptionNotExists(stCaption$)
  184. DECLARE SUB XZoomWindow
  185. DECLARE SUB XMaxWindow
  186. DECLARE SUB XWindowMaximized
  187. DECLARE SUB XWindowNotMaximized
  188. DECLARE SUB XMinWindow
  189. DECLARE SUB XWindowMinimized
  190. DECLARE SUB XWindowNotMinimized
  191. DECLARE SUB XRestoreWindow
  192. DECLARE SUB XSizeActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%)
  193. DECLARE SUB XMoveActiveWindow (iXPixels%, iYPixels%, fAbsOrRel%)
  194. DECLARE FUNCTION SKeyString$(s$)
  195. DECLARE FUNCTION SHideKeys$(s$)
  196. DECLARE FUNCTION BMenuItemExists%(stMenu$,stMenuItem$,stHMenuItem$)
  197. DECLARE FUNCTION IGetMenuCount%(stMenu$, stMenuItem$)
  198. DECLARE FUNCTION SGetMenuItemText$(stMenu$,stMenuItem$, iIndex%)
  199. DECLARE FUNCTION BMenuItemGrayed%(stMenu$, stMenuItem$, stHMenuItem$)
  200. DECLARE FUNCTION BMenuItemChecked%(stMenu$, stMenuItem$, stHMenuItem$)
  201. DECLARE FUNCTION BMenuItemEnabled%(stMenu$,stMenuItem$, stHMenuItem$)
  202. DECLARE FUNCTION SGetCaption$()
  203. DECLARE FUNCTION BWindowMaximized%
  204. DECLARE FUNCTION BWindowMinimized%
  205. 'Prototypes from FTestUtl.mst
  206. DECLARE SUB XFileExists(stFileSpec$)
  207. DECLARE SUB XFileNotExists(stFileSpec$)
  208. DECLARE SUB XFileCmp(stFileSpec1$,stFileSpec2$)
  209. DECLARE SUB XFileNotCmp(stFileSpec1$,stFileSpec2$)
  210. DECLARE SUB XDeleteFile(stFileSpec$)
  211. DECLARE SUB XDeleteFileIfExists(stFileSpec$)
  212. DECLARE SUB XCreateFile(stFileSpec$,s$)
  213. DECLARE SUB XAppendFile(stFileSpec$,s$)
  214. DECLARE SUB XWaitMessageFile(s$,Message$, WaitTime%)
  215. DECLARE SUB XCWDCmp(s$)
  216. DECLARE SUB XCWDNotCmp(s$)
  217. DECLARE SUB XDriveCmp(s$)
  218. DECLARE SUB XDriveNotCmp(s$)
  219. DECLARE SUB XChangeCWD(s$)
  220. DECLARE SUB XCreateDir(s$)
  221. DECLARE SUB XChangeDrive(s$)
  222. DECLARE SUB XStartApp(stAppName$, stClassname$)
  223. DECLARE SUB XSetCleanup (sCleanup$)
  224. DECLARE SUB XDoCleanup
  225. DECLARE SUB XMoveMouse (x%, y%)
  226. DECLARE SUB XClickMouse(button%, x%, y%)
  227. DECLARE SUB XDblClickMouse(button%, x%, y%)
  228. DECLARE SUB XDragMouse (button%, Begx%, Begy%, Endx%, Endy%)
  229. DECLARE SUB XClipBoardCmp (s$)
  230. DECLARE SUB XClipBoardNotCmp (s$)
  231. DECLARE FUNCTION BFileExists%(stFileSpec$)
  232. DECLARE FUNCTION BFileCmp%(stFileSpec1$,stFileSpec2$)
  233. DECLARE FUNCTION BCWDCmp%(s$)
  234. DECLARE FUNCTION BDriveCmp%(s$)
  235. DECLARE FUNCTION HStartApp%(stAppName$)
  236. DECLARE FUNCTION BClipBoardCmp (s$)
  237. '$INCLUDE 'FTestLog.mst'
  238. '$INCLUDE 'FTestKey.mst'
  239. '$INCLUDE 'FTestUtl.mst'
  240. ' These routines have to be after the above includes so that
  241. ' the functions used are declared
  242. ON END XDoCleanup
  243. ' Set a UAE trap and log failure if one occurs
  244. TRAP UAETrap FROM "TESTDRVR.EXE"
  245. XSetTerminate TRUE
  246. XLogFailure "Application UAEed"
  247. END TRAP
  248. ' in the FastTest code, gErrorType will be set to one of the following
  249. ' CASE items to be handled and set back to ET_NOTHING when the particular
  250. ' place where an error could occur is past.
  251. ON ERROR GOTO XErrorHandler
  252. GOTO UsersCode ' branch around code used by On Error
  253. XErrorHandler: ' execute here on error conditions
  254. SELECT CASE gErrorType
  255. CASE 0
  256. XSetTerminate TRUE
  257. XLogFailure "Internal FastTest Error" ' catch undeclared ET vars
  258. CASE ET_NOTHING
  259. XSetTerminate TRUE
  260. XLogFailure "Unexpected RunTime error;" + ERF + ":" + STR$(ERR) + " " + ERROR$(ERR)
  261. CASE ET_NEXT
  262. ' Code that uses this will check the global error variable
  263. ' and log an appropriate error if one occurred
  264. gfError = TRUE
  265. RESUME NEXT
  266. CASE ET_LOG ' something happened during logging, let user know
  267. Print "****** A Log error occurred ******"
  268. Pause "****** A Log error occurred ******"
  269. END
  270. END SELECT
  271. XSetTerminate TRUE
  272. XLogFailure "Internal FastTest error"
  273. UsersCode: