home *** CD-ROM | disk | FTP | other *** search
- '******************************** TUTOR.MST **********************************
- 'Demonstrates: This will test several components of the Windows WRITE.EXE.
- '
- 'Required Files: MSTEST.INC, WRITE.EXE
- '
- 'Uses: TESTSCRN, TESTCTRL, TESTEVENT.
- '
- 'Complexity Level: INTRODUCTORY
- '
- 'Notes: Assumes WRITE.EXE is in the PATH. This example also creates a screen
- ' image file (TUTOR.WTS) to demonstrate TESTSCRN.
- '
- '******************************************************************************
-
- Declare Sub Init
- Declare Sub Windows
- Declare Sub Menus
- Declare Sub EnterData
- Declare Sub Dialogs
- Declare Sub TestBold
- Declare Sub EndTest
-
- '******************************************************************************
- ' CONST
- '******************************************************************************
-
- Const AppName$ = "Write"
-
- Global WinHandle%, logfile%, ErrCount, MenuName$(7)
-
- '******************************************************************************
- ' DEFINES
- '******************************************************************************
-
- '$DEFINE TESTSCRN
- '$DEFINE TESTCTRL
- '$DEFINE TESTEVNT
-
- '******************************************************************************
- ' INCLUDES
- '******************************************************************************
-
- '$INCLUDE 'mstest.inc'
-
- '******************************************************************************
- ' Main program code
- '******************************************************************************
-
- ON ERROR GOTO ErrorTrap
-
- Init '*** Initialize logging, global constants.
- Windows '*** Test various windowing features of app.
- Menus '*** Test various menus.
- EnterData '*** Show keystrokes.
- Dialogs '*** Test the save dialog.
- TestBold '*** Demonstrate saving screen image.
- EndTest '*** Shut down.
-
- END
-
- '******************************************************************************
- ' TRAPS
- '******************************************************************************
-
- ErrorTrap:
-
- SELECT CASE Err
- CASE ERR_INVALID_PATH
- PRINT "Path not found. Error number ", Err
- PRINT " on line ", ERL
- PRINT " in script ", ERF
- PRINT ERROR$ ' The error message.
- END
- CASE ERR_CANT_OPEN_FILE
- PRINT "Can't Open File. Error number ", Err
- PRINT " on line ", ERL
- PRINT " in script ", ERF
- PRINT ERROR$ ' The error message.
- END
- CASE ELSE
- PRINT "Unexpected error: Number ", Err
- PRINT " on line ", ERL
- PRINT " in script ", ERF
- PRINT ERROR$ ' The error message.
- END
- END SELECT
-
-
- '******************************************************************************
- ' SUBs and FUNCTIONs
- '******************************************************************************
-
-
-
- '******************************************************************************
- ' SUB Init sets up several variables that are used thoughout the test.
- '******************************************************************************
- SUB Init STATIC
-
- ErrCount = 0
- logfile = FREEFILE
- MenuName(0) = "&File"
- MenuName(1) = "&Edit"
- MenuName(2) = "&Search"
- MenuName(3) = "&Character"
- MenuName(4) = "&Paragraph"
- MenuName(5) = "&Document"
- MenuName(6) = "&Help"
-
- 'Set log file and write header to file.
-
- PRINT, "**********************************************"
- PRINT, "STARTING TEST OF WRITE.EXE APPLICATION"
- PRINT, " " + DATETIME$
- PRINT, "**********************************************"
-
- 'Run the Windows WRITE.EXE program and get its window handle.
-
- RUN AppName$, NOWAIT
- WinHandle = WGetActWnd(0)
-
- END SUB
-
- '******************************************************************************
- ' SUB Window will size WRITE and set it's position.
- '******************************************************************************
-
- SUB Windows STATIC
-
- DIM i%
-
- 'Position and size the form.
-
- WSetWndPos WinHandle, 50, 50
- WSetWndSiz WinHandle, 300, 200
-
- 'Adjust the window to several locations.
-
- For i = 1 to 10
- WAdjWndSiz WinHandle, 4*i, 4*i
- Next i
-
- 'Maximize the window.
-
- WMaxWnd WinHandle
- WMinWnd WinHandle
- WResWnd WinHandle
-
- END SUB
-
- '******************************************************************************
- ' SUB Menu will check to see if the correct amount of menus exist and check
- ' to see if they are Enabled correctly.
- '******************************************************************************
-
- SUB Menus STATIC
- DIM i%, ret%
-
- 'Determine if there are seven menus.
-
- IF WMenuCount() <> 7 THEN
- PRINT, "Wrong Number of menu items"
- ErrCount = ErrCount + 1
- ENDIF
-
- For i = 1 to 7
-
- 'Check to see if the names are correct. This example will fail
- 'for Windows 3.1 WRITE.EXE, since the "&Search" menu was changed
- 'to the "Fi&nd" menu.
- IF WMenuExists(MenuName(i-1)) = FALSE THEN
- PRINT, "Menu item does not exist..."
- ErrCount = ErrCount + 1
- ENDIF
-
- 'Make sure they are all Enabled.
- IF WMenuEnabled(MenuName(i-1)) = FALSE THEN
- PRINT, "Menu item not enabled..." + MenuName(i-1)
- ErrCount = ErrCount + 1
- ENDIF
-
- Next i
-
- END SUB
-
- '******************************************************************************
- ' SUB EnterData will enter text into the WRITE document.
- '******************************************************************************
-
- SUB EnterData STATIC
-
- DoKeys "Uppercase letters from A to Z: ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- DoKeys "{ENTER}"
- DoKeys "Lowercase letters from a to z: abcdefghijklmnopqrstuvwxyz"
- DoKeys "{ENTER}"
- DoKeys "Numbers from 0 to 9: 0123456789"
- DoKeys "{ENTER}"
- DoKeys "Numbers from 9 to 0: 9876543210"
- DoKeys "{ENTER}"
-
- END SUB
-
- '******************************************************************************
- ' SUB Dialogs brings up the Goto Page and checks to see if the items of the
- ' dialog box are correct.
- '******************************************************************************
-
- SUB Dialogs STATIC
-
- 'Hot Key for the "Goto Page" dialog box.
- DoKeys "{F4}"
-
- 'Check to see that the buttons exist and are Enabled.
- ret% = WButtonExists("OK")
- ret% = WButtonExists("Cancel")
- ret% = WButtonEnabled("OK")
-
- 'Make sure there is a "Page Number" label.
- IF WEditExists("&Page Number:") = FALSE THEN
- PRINT, "Goto Page dialog box - edit box name incorrect"
- ErrCount = ErrCount + 1
- ENDIF
-
- 'Check to see if the edit box contains "1".
- IF EditSelText("&Page Number:") <> "1" THEN
- PRINT, "Goto Page dialog box edit text incorrect"
- ErrCount = ErrCount + 1
- ENDIF
-
- 'Close the dialog box.
- WButtonClick "Cancel"
-
- END SUB
-
- '******************************************************************************
- ' SUB TestBold will demonstrate how to save an image to file and then later
- ' compare the image to another screen.
- '******************************************************************************
-
- SUB TestBold STATIC
-
- ret% = fDumpWindow("tutor.wts",WinHandle,0,0,FALSE)
-
- DoKeys "^{HOME}" 'Goto beginning of file.
- DoKeys "+{END}" 'Select the first line (SHIFT + END).
- DoKeys "^B" 'Make the first line bold (CTRL + B).
-
- IF fCompWindow("tutor.wts", WinHandle, 0, FALSE, FALSE) = 0 THEN
- PRINT, "Bold failed..."
- ErrCount = ErrCount + 1
- ENDIF
-
- END SUB
-
-
- '******************************************************************************
- ' SUB EndTest will save the output of the WRITE.EXE document. If TUTOR.WRI
- ' exists, the you will need to overwrite the file, else just save the file.
- '******************************************************************************
-
- SUB EndTest STATIC
-
- IF NOT EXISTS("tutor.wri") THEN
- DoKeys "%FX"
- DoKeys "y"
- DoKeys "tutor.wri"
- WButtonClick "OK"
- ELSE
- DoKeys "%FX"
- DoKeys "y"
- DoKeys "tutor.wri"
- WButtonClick "OK"
- DoKeys "y"
- END IF
-
- PRINT, "**********************************************"
- PRINT, "SUCCESSFULLY COMPLETED WRITE.EXE TEST"
- PRINT, " " + DATETIME$
- PRINT, "Total of ", ErrCount, " errors detected"
- PRINT, "**********************************************"
-
- END SUB
-
-