background image
<< Porting Tests - Supporting differences in application behavior | Porting Tests - the sPath variable >>
Porting Tests - SGetGUIType function
<< Porting Tests - Supporting differences in application behavior | Porting Tests - the sPath variable >>
278
User's Guide
13 P
ORTING
T
ESTS
TO
O
THER
GUI
S
Supporting differences in application behavior
case pm:
// code to test feature on Presentation Manager
Text field requires
Return keystroke
On some GUIs, the Enter/Return key must be pressed after data is entered
into a text field. Suppose you want to create a testcase which enters invalid
data into the field, and then checks if the application detects the error. After
the testcase enters the invalid data, it needs to use the GetGUIType function
to determine the GUI, and then press the Return key if the GUI requires it.
For example:
// code to enter an invalid string into field
if (GetGUIType () == motif)
MyTextField.TypeKeys ("<Return>")
// code to verify that application detected error
Error messages are
different
The VerifyErrorBox function, shown below, illustrates how to solve the
problem of different error messages on each GUI platforms. In this example,
Motif always adds the prefix "Error:" to its message, while the other
platforms do not.
VerifyErrorBox (STRING sMsg)
// verifies that the error box has the correct error
// message, then dismisses the error box
const ERROR_PREFIX = "ERROR: "
const ERROR_PREFIX_LEN = Len (ERROR_PREFIX)
STRING sActMsg = MessageBox.Message.GetText ()
// strip prefix "ERROR: " from Motif error messages
if (GetGUIType () == motif)
sActMsg = SubStr (sActMsg, ERROR_PREFIX_LEN + 1)
Verify (sActMsg, sMsg)
MessageBox.Accept ()
Mechanism for
navigating directories
is different
In the Windows Open dialog, to navigate to a directory you can enter the path
name of the directory into a text field. The Macintosh GUI, however, does not
allow you to enter paths; you must instead navigate to a working directory by
selecting successive directories from a list.
The SetWorkingDirectory function, shown below, illustrates how to solve this
problem. The function receives the sPath parameter, which is the path of the
directory to change to. The function contains a case statement which
·
For the Macintosh, parses sPath into its constituent directories and
double-selects each directory name in succession until the working
directory is reached.