ObjCPPAPITests.mm 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. [func useEmulatorWithHost:@"host" port:123];
  33. #pragma mark - HTTPSCallable and HTTPSCallableResult
  34. [callable
  35. callWithCompletion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
  36. __unused id data = result.data;
  37. }];
  38. [callable callWithObject:nil
  39. completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) {
  40. [result data];
  41. }];
  42. callable.timeoutInterval = 60;
  43. [callable timeoutInterval];
  44. }
  45. #pragma mark - FunctionsError
  46. - (FIRFunctionsErrorCode)errorCodes:(NSError *)error {
  47. switch (error.code) {
  48. case FIRFunctionsErrorCodeOK:
  49. case FIRFunctionsErrorCodeCancelled:
  50. case FIRFunctionsErrorCodeUnknown:
  51. case FIRFunctionsErrorCodeInvalidArgument:
  52. case FIRFunctionsErrorCodeDeadlineExceeded:
  53. case FIRFunctionsErrorCodeNotFound:
  54. case FIRFunctionsErrorCodeAlreadyExists:
  55. case FIRFunctionsErrorCodePermissionDenied:
  56. case FIRFunctionsErrorCodeResourceExhausted:
  57. case FIRFunctionsErrorCodeFailedPrecondition:
  58. case FIRFunctionsErrorCodeAborted:
  59. case FIRFunctionsErrorCodeOutOfRange:
  60. case FIRFunctionsErrorCodeUnimplemented:
  61. case FIRFunctionsErrorCodeInternal:
  62. case FIRFunctionsErrorCodeUnavailable:
  63. case FIRFunctionsErrorCodeDataLoss:
  64. case FIRFunctionsErrorCodeUnauthenticated:
  65. return (FIRFunctionsErrorCode)error.code;
  66. }
  67. return (FIRFunctionsErrorCode)error.code;
  68. }
  69. @end