Skip to content

Commit 0288d6c

Browse files
test: Fix checkTotalFrames (#3485)
Don't base min and max expected frames on the current frame rate as it could change while rendering frames.
1 parent 29d558e commit 0288d6c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Samples/iOS-Swift/iOS-SwiftUITests/LaunchUITests.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,16 @@ class LaunchUITests: BaseUITest {
109109
let endDate = Date()
110110

111111
let secondsBetween = endDate.timeIntervalSince(startDate)
112-
113-
// Retrieving the number of frames from the text label is inaccurate.
114-
// Therefore, we add a one-second tolerance for the expected amount of frames.
115-
// We only want to validate if the number of total frames is entirely off.
116-
let maximumFramesPerSecond = Double(UIScreen.main.maximumFramesPerSecond)
117-
118-
let expectedMinimumTotalFrames = (secondsBetween - 1.0) * maximumFramesPerSecond
119-
let expectedMaximumTotalFrames = (secondsBetween + 1.0) * maximumFramesPerSecond
112+
113+
// We don't calculate the min and max values based on the frame rate, as it could have changed while waiting for them to render.
114+
// Instead, we pick the minimum value based on 60fps and the maximum value based on 120fps.
115+
let expectedMinimumTotalFrames = (secondsBetween - 1.0) * 60
116+
let expectedMaximumTotalFrames = (secondsBetween + 1.0) * 120
120117

121118
let actualTotalFrames = Double(endTotalFrames - startTotalFrames)
122119

123-
XCTAssertGreaterThanOrEqual(actualTotalFrames, expectedMinimumTotalFrames, "Actual frames:\(actualTotalFrames) should be greater than \(expectedMinimumTotalFrames) with frame rate of \(maximumFramesPerSecond)")
124-
XCTAssertLessThanOrEqual(actualTotalFrames, expectedMaximumTotalFrames, "Actual frames:\(actualTotalFrames) should be less than \(expectedMaximumTotalFrames) with frame rate of \(maximumFramesPerSecond)")
120+
XCTAssertGreaterThanOrEqual(actualTotalFrames, expectedMinimumTotalFrames, "Actual frames:\(actualTotalFrames) should be greater than \(expectedMinimumTotalFrames)")
121+
XCTAssertLessThanOrEqual(actualTotalFrames, expectedMaximumTotalFrames, "Actual frames:\(actualTotalFrames) should be less than \(expectedMaximumTotalFrames)")
125122
}
126123

127124
/**

0 commit comments

Comments
 (0)