From df7f7802968909a29c186c005223774ef7fabc1a Mon Sep 17 00:00:00 2001 From: pinlu Date: Thu, 19 Jan 2023 15:57:24 -0800 Subject: [PATCH] Improve style. --- .../Fakes/GIDFakeAuthorizationFlowProcessor.h | 2 +- .../Fakes/GIDFakeAuthorizationFlowProcessor.m | 1 - GoogleSignIn/Tests/Unit/GIDSignInTest.m | 13 ++++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h index ac4a5d98..f8ce6128 100644 --- a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h +++ b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN /// The block type providing the response for the method `startWithOptions:emmSupport:completion:`. /// /// @param authorizationResponse The `OIDAuthorizationResponse` object returned on success. -/// @param error The error returned on failure. +/// @param error An `NSError` returned on failure. typedef void(^GIDAuthorizationFlowProcessorFakeResponseProviderBlock) (OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error); diff --git a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m index 57376f98..7077fd44 100644 --- a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m +++ b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m @@ -41,7 +41,6 @@ - (BOOL)isStarted { } - (BOOL)resumeExternalUserAgentFlowWithURL:(NSURL *)url { - NSAssert(NO, @"Not implemented."); return YES; } diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 5e3d593e..0bc9b0e6 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -104,9 +104,7 @@ static NSString * const kFakeUserFamilyName = @"username"; static NSString * const kFakeUserPictureURL = @"fake_user_picture_url"; -static NSString * const kContinueURL = @"com.google.UnitTests:/oauth2callback"; -static NSString * const kContinueURLWithClientID = @"FakeClientID:/oauth2callback"; -static NSString * const kWrongSchemeURL = @"wrong.app:/oauth2callback"; +static NSString * const kRightPathURL = @"com.google.UnitTests:/oauth2callback"; static NSString * const kWrongPathURL = @"com.google.UnitTests:/wrong_path"; static NSString * const kEMMRestartAuthURL = @@ -572,6 +570,11 @@ - (void)testSignOut { XCTAssertNil([_keychainHandler loadAuthState]); } +- (void)testHandleRightPath { + XCTAssertTrue([_signIn handleURL:[NSURL URLWithString:kRightPathURL]]); + XCTAssertFalse(_completionCalled, @"should not call delegate"); +} + - (void)testNotHandleWrongPath { XCTAssertFalse([_signIn handleURL:[NSURL URLWithString:kWrongPathURL]], @"should not handle URL"); XCTAssertFalse(_completionCalled, @"should not call delegate"); @@ -1077,10 +1080,10 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow // Mock `maybeFetchToken:` method in Sign in flow. if (!(authError || modalCancel)) { [[[_authState expect] andReturn:nil] lastTokenResponse]; - #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST +#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST // Corresponds to EMM support [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse]; - #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST +#endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST [[[_authState expect] andReturn:nil] lastTokenResponse]; [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse]; [[[_authState expect] andReturn:authResponse] lastAuthorizationResponse];