FPRInstrumentationTest.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2020 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 "FirebasePerformance/Sources/Instrumentation/FPRInstrumentation.h"
  16. #import "FirebasePerformance/Sources/Instrumentation/Network/FPRNSURLSessionInstrument.h"
  17. #import <OCMock/OCMock.h>
  18. @interface FPRInstrumentationTest : XCTestCase
  19. @end
  20. @implementation FPRInstrumentationTest
  21. - (void)setUp {
  22. id FPRNSURLSessionClassMock = OCMClassMock([FPRNSURLSessionInstrument class]);
  23. OCMStub([FPRNSURLSessionClassMock alloc]).andReturn(FPRNSURLSessionClassMock);
  24. }
  25. - (void)testInit {
  26. FPRInstrumentation *instrumentation = [[FPRInstrumentation alloc] init];
  27. XCTAssertNotNil(instrumentation);
  28. }
  29. #pragma mark - Unswizzle based tests
  30. #ifndef SWIFT_PACKAGE
  31. - (void)testRegisterInstrumentGroup {
  32. FPRInstrumentation *instrumentation = [[FPRInstrumentation alloc] init];
  33. NSUInteger numberOfInstrumentsInGroup =
  34. [instrumentation registerInstrumentGroup:kFPRInstrumentationGroupNetworkKey];
  35. XCTAssertGreaterThan(numberOfInstrumentsInGroup, 0);
  36. [instrumentation deregisterInstrumentGroup:kFPRInstrumentationGroupNetworkKey];
  37. }
  38. - (void)testDeregisterInstrumentGroup {
  39. FPRInstrumentation *instrumentation = [[FPRInstrumentation alloc] init];
  40. [instrumentation registerInstrumentGroup:kFPRInstrumentationGroupNetworkKey];
  41. XCTAssertTrue([instrumentation deregisterInstrumentGroup:kFPRInstrumentationGroupNetworkKey]);
  42. }
  43. #endif // SWIFT_PACKAGE
  44. @end