Handlers
-
Handles launch environments passed by the UI test runner. Launch environments passed by the AutoMate are working.
LaunchEnvironmentManager
should 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):
true
yes
1
false
no
0
Example:
let launchManager = LaunchEnvironmentManager() launchManager.add(handler: AnimationHandler(), for: .animation) launchManager.setup()
Note
Launch environment for the handler can be set by the
AnimationLaunchEnvironment
from the AutoMate project.Note
AnimationHandler
should be used with theAM_ANIMATION_KEY
key, but its implementation doesn’t require to use it. Any key provided to theLaunchEnvironmentManager.add(handler:for:)
method will be handled correctly.Seealso
-
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):
true
yes
1
false
no
0
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
defaultIsInUITestHandler
singleton could be used intead of creating new instance of theIsInUITestHandler
.Note
Launch environment for the handler can be set by the
IsInUITestLaunchEnvironment
from the AutoMate project.Note
IsInUITestHandler
should be used with theAM_IS_IN_UI_TEST
key, but its implementation doesn’t require to use it. Any key provided to theLaunchEnvironmentManager.add(handler:for:)
method will be handled correctly.Seealso
Seealso
Declaration
Swift
public class IsInUITestHandler : Handler
-
Handles contacts by using
Contacts
framework.Handler should be added to
LaunchEnvironmentManager
.Used key:
AM_CONTACTS_KEY
/AutoMateLaunchOptionKey.contacts
.Supported values:
LaunchEnvironmentResource
resources 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
defaultContactsHander
singleton could be used intead of creating new instance of theContactsHandler
.Note
Launch environment for the handler can be set by the
ContactLaunchEnvironment
from the AutoMate project.Note
ContactsHandler
should be used with theAM_CONTACTS_KEY
key, but its implementation doesn’t require to use it. Any key provided to theLaunchEnvironmentManager.add(handler:for:)
method will be handled correctly.Seealso
Seealso
Seealso
Declaration
Swift
public struct ContactsHandler<C, I> : Handler where C : ContactParser, I : ContactsInterface
-
Handles events and reminders by using
EventKit
framework.Handler should be added to
LaunchEnvironmentManager
.Used key:
AM_EVENTS_KEY
,AM_REMINDERS_KEY
/AutoMateLaunchOptionKey.events
,AutoMateLaunchOptionKey.reminders
.Supported values:
LaunchEnvironmentResource
resources 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
defaultEventKitHander
singleton could be used intead of creating new instance of theEventKitHandler
.Note
Launch environment for the handler can be set by the
EventLaunchEnvironment
andReminderLaunchEnvironment
from the AutoMate project.Warning
EventKitHandler
is working only with theAM_EVENTS_KEY
andAM_REMINDERS_KEY
key. If any other key will be used handler will throw an exception.Seealso
Seealso
Seealso
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
LaunchEnvironmentManager
to handle launch environments.Seealso
LaunchEnvironmentManager
Declaration
Swift
public protocol Handler