GIDSignInInternalOptionsTest.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <XCTest/XCTest.h>
  15. #import "GoogleSignIn/Sources/GIDSignInInternalOptions.h"
  16. #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h"
  17. #ifdef SWIFT_PACKAGE
  18. @import OCMock;
  19. #else
  20. #import <OCMock/OCMock.h>
  21. #endif
  22. @interface GIDSignInInternalOptionsTest : XCTestCase
  23. @end
  24. @implementation GIDSignInInternalOptionsTest
  25. - (void)testDefaultOptions {
  26. id configuration = OCMStrictClassMock([GIDConfiguration class]);
  27. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  28. id presentingViewController = OCMStrictClassMock([UIViewController class]);
  29. #elif TARGET_OS_OSX
  30. id presentingWindow = OCMStrictClassMock([NSWindow class]);
  31. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  32. NSString *loginHint = @"login_hint";
  33. GIDSignInCompletion completion = ^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {};
  34. GIDSignInInternalOptions *options =
  35. [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
  36. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  37. presentingViewController:presentingViewController
  38. #elif TARGET_OS_OSX
  39. presentingWindow:presentingWindow
  40. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  41. loginHint:loginHint
  42. addScopesFlow:NO
  43. completion:completion];
  44. XCTAssertTrue(options.interactive);
  45. XCTAssertFalse(options.continuation);
  46. XCTAssertFalse(options.addScopesFlow);
  47. XCTAssertNil(options.extraParams);
  48. OCMVerifyAll(configuration);
  49. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  50. OCMVerifyAll(presentingViewController);
  51. #elif TARGET_OS_OSX
  52. OCMVerifyAll(presentingWindow);
  53. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  54. }
  55. - (void)testSilentOptions {
  56. GIDSignInCompletion completion = ^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {};
  57. GIDSignInInternalOptions *options = [GIDSignInInternalOptions
  58. silentOptionsWithCompletion:completion];
  59. XCTAssertFalse(options.interactive);
  60. XCTAssertFalse(options.continuation);
  61. XCTAssertNil(options.extraParams);
  62. XCTAssertEqual(options.completion, completion);
  63. }
  64. @end