Skip to content

Commit

Permalink
Fix Performance Unit Tests requiring Swizzling
Browse files Browse the repository at this point in the history
  • Loading branch information
samedson committed Oct 3, 2024
1 parent c216e1f commit 25a120b
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#import "FirebasePerformance/Sources/Common/FPRDiagnostics.h"

#import <GoogleUtilities/GULSwizzler.h>
#ifdef UNSWIZZLE_AVAILABLE
#ifdef FPR_UNSWIZZLE_AVAILABLE
#import <GoogleUtilities/GULSwizzler+Unswizzle.h>
#endif

Expand Down Expand Up @@ -76,7 +76,7 @@ - (void)swizzle {

- (void)unswizzle {
_swizzled = NO;
#ifdef UNSWIZZLE_AVAILABLE
#ifdef FPR_UNSWIZZLE_AVAILABLE
[GULSwizzler unswizzleClass:_class selector:_selector isClassSelector:_isClassSelector];
#else
NSAssert(NO, @"Unswizzling is disabled.");
Expand Down
4 changes: 0 additions & 4 deletions FirebasePerformance/Tests/Unit/FPRClassInstrumentorTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ - (void)testCannotInstrumentSameSelectorTwice {

#pragma mark - Unswizzle based tests

#if !SWIFT_PACKAGE

/** Tests swizzling an instance selector. */
- (void)testSwizzleInstanceSelector {
FPRClassInstrumentor *classInstrumentor =
Expand Down Expand Up @@ -158,6 +156,4 @@ - (void)testVoidReturnClassSelector {
[classInstrumentor unswizzle];
}

#endif // SWIFT_PACKAGE

@end
4 changes: 0 additions & 4 deletions FirebasePerformance/Tests/Unit/FPRInstrumentTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ - (void)testRegisterAlreadyRegisteredClassInstrumentor {

#pragma mark - Unswizzle based tests

#if !SWIFT_PACKAGE

- (void)testDeregisterInstrumentors {
FPRInstrument *instrument = [[FPRInstrument alloc] init];
FPRClassInstrumentor *classInstrumentor =
Expand All @@ -86,6 +84,4 @@ - (void)testDeregisterInstrumentors {
[classInstrumentor unswizzle];
}

#endif // SWIFT_PACKAGE

@end
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#pragma mark - Unswizzle based tests

#if !SWIFT_PACKAGE

#import "FirebasePerformance/Tests/Unit/Instruments/FPRNSURLConnectionInstrumentTestDelegates.h"

#import <XCTest/XCTest.h>
Expand Down Expand Up @@ -519,5 +517,3 @@ - (void)testDownloadDelegateCompletionAPIGetsCalledEvenIfDataDelegateIsImplement
}

@end

#endif // SWIFT_PACKAGE
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#pragma mark - Unswizzle based tests

#ifndef SWIFT_PACKAGE

#import "FirebasePerformance/Tests/Unit/Instruments/FPRNSURLSessionInstrumentTestDelegates.h"

#import <XCTest/XCTest.h>
Expand Down Expand Up @@ -836,5 +834,3 @@ - (void)testMutableRequestURLs {
}

@end

#endif // SWIFT_PACKAGE
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#pragma mark - Unswizzle based tests

#if !SWIFT_PACKAGE

#import "FirebasePerformance/Sources/Instrumentation/UIKit/FPRUIViewControllerInstrument.h"

#import <XCTest/XCTest.h>
Expand Down Expand Up @@ -173,4 +171,3 @@ - (void)testViewDidAppearInvokesPreviousViewDidDisappear {

@end

#endif // SWIFT_PACKAGE
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ let package = Package(
.product(name: "GoogleDataTransport", package: "GoogleDataTransport"),
.product(name: "GULEnvironment", package: "GoogleUtilities"),
.product(name: "GULMethodSwizzler", package: "GoogleUtilities"),
.product(name: "GULSwizzlerTestHelpers", package: "GoogleUtilities"),
.product(name: "GULUserDefaults", package: "GoogleUtilities"),
.product(name: "nanopb", package: "nanopb"),
],
Expand All @@ -895,6 +896,7 @@ let package = Package(
.define("PB_NO_PACKED_STRUCTS", to: "1"),
.define("PB_ENABLE_MALLOC", to: "1"),
.define("FIRPerformance_LIB_VERSION", to: firebaseVersion),
.define("FPR_UNSWIZZLE_AVAILABLE", to: "1"),
],
linkerSettings: [
.linkedFramework("MobileCoreServices", .when(platforms: [.iOS, .tvOS])),
Expand All @@ -907,6 +909,8 @@ let package = Package(
"FirebasePerformanceTarget",
"SharedTestUtilities",
"GCDWebServer",
.product(name: "GULMethodSwizzler", package: "GoogleUtilities"),
.product(name: "GULSwizzlerTestHelpers", package: "GoogleUtilities"),
.product(name: "OCMock", package: "ocmock"),
],
path: "FirebasePerformance/Tests/Unit",
Expand Down

0 comments on commit 25a120b

Please sign in to comment.