GIDSignInInternalOptionsTest.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. id presentingViewController = OCMStrictClassMock([UIViewController class]);
  28. NSString *loginHint = @"login_hint";
  29. GIDSignInCallback callback = ^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {};
  30. GIDSignInInternalOptions *options =
  31. [GIDSignInInternalOptions defaultOptionsWithConfiguration:configuration
  32. presentingViewController:presentingViewController
  33. loginHint:loginHint
  34. callback:callback];
  35. XCTAssertTrue(options.interactive);
  36. XCTAssertFalse(options.continuation);
  37. XCTAssertNil(options.extraParams);
  38. OCMVerifyAll(configuration);
  39. OCMVerifyAll(presentingViewController);
  40. }
  41. - (void)testSilentOptions {
  42. GIDSignInCallback callback = ^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {};
  43. GIDSignInInternalOptions *options = [GIDSignInInternalOptions silentOptionsWithCallback:callback];
  44. XCTAssertFalse(options.interactive);
  45. XCTAssertFalse(options.continuation);
  46. XCTAssertNil(options.extraParams);
  47. XCTAssertEqual(options.callback, callback);
  48. }
  49. @end