Class
caplin.component.testing

ComponentFixture

Constructor Summary

Attributes Name and Description
caplin.component.testing.ComponentFixture(String sXml, caplin.component.testing.ComponentModelFixture oModelFixture, caplin.dom.testing.ViewFixture oViewFixture)

Constructs a caplin.component.testing.ComponentFixture.

Method Summary

Attributes Name and Description
void addSubFixtures( oFixtureRegistry)

The ComponentFixture adds the following sub-fixtures:

  • model: the presentation model fixture, for manipulating and verifying properties in the presentation model
  • view: the view fixture, the view fixture, for manipulating and verifying the state of elements on the component's view
  • componentFrame: the component frame fixture, for verifying the state of the caplin.component.frame.ComponentFrame housing the component

void addViewFixtureHandlers(Map viewHandlersMap)

Allows custom view handlers to be added.

void canHandleExactMatch()

boolean canHandleProperty(String sProperty)

ComponentFixture handles the 'opened' property.

void doGiven(String sProperty, String vValue)

This method creates and opens the component created, and sets it on the presentation model and view sub-fixtures so that tests may manipulate model properties and the view elements.

void doThen(String sProperty, String vValue)

doThen is not supported on the ComponentFixture.

void doWhen(String sProperty, String vValue)

doWhen is not supported on the ComponentFixture.

void getComponent()

Returns the Component under test.

void onOpen(function fCallback)

This method can be called to set a function on the fixture which will be executed whenever the component is created and opened.

void setUp()

Upon set-up of the ComponentFixture, the ComponentFactory is configured not to create an ErrorComponent.

void tearDown()

Upon tear-down of the ComponentFixture, the component created is closed and the ComponentFactory is re-configured to its original settings.

void tearDownOldComponentAndRecreateWithNewXML(String sXml)

Tear down this fixture and and recreate the component with the passed in xml string.

Constructor Detail

caplin.component.testing.ComponentFixture(String sXml, caplin.component.testing.ComponentModelFixture oModelFixture, caplin.dom.testing.ViewFixture oViewFixture)

Constructs a caplin.component.testing.ComponentFixture.

Parameters
String sXml the component XML required by the {@link caplin.component.ComponentFactory ComponentFactory} to create the component. Required.
caplin.component.testing.ComponentModelFixture oModelFixture the presentation model fixture. Required.
caplin.dom.testing.ViewFixture oViewFixture the view fixture. Optional. The ComponentFixture serves to create components using the ComponentFactory when these are required in the system under test.

In addition to creating and opening the component, the ComponentFixture defines several sub-fixtures to be added to the test runner, enabling the testing and manipulation of the view and presentation model of the component.

Method Detail

void addSubFixtures( oFixtureRegistry)

The ComponentFixture adds the following sub-fixtures:

  • model: the presentation model fixture, for manipulating and verifying properties in the presentation model
  • view: the view fixture, the view fixture, for manipulating and verifying the state of elements on the component's view
  • componentFrame: the component frame fixture, for verifying the state of the caplin.component.frame.ComponentFrame housing the component

Parameters
oFixtureRegistry
See
caplin.testing.Fixture#addSubFixtures

void addViewFixtureHandlers(Map viewHandlersMap)

Allows custom view handlers to be added. The ViewFixture's addViewHandlers method throws an exception if an attempt is made to override an existing handler.

Parameters
Map viewHandlersMap A map of handler name to handler class constructor reference

void canHandleExactMatch()

See
caplin.testing.Fixture#canHandleExactMatch

boolean canHandleProperty(String sProperty)

ComponentFixture handles the 'opened' property.

Parameters
String sProperty name of the property
See
caplin.testing.Fixture#canHandleProperty

void doGiven(String sProperty, String vValue)

This method creates and opens the component created, and sets it on the presentation model and view sub-fixtures so that tests may manipulate model properties and the view elements.

Parameters
String sProperty name of the property
String vValue value of the property
See
caplin.testing.Fixture#doGiven

void doThen(String sProperty, String vValue)

doThen is not supported on the ComponentFixture.

Parameters
String sProperty name of the property
String vValue value of the property
See
caplin.testing.Fixture#doThen

void doWhen(String sProperty, String vValue)

doWhen is not supported on the ComponentFixture.

Parameters
String sProperty name of the property
String vValue value of the property
See
caplin.testing.Fixture#doWhen

void getComponent()

Returns the Component under test.

void onOpen(function fCallback)

This method can be called to set a function on the fixture which will be executed whenever the component is created and opened.

Parameters
function fCallback the function to execute on opening the component

void setUp()

Upon set-up of the ComponentFixture, the ComponentFactory is configured not to create an ErrorComponent. If no component can be created with the given XML configuration, an exception will be thrown instead.

See
caplin.testing.Fixture#setUp

void tearDown()

Upon tear-down of the ComponentFixture, the component created is closed and the ComponentFactory is re-configured to its original settings.

See
caplin.testing.Fixture#tearDown

void tearDownOldComponentAndRecreateWithNewXML(String sXml)

Tear down this fixture and and recreate the component with the passed in xml string.

Parameters
String sXml the xml string for the component.