Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions WebDriverAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@
64B2650B228CE4FF002A5025 /* FBTVNavigationTracker-Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 64B26509228CE4FF002A5025 /* FBTVNavigationTracker-Private.h */; };
64E3502E2AC0B6EB005F3ACB /* NSDictionary+FBUtf8SafeDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 716F0DA02A16CA1000CDD977 /* NSDictionary+FBUtf8SafeDictionary.m */; };
64E3502F2AC0B6FE005F3ACB /* NSDictionary+FBUtf8SafeDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 716F0D9F2A16CA1000CDD977 /* NSDictionary+FBUtf8SafeDictionary.h */; };
6F2059772E4E0E3500E9D188 /* NSRunLoop+Monotonic.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F2059762E4E0E3500E9D188 /* NSRunLoop+Monotonic.m */; };
6F2059782E4E0E3500E9D188 /* NSRunLoop+Monotonic.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F2059752E4E0E3500E9D188 /* NSRunLoop+Monotonic.h */; };
6F2059792E4E0E3500E9D188 /* NSRunLoop+Monotonic.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F2059752E4E0E3500E9D188 /* NSRunLoop+Monotonic.h */; };
6F20597A2E4E0E3500E9D188 /* NSRunLoop+Monotonic.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F2059762E4E0E3500E9D188 /* NSRunLoop+Monotonic.m */; };
711084441DA3AA7500F913D6 /* FBXPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 711084421DA3AA7500F913D6 /* FBXPath.h */; settings = {ATTRIBUTES = (Public, ); }; };
711084451DA3AA7500F913D6 /* FBXPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 711084431DA3AA7500F913D6 /* FBXPath.m */; };
7119097C2152580600BA3C7E /* XCUIScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 7119097B2152580600BA3C7E /* XCUIScreen.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -968,6 +972,8 @@
64B26506228C54F2002A5025 /* XCUIElementDouble.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XCUIElementDouble.h; sourceTree = "<group>"; };
64B26507228C5514002A5025 /* XCUIElementDouble.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XCUIElementDouble.m; sourceTree = "<group>"; };
64B26509228CE4FF002A5025 /* FBTVNavigationTracker-Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FBTVNavigationTracker-Private.h"; sourceTree = "<group>"; };
6F2059752E4E0E3500E9D188 /* NSRunLoop+Monotonic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSRunLoop+Monotonic.h"; sourceTree = "<group>"; };
6F2059762E4E0E3500E9D188 /* NSRunLoop+Monotonic.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSRunLoop+Monotonic.m"; sourceTree = "<group>"; };
711084421DA3AA7500F913D6 /* FBXPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBXPath.h; sourceTree = "<group>"; };
711084431DA3AA7500F913D6 /* FBXPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBXPath.m; sourceTree = "<group>"; };
7119097B2152580600BA3C7E /* XCUIScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCUIScreen.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1747,6 +1753,8 @@
EE9AB73E1CAEDF0C008C271F /* Categories */ = {
isa = PBXGroup;
children = (
6F2059752E4E0E3500E9D188 /* NSRunLoop+Monotonic.h */,
6F2059762E4E0E3500E9D188 /* NSRunLoop+Monotonic.m */,
716F0D9F2A16CA1000CDD977 /* NSDictionary+FBUtf8SafeDictionary.h */,
716F0DA02A16CA1000CDD977 /* NSDictionary+FBUtf8SafeDictionary.m */,
71555A3B1DEC460A007D4A8B /* NSExpression+FBFormat.h */,
Expand Down Expand Up @@ -2396,6 +2404,7 @@
641EE6802240C5CA00173FCB /* FBElementTypeTransformer.h in Headers */,
641EE6812240C5CA00173FCB /* FBXCAXClientProxy.h in Headers */,
641EE6822240C5CA00173FCB /* FBElementCache.h in Headers */,
6F2059782E4E0E3500E9D188 /* NSRunLoop+Monotonic.h in Headers */,
641EE6832240C5CA00173FCB /* XCTMetric.h in Headers */,
641EE6842240C5CA00173FCB /* XCTestContextScope.h in Headers */,
7182271D258744AB00661B83 /* RouteResponse.h in Headers */,
Expand Down Expand Up @@ -2712,6 +2721,7 @@
EE35AD261E3B77D600A02D78 /* XCApplicationMonitor_iOS.h in Headers */,
0E04133B2DF1E15900AF007C /* XCUIElement+FBMinMax.h in Headers */,
EE3A18661CDE734B00DE4205 /* FBKeyboard.h in Headers */,
6F2059792E4E0E3500E9D188 /* NSRunLoop+Monotonic.h in Headers */,
AD6C269C1CF2494200F8B5FF /* XCUIApplication+FBHelpers.h in Headers */,
714D88CC2733FB970074A925 /* FBXMLGenerationOptions.h in Headers */,
EE35AD101E3B77D600A02D78 /* _XCTestObservationCenterImplementation.h in Headers */,
Expand Down Expand Up @@ -3225,6 +3235,7 @@
71BB58F22B96511800CB9BFE /* FBVideoCommands.m in Sources */,
641EE61F2240C5CA00173FCB /* FBXCodeCompatibility.m in Sources */,
71E75E70254824230099FC87 /* XCUIElementQuery+FBHelpers.m in Sources */,
6F2059772E4E0E3500E9D188 /* NSRunLoop+Monotonic.m in Sources */,
641EE6212240C5CA00173FCB /* FBElementTypeTransformer.m in Sources */,
13DE7A5E287CA444003243C6 /* FBXCElementSnapshotWrapper+Helpers.m in Sources */,
641EE6232240C5CA00173FCB /* FBScreen.m in Sources */,
Expand Down Expand Up @@ -3268,6 +3279,7 @@
71555A3E1DEC460A007D4A8B /* NSExpression+FBFormat.m in Sources */,
AD6C269D1CF2494200F8B5FF /* XCUIApplication+FBHelpers.m in Sources */,
EE3A18671CDE734B00DE4205 /* FBKeyboard.m in Sources */,
6F20597A2E4E0E3500E9D188 /* NSRunLoop+Monotonic.m in Sources */,
719DCF172601EAFB000E765F /* FBNotificationsHelper.m in Sources */,
E444DCAC24913C220060D7EB /* Route.m in Sources */,
713C6DD01DDC772A00285B92 /* FBElementUtils.m in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions WebDriverAgentLib/Categories/NSRunLoop+Monotonic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>

@interface NSRunLoop (Monotonic)
- (void)runForMonotonicInterval:(NSTimeInterval)seconds;
Comment thread
codeskyblue marked this conversation as resolved.
Comment thread
KazuCocoa marked this conversation as resolved.
@end
13 changes: 13 additions & 0 deletions WebDriverAgentLib/Categories/NSRunLoop+Monotonic.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "NSRunLoop+Monotonic.h"
#import <QuartzCore/QuartzCore.h> // 为了用 CACurrentMediaTime()
Comment thread
codeskyblue marked this conversation as resolved.
Outdated

@implementation NSRunLoop (Monotonic)

- (void)runForMonotonicInterval:(NSTimeInterval)seconds {
CFTimeInterval end = CACurrentMediaTime() + seconds;
while (CACurrentMediaTime() < end) {
[self runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
Comment thread
KazuCocoa marked this conversation as resolved.
Outdated
}
}

@end
5 changes: 3 additions & 2 deletions WebDriverAgentLib/Utilities/FBRunLoopSpinner.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <stdatomic.h>

#import "FBErrorBuilder.h"
#import "NSRunLoop+Monotonic.h"

static const NSTimeInterval FBWaitInterval = 0.1;

Expand All @@ -30,7 +31,7 @@ + (void)spinUntilCompletion:(void (^)(void(^completion)(void)))block
atomic_fetch_or(&didFinish, true);
});
while (!atomic_fetch_and(&didFinish, false)) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:FBWaitInterval]];
[[NSRunLoop currentRunLoop] runForMonotonicInterval:FBWaitInterval];
}
}

Expand Down Expand Up @@ -71,7 +72,7 @@ - (BOOL)spinUntilTrue:(FBRunLoopSpinnerBlock)untilTrue error:(NSError **)error
{
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:self.timeout];
while (!untilTrue()) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:self.interval]];
Comment thread
codeskyblue marked this conversation as resolved.
[[NSRunLoop currentRunLoop] runForMonotonicInterval:self.interval];
if (timeoutDate.timeIntervalSinceNow < 0) {
return
[[[FBErrorBuilder builder]
Expand Down
Loading