home *** CD-ROM | disk | FTP | other *** search
- '******************************** TSTSUITE.FTI ********************************
- 'Demonstrates: A sample Include file for multiple FASTTEST test scripts in a
- ' suite
- '
- 'Required Files: FASTTEST.INC
- '
- 'Uses: FASTTEST.INC
- '
- 'Complexity Level: INTERMEDIATE
- '
- 'Notes: Assumes target application (NOTEPAD.EXE) is in the PATH and
- ' LOG_FILE is in parent directory.
- '
- '******************************************************************************
-
- Declare Sub Initialize ()
- Declare Sub Cleanup ()
- Declare Sub StartLog (testName$)
- Declare Sub EndLog (logFile$, resultFile$)
- Declare Sub EditCut ()
- Declare Sub EditPaste ()
- Declare Sub FileNewClear ()
- Declare Sub FileOpen (fileName$)
- Declare Function FileExit (YesNoCancel$, fileName$, replace%) As Integer
- Declare Function SaveFile (YesNoCancel$, fileName$, replace%) As Integer
- Declare Function SrchFind (Target$) As Integer
- Declare Function VerifyEditAndClipBoard (editStr$, clipStr$) As Integer
-
- '$Include 'FASTTEST.INC'
-
-
- '******************************************************************************
- ' CONSTs
- '******************************************************************************
-
- ' File names and numbers
- Const PROGRAM_NAME = "NOTEPAD.EXE" ' Target application
- Const LOG_FILE = "..\FTSUITE.LOG" ' Main log file
- Const RESULT_FILE = "FTRESULT.TXT" ' Results file
- Const TEMP_FILE = "FILEMENU.TMP"
-
- ' Log and result file strings
- Const PASS = " passed "
- Const FAIL = " FAILED "
- Const ERRSTR = " *** ERROR - "
-
- ' Function return codes
- Const SUCCESS = TRUE
- Const R_FILECREATED = 1
- Const R_CREATEABORTED = 2
- Const R_REPLACE = 3
- Const R_REPLACEABORTED = 4
- Const R_ERRORNODIALOG = 5
- Const R_NODIALOG = 6
- Const R_NOTFOUND = 7
- Const R_CLIPNOMATCH = 8
- Const R_EDITNOMATCH = 16
-
- ' Static / Dialog title strings
- Const PROGRAM_TITLE = "NotePad"
- Const SAVE_AS_DIALOG_TITLE = "Save As"
- Const FIND_DIALOG_TITLE = "Find"
-
- ' Application specific keys
- CONST K_YES = "Y"
- CONST K_NO = "N"
- CONST K_CANCEL = "ESC"
- Const K_BOF = "HOME"
- Const K_SELALL = "END"
-
- ' Menu definitions
- Const FILE_MENU = "&File"
- Const FILE_NEW = "&New"
- Const FILE_OPEN = "&Open..."
- Const FILE_EXIT = "E&xit"
-
- Const EDIT_MENU = "&Edit"
- Const EDIT_CUT = "Cu&t"
- Const EDIT_PASTE = "&Paste"
-
- Const SEARCH_MENU = "&Search"
- Const SEARCH_FIND = "&Find..."
-
- Const SYSMENU_CLOSE = "&Close"
-
-
- '******************************************************************************
- ' SUBs and FUNCTIONs
- '******************************************************************************
-
-
- '******************************************************************************
- 'SUB Initialize opens the log and result files and starts the target application
- '******************************************************************************
- Sub Initialize () Static
- xDeleteFileIfExists RESULT_FILE
- xSetLogOptions LOG_DISK
- xSetLogFileName RESULT_FILE
- xStartApp PROGRAM_NAME, ""
- End Sub
-
-
- '******************************************************************************
- 'SUB StartLog writes the current test name to the log and result files
- '******************************************************************************
- Sub StartLog (testName$) Static
- xAppendFile LOG_FILE, testName$
- xLog testName$
- End Sub
-
-
- '******************************************************************************
- 'SUB EndLog writes pass/fail information to the log file and specific results
- 'to the result file (if any).
- '******************************************************************************
- Sub EndLog (logFile$, resultFile$) Static
- XAppendFile LOG_FILE, logFile$
- If resultFile$ <> "" Then
- xLogFailure resultFile$
- Else
- xLog logFile$
- End If
- End Sub
-
-
- '******************************************************************************
- 'SUB Cleanup closes the target application and log and result files
- '******************************************************************************
- Sub CleanUp () Static
- hWnd% = WFndWnd(PROGRAM_TITLE, FW_PART Or FW_NOFOCUS Or FW_NOCASE)
- If hWnd% <> 0 and WSysMenuExists(hWnd%) Then
- wSysMenu(hWnd%)
- WMenu SYSMENU_CLOSE
- End If
- Close
- End Sub
-
-
-
- '******************************************************************************
- 'SUB FileNewClear calls SUB DoCommand to choose the "New" option from the
- '"File" menu without saving any changes.
- '******************************************************************************
- Sub FileNewClear () Static
- xSelectMenuItem FILE_MENU, FILE_NEW, ""
- If BDialogBoxExists(PROGRAM_TITLE) Then
- xAlt K_NO
- End If
- End Sub
-
-
- '******************************************************************************
- 'FUNCTION FileOpen chooses the "Open" option from the "File" menu to open an
- 'existing file.
- '******************************************************************************
- Sub FileOpen (fileName$) Static
- xSelectMenuItem FILE_MENU, FILE_OPEN, ""
- xEnter fileName$
- End Sub
-
-
- '******************************************************************************
- 'FUNCTION FileExit chooses the "Exit" option from the "File" menu to exit the
- 'target application, answering the save file dialog(s) if necessary.
- '******************************************************************************
- Function FileExit (YesNoCancel$, fileName$, replace%) Static As Integer
- xSelectMenuItem FILE_MENU, FILE_EXIT, ""
- result% = SaveFile (YesNoCancel$, fileName$, replace%)
- FileExit = result%
- End Function
-
-
- '******************************************************************************
- 'FUNCTION SaveFile answers the appropriate file save dialog(s) if they exist
- '(determined by using the TESTCTRL routines WFndWnd and WFndWndC).
- '******************************************************************************
- Function SaveFile (YesNoCancel$, fileName$, replace%) Static As Integer
-
- SaveFile = SUCCESS
-
- 'Check to see if Notepad is prompting to save the current file
- If BDialogBoxExists(PROGRAM_TITLE) Then
- If YesNoCancel$ <> K_CANCEL Then
- xAlt YesNoCancel$
- Else
- xKey YesNoCancel$
- End if
-
- 'K_YES indicates we want to save current file - respond to Save dialog
- If YesNoCancel$ = K_YES Then
- If WFndWnd(SAVE_AS_DIALOG_TITLE, FW_PART Or FW_NOFOCUS Or FW_NOCASE) Then
- xEnter fileName$
-
- 'Check to see if we are saving over an existing file
- If BDialogBoxExists(PROGRAM_TITLE) Then
- If replace% Then
- xAlt K_YES
- SaveFile = R_REPLACED
- Else
- xAlt K_NO
- SaveFile = R_REPLACEABORT
- End If
- End If
- Else
- SaveFile = R_ERRORNODIALOG
- End If
- End If
- Else
- SaveFile = R_NODIALOG
- End If
- End Function
-
-
- '******************************************************************************
- 'SUB EditCut Chooses the "Cut" option from the "Edit" menu to copy the currently
- 'selected text from the application's edit field to the cipboard.
- '******************************************************************************
- Sub EditCut () Static
- xSelectMenuItem EDIT_MENU, EDIT_CUT, ""
- End Sub
-
-
- '******************************************************************************
- 'SUB EditPaste Chooses the "Paste" option from the "Edit" menu to copy the
- 'currently clipboard contents to the application's edit field.
- '******************************************************************************
- Sub EditPaste () Static
- xSelectMenuItem EDIT_MENU, EDIT_PASTE, ""
- End Sub
-
-
- '******************************************************************************
- 'FUNCTION SrchFind Chooses the "Find" option from the "Search" menu to attempt
- 'to locate the specified text in the target applications edit field. If the
- 'application dialog indicating Find failed does not exist, the text selected by
- 'Find is Cut to the clipboard and compared with the target$.
- '******************************************************************************
- Function SrchFind (target$) Static As Integer
-
- xSelectMenuItem SEARCH_MENU, SEARCH_FIND, ""
- xEnter target$
-
- If BDialogBoxExists(PROGRAM_TITLE) Then
- SrchFind = R_NOTFOUND
- xEnter ""
- If BDialogBoxExists(FIND_DIALOG_TITLE) Then
- xKey K_CANCEL
- End If
- Else
- If BDialogBoxExists(FIND_DIALOG_TITLE) Then
- xKey K_CANCEL
- End If
- EditCut
- If BClipBoardCmp(target$) Then
- SrchFind = SUCCESS
- Else
- SrchFind = R_ERRORNODIALOG
- End If
- End If
-
- End Function
-
-
- '******************************************************************************
- 'FUNCTION VerifyEditAndClipBoard checks that the application edit field (current
- 'text is retrieved using TESTCTRLs EditText() function) and the clipboard both
- 'contain the specified text. Since the target application does not have a label
- 'control associated with its main edit field, an empty string is passed to
- 'EditText(); this will fail if the application edit control does not have the
- 'focus at the time VerifyEditAndClipboard is called.
- '******************************************************************************
- Function VerifyEditAndClipboard (editStr$, clipStr$) Static As Integer
-
- If BEditTextExists(editStr$) Then
- If BClipBoardCmp(clipStr$) Then
- VerifyEditAndClipboard = R_CLIPNOMATCH Or R_EDITNOMATCH
- Else
- VerifyEditAndClipboard = R_EDITNOMATCH
- End If
- Else
- If Not BClipBoardCmp(clipStr$) Then
- VerifyEditAndClipboard = R_CLIPNOMATCH
- Else
- VerifyEditAndClipboard = SUCCESS
- End If
- End If
-
- End Function
-
-