Example: Defining a Custom Verification Property

Let's look at an example of defining a custom verification property. Say you want to test a dialog box. Dialog boxes come with the following built-in verification properties:
  • Caption
  • Children
  • DefaultButton
  • Enabled
  • Focus
  • Rect
  • State

And let's say that you have defined a class property, NumChildren, that you want to make available to the verification system.

Here is the class property definition:
property NumChildren
INTEGER Get ()
return ListCount (GetChildren ())

That property returns the number of children in the object, as follows:

  • The built-in method GetChildren returns the children in the dialog box in a list.
  • The built-in function ListCount returns the number of elements in the list returned by GetChildren.
To make the NumChildren class property available to the verification system (that is, to also make it a verification property) you list it as an element in the variable lsPropertyNames. So here is part of the extended DialogBox declaration that you would define in an include file:
winclass DialogBox : DialogBox
  // user-defined property
  property NumChildren
    INTEGER Get ()
      return ListCount (GetChildren ())
  // list of custom verification properties
  LIST OF STRING lsPropertyNames = {"NumChildren"}

Now when you verify a dialog box in a test case, you can verify your custom property since it will display in the list of DialogBox properties to verify.

Note: As an alternative, instead of defining NumChildren as a class property, you could also define it as a variable, then initialize the variable in a script. For example, in your include file, you would have:
winclass DialogBox : DialogBox
  INTEGER NumChild2
  // list of custom verification properties
  LIST OF STRING lsPropertyNames = {"NumChild2"}
And in your script-before you do the verification-you would initialize the value for the dialog box under test, such as:
Find.NumChild2 = ListCount (Find.GetChildren ())