ObjCPPAPITests.mm 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2022 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 <FirebaseFunctions/FirebaseFunctions-Swift.h>
  16. #import "FirebaseCore/FirebaseCore.h"
  17. @interface ObjCPPAPICoverage : XCTestCase
  18. @end
  19. @implementation ObjCPPAPICoverage
  20. - (void)apis {
  21. #pragma mark - Functions
  22. FIRApp *app = [FIRApp defaultApp];
  23. FIRFunctions *func = [FIRFunctions functions];
  24. func = [FIRFunctions functionsForApp:app];
  25. func = [FIRFunctions functionsForRegion:@"my-region"];
  26. func = [FIRFunctions functionsForCustomDomain:@"my-domain"];
  27. func = [FIRFunctions functionsForApp:app region:@"my-region"];
  28. func = [FIRFunctions functionsForApp:app customDomain:@"my-domain"];
  29. FIRHTTPSCallable *callable = [func HTTPSCallableWithName:@"name"];
  30. NSURL *url = [NSURL URLWithString:@"http://host:123/project/location/name"];
  31. callable = [func HTTPSCallableWithURL:url];
  32. FIRHTTPSCallableOptions *options =
  33. [[FIRHTTPSCallableOptions alloc] initWithRequireLimitedUseAppCheckTokens:YES];
  34. __unused BOOL requireLimitedUseAppCheckTokens = options.requireLimitedUseAppCheckTokens;
  35. callable = [func HTTPSCallableWithURL:url options:options];
  36. callable = [func HTTPSCallableWithName:@"name" options:options];
  37. [func useEmulatorWithHost:@"host" port:123];
  38. #pragma mark - HTTPSCallable and HTTPSCallableResult
  39. [callable
  40. callWithCompletion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
  41. __unused id data = result.data;
  42. }];
  43. [callable callWithObject:nil
  44. completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
  45. [result data];
  46. }];
  47. callable.timeoutInterval = 60;
  48. [callable timeoutInterval];
  49. }
  50. #pragma mark - FunctionsError
  51. - (FIRFunctionsErrorCode)errorCodes:(NSError *)error {
  52. switch (error.code) {
  53. case FIRFunctionsErrorCodeOK:
  54. case FIRFunctionsErrorCodeCancelled:
  55. case FIRFunctionsErrorCodeUnknown:
  56. case FIRFunctionsErrorCodeInvalidArgument:
  57. case FIRFunctionsErrorCodeDeadlineExceeded:
  58. case FIRFunctionsErrorCodeNotFound:
  59. case FIRFunctionsErrorCodeAlreadyExists:
  60. case FIRFunctionsErrorCodePermissionDenied:
  61. case FIRFunctionsErrorCodeResourceExhausted:
  62. case FIRFunctionsErrorCodeFailedPrecondition:
  63. case FIRFunctionsErrorCodeAborted:
  64. case FIRFunctionsErrorCodeOutOfRange:
  65. case FIRFunctionsErrorCodeUnimplemented:
  66. case FIRFunctionsErrorCodeInternal:
  67. case FIRFunctionsErrorCodeUnavailable:
  68. case FIRFunctionsErrorCodeDataLoss:
  69. case FIRFunctionsErrorCodeUnauthenticated:
  70. return (FIRFunctionsErrorCode)error.code;
  71. }
  72. return (FIRFunctionsErrorCode)error.code;
  73. }
  74. @end