SLAlertHandler Class Reference
| 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
SLAlertHandlersgiven a chance to handle (dismiss) an alert when it is shown.
Checking Dismissal Status
-
– didHandleAlertReturns YES if the receiver has dismissed an alert, NO otherwise.
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
-
+ setLoggingEnabled:Enables or disables alert-handling logging.
-
+ loggingEnabledReturns
YESif Subliminal should log alerts as they are handled.
Internal Methods
-
+ loadUIAAlertHandlingLoads Subliminal’s alert-handling mechanism into UIAutomation.
Class Methods
addHandler:
Allows tests to manually handle particular alerts.
+ (void)addHandler:(SLAlertHandler *)handlerParameters
- 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:
handlermust either be anSLAlertDismissHandler, or must be a handler produced usingandThen:where the last “chained” handler is anSLAlertDismissHandler.
Declared In
SLAlert.hloadUIAAlertHandling
Loads Subliminal’s alert-handling mechanism into UIAutomation.
+ (void)loadUIAAlertHandlingDiscussion
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.hloggingEnabled
Returns YES if Subliminal should log alerts as they are handled.
+ (BOOL)loggingEnabledReturn Value
YES if alert-handling logging is enabled, NO otherwise.
Discussion
Logging is disabled by default.
See Also
Declared In
SLAlert.hremoveHandler:
Removes the specified handler from the queue of SLAlertHandlers given a
chance to handle (dismiss) an alert when it is shown.
+ (void)removeHandler:(SLAlertHandler *)handlerParameters
- handler
An alert handler to remove.
Exceptions
- NSInternalInconsistencyException
Thrown if
handlerhas not yet been added.
Declared In
SLAlert.hsetLoggingEnabled:
Enables or disables alert-handling logging.
+ (void)setLoggingEnabled:(BOOL)enableLoggingParameters
- 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.hInstance 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 *)nextHandlerParameters
- 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.hdidHandleAlert
Returns YES if the receiver has dismissed an alert, NO otherwise.
- (BOOL)didHandleAlertReturn 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