GIDSignInInternalOptionsTest.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 = ^(GIDSignInResult *_Nullable signInResult,
  34. NSError * _Nullable error) {};
  35. GIDSignInInternalOptions *options =
  36. [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
  37. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  38. presentingViewController:presentingViewController
  39. #elif TARGET_OS_OSX
  40. presentingWindow:presentingWindow
  41. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  42. loginHint:loginHint
  43. addScopesFlow:NO
  44. completion:completion];
  45. XCTAssertTrue(options.interactive);
  46. XCTAssertFalse(options.continuation);
  47. XCTAssertFalse(options.addScopesFlow);
  48. XCTAssertNil(options.extraParams);
  49. OCMVerifyAll(configuration);
  50. #if TARGET_OS_IOS || TARGET_OS_MACCATALYST
  51. OCMVerifyAll(presentingViewController);
  52. #elif TARGET_OS_OSX
  53. OCMVerifyAll(presentingWindow);
  54. #endif // TARGET_OS_IOS || TARGET_OS_MACCATALYST
  55. }
  56. - (void)testSilentOptions {
  57. GIDSignInCompletion completion = ^(GIDSignInResult *_Nullable signInResult,
  58. NSError * _Nullable error) {};
  59. GIDSignInInternalOptions *options = [GIDSignInInternalOptions silentOptionsWithCompletion:completion];
  60. XCTAssertFalse(options.interactive);
  61. XCTAssertFalse(options.continuation);
  62. XCTAssertNil(options.extraParams);
  63. XCTAssertEqual(options.completion, completion);
  64. }
  65. @end