OpenCTF  1.5.0
Open Component Test Framework
 All Classes Functions Variables
TComponentHandler Class Reference

A test handler for a given type of components. More...

Inheritance diagram for TComponentHandler:
IComponentHandler

List of all members.

Public Member Functions

 TComponentHandler (const TClass ComponentClass, const string Suitename= '')
 Creates a handler instance.
ITestSuite GetSuite ()
 Get the test suite.

Protected Member Functions

Boolean Accepts (const TComponent Component)
 This methods decides if the passed component should be included in the test suite.
 AddTest (const ITest Test)
 this method is a shortcut for CurrentSuite.AddTest(...));
 AddTests ()
 Adds all component tests for the component to the test suite.
 AddFormTests ()
 Adds tests for the form to the test suite.
 CheckEvents (const string *Events)
 Checks for assigned event handlers.
 CheckUnassignedEvents (const string *Events)
 Checks for unassigned event handlers.
 CheckProperties (const string *Properties)
 Checks for assigned properties.
 CheckUnassignedProperties (const string *Properties)
 Check for unassigned properties.
Boolean Handles (const TComponent Form)
 Form filter method.
Boolean HasProperty (const TComponent Component, const string PropName, const TTypeKinds AKinds=[])
 Checks for the existence of a property.

Protected Attributes

TComponent Form
 The form or datamodule which will be tested.

Detailed Description

A test handler for a given type of components.

  • The method TComponentHandler::Accepts controls which components will be tested, it can be overriden to change the default behaviour.

Constructor & Destructor Documentation

TComponentHandler::TComponentHandler ( const TClass  ComponentClass,
const string  Suitename = '' 
)

Creates a handler instance.

This constructor will create a handler instance which will by default generate a test for every component in the form (or datamodule) which is a subtype of the given component class.

Parameters:
ComponentClassthe component class which will be accepted (and tested).
Suitenameoptional test suite name

Member Function Documentation

Boolean TComponentHandler::Accepts ( const TComponent  Component) [protected]

This methods decides if the passed component should be included in the test suite.

The default implementation checks if the component class is a subclass of the handled class. This method may be overriden to add more filter conditions.

Parameters:
Componentthe component to be checked

Adds tests for the form to the test suite.

  • To add tests for the form, overwrite the empty default declaration of this method.
TComponentHandler::AddTest ( const ITest  Test) [protected]

this method is a shortcut for CurrentSuite.AddTest(...));

Parameters:
Testthe test that will be added to the CurrentSuite
TComponentHandler::AddTests ( ) [protected]

Adds all component tests for the component to the test suite.

  • If you write a new component handler, you have to provide an implementation of this method.

Example:

 procedure TMenuItemHandler.AddTests;
 begin
   inherited;
   CurrentSuite.AddTest(TMenuItemTest.Create(CurrentComponent));
 end;
TComponentHandler::CheckEvents ( const string *  Events) [protected]

Checks for assigned event handlers.

 procedure TCustomClientDataSetTestHandler.AddTests(const SubComponent: TComponent);
 begin
   inherited;
   // check if the OnReconcileError event handler is assigned
   CheckEvents(['OnReconcileError']);
   // check if the ProviderName property is assigned
   CheckProperties(['ProviderName']);
 end;
TComponentHandler::CheckProperties ( const string *  Properties) [protected]

Checks for assigned properties.

 procedure TDbAwareComponentTestHandler.AddTests(const
   SubComponent: TComponent);
 begin
   CheckProperties(['DataSource', 'DataField']);
 end;
TComponentHandler::CheckUnassignedEvents ( const string *  Events) [protected]

Checks for unassigned event handlers.

See also:
CheckEvents
TComponentHandler::CheckUnassignedProperties ( const string *  Properties) [protected]

Check for unassigned properties.

See also:
CheckProperties
Boolean TComponentHandler::Handles ( const TComponent  Form) [protected]

Form filter method.

This method decides if the handler will generate test cases for the given form.

The default implementation always returns True.

If you write a component handler, you can overwrite this method to allow only special form classes to be processed.

For example, a component handler for visual components can overwrite this method and check if the passed parameter is a subclass of TCustomForm:

 Result := Form is TCustomForm;
Parameters:
FormThe form (or datamodule) to be tested.

Member Data Documentation

The form or datamodule which will be tested.

See also:
GetForm For reading
SetForm For writing