Handlers
-
Handles launch environments passed by the UI test runner. Launch environments passed by the AutoMate are working.
LaunchEnvironmentManagershould be initialized in the application delegate in methodapplication(_:didFinishLaunchingWithOptions:).Example:
See morelet launchManager = aunchEnvironmentManager() launchManager.add(handler: defaultEventKitHander, for: .events) launchManager.add(handler: defaultEventKitHander, for: .reminders) launchManager.add(handler: defaultContactsHander, for: .contacts) launchManager.add(handler: defaultIsInUITestHandler, for: .isInUITest) launchManager.add(handler: AnimationHandler(), for: .animation) launchManager.setup()Declaration
Swift
public final class LaunchEnvironmentManager
-
Handles enabling and disabling UIKit animations.
Handler should be added to
LaunchEnvironmentManager.Used key:
AM_ANIMATION_KEY/AutoMateLaunchOptionKey.animation.Supported values (case insensitive):
trueyes1falseno0
Example:
let launchManager = LaunchEnvironmentManager() launchManager.add(handler: AnimationHandler(), for: .animation) launchManager.setup()Note
Launch environment for the handler can be set by the
AnimationLaunchEnvironmentfrom the AutoMate project.Note
AnimationHandlershould be used with theAM_ANIMATION_KEYkey, but its implementation doesn’t require to use it. Any key provided to theLaunchEnvironmentManager.add(handler:for:)method will be handled correctly.See moreSeealso
-
Provides information whether the application is running under UI test environment.
Handler should be added to
LaunchEnvironmentManager.Used key:
AM_IS_IN_UI_TEST/AutoMateLaunchOptionKey.isInUITest.Supported values (case insensitive):
trueyes1falseno0
Example:
let launchManager = LaunchEnvironmentManager() let isInUITest = IsInUITestHandler() launchManager.add(handler: isInUITest, for: .isInUITest) launchManager.setup()Later in the code, you can check whether the application is running in UI test environment, by using below example:
Example:
if isInUITest.inUITest { ... }Note
defaultIsInUITestHandlersingleton could be used intead of creating new instance of theIsInUITestHandler.Note
Launch environment for the handler can be set by the
IsInUITestLaunchEnvironmentfrom the AutoMate project.Note
IsInUITestHandlershould be used with theAM_IS_IN_UI_TESTkey, but its implementation doesn’t require to use it. Any key provided to theLaunchEnvironmentManager.add(handler:for:)method will be handled correctly.Seealso
See moreSeealso
Declaration
Swift
public class IsInUITestHandler : Handler
-
Handles contacts by using
Contactsframework.Handler should be added to
LaunchEnvironmentManager.Used key:
AM_CONTACTS_KEY/AutoMateLaunchOptionKey.contacts.Supported values:
LaunchEnvironmentResourceresources representation as a string.Example:
let launchManager = LaunchEnvironmentManager() let contactsHander = ContactsHandler(withParser: ContactDictionaryParser(with: CNContactStore()), contactsInterface: ContactsInterface()) launchManager.add(handler: contactsHander, for: .contacts) launchManager.setup()Note
defaultContactsHandersingleton could be used intead of creating new instance of theContactsHandler.Note
Launch environment for the handler can be set by the
ContactLaunchEnvironmentfrom the AutoMate project.Note
ContactsHandlershould be used with theAM_CONTACTS_KEYkey, but its implementation doesn’t require to use it. Any key provided to theLaunchEnvironmentManager.add(handler:for:)method will be handled correctly.Seealso
Seealso
See moreSeealso
Declaration
Swift
public struct ContactsHandler<C, I> : Handler where C : ContactParser, I : ContactsInterface
-
Handles events and reminders by using
EventKitframework.Handler should be added to
LaunchEnvironmentManager.Used key:
AM_EVENTS_KEY,AM_REMINDERS_KEY/AutoMateLaunchOptionKey.events,AutoMateLaunchOptionKey.reminders.Supported values:
LaunchEnvironmentResourceresources representation as a string.Example:
let launchManager = LaunchEnvironmentManager() let eventsHander = EventKitHandler(withParsers: EventDictionaryParser(with: EKEventStore()), ReminderDictionaryParser(with: EKEventStore()), eventKitInterface: EventKitInterface()) launchManager.add(handler: eventsHander, for: .events) launchManager.add(handler: eventsHander, for: .reminders) launchManager.setup()Note
defaultEventKitHandersingleton could be used intead of creating new instance of theEventKitHandler.Note
Launch environment for the handler can be set by the
EventLaunchEnvironmentandReminderLaunchEnvironmentfrom the AutoMate project.Warning
EventKitHandleris working only with theAM_EVENTS_KEYandAM_REMINDERS_KEYkey. If any other key will be used handler will throw an exception.Seealso
Seealso
See moreSeealso
Declaration
Swift
public class EventKitHandler<E: EventParser, R: ReminderParser, I: EventKitInterfaceProtocol>: Handler where E.T == [String: Any], R.T == [String: Any]
-
Protocol defining necessary methods required by the
LaunchEnvironmentManagerto handle launch environments.See moreSeealso
LaunchEnvironmentManagerDeclaration
Swift
public protocol Handler
Handlers Reference