Creates an instance of an UITest.
In the background, the class UITest uses the Greensock TimelineMax class. The opts object is passed directly to the TimelineMax class, so it can use any key that uses the TimelineMax class.
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object |
optional
An options object to specify the behaviour of the test case.
|
- See:
Example
// Create the UITest object
const test = new UITest({
timeScale: 2
})
// Add an action to the test case
test.tap(button, {eventType: 'click'})
// Start the test case
test.start()
Members
-
Gets the Greensock TimelineMax object, used in the background of UITest.
Methods
-
clear ()UITest
-
Clears all instructions of the test case.
Returns:
Type Description UITest A reference to the UITest for chaining. -
Executes a pan event (pointerdown, pointermove, pointerup) on a specific element.
Name Type Default Description element
HTMLElement | string The HTML element on which the event is to be executed, e.g. button, document, h2, canvas, etc. or an selector string. If a selector has been specified, it is evaluated immediately before the event is called using the querySelector method.
position
Array.<number> | object | PIXI.DisplayObject The center of the element. optional The local position of the event in the context of the specified HTML element. If no position is specified, the center of the HTML element is used. The position can be specified as an array of numbers, as an object with the two properties x and y, or as a PIXI.Display object.
timelinePosition
number One second after the last action. optional The position in seconds when the event should be triggered, see shttps://greensock.com/docs/TimelineMax/addCallback().
opts
object optional An options object to specify the behaviour of the action.
Name Type Default Description onStart
function optional A function that runs after the first event is fired. Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
onUpdate
function optional A function that runs after each execution of the second event. Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
onComplete
function optional A function that runs after the third event is fired. Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
to
Array.<number> | object | PIXI.DisplayObject {x: 0, y: 0} optional The target of the pan process. The position can be specified as an array of numbers, as an object with the two properties x and y, or as a PIXI.Display object.
duration
number 1 optional The duration of the pan animation in seconds, see https://greensock.com/docs/TweenLite/duration().
ease
Ease Power0.easeNone optional The easing of the pan animation, see https://greensock.com/docs/Easing.
eventTypes
Array.<string> ['pointerdown', 'pointermove', 'pointerup'] optional The event types to use. If no types are specified, the event types specified in the UITest constructor are used (or auto if not specified).
context
Window | Frame window optional The context within which the optionally specified element selector should be executed.
bubbles
boolean true optional The Event property bubbles indicates whether the event bubbles up through the DOM or not.
cancelable
boolean true optional Events' cancelable property indicates if the event can be canceled, and therefore prevented as if the event never happened. If the event is not cancelable, then its cancelable property will be false and the event listener cannot stop the event from occurring.
-
Executes a pinch event (pointerdown, pointermove, pointerup) on a specific element with two "fingers" simultaneously.
Name Type Default Description element
HTMLElement | string The HTML element on which the event is to be executed, e.g. button, document, h2, canvas, etc. or an selector string. If a selector has been specified, it is evaluated immediately before the event is called using the querySelector method.
position
Array.<number> | object | PIXI.DisplayObject The center of the element. optional The local position of the event in the context of the specified HTML element. If no position is specified, the center of the HTML element is used. The position can be specified as an array of numbers, as an object with the two properties x and y, or as a PIXI.Display object.
timelinePosition
number One second after the last action. optional The position in seconds when the event should be triggered, see shttps://greensock.com/docs/TimelineMax/addCallback().
opts
object optional An options object to specify the behaviour of the action.
Name Type Default Description onStart
function optional A function that runs after the first events are fired. Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
onUpdate
function optional A function that runs after each execution of the second events. Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
onComplete
function optional A function that runs after the third events are fired. Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
doubleCallbacks
boolean false optional The callbacks onStart, onUpdate and onComplete will be fired only for one finger. If set to true, the events will be fired for both fingers.
distance
number 100 optional The distance in pixels, how far the two "fingers" should move apart. If to or bezier specified, distance is ignored.
to
Array.<Array.<number>> | Array.<object> | Array.<PIXI.DisplayObject> optional The targets of the pinch process. The position must be an array with two entries. An entry can be specified as an array of numbers, as an object with the two properties x and y, or as a PIXI.Display object. If bezier is specified, to is ignored.
bezier
Array.<Array.<number>> | Array.<object> | Array.<PIXI.DisplayObject> optional The targets of the pinch process. The position must be an array with two entries. An entry may be an array of positions or a bezier object (https://greensock.com/docs/Plugins/BezierPlugin). A position in the array or the values array of the bezier object can be specified as an array of numbers, as an object with the two properties x and y, or as a PIXI.Display object. If bezier is specified, to is ignored.
duration
number 1 optional The duration of the pan animation in seconds, see https://greensock.com/docs/TweenLite/duration().
ease
Ease Power0.easeNone optional The easing of the pan animation, see https://greensock.com/docs/Easing.
eventTypes
Array.<string> ['pointerdown', 'pointermove', 'pointerup'] optional The event types to use. If no types are specified, the event types specified in the UITest constructor are used (or auto if not specified).
context
Window | Frame window optional The context within which the optionally specified element selector should be executed.
bubbles
boolean true optional The Event property bubbles indicates whether the event bubbles up through the DOM or not.
cancelable
boolean true optional Events' cancelable property indicates if the event can be canceled, and therefore prevented as if the event never happened. If the event is not cancelable, then its cancelable property will be false and the event listener cannot stop the event from occurring.
-
restart ()UITest
-
Restarts the test case.
Returns:
Type Description UITest A reference to the UITest for chaining. -
start ()UITest
-
Starts the test case and executes the corresponding statements in the specified order.
Returns:
Type Description UITest A reference to the UITest for chaining. -
stop ()UITest
-
Stops the test case and stops executing any further instructions.
Returns:
Type Description UITest A reference to the UITest for chaining. -
Executes a tap event (pointerdown, pointerup) on a specific element.
Name Type Default Description element
HTMLElement | string The HTML element on which the event is to be executed, e.g. button, document, h2, canvas, etc. or an selector string. If a selector has been specified, it is evaluated immediately before the event is called using the querySelector method.
position
Array.<number> | object | PIXI.DisplayObject The center of the element. optional The local position of the event in the context of the specified HTML element. If no position is specified, the center of the HTML element is used. The position can be specified as an array of numbers, as an object with the two properties x and y, or as a PIXI.Display object.
timelinePosition
number One second after the last action. optional The position in seconds when the event should be triggered, see shttps://greensock.com/docs/TimelineMax/addCallback().
opts
object optional An options object to specify the behaviour of the action.
Name Type Default Description onStart
function optional A function that runs after the first event is fired. Will not be fired if only one event is running (for example, a click event). Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
onComplete
function optional A function that runs after the second event is fired. Always fired, even if only one event is running (for example, a click event). Receives the fired event object as the first parameter. The test case (UITest) is bound to this.
eventTypes
Array.<string> ['pointerdown', 'pointerup'] optional The event types to use. If no types are specified, the event types specified in the UITest constructor are used (or auto if not specified).
eventType
string optional If you want the tap method to fire only one event (for example, a click event), you can specify the opts.eventType parameter. If eventType is not null, the parameter opts.eventTypes is ignored.
context
Window | Frame window optional The context within which the optionally specified element selector should be executed.
bubbles
boolean true optional The Event property bubbles indicates whether the event bubbles up through the DOM or not.
cancelable
boolean true optional Events' cancelable property indicates if the event can be canceled, and therefore prevented as if the event never happened. If the event is not cancelable, then its cancelable property will be false and the event listener cannot stop the event from occurring.