Kaynağa Gözat

Address build warnings.

Peter Andrews 4 yıl önce
ebeveyn
işleme
a9bc42a170

+ 9 - 9
GoogleSignIn/Sources/GIDAuthentication.m

@@ -92,10 +92,10 @@ static NSString *const kNewIOSSystemName = @"iOS";
                request:(NSMutableURLRequest *)request
      finishedWithError:(nullable NSError *)error {
   [GIDAuthentication handleTokenFetchEMMError:error completion:^(NSError *_Nullable error) {
-    if (!_delegate || !_selector) {
+    if (!self->_delegate || !self->_selector) {
       return;
     }
-    NSMethodSignature *signature = [_delegate methodSignatureForSelector:_selector];
+    NSMethodSignature *signature = [self->_delegate methodSignatureForSelector:self->_selector];
     if (!signature) {
       return;
     }
@@ -103,8 +103,8 @@ static NSString *const kNewIOSSystemName = @"iOS";
     id argument2 = request;
     id argument3 = error;
     NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
-    [invocation setTarget:_delegate];  // index 0
-    [invocation setSelector:_selector];  // index 1
+    [invocation setTarget:self->_delegate];  // index 0
+    [invocation setSelector:self->_selector];  // index 1
     [invocation setArgument:&argument1 atIndex:2];
     [invocation setArgument:&argument2 atIndex:3];
     [invocation setArgument:&argument3 atIndex:4];
@@ -236,22 +236,22 @@ static NSString *const kNewIOSSystemName = @"iOS";
       [self willChangeValueForKey:NSStringFromSelector(@selector(accessTokenExpirationDate))];
       [self willChangeValueForKey:NSStringFromSelector(@selector(idToken))];
       [self willChangeValueForKey:NSStringFromSelector(@selector(idTokenExpirationDate))];
-      [_authState updateWithTokenResponse:tokenResponse error:nil];
+      [self->_authState updateWithTokenResponse:tokenResponse error:nil];
       [self didChangeValueForKey:NSStringFromSelector(@selector(accessToken))];
       [self didChangeValueForKey:NSStringFromSelector(@selector(accessTokenExpirationDate))];
       [self didChangeValueForKey:NSStringFromSelector(@selector(idToken))];
       [self didChangeValueForKey:NSStringFromSelector(@selector(idTokenExpirationDate))];
     } else {
       if (error.domain == OIDOAuthTokenErrorDomain) {
-        [_authState updateWithAuthorizationError:error];
+        [self->_authState updateWithAuthorizationError:error];
       }
     }
     [GIDAuthentication handleTokenFetchEMMError:error completion:^(NSError *_Nullable error) {
       // Process the handler queue to call back.
       NSArray *authenticationHandlerQueue;
-      @synchronized(_authenticationHandlerQueue) {
-        authenticationHandlerQueue = [_authenticationHandlerQueue copy];
-        [_authenticationHandlerQueue removeAllObjects];
+      @synchronized(self->_authenticationHandlerQueue) {
+        authenticationHandlerQueue = [self->_authenticationHandlerQueue copy];
+        [self->_authenticationHandlerQueue removeAllObjects];
       }
       for (GIDAuthenticationAction action in authenticationHandlerQueue) {
         dispatch_async(dispatch_get_main_queue(), ^{

+ 1 - 1
GoogleSignIn/Sources/GIDCallbackQueue.h

@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
 @class GIDCallbackQueue;
 
 // The block type of callbacks in the queue.
-typedef void (^GIDCallbackQueueCallback)();
+typedef void (^GIDCallbackQueueCallback)(void);
 
 // The class handles a queue for callbacks for asynchronous operations.
 // The queue starts in a ready state. Call |wait| and |next| to mark the

+ 1 - 1
GoogleSignIn/Sources/GIDEMMErrorHandler.h

@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
 // after the user interacts with the error dialog;
 // if the return value is |NO|, |completion| will be called before returning.
 - (BOOL)handleErrorFromResponse:(NSDictionary<NSString *, id> *)response
-                     completion:(void (^)())completion;
+                     completion:(void (^)(void))completion;
 
 @end
 

+ 6 - 6
GoogleSignIn/Sources/GIDEMMErrorHandler.m

@@ -54,7 +54,7 @@ typedef enum {
 }
 
 - (BOOL)handleErrorFromResponse:(NSDictionary<NSString *, id> *)response
-                     completion:(void (^)())completion {
+                     completion:(void (^)(void))completion {
   ErrorCode errorCode = ErrorCodeNone;
   NSURL *appVerificationURL;
   @synchronized(self) {  // for accessing _pendingDialog
@@ -99,11 +99,11 @@ typedef enum {
     alertWindow.rootViewController.view.backgroundColor = [UIColor clearColor];
     alertWindow.windowLevel = UIWindowLevelAlert;
     [alertWindow makeKeyAndVisible];
-    void (^finish)() = ^{
+    void (^finish)(void) = ^{
       alertWindow.hidden = YES;
       alertWindow.rootViewController = nil;
       [keyWindow makeKeyAndVisible];
-      _pendingDialog = NO;
+      self->_pendingDialog = NO;
       completion();
     };
     UIAlertController *alert;
@@ -133,7 +133,7 @@ typedef enum {
 #pragma mark - Alerts
 
 // Returns an alert controller for device not compliant error.
-- (UIAlertController *)deviceNotCompliantAlertWithCompletion:(void (^)())completion {
+- (UIAlertController *)deviceNotCompliantAlertWithCompletion:(void (^)(void))completion {
   UIAlertController *alert =
       [UIAlertController alertControllerWithTitle:[self unableToAccessString]
                                           message:[self deviceNotCompliantString]
@@ -147,7 +147,7 @@ typedef enum {
 };
 
 // Returns an alert controller for passcode required error.
-- (UIAlertController *)passcodeRequiredAlertWithCompletion:(void (^)())completion {
+- (UIAlertController *)passcodeRequiredAlertWithCompletion:(void (^)(void))completion {
   UIAlertController *alert =
       [UIAlertController alertControllerWithTitle:[self unableToAccessString]
                                           message:[self passcodeRequiredString]
@@ -188,7 +188,7 @@ typedef enum {
 
 // Returns an alert controller for app verification required error.
 - (UIAlertController *)appVerificationRequiredAlertWithURL:(nullable NSURL *)url
-                                                completion:(void (^)())completion {
+                                                completion:(void (^)(void))completion {
   UIAlertController *alert;
   if (url) {
     // If the URL is provided, prompt user to open this URL or cancel.

+ 12 - 12
GoogleSignIn/Sources/GIDSignIn.m

@@ -391,8 +391,8 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
       } else {
         if (options.callback) {
           dispatch_async(dispatch_get_main_queue(), ^{
-            options.callback(_currentUser, nil);
-            _currentOptions = nil;
+            options.callback(self->_currentUser, nil);
+            self->_currentOptions = nil;
           });
         }
       }
@@ -448,9 +448,9 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
          presentingViewController:options.presentingViewController
                          callback:^(OIDAuthorizationResponse *_Nullable authorizationResponse,
                                     NSError *_Nullable error) {
-    if (_restarting) {
+    if (self->_restarting) {
       // The auth flow is restarting, so the work here would be performed in the next round.
-      _restarting = NO;
+      self->_restarting = NO;
       return;
     }
 
@@ -524,7 +524,7 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
     if (options.callback) {
       dispatch_async(dispatch_get_main_queue(), ^{
         options.callback(nil, error);
-        _currentOptions = nil;
+        self->_currentOptions = nil;
       });
     }
     return;
@@ -617,8 +617,8 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
         return;
       }
       [self willChangeValueForKey:NSStringFromSelector(@selector(currentUser))];
-      _currentUser = [[GIDGoogleUser alloc] initWithAuthState:authState
-                                                  profileData:handlerAuthFlow.profileData];
+      self->_currentUser = [[GIDGoogleUser alloc] initWithAuthState:authState
+                                                        profileData:handlerAuthFlow.profileData];
       [self didChangeValueForKey:NSStringFromSelector(@selector(currentUser))];
     }
   }];
@@ -689,10 +689,10 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   __weak GIDAuthFlow *weakAuthFlow = authFlow;
   [authFlow addCallback:^() {
     GIDAuthFlow *handlerAuthFlow = weakAuthFlow;
-    if (_currentOptions.callback) {
+    if (self->_currentOptions.callback) {
       dispatch_async(dispatch_get_main_queue(), ^{
-        _currentOptions.callback(_currentUser, handlerAuthFlow.error);
-        _currentOptions = nil;
+        self->_currentOptions.callback(self->_currentUser, handlerAuthFlow.error);
+        self->_currentOptions = nil;
       });
     }
   }];
@@ -745,8 +745,8 @@ static const NSTimeInterval kMinimumRestoredAccessTokenTimeToExpire = 600.0;
   dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
                  (int64_t)(kPresentationDelayAfterCancel * NSEC_PER_SEC)),
                  dispatch_get_main_queue(), ^{
-    [self signInWithOptions:[_currentOptions optionsWithExtraParameters:extraParameters
-                                                        forContinuation:YES]];
+    [self signInWithOptions:[self->_currentOptions optionsWithExtraParameters:extraParameters
+                                                              forContinuation:YES]];
   });
   return YES;
 }

+ 4 - 4
GoogleSignIn/Tests/Unit/GIDAuthenticationTest.m

@@ -144,9 +144,9 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
                               OIDTokenCallback callback) {
     XCTAssertNotNil(authorizationResponse.request.clientID);
     XCTAssertNotNil(authorizationResponse.request.configuration.tokenEndpoint);
-    XCTAssertNil(_tokenFetchHandler);  // only one on-going fetch allowed
-    _tokenFetchHandler = [callback copy];
-    _tokenRequest = [request copy];
+    XCTAssertNil(self->_tokenFetchHandler);  // only one on-going fetch allowed
+    self->_tokenFetchHandler = [callback copy];
+    self->_tokenRequest = [request copy];
     return nil;
   }];
   _observedAuths = [[NSMutableArray alloc] init];
@@ -155,7 +155,7 @@ _Static_assert(kChangeTypeEnd == (sizeof(kObservedProperties) / sizeof(*kObserve
   [GULSwizzler swizzleClass:[UIDevice class]
                    selector:@selector(systemName)
             isClassSelector:NO
-                  withBlock:^(id sender) { return _fakeSystemName; }];
+                  withBlock:^(id sender) { return self->_fakeSystemName; }];
 }
 
 - (void)tearDown {

+ 3 - 3
GoogleSignIn/Tests/Unit/GIDEMMErrorHandlerTest.m

@@ -69,11 +69,11 @@ NS_ASSUME_NONNULL_BEGIN
   [GULSwizzler swizzleClass:[UIWindow class]
                    selector:@selector(makeKeyAndVisible)
             isClassSelector:NO
-                  withBlock:^() { _keyWindowSet = YES; }];
+                  withBlock:^() { self->_keyWindowSet = YES; }];
   [GULSwizzler swizzleClass:[UIViewController class]
                    selector:@selector(presentViewController:animated:completion:)
             isClassSelector:NO
-                  withBlock:^(id obj, id arg1) { _presentedViewController = arg1; }];
+                  withBlock:^(id obj, id arg1) { self->_presentedViewController = arg1; }];
   [GULSwizzler swizzleClass:[GIDSignInStrings class]
                    selector:@selector(localizedStringForKey:text:)
             isClassSelector:YES
@@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
 }
 
 // Expects opening a particular URL string in performing an action.
-- (void)expectOpenURLString:(NSString *)urlString inAction:(void (^)())action {
+- (void)expectOpenURLString:(NSString *)urlString inAction:(void (^)(void))action {
   // Swizzle and mock [UIApplication sharedApplication] since it is unavailable in unit tests.
   id mockApplication = OCMStrictClassMock([UIApplication class]);
   [GULSwizzler swizzleClass:[UIApplication class]

+ 3 - 3
GoogleSignIn/Tests/Unit/GIDMDMPasscodeStateTests.m

@@ -48,12 +48,12 @@
   }
   _canEvaluatePolicyCalled = NO;
   id canEvaluatePolicyError = ^BOOL(id context, LAPolicy policy, NSError * _Nullable *error) {
-    _canEvaluatePolicyCalled = YES;
+    self->_canEvaluatePolicyCalled = YES;
     XCTAssertEqual(policy, LAPolicyDeviceOwnerAuthentication);
     if (error) {
-      *error = _nextCanEvaluatePolicyError;
+      *error = self->_nextCanEvaluatePolicyError;
     }
-    return _nextCanEvaluatePolicyResult;
+    return self->_nextCanEvaluatePolicyResult;
   };
   [GULSwizzler swizzleClass:[LAContext class]
                    selector:@selector(canEvaluatePolicy:error:)

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

@@ -86,7 +86,6 @@ static NSString * const kFakeUserName = @"fake username";
 static NSString * const kFakeUserGivenName = @"fake";
 static NSString * const kFakeUserFamilyName = @"username";
 static NSString * const kFakeUserPictureURL = @"fake_user_picture_url";
-static const NSTimeInterval kIDTokenExpiration = 12345;
 
 static NSString * const kContinueURL = @"com.google.UnitTests:/oauth2callback";
 static NSString * const kContinueURLWithClientID = @"FakeClientID:/oauth2callback";
@@ -272,22 +271,23 @@ static void *kTestObserverContext = &kTestObserverContext;
   OCMStub([_authorization initWithAuthState:OCMOCK_ANY]).andReturn(_authorization);
   OCMStub([_authorization saveAuthorization:OCMOCK_ANY toKeychainForName:OCMOCK_ANY])
       .andDo(^(NSInvocation *invocation) {
-        _keychainSaved = _saveAuthorizationReturnValue;
-        [invocation setReturnValue:&_saveAuthorizationReturnValue];
+        self->_keychainSaved = self->_saveAuthorizationReturnValue;
+        [invocation setReturnValue:&self->_saveAuthorizationReturnValue];
       });
   OCMStub([_authorization removeAuthorizationFromKeychainForName:OCMOCK_ANY])
       .andDo(^(NSInvocation *invocation) {
-        _keychainRemoved = YES;
+        self->_keychainRemoved = YES;
       });
   _user = OCMStrictClassMock([GIDGoogleUser class]);
   _authentication = OCMStrictClassMock([GIDAuthentication class]);
   _oidAuthorizationService = OCMStrictClassMock([OIDAuthorizationService class]);
   OCMStub([_oidAuthorizationService
-      presentAuthorizationRequest:SAVE_TO_ARG_BLOCK(_savedAuthorizationRequest)
-         presentingViewController:SAVE_TO_ARG_BLOCK(_savedPresentingViewController)
-                         callback:COPY_TO_ARG_BLOCK(_savedAuthorizationCallback)]);
-  OCMStub([_oidAuthorizationService performTokenRequest:SAVE_TO_ARG_BLOCK(_savedTokenRequest)
-                                               callback:COPY_TO_ARG_BLOCK(_savedTokenCallback)]);
+      presentAuthorizationRequest:SAVE_TO_ARG_BLOCK(self->_savedAuthorizationRequest)
+         presentingViewController:SAVE_TO_ARG_BLOCK(self->_savedPresentingViewController)
+                         callback:COPY_TO_ARG_BLOCK(self->_savedAuthorizationCallback)]);
+  OCMStub([self->_oidAuthorizationService
+      performTokenRequest:SAVE_TO_ARG_BLOCK(self->_savedTokenRequest)
+                 callback:COPY_TO_ARG_BLOCK(self->_savedTokenCallback)]);
 
   // Fakes
   _fetcherService = [[GIDFakeFetcherService alloc] init];
@@ -1031,9 +1031,9 @@ static void *kTestObserverContext = &kTestObserverContext;
       if (!user) {
         XCTAssertNotNil(error, @"should have an error if user is nil");
       }
-      XCTAssertFalse(_callbackCalled, @"callback already called");
-      _callbackCalled = YES;
-      _authError = error;
+      XCTAssertFalse(self->_callbackCalled, @"callback already called");
+      self->_callbackCalled = YES;
+      self->_authError = error;
     }];
 
     [_authorization verify];