pinlu 3 жил өмнө
parent
commit
89649b130b

+ 4 - 8
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 <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);
 
@@ -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

+ 22 - 1
GoogleSignIn/Sources/GIDAuthorizationFlowProcessor/Implementations/Fakes/GIDFakeAuthorizationFlowProcessor.m

@@ -1,5 +1,27 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #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
@@ -8,7 +30,6 @@
                                    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);
   });

+ 5 - 12
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 @@ static NSString *const kNewScope = @"newScope";
   // Fake for `GIDHTTPFetcher`.
   GIDFakeHTTPFetcher *_httpFetcher;
   
-  // Fake for `GIDAuthorizationFlowProcessor`
+  // Fake for `GIDAuthorizationFlowProcessor`.
   GIDFakeAuthorizationFlowProcessor *_authorizationFlowProcessor;
 
   // Fake for `GIDProfileDataFetcher`.
@@ -281,14 +282,6 @@ static NSString *const kNewScope = @"newScope";
   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 @@ static NSString *const kNewScope = @"newScope";
   // 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;