Skip to content

Commit

Permalink
Internal Commit Uploaded
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 689147058
  • Loading branch information
mobile-devx-github-bot committed Oct 23, 2024
1 parent 43f2a6e commit 2f21dce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions AppFramework/Config/GREYAppConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static BOOL IsStandaloneMode(void) {
kGREYConfigKeyInteractionTimeoutDuration : @(30),
kGREYConfigKeyCALayerMaxAnimationDuration : @(10),
kGREYConfigKeySynchronizationEnabled : @YES,
kGREYConfigKeyMainQueueTrackingEnabled : @YES,
kGREYConfigKeyNSTimerMaxTrackableInterval : @(1.5),
kGREYConfigKeyCALayerModifyAnimations : @YES,
kGREYConfigKeyDispatchAfterMaxTrackableDelay : @(1.5),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ - (BOOL)isIdleNow {
if (trackerIsIdle && isDead) {
[[GREYUIThreadExecutor sharedInstance] deregisterIdlingResource:self];
}
return trackerIsIdle;
// In apps with unusually high main thread activity, the main thread may never be condidered
// idle, or may only rarely become idle. This is a safety valve to allow this tracker to be
// selectively disabled, because otherwise, tests that should take seconds can take minues or
// even hours.
BOOL mainQueueTrackingEnabled = [GREYConfiguration.sharedConfiguration
valueForConfigKey:kGREYConfigKeyMainQueueTrackingEnabled];
return trackerIsIdle || !mainQueueTrackingEnabled;
}

@end
10 changes: 10 additions & 0 deletions CommonLib/Config/GREYConfigKey.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ GREY_EXTERN GREYConfigKey const kGREYConfigKeyInteractionTimeoutDuration;
*/
GREY_EXTERN GREYConfigKey const kGREYConfigKeySynchronizationEnabled;

/**
* Configuration that enables or disables EarlGrey's main queue tracking. When disabled, Earl Grey
* will not wait for the main queue to become idle. All other synchronization remains enabled.
*
* @remark This can make apps with high levels of main thread activity testable. If you find
* yourself having to enable this, you should actively look for ways to move activity off of the
* main thread if at all possible, for both performance and battery life reasons.
*/
GREY_EXTERN GREYConfigKey const kGREYConfigKeyMainQueueTrackingEnabled;

/**
* Configuration that enables synchronization for different app state. By default, EarlGrey will
* wait for all tracked app state resources to be idle. Set this config value to options with @c
Expand Down
2 changes: 2 additions & 0 deletions CommonLib/Config/GREYConfigKey.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
GREYConfigKey const kGREYConfigKeyInteractionTimeoutDuration =
@"GREYConfigKeyInteractionTimeoutDuration";
GREYConfigKey const kGREYConfigKeySynchronizationEnabled = @"GREYConfigKeySynchronizationEnabled";
GREYConfigKey const kGREYConfigKeyMainQueueTrackingEnabled =
@"GREYConfigKeyMainQueueTrackingEnabled";
GREYConfigKey const kGREYConfigKeyNSTimerMaxTrackableInterval =
@"GREYConfigKeyNSTimerMaxTrackableInterval";
GREYConfigKey const kGREYConfigKeyCALayerModifyAnimations = @"GREYConfigKeyCALayerModifyAnimations";
Expand Down

0 comments on commit 2f21dce

Please sign in to comment.