Inherits from NSObject
Declared in SLAlert.h

Overview

The “dismiss” methods of SLAlert vend instances of SLAlertHandler that can dismiss corresponding alerts when they appear, and report the status of dismissal to the tests.

The methods in the SLAlertHandler (Debugging) category may be useful in debugging Subliminal tests.

The methods in the SLAlertHandler (Internal) category are to be used only within Subliminal.

Tasks

Adding and Removing Handlers

  • + addHandler:

    Allows tests to manually handle particular alerts.

  • + removeHandler:

    Removes the specified handler from the queue of SLAlertHandlers given a chance to handle (dismiss) an alert when it is shown.

Checking Dismissal Status

Chaining Handlers

  • – andThen:

    Creates and returns an alert handler which handles a corresponding alert by performing the action of the receiver and then that of the specified handler.

Debugging Tests

Internal Methods

Class Methods

addHandler:

Allows tests to manually handle particular alerts.

+ (void)addHandler:(SLAlertHandler *)handler

Parameters

handler

An alert handler.

Discussion

Tests can add multiple handlers at one time; when an alert is shown, they are checked in order of addition, and the first one that matches the alert is given the chance to handle (dismiss) the alert. If the handler succeeds, it is removed; otherwise, the remaining handlers are checked.

If an alert is not handled by any handler, it will be automatically dismissed by tapping the cancel button, if the button exists, then tapping the default button, if one is identifiable. If the alert is still not dismissed, the tests will hang.

Each handler must be added only once.

Warning: Handlers must be added before the alerts they handle might appear.

Exceptions

NSInternalInconsistencyException

Thrown if a handler is added multiple times.

NSInternalInconsistencyException

Thrown if the handler will not ultimately try to dismiss a corresponding alert: handler must either be an SLAlertDismissHandler, or must be a handler produced using andThen: where the last “chained” handler is an SLAlertDismissHandler.

Declared In

SLAlert.h

loadUIAAlertHandling

Loads Subliminal’s alert-handling mechanism into UIAutomation.

+ (void)loadUIAAlertHandling

Discussion

SLAlertHandler is not fully functional until this method is called.

This method is to be called by the test controller on startup.

Declared In

SLAlert.h

loggingEnabled

Returns YES if Subliminal should log alerts as they are handled.

+ (BOOL)loggingEnabled

Return Value

YES if alert-handling logging is enabled, NO otherwise.

Discussion

Logging is disabled by default.

Declared In

SLAlert.h

removeHandler:

Removes the specified handler from the queue of SLAlertHandlers given a chance to handle (dismiss) an alert when it is shown.

+ (void)removeHandler:(SLAlertHandler *)handler

Parameters

handler

An alert handler to remove.

Exceptions

NSInternalInconsistencyException

Thrown if handler has not yet been added.

Declared In

SLAlert.h

setLoggingEnabled:

Enables or disables alert-handling logging.

+ (void)setLoggingEnabled:(BOOL)enableLogging

Parameters

enableLogging

If YES, alert-handling logging is enabled; otherwise, alert-handling logging is disabled.

Discussion

If logging is enabled, Subliminal will log alerts as they are handled (by handlers registered by tests or by Subliminal’s default handler).

Logging is disabled by default.

Declared In

SLAlert.h

Instance Methods

andThen:

Creates and returns an alert handler which handles a corresponding alert by performing the action of the receiver and then that of the specified handler.

- (SLAlertHandler *)andThen:(SLAlertHandler *)nextHandler

Parameters

nextHandler

A handler whose action should be performed after the action of the receiver.

Return Value

A newly created alert handler that performs the action of the receiver and then the action of nextHandler.

Discussion

This method allows alert handlers to be “chained”, so that (for instance) text can be entered into an alert’s text field, and then the alert dismissed:

 SLAlert *alert = [SLAlert alertWithTitle:alertTitle];

 SLAlertHandler *setUsername = [alert setText:@"user" ofFieldOfType:SLAlertTextFieldTypeLogin];
 SLAlertHandler *setPassword = [alert setText:@"password" ofFieldOfType:SLAlertTextFieldTypePassword];
 SLAlertHandler *dismiss = [alert dismissWithButtonTitled:@"Ok"];
 SLAlertHandler *alertHandler = [[setUsername andThen:setPassword] andThen:dismiss];

 [SLAlertHandler addHandler:alertHandler];

Declared In

SLAlert.h

didHandleAlert

Returns YES if the receiver has dismissed an alert, NO otherwise.

- (BOOL)didHandleAlert

Return Value

YES if the receiver has dismissed an alert, NO otherwise.

Discussion

Tests should assert that this is true within a timeout of SLAlertHandlerDidHandleAlertDelay.

Exceptions

NSInternalInconsistencyException

Thrown if the receiver has not been added.

See Also

Declared In

SLAlert.h