Skip to content

Commit 7ec13fc

Browse files
Internal Commit Uploaded
PiperOrigin-RevId: 689147058
1 parent 43f2a6e commit 7ec13fc

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

AppFramework/Config/GREYAppConfiguration.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static BOOL IsStandaloneMode(void) {
126126
kGREYConfigKeyInteractionTimeoutDuration : @(30),
127127
kGREYConfigKeyCALayerMaxAnimationDuration : @(10),
128128
kGREYConfigKeySynchronizationEnabled : @YES,
129+
kGREYConfigKeyMainQueueTrackingEnabled : @YES,
129130
kGREYConfigKeyNSTimerMaxTrackableInterval : @(1.5),
130131
kGREYConfigKeyCALayerModifyAnimations : @YES,
131132
kGREYConfigKeyDispatchAfterMaxTrackableDelay : @(1.5),

AppFramework/IdlingResources/GREYDispatchQueueIdlingResource.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ - (BOOL)isIdleNow {
6565
if (trackerIsIdle && isDead) {
6666
[[GREYUIThreadExecutor sharedInstance] deregisterIdlingResource:self];
6767
}
68-
return trackerIsIdle;
68+
// In apps with unusually high main thread activity, the main thread may never be condidered
69+
// idle, or may only rarely become idle. This is a safety valve to allow this tracker to be
70+
// selectively disabled, because otherwise, tests that should take seconds can take minues or
71+
// even hours.
72+
BOOL mainQueueTrackingEnabled = [GREYConfiguration.sharedConfiguration valueForConfigKey:kGREYConfigKeyMainQueueTrackingEnabled];
73+
return trackerIsIdle || !mainQueueTrackingEnabled;
6974
}
7075

7176
@end

CommonLib/Config/GREYConfigKey.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ GREY_EXTERN GREYConfigKey const kGREYConfigKeyInteractionTimeoutDuration;
5454
*/
5555
GREY_EXTERN GREYConfigKey const kGREYConfigKeySynchronizationEnabled;
5656

57+
/**
58+
* Configuration that enables or disables EarlGrey's main queue tracking. When disabled, Earl Grey
59+
* will not wait for the main queue to become idle. All other synchronization remains enabled.
60+
*
61+
* @remark This can make apps with high levels of main thread activity testable. If you find
62+
* yourself having to enable this, you should actively look for ways to move activity off of the
63+
* main thread if at all possible, for both performance and battery life reasons.
64+
*/
65+
GREY_EXTERN GREYConfigKey const kGREYConfigKeyMainQueueTrackingEnabled;
66+
5767
/**
5868
* Configuration that enables synchronization for different app state. By default, EarlGrey will
5969
* wait for all tracked app state resources to be idle. Set this config value to options with @c

CommonLib/Config/GREYConfigKey.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
GREYConfigKey const kGREYConfigKeyInteractionTimeoutDuration =
2222
@"GREYConfigKeyInteractionTimeoutDuration";
2323
GREYConfigKey const kGREYConfigKeySynchronizationEnabled = @"GREYConfigKeySynchronizationEnabled";
24+
GREYConfigKey const kGREYConfigKeyMainQueueTrackingEnabled = @"GREYConfigKeyMainQueueTrackingEnabled";
2425
GREYConfigKey const kGREYConfigKeyNSTimerMaxTrackableInterval =
2526
@"GREYConfigKeyNSTimerMaxTrackableInterval";
2627
GREYConfigKey const kGREYConfigKeyCALayerModifyAnimations = @"GREYConfigKeyCALayerModifyAnimations";

0 commit comments

Comments
 (0)