diff --git a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h index 25b91e9d..ac4a5d98 100644 --- a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h +++ b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h @@ -18,18 +18,14 @@ #import "GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/API/GIDAuthorizationFlowProcessor.h" -#ifdef SWIFT_PACKAGE -@import AppAuth; -#else -#import -#endif +@class OIDAuthorizationResponse; NS_ASSUME_NONNULL_BEGIN /// The block type providing the response for the method `startWithOptions:emmSupport:completion:`. /// -/// @param authorizationResponse The OIDAuthorizationResponse object returned if succeeded. -/// @param error The error returned if failed. +/// @param authorizationResponse The `OIDAuthorizationResponse` object returned on success. +/// @param error The error returned on failure. typedef void(^GIDAuthorizationFlowProcessorFakeResponseProviderBlock) (OIDAuthorizationResponse *_Nullable authorizationResponse, NSError *_Nullable error); @@ -40,12 +36,12 @@ typedef void(^GIDAuthorizationFlowProcessorFakeResponseProviderBlock) typedef void (^GIDAuthorizationFlowProcessorTestBlock) (GIDAuthorizationFlowProcessorFakeResponseProviderBlock responseProvider); +/// The fake implementation of the protocol `GIDAuthorizationFlowProcessor`. @interface GIDFakeAuthorizationFlowProcessor : NSObject /// The test block which provides the response value. @property(nonatomic) GIDAuthorizationFlowProcessorTestBlock testBlock; - @end NS_ASSUME_NONNULL_END diff --git a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m index 49ac355a..eefe0097 100644 --- a/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m +++ b/GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m @@ -1,5 +1,11 @@ #import "GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h" +#ifdef SWIFT_PACKAGE +@import AppAuth; +#else +#import +#endif + @implementation GIDFakeAuthorizationFlowProcessor - (void)startWithOptions:(GIDSignInInternalOptions *)options @@ -8,7 +14,6 @@ - (void)startWithOptions:(GIDSignInInternalOptions *)options NSError *_Nullable error))completion { NSAssert(self.testBlock != nil, @"Set the test block before invoking this method."); - self.testBlock(^(OIDAuthorizationResponse *authorizationResponse, NSError *error) { completion(authorizationResponse, error); }); diff --git a/GoogleSignIn/Tests/Unit/GIDSignInTest.m b/GoogleSignIn/Tests/Unit/GIDSignInTest.m index 50a30c3a..7817f0c1 100644 --- a/GoogleSignIn/Tests/Unit/GIDSignInTest.m +++ b/GoogleSignIn/Tests/Unit/GIDSignInTest.m @@ -26,6 +26,7 @@ // Test module imports @import GoogleSignIn; +#import "GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/API/GIDAuthorizationFlowProcessor.h" #import "GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h" #import "GoogleSignIn/Sources/GIDEMMSupport.h" #import "GoogleSignIn/Sources/GIDGoogleUser_Private.h" @@ -192,7 +193,7 @@ @interface GIDSignInTest : XCTestCase { // Fake for `GIDHTTPFetcher`. GIDFakeHTTPFetcher *_httpFetcher; - // Fake for `GIDAuthorizationFlowProcessor` + // Fake for `GIDAuthorizationFlowProcessor`. GIDFakeAuthorizationFlowProcessor *_authorizationFlowProcessor; // Fake for `GIDProfileDataFetcher`. @@ -281,14 +282,6 @@ - (void)setUp { OCMStub([_authorization initWithAuthState:OCMOCK_ANY]).andReturn(_authorization); _user = OCMStrictClassMock([GIDGoogleUser class]); _oidAuthorizationService = OCMStrictClassMock([OIDAuthorizationService class]); -// OCMStub([_oidAuthorizationService -// presentAuthorizationRequest:OCMOCK_ANY -//#if TARGET_OS_IOS || TARGET_OS_MACCATALYST -// presentingViewController:SAVE_TO_ARG_BLOCK(self->_savedPresentingViewController) -//#elif TARGET_OS_OSX -// presentingWindow:SAVE_TO_ARG_BLOCK(self->_savedPresentingWindow) -//#endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST -// callback:COPY_TO_ARG_BLOCK(self->_savedAuthorizationCallback)]); OCMStub([self->_oidAuthorizationService performTokenRequest:SAVE_TO_ARG_BLOCK(self->_savedTokenRequest) callback:COPY_TO_ARG_BLOCK(self->_savedTokenCallback)]); @@ -1054,9 +1047,9 @@ - (void)OAuthLoginWithAddScopesFlow:(BOOL)addScopesFlow // Set the response for `GIDProfileDataFetcher`. GIDProfileDataFetcherTestBlock profileDataFetcherTestBlock = ^(GIDProfileDataFetcherFakeResponseProvider responseProvider) { - GIDProfileData *profileData = [GIDProfileData testInstance]; - responseProvider(profileData, nil); - }; + GIDProfileData *profileData = [GIDProfileData testInstance]; + responseProvider(profileData, nil); + }; _profileDataFetcher.testBlock = profileDataFetcherTestBlock;