Fixed formatting in MPPHandLandmarkerTests.m

This commit is contained in:
Prianka Liz Kariat 2023-06-14 15:52:26 +05:30
parent 0ae27fad37
commit 94a9464750

View File

@ -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
assertCreateHandLandmarkerWithOptions:options
failsWithExpectedError: failsWithExpectedError:
[NSError [NSError errorWithDomain:kExpectedErrorDomain
errorWithDomain:kExpectedErrorDomain
code:MPPTasksErrorCodeInvalidArgumentError code:MPPTasksErrorCodeInvalidArgumentError
userInfo:@{ userInfo:@{
NSLocalizedDescriptionKey : NSLocalizedDescriptionKey :
@ -317,8 +317,7 @@ 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
@ -335,8 +334,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
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];
@ -375,8 +373,7 @@ 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];
@ -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];
@ -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;
@ -556,16 +545,13 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
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