Notification Test Example Code (1 of 2)

This functionality is supported only if you are using the Classic Agent.

This topic contains the complete test case file for a single-user notification test. It shows a testing technique for a type of communication frequently used in client/server applications. Notification Test Example Code (2 of 2) shows a notification test between two users running their own copies of the client application. This illustrates doing the simplest case first and then adding the next level of complexity when you go from one user to two users. For additional information on the testing technique, see Notification Test Example Explained (1 of 2).

// ccmail.t
use "ccmail.inc"
LogMeIn()
  LogInUser(GetMachineData( NULL, "Username" ), 
    GetMachineData( NULL, "Password" ) )

//------------------------------------------------------------
multitestcase SingleUserNotification ( STRING sMachine1 optional )
  if( sMachine1 == NULL )
    sMachine1 = "(local)"

  //=== MULTI-APPLICATION SETUP SECTION ===================//
  SetUpMachine( sMachine1, CcMail, "EnsureInBoxIsEmpty" )
  SetMachineData( sMachine1, "Username", "QAtest1" )
  SetMachineData( sMachine1, "Password", "QAtest1" )
  SetMultiAppStates()

  //=== TEST BEGINS HERE ==================================//
  SetMachine( sMachine1 )
  SimpleMessage( "QAtest1", "Message to myself", "A message to myself" )
  Verify( CcMailNewMailAlert.Exists( NOTIFICATION_TIMEOUT ), TRUE )
  Verify( CcMailNewMailAlert.IsActive(), TRUE, "ALERT" )
  CcMailNewMailAlert.OK.Click()
  CcMail.xWindow.GoToInbox.Pick ()
  Verify( CcMail.Message.DeleteMessage.IsEnabled(), TRUE, 
    "MESSAGE WAITING" )

Utility function

void SimpleMessage (STRING sRecipient, STRING sSubject,
  STRING sBody)
CcMail.Message.NewMessage.Pick()

NewMessage.MailingLabel.Recipient.SetText (sRecipient)
NewMessage.MailingLabel.Recipient.TypeKeys ("<Enter>")
NewMessage.MailingLabel.Recipient.TypeKeys ("<Enter>")
NewMessage.MailingLabel.SubjectField.SetText (sSubject)
NewMessage.MailingLabel.SubjectField.TypeKeys ("<Enter>")
NewMessage.EditBody.Body.TypeKeys (sBody)
NewMessage.EditBody.Body.TypeKeys ("<Ctrl-s>")

This function uses standard methods on Ccmail window components, defined in ccmail.inc, to do the following:

  1. Pick the NewMessage item from the Message menu.
  2. Enter the string in argument one into the Recipient field and press the Enter key twice to move to the Subject field.
  3. Enter the string in argument two into the Subject field and press Enter to move to the message body portion of the window (EditBody.Body).
  4. Type the string in argument three into the Body field and type Ctrl + s to send the message.

The following block of code verifies the results of the test.

Verify(CcMailNewMailAlert.Exists(NOTIFICATION_TIMEOUT),
  TRUE )
Verify(CcMailNewMailAlert.IsActive(), TRUE, "ALERT")
CcMailNewMailAlert.OK.Click()
CcMail.xWindow.GoToInbox.Pick ()
Verify(CcMail.Message.DeleteMessage.IsEnabled(), TRUE, 
  "MESSAGE WAITING")

The above code does the following:

  1. Verifies that the sent message was received, as indicated by the NewMailAlert message box. The NOTIFICATION_TIMEOUT value causes the Verify function to wait for that period of time for the window to exist. If the timeout value is reached, the Verify raises an exception.
  2. Verify that the dialog box CcMailNewMailAlert is active.
  3. If the Verify executes without an exception, click on the OK button in the CcMailNewMailAlert dialog box.
  4. Pick the GoToInbox menu item from the Window menu.
  5. Verify that a message exists in the Inbox by checking to see that the Message menu has its DeleteMessage menu item enabled. If the menu item is not enabled, there is no message in the Inbox and the Verify function raises an exception.
  • This script continues in Notification Test Example Code (2 of 2).