Skip to content

Commit

Permalink
Improve style.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-4-Git committed Jan 18, 2023
1 parent 2d60ea9 commit c54f930
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@

#import "GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/API/GIDAuthorizationFlowProcessor.h"

#ifdef SWIFT_PACKAGE
@import AppAuth;
#else
#import <AppAuth/AppAuth.h>
#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);

Expand All @@ -40,12 +36,12 @@ typedef void(^GIDAuthorizationFlowProcessorFakeResponseProviderBlock)
typedef void (^GIDAuthorizationFlowProcessorTestBlock)
(GIDAuthorizationFlowProcessorFakeResponseProviderBlock responseProvider);

/// The fake implementation of the protocol `GIDAuthorizationFlowProcessor`.
@interface GIDFakeAuthorizationFlowProcessor : NSObject <GIDAuthorizationFlowProcessor>

/// The test block which provides the response value.
@property(nonatomic) GIDAuthorizationFlowProcessorTestBlock testBlock;


@end

NS_ASSUME_NONNULL_END
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#import "GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.h"

#ifdef SWIFT_PACKAGE
@import AppAuth;
#else
#import <AppAuth/AppAuth.h>
#endif

@implementation GIDFakeAuthorizationFlowProcessor

- (void)startWithOptions:(GIDSignInInternalOptions *)options
Expand All @@ -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);
});
Expand Down
17 changes: 5 additions & 12 deletions GoogleSignIn/Tests/Unit/GIDSignInTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -192,7 +193,7 @@ @interface GIDSignInTest : XCTestCase {
// Fake for `GIDHTTPFetcher`.
GIDFakeHTTPFetcher *_httpFetcher;

// Fake for `GIDAuthorizationFlowProcessor`
// Fake for `GIDAuthorizationFlowProcessor`.
GIDFakeAuthorizationFlowProcessor *_authorizationFlowProcessor;

// Fake for `GIDProfileDataFetcher`.
Expand Down Expand Up @@ -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)]);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit c54f930

Please sign in to comment.