Fixed formatting in MPPHandLandmarkerTests.m
This commit is contained in:
parent
0ae27fad37
commit
94a9464750
|
@ -167,7 +167,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
- (MPPHandLandmarker *)createHandLandmarkerWithOptionsSucceeds:
|
- (MPPHandLandmarker *)createHandLandmarkerWithOptionsSucceeds:
|
||||||
(MPPHandLandmarkerOptions *)handLandmarkerOptions {
|
(MPPHandLandmarkerOptions *)handLandmarkerOptions {
|
||||||
NSError* error;
|
NSError *error;
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker =
|
||||||
[[MPPHandLandmarker alloc] initWithOptions:handLandmarkerOptions error:&error];
|
[[MPPHandLandmarker alloc] initWithOptions:handLandmarkerOptions error:&error];
|
||||||
XCTAssertNotNil(handLandmarker);
|
XCTAssertNotNil(handLandmarker);
|
||||||
|
@ -298,10 +298,10 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
options.runningMode = runningModesToTest[i];
|
options.runningMode = runningModesToTest[i];
|
||||||
options.handLandmarkerLiveStreamDelegate = self;
|
options.handLandmarkerLiveStreamDelegate = self;
|
||||||
|
|
||||||
[self assertCreateHandLandmarkerWithOptions:options
|
[self
|
||||||
failsWithExpectedError:
|
assertCreateHandLandmarkerWithOptions:options
|
||||||
[NSError
|
failsWithExpectedError:
|
||||||
errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
code:MPPTasksErrorCodeInvalidArgumentError
|
code:MPPTasksErrorCodeInvalidArgumentError
|
||||||
userInfo:@{
|
userInfo:@{
|
||||||
NSLocalizedDescriptionKey :
|
NSLocalizedDescriptionKey :
|
||||||
|
@ -317,33 +317,31 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
options.runningMode = MPPRunningModeLiveStream;
|
options.runningMode = MPPRunningModeLiveStream;
|
||||||
|
|
||||||
[self
|
[self assertCreateHandLandmarkerWithOptions:options
|
||||||
assertCreateHandLandmarkerWithOptions:options
|
failsWithExpectedError:
|
||||||
failsWithExpectedError:
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
code:MPPTasksErrorCodeInvalidArgumentError
|
||||||
code:MPPTasksErrorCodeInvalidArgumentError
|
userInfo:@{
|
||||||
userInfo:@{
|
NSLocalizedDescriptionKey :
|
||||||
NSLocalizedDescriptionKey :
|
@"The vision task is in live stream mode. An "
|
||||||
@"The vision task is in live stream mode. An "
|
@"object must be set as the delegate of the task "
|
||||||
@"object must be set as the delegate of the task "
|
@"in its options to ensure asynchronous delivery "
|
||||||
@"in its options to ensure asynchronous delivery "
|
@"of results."
|
||||||
@"of results."
|
}]];
|
||||||
}]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testDetectFailsWithCallingWrongApiInImageMode {
|
- (void)testDetectFailsWithCallingWrongApiInImageMode {
|
||||||
MPPHandLandmarkerOptions *options =
|
MPPHandLandmarkerOptions *options =
|
||||||
[self handLandmarkerOptionsWithModelFileInfo:kHandLandmarkerBundleAssetFile];
|
[self handLandmarkerOptionsWithModelFileInfo:kHandLandmarkerBundleAssetFile];
|
||||||
|
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:options];
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:options];
|
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
NSError *liveStreamApiCallError;
|
NSError *liveStreamApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&liveStreamApiCallError]);
|
error:&liveStreamApiCallError]);
|
||||||
|
|
||||||
NSError *expectedLiveStreamApiCallError =
|
NSError *expectedLiveStreamApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -357,8 +355,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
NSError *videoApiCallError;
|
NSError *videoApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectInVideoFrame:image
|
XCTAssertFalse([handLandmarker detectInVideoFrame:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&videoApiCallError]);
|
error:&videoApiCallError]);
|
||||||
|
|
||||||
NSError *expectedVideoApiCallError =
|
NSError *expectedVideoApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -375,15 +373,14 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
[self handLandmarkerOptionsWithModelFileInfo:kHandLandmarkerBundleAssetFile];
|
[self handLandmarkerOptionsWithModelFileInfo:kHandLandmarkerBundleAssetFile];
|
||||||
options.runningMode = MPPRunningModeVideo;
|
options.runningMode = MPPRunningModeVideo;
|
||||||
|
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:options];
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:options];
|
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
NSError *liveStreamApiCallError;
|
NSError *liveStreamApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&liveStreamApiCallError]);
|
error:&liveStreamApiCallError]);
|
||||||
|
|
||||||
NSError *expectedLiveStreamApiCallError =
|
NSError *expectedLiveStreamApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -414,8 +411,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
options.runningMode = MPPRunningModeLiveStream;
|
options.runningMode = MPPRunningModeLiveStream;
|
||||||
options.handLandmarkerLiveStreamDelegate = self;
|
options.handLandmarkerLiveStreamDelegate = self;
|
||||||
|
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:options];
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:options];
|
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
|
@ -433,8 +429,8 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
NSError *videoApiCallError;
|
NSError *videoApiCallError;
|
||||||
XCTAssertFalse([handLandmarker detectInVideoFrame:image
|
XCTAssertFalse([handLandmarker detectInVideoFrame:image
|
||||||
timestampInMilliseconds:0
|
timestampInMilliseconds:0
|
||||||
error:&videoApiCallError]);
|
error:&videoApiCallError]);
|
||||||
|
|
||||||
NSError *expectedVideoApiCallError =
|
NSError *expectedVideoApiCallError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -451,17 +447,16 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
[self handLandmarkerOptionsWithModelFileInfo:kHandLandmarkerBundleAssetFile];
|
[self handLandmarkerOptionsWithModelFileInfo:kHandLandmarkerBundleAssetFile];
|
||||||
options.runningMode = MPPRunningModeVideo;
|
options.runningMode = MPPRunningModeVideo;
|
||||||
|
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:options];
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:options];
|
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
MPPHandLandmarkerResult *handLandmarkerResult =
|
MPPHandLandmarkerResult *handLandmarkerResult = [handLandmarker detectInVideoFrame:image
|
||||||
[handLandmarker detectInVideoFrame:image timestampInMilliseconds:i error:nil];
|
timestampInMilliseconds:i
|
||||||
|
error:nil];
|
||||||
[self assertHandLandmarkerResult:handLandmarkerResult
|
[self assertHandLandmarkerResult:handLandmarkerResult
|
||||||
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests
|
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests thumbUpHandLandmarkerResult]];
|
||||||
thumbUpHandLandmarkerResult]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,8 +471,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
expectation.expectedFulfillmentCount = 1;
|
expectation.expectedFulfillmentCount = 1;
|
||||||
|
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:options];
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:options];
|
|
||||||
|
|
||||||
_outOfOrderTimestampTestDict = @{
|
_outOfOrderTimestampTestDict = @{
|
||||||
kLiveStreamTestsDictHandLandmarkerKey : handLandmarker,
|
kLiveStreamTestsDictHandLandmarkerKey : handLandmarker,
|
||||||
|
@ -489,9 +483,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
XCTAssertTrue([handLandmarker detectAsyncInImage:image timestampInMilliseconds:1 error:nil]);
|
XCTAssertTrue([handLandmarker detectAsyncInImage:image timestampInMilliseconds:1 error:nil]);
|
||||||
|
|
||||||
NSError *error;
|
NSError *error;
|
||||||
XCTAssertFalse([handLandmarker detectAsyncInImage:image
|
XCTAssertFalse([handLandmarker detectAsyncInImage:image timestampInMilliseconds:0 error:&error]);
|
||||||
timestampInMilliseconds:0
|
|
||||||
error:&error]);
|
|
||||||
|
|
||||||
NSError *expectedError =
|
NSError *expectedError =
|
||||||
[NSError errorWithDomain:kExpectedErrorDomain
|
[NSError errorWithDomain:kExpectedErrorDomain
|
||||||
|
@ -528,8 +520,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
expectation.expectedFulfillmentCount = iterationCount + 1;
|
expectation.expectedFulfillmentCount = iterationCount + 1;
|
||||||
expectation.inverted = YES;
|
expectation.inverted = YES;
|
||||||
|
|
||||||
MPPHandLandmarker *handLandmarker =
|
MPPHandLandmarker *handLandmarker = [self createHandLandmarkerWithOptionsSucceeds:options];
|
||||||
[self createHandLandmarkerWithOptionsSucceeds:options];
|
|
||||||
|
|
||||||
_liveStreamSucceedsTestDict = @{
|
_liveStreamSucceedsTestDict = @{
|
||||||
kLiveStreamTestsDictHandLandmarkerKey : handLandmarker,
|
kLiveStreamTestsDictHandLandmarkerKey : handLandmarker,
|
||||||
|
@ -542,9 +533,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
MPPImage *image = [self imageWithFileInfo:kThumbUpImage];
|
||||||
|
|
||||||
for (int i = 0; i < iterationCount; i++) {
|
for (int i = 0; i < iterationCount; i++) {
|
||||||
XCTAssertTrue([handLandmarker detectAsyncInImage:image
|
XCTAssertTrue([handLandmarker detectAsyncInImage:image timestampInMilliseconds:i error:nil]);
|
||||||
timestampInMilliseconds:i
|
|
||||||
error:nil]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSTimeInterval timeout = 0.5f;
|
NSTimeInterval timeout = 0.5f;
|
||||||
|
@ -553,19 +542,16 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
|
|
||||||
- (void)handLandmarker:(MPPHandLandmarker *)handLandmarker
|
- (void)handLandmarker:(MPPHandLandmarker *)handLandmarker
|
||||||
didFinishDetectionWithResult:(MPPHandLandmarkerResult *)handLandmarkerResult
|
didFinishDetectionWithResult:(MPPHandLandmarkerResult *)handLandmarkerResult
|
||||||
timestampInMilliseconds:(NSInteger)timestampInMilliseconds
|
timestampInMilliseconds:(NSInteger)timestampInMilliseconds
|
||||||
error:(NSError *)error {
|
error:(NSError *)error {
|
||||||
[self assertHandLandmarkerResult:handLandmarkerResult
|
[self assertHandLandmarkerResult:handLandmarkerResult
|
||||||
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests
|
isApproximatelyEqualToExpectedResult:[MPPHandLandmarkerTests thumbUpHandLandmarkerResult]];
|
||||||
thumbUpHandLandmarkerResult]];
|
|
||||||
|
|
||||||
if (handLandmarker == _outOfOrderTimestampTestDict[kLiveStreamTestsDictHandLandmarkerKey]) {
|
if (handLandmarker == _outOfOrderTimestampTestDict[kLiveStreamTestsDictHandLandmarkerKey]) {
|
||||||
[_outOfOrderTimestampTestDict[kLiveStreamTestsDictExpectationKey] fulfill];
|
[_outOfOrderTimestampTestDict[kLiveStreamTestsDictExpectationKey] fulfill];
|
||||||
} else if (handLandmarker ==
|
} else if (handLandmarker == _liveStreamSucceedsTestDict[kLiveStreamTestsDictHandLandmarkerKey]) {
|
||||||
_liveStreamSucceedsTestDict[kLiveStreamTestsDictHandLandmarkerKey]) {
|
|
||||||
[_liveStreamSucceedsTestDict[kLiveStreamTestsDictExpectationKey] fulfill];
|
[_liveStreamSucceedsTestDict[kLiveStreamTestsDictExpectationKey] fulfill];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user