Title: Theory / Important / CS / Programming / Objective-C / test / Earl Grey / LaunchManager
Tags: automatedNewLineAfterCommaSpace
On every note of this deck, unless a note says otherwise:
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_configuration.h
Variables: AppLaunchConfiguration app_launch_configuration

Typ: AppLaunchManagerObserver
Meaning: Protocol that test cases can implement to be notified by AppLaunchManager.
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Language: Objective-C
Name: AppLaunchManager

Instruction: [app_launch_manager_observer
  appLaunchManagerDidRelaunchApp:appLaunchManager
  runResets:runResets
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Effect: Called when app gets relaunched (due to force restart, or changing the arguments).
|runResets| indicates whether to reset all app status and provide clean test case setups.
Language: Objective-C
Variables: AppLaunchManagerObserver app_launch_manager_observer

Instruction: [AppLaunchManagerObserver
  sharedManager
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Language: Objective-C
Returns: the singleton instance of this class.

Instruction: [launch_manager
  configuration:configuration
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Effect: Ensure that the app has been started with |configuration|. Restart or fails depending on configuration if it is not the case
Language: Objective-C
Variables: AppLaunchManager launch_manager

Instruction: [launch_manager
  backgroundAndForegroundApp
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Effect: Moves app to background and then moves it back. In EG1, this method is a no-op.
Language: Objective-C
Variables: AppLaunchManager launch_manager

Instruction: [launch_manager
  addObserver:observer
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Effect: add observer to launch_manager
Language: Objective-C
Variables: AppLaunchManager launch_manager

Instruction: [launch_manager
  removeObserver:observer
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_manager.h;drc=d0889865de20c5b3bc59d58674eb2dcc02dd2269;l=47
Effect: remove observer to launch_manager
Language: Objective-C
Variables: AppLaunchManager launch_manager

Typ: RelaunchPolicy
TypMeaning: Useful combinations of whether force a relaunch, whether kill app gracefully, whether run resets after a relaunch.
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_configuration.h
Language: Objective-C
Value: NoForceRelaunchAndKeepState
Value2: NoForceRelaunchAndResetState
Value3: ForceRelaunchByKilling
Value4: ForceRelaunchByCleanShutdown

Typ: AppLaunchConfiguration
Meaning: Configuration for launching the app in EGTests.
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_configuration.h
Language: Objective-C

Variable: app_launch_configuration.variations_enabled
Meaning: Enabled variations.
Language: Objective-C

Variable: app_launch_configuration.features_(en|dis)abled
Meaning: (En|Dis)abled features.
Language: Objective-C

Variable: app_launch_configuration.trigger_variations_enabled
Meaning: Enabled trigger variations.
Language: Objective-C

Variable: app_launch_configuration.additional_args
Meaning: Additional arguments to be directly forwarded to the app.
Language: Objective-C

Variable: app_launch_configuration.relaunch_policy
Meaning: relaunch_policy
Language: Objective-C
Typ: RelaunchPolicy

Typ: AppLaunchManagerAppInterface
Meaning: Contains helpers for AppLaunchManager that are compiled into the app binary and can be called from either app or test code.
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_configuration.h
Language: Objective-C

Instruction: [AppLaunchManagerAppInterface
  processIdentifier
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/app_launch_configuration.h
Language: Objective-C
Returns: current host app PID.

Typ: BaseEarlGreyTestCase
Meaning: Base class for all Earl Grey tests.
Provides EG1-compatible start-of-test-case hooks for EG2 tests, as well as handling common EG2 app-launching logic. This class also sets up code coverage by default.
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/base_earl_grey_test_case.h
Language: Objective-C

Instruction: [BaseEarlGreyTestCase setUpForTestCase]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/base_earl_grey_test_case.h
Effect: Invoked once per test case after launching test app from -setUp.
Subclasses can use this method to perform class level setup instead of overriding +setUp, as due to EG2 limitations (crbug.com/961879) +setUp would execute before the application is launched and thus not function in the expected way. Subclasses must not call this method directly. Protected method.
Language: Objective-C

Instruction: [base_earl_grey_test_case
  setUp
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/base_earl_grey_test_case.h
Effect: Invoked upon starting each test method in a test case.
Language: Objective-C
Variables: BaseEarlGreyTestCase base_earl_grey_test_case

Instruction: [base_earl_grey_test_case
  appConfigurationForTestCase
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/base_earl_grey_test_case.h
Language: Objective-C
Returns: An |AppLaunchConfiguration| for host app used across a TestCase.
Subclasses must override this method to change app launching configuration (  f.e. features or flags). Default implementation returns default AppLaunchConfiguration object.
Variables: BaseEarlGreyTestCase base_earl_grey_test_case

Instruction: [BaseEarlGreyTestCaseAppInterface
  logMessage:message
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/base_earl_grey_test_case_app_interface.h
Effect: Logs |message| from the app process (as opposed to the test process).
Language: Objective-C

Instruction: [BaseEarlGreyTestCaseAppInterface
  enableFasteAnimation
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/base_earl_grey_test_case_app_interface.h
Effect: Adjusts the speed property of CALayer to 100 to speed up XCUITests.
Language: Objective-C

Instruction: [CoverageUtils
  configureCoverageReportPath
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/coverage_utils.h
Effect: On first call in a debug build with IOS_ENABLE_COVERAGE enabled, will set the filename of the coverage file. Will do nothing on subsequent calls, but is safe to call.
Language: Objective-C

Instruction: [CoverageUtils
  resetCoverageProfileCounters
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/coverage_utils.h
Effect: Resets coverage counter and already-dumped flag so that incremental coverage data can be dumped to the same raw coverage data file. This should be called only once in between two write coverage data calls.
Language: Objective-C

Instruction: [CoverageUtils
  writeClangCoverageProfile
]
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/coverage_utils.h
Effect: Writes the raw coverage data to previously configured report path.
Language: Objective-C

Instruction: EARL_GREY_TEST_DISABLED(message)
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/disabled_test_macros.h
Effect: forces an Earl Grey test to pass because of a bug
Language: Objective-C
Extra: Disabling at compile-time is always preferred.
Example:
- (void)testFoo
 if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET) {
  EARL_GREY_TEST_DISABLED(@"Disabled on iPad.");
}
Intuition: disable tests that fail due to a bug. This macro should be used when the configuration for which the test should be disabled can only be determined at runtime

Instruction: EARL_GREY_TEST_SKIPPED(message)
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/disabled_test_macros.h
Effect: forces an Earl Grey test to pass, disabel it for some specific configuration
Language: Objective-C
Extra: A macro that forces an Earl Grey test to pass. This should be used when a test
fails for a specific configuration because it is not supported, but there is no
error. This macro should only be used when the configuration for which the test
should be disabled can only be determined at runtime.
Disabling at compile-time is always preferred.
Example:
- (void)testFoo
if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET) {
  EARL_GREY_TEST_SKIPPED(@"Test not supported on iPad.");
}

Instruction: testing::ButtonWithAccessibilityLabel(label)
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/matchers.h
Language: Objective-C
Returns: Matcher for element with accessibility label corresponding to |label| and accessibility trait UIAccessibilityTraitButton.

Instruction: testing::ElementToDismissAlert(cancel_text)
Page: https://source.chromium.org/chromium/chromium/src/+/main:ios/testing/earl_grey/matchers.h
Language: Objective-C
Returns: Matcher for a UI element to tap to dismiss an alert (e.g. context menu), where |cancel_text| is the localized text used for the action sheet cancel control.
Extra: // On phones, where the alert is an action sheet, this will be a matcher for the
// menu item with |cancel_text| as its label.
// On tablets, where the alert is a popover, this will be a matcher for some
// element outside of the popover.