Kaynağa Gözat

Improve documentation and style.

pinlu 3 yıl önce
ebeveyn
işleme
a81e1aa716

+ 6 - 6
GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.h

@@ -22,14 +22,14 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-/// The block which provides the response for user info request.
+/// The block type providing the response for user info request.
 ///
-/// @param profileData The `GIDProfileData` object returned if succeeded.
-/// @param error The error returned if failed.
+/// @param profileData The `GIDProfileData` object returned on success.
+/// @param error The error returned on failure.
 typedef void (^GIDProfileDataFetcherFakeResponseProvider)(GIDProfileData *_Nullable profileData,
                                                           NSError *_Nullable error);
 
-/// The block to set up the response value.
+/// The block type setting up the response value.
 ///
 /// @param responseProvider The block which provides the response.
 typedef void (^GIDProfileDataFetcherTestBlock)(GIDProfileDataFetcherFakeResponseProvider
@@ -37,8 +37,8 @@ typedef void (^GIDProfileDataFetcherTestBlock)(GIDProfileDataFetcherFakeResponse
 
 @interface GIDFakeProfileDataFetcher : NSObject <GIDProfileDataFetcher>
 
-/// Set the test block which provides the response value.
-- (void)setTestBlock:(GIDProfileDataFetcherTestBlock)block;
+/// The test block to set up the response value.
+@property(nonatomic) GIDProfileDataFetcherTestBlock testBlock;
 
 @end
 

+ 1 - 7
GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.m

@@ -10,12 +10,6 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface GIDFakeProfileDataFetcher ()
-
-@property(nonatomic) GIDProfileDataFetcherTestBlock testBlock;
-
-@end
-
 @implementation GIDFakeProfileDataFetcher
 
 - (void)fetchProfileDataWithAuthState:(OIDAuthState *)authState
@@ -27,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
   });
 }
 
-- (nullable GIDProfileData*)fetchProfileDataWithIDToken:(OIDIDToken *)idToken {
+- (nullable GIDProfileData *)fetchProfileDataWithIDToken:(OIDIDToken *)idToken {
   NSAssert(self.testBlock != nil, @"Set the test block before invoking this method.");
   __block GIDProfileData *profileDataToReturn;
   self.testBlock(^(GIDProfileData *_Nullable profileData, NSError *_Nullable error) {

+ 19 - 19
GoogleSignIn/Tests/Unit/GIDSignInTest.m

@@ -34,6 +34,7 @@
 #import "GoogleSignIn/Sources/GIDKeychainHandler/Implementations/Fakes/GIDFakeKeychainHandler.h"
 #import "GoogleSignIn/Sources/GIDHTTPFetcher/Implementations/Fakes/GIDFakeHTTPFetcher.h"
 #import "GoogleSignIn/Sources/GIDHTTPFetcher/Implementations/GIDHTTPFetcher.h"
+#import "GoogleSignIn/Sources/GIDProfileDataFetcher/API/GIDProfileDataFetcher.h"
 #import "GoogleSignIn/Sources/GIDProfileDataFetcher/Implementations/Fakes/GIDFakeProfileDataFetcher.h"
 
 
@@ -186,39 +187,39 @@ static NSString *const kNewScope = @"newScope";
   // Whether or not the OS version is eligible for EMM.
   BOOL _isEligibleForEMM;
 
-  // Mock |OIDAuthState|.
+  // Mock `OIDAuthState`.
   id _authState;
 
-  // Mock |OIDTokenResponse|.
+  // Mock `OIDTokenResponse`.
   id _tokenResponse;
 
-  // Mock |OIDTokenRequest|.
+  // Mock `OIDTokenRequest`.
   id _tokenRequest;
 
-  // Mock |GTMAppAuthFetcherAuthorization|.
+  // Mock `GTMAppAuthFetcherAuthorization`.
   id _authorization;
   
-  // Fake for |GIDKeychainHandler|.
+  // Fake for `GIDKeychainHandler`.
   GIDFakeKeychainHandler *_keychainHandler;
 
-  // Fake for |GIDHTTPFetcher|.
+  // Fake for `GIDHTTPFetcher`.
   GIDFakeHTTPFetcher *_httpFetcher;
   
-  // Fake for |GIDProfileDataFetcher|.
+  // Fake for `GIDProfileDataFetcher`.
   GIDFakeProfileDataFetcher *_profileDataFetcher;
   
 #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
-  // Mock |UIViewController|.
+  // Mock `UIViewController`.
   id _presentingViewController;
 #elif TARGET_OS_OSX
-  // Mock |NSWindow|.
+  // Mock `NSWindow`.
   id _presentingWindow;
 #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
 
-  // Mock for |GIDGoogleUser|.
+  // Mock for `GIDGoogleUser`.
   id _user;
 
-  // Mock for |OIDAuthorizationService|
+  // Mock for `OIDAuthorizationService`.
   id _oidAuthorizationService;
 
   // Parameter saved from delegate call.
@@ -230,16 +231,16 @@ static NSString *const kNewScope = @"newScope";
   // Fake [NSBundle mainBundle];
   GIDFakeMainBundle *_fakeMainBundle;
 
-  // The |GIDSignIn| object being tested.
+  // The `GIDSignIn` object being tested.
   GIDSignIn *_signIn;
 
-  // The configuration to be used when testing |GIDSignIn|.
+  // The configuration to be used when testing `GIDSignIn`.
   GIDConfiguration *_configuration;
 
-  // The login hint to be used when testing |GIDSignIn|.
+  // The login hint to be used when testing `GIDSignIn`.
   NSString *_hint;
 
-  // The completion to be used when testing |GIDSignIn|.
+  // The completion to be used when testing `GIDSignIn`.
   GIDSignInCompletion _completion;
 
   // The saved authorization request.
@@ -436,7 +437,7 @@ static NSString *const kNewScope = @"newScope";
     responseProvider(fakeProfileData, nil);
   };
   
-  [_profileDataFetcher setTestBlock:testBlock];
+  _profileDataFetcher.testBlock = testBlock;
   [_signIn restorePreviousSignInNoRefresh];
 
   XCTAssertEqual(_signIn.currentUser.userID, kFakeGaiaID);
@@ -1070,7 +1071,6 @@ static NSString *const kNewScope = @"newScope";
   [[[mockEMMErrorHandler expect] andReturnValue:@YES]
       handleErrorFromResponse:callbackParams completion:SAVE_TO_ARG_BLOCK(completion)];
 
-
   [self OAuthLoginWithAddScopesFlow:NO
                           authError:callbackParams[@"error"]
                          tokenError:nil
@@ -1221,14 +1221,14 @@ static NSString *const kNewScope = @"newScope";
                codeVerifier:nil
        additionalParameters:tokenResponse.request.additionalParameters];
   
-  // Set the response for GIDProfileDataFetcher.
+  // Set the response for `GIDProfileDataFetcher`.
     GIDProfileDataFetcherTestBlock testBlock = ^(GIDProfileDataFetcherFakeResponseProvider
                                                  responseProvider) {
       GIDProfileData *profileData = [GIDProfileData testInstance];
       responseProvider(profileData, nil);
     };
     
-    [_profileDataFetcher setTestBlock:testBlock];
+    _profileDataFetcher.testBlock = testBlock;
 
   if (restoredSignIn) {
     // maybeFetchToken