Skip to content

Commit 37b6235

Browse files
committed
Run Style.sh
1 parent f6e26aa commit 37b6235

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

FirebasePerformance/Sources/AppActivity/FPRScreenTraceTracker.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ - (void)updateCachedSlowBudget {
256256
NSInteger effectiveFPS = (_cachedMaxFPS == 60) ? 59 : _cachedMaxFPS;
257257
_cachedSlowBudget = 1.0 / effectiveFPS;
258258
} else {
259-
// Fallback to 59 FPS (matching legacy behavior) if maximumFramesPerSecond is unavailable or invalid.
259+
// Fallback to 59 FPS (matching legacy behavior) if maximumFramesPerSecond is unavailable or
260+
// invalid.
260261
_cachedMaxFPS = 59;
261262
_cachedSlowBudget = 1.0 / 59.0;
262263
}

FirebasePerformance/Tests/Unit/FPRScreenTraceTrackerTest.m

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,12 @@ - (void)testSlowFrameIsRecordedWithCustomMaxFPSOnTvOS {
910910
// At 50 FPS, slow budget = 1.0/50 = 0.02 seconds = 20ms.
911911
UIScreen *mainScreen = [UIScreen mainScreen];
912912
NSInteger originalMaxFPS = mainScreen.maximumFramesPerSecond;
913-
913+
914914
// Use method swizzling to stub maximumFramesPerSecond.
915-
Method originalMethod = class_getInstanceMethod([UIScreen class], @selector(maximumFramesPerSecond));
915+
Method originalMethod =
916+
class_getInstanceMethod([UIScreen class], @selector(maximumFramesPerSecond));
916917
IMP originalIMP = method_getImplementation(originalMethod);
917-
918+
918919
NSInteger (^stubBlock)(id) = ^NSInteger(id self) {
919920
return 50; // Return 50 FPS for testing.
920921
};
@@ -956,7 +957,8 @@ - (void)testSlowFrameIsRecordedWithCustomMaxFPSOnTvOS {
956957
@"Frame at 21ms should be marked as slow at 50 FPS (20ms threshold)");
957958

958959
// Test with 19ms frame (should NOT be slow).
959-
CFAbsoluteTime thirdFrameRenderTimestamp = secondFrameRenderTimestamp + 0.019; // 19ms, not slow
960+
CFAbsoluteTime thirdFrameRenderTimestamp =
961+
secondFrameRenderTimestamp + 0.019; // 19ms, not slow
960962
OCMExpect([displayLinkMock timestamp]).andReturn(thirdFrameRenderTimestamp);
961963
[testTracker displayLinkStep];
962964

@@ -975,9 +977,10 @@ - (void)testSlowFrameIsRecordedWithCustomMaxFPSOnTvOS {
975977
*/
976978
- (void)testSlowFrameEpsilonHandlesBoundaryCases {
977979
// Swizzle UIScreen.maximumFramesPerSecond to return 60 FPS.
978-
Method originalMethod = class_getInstanceMethod([UIScreen class], @selector(maximumFramesPerSecond));
980+
Method originalMethod =
981+
class_getInstanceMethod([UIScreen class], @selector(maximumFramesPerSecond));
979982
IMP originalIMP = method_getImplementation(originalMethod);
980-
983+
981984
NSInteger (^stubBlock)(id) = ^NSInteger(id self) {
982985
return 60; // Return 60 FPS for testing.
983986
};
@@ -1025,9 +1028,10 @@ - (void)testSlowFrameEpsilonHandlesBoundaryCases {
10251028
@"Frame exactly at threshold should NOT be marked as slow due to epsilon");
10261029

10271030
// Test with frame just above threshold + epsilon (should be slow).
1028-
// Use a value clearly above threshold + epsilon (0.001) to account for floating point precision.
1029-
// We use 0.002 above threshold to ensure it's clearly above the epsilon threshold.
1030-
CFTimeInterval justAboveThreshold = exactThreshold + 0.001 + 0.001; // 0.002 above threshold (epsilon is 0.001)
1031+
// Use a value clearly above threshold + epsilon (0.001) to account for floating point
1032+
// precision. We use 0.002 above threshold to ensure it's clearly above the epsilon threshold.
1033+
CFTimeInterval justAboveThreshold =
1034+
exactThreshold + 0.001 + 0.001; // 0.002 above threshold (epsilon is 0.001)
10311035
CFAbsoluteTime thirdFrameRenderTimestamp = secondFrameRenderTimestamp + justAboveThreshold;
10321036
OCMExpect([displayLinkMock timestamp]).andReturn(thirdFrameRenderTimestamp);
10331037
[testTracker displayLinkStep];
@@ -1042,14 +1046,15 @@ - (void)testSlowFrameEpsilonHandlesBoundaryCases {
10421046
}
10431047

10441048
#if TARGET_OS_TV
1045-
/** Tests that the slow budget is recomputed when UIScreenModeDidChangeNotification is posted on tvOS.
1046-
* This verifies that the tracker adapts to display mode changes that affect refresh rate.
1049+
/** Tests that the slow budget is recomputed when UIScreenModeDidChangeNotification is posted on
1050+
* tvOS. This verifies that the tracker adapts to display mode changes that affect refresh rate.
10471051
*/
10481052
- (void)testScreenModeChangeUpdatesSlowBudgetOnTvOS {
10491053
// Swizzle UIScreen.maximumFramesPerSecond to return 60 FPS initially, then 50 FPS.
1050-
Method originalMethod = class_getInstanceMethod([UIScreen class], @selector(maximumFramesPerSecond));
1054+
Method originalMethod =
1055+
class_getInstanceMethod([UIScreen class], @selector(maximumFramesPerSecond));
10511056
IMP originalIMP = method_getImplementation(originalMethod);
1052-
1057+
10531058
__block NSInteger stubbedMaxFPS = 60;
10541059
NSInteger (^stubBlock)(id) = ^NSInteger(id self) {
10551060
return stubbedMaxFPS;
@@ -1103,7 +1108,8 @@ - (void)testScreenModeChangeUpdatesSlowBudgetOnTvOS {
11031108
// Wait for the async update to complete. Since screenModeDidChangeNotification dispatches
11041109
// async to main queue, and tests run on main thread, we need to run the run loop to process it.
11051110
// Run the run loop once to process the async dispatch.
1106-
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
1111+
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
1112+
beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
11071113

11081114
// Verify the new budget is used: at 50 FPS, slow budget = 20ms.
11091115
// An 18ms frame should NOT be slow at 50 FPS (it's below the 20ms threshold).
@@ -1120,8 +1126,9 @@ - (void)testScreenModeChangeUpdatesSlowBudgetOnTvOS {
11201126

11211127
int64_t slowFramesAfterModeChange = testTracker.slowFramesCount;
11221128
// At 50 FPS (20ms threshold), 18ms frame should NOT be slow.
1123-
XCTAssertEqual(slowFramesAfterModeChange, initialSlowFramesCount,
1124-
@"After mode change to 50 FPS, 18ms frame should NOT be slow (threshold is 20ms)");
1129+
XCTAssertEqual(
1130+
slowFramesAfterModeChange, initialSlowFramesCount,
1131+
@"After mode change to 50 FPS, 18ms frame should NOT be slow (threshold is 20ms)");
11251132
} @finally {
11261133
// Restore original implementation.
11271134
method_setImplementation(originalMethod, originalIMP);

0 commit comments

Comments
 (0)