Skip to content

Commit 0878411

Browse files
test(macos-helper): pin the scroll overflow a child outside the content adds
Trims the comments the change added to the comment rule.
1 parent 50acc2d commit 0878411

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎apple/macos-helper/Sources/AgentDeviceMacOSHelper/BackgroundInteraction.swift‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,8 @@ func scrollBarValue(current: Double, signedTravel: Double, overflow: Double) ->
259259
min(1, max(0, current + signedTravel / overflow))
260260
}
261261

262-
/// How far a scroll area's content reaches past the area along one axis. The content is the span
263-
/// all of its children cover: a SwiftUI `Form` lists each row as a child of the scroll area, with no
264-
/// single document view as tall as the content.
262+
/// A SwiftUI `Form` lists each row as a child of the scroll area, with no single document view as
263+
/// tall as the content, so the content is the span all of the area's children cover.
265264
func scrollContentOverflow(area: RectResponse, contentFrames: [RectResponse], isVertical: Bool)
266265
-> Double
267266
{

‎apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/BackgroundInteractionTests.swift‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ final class BackgroundInteractionTests: XCTestCase {
7878
XCTAssertEqual(scrollBarValue(current: 0.1, signedTravel: -600, overflow: 1200), 0)
7979
}
8080

81-
/// A SwiftUI `Form` lists its rows as children of the scroll area: together they overflow it
82-
/// although no single row is as tall as the area.
8381
func testScrollOverflowSpansEveryContentChild() {
8482
let area = RectResponse(x: 0, y: 100, width: 400, height: 600)
8583
let rows = (0..<10).map { row in
@@ -89,6 +87,16 @@ final class BackgroundInteractionTests: XCTestCase {
8987
XCTAssertEqual(scrollContentOverflow(area: area, contentFrames: rows, isVertical: false), -40)
9088
}
9189

90+
func testScrollOverflowCountsAChildFarOutsideTheContent() {
91+
let area = RectResponse(x: 0, y: 100, width: 400, height: 600)
92+
let rows = (0..<10).map { row in
93+
RectResponse(x: 20, y: 100 + Double(row) * 120, width: 360, height: 100)
94+
}
95+
let header = RectResponse(x: 0, y: -5000, width: 400, height: 40)
96+
XCTAssertEqual(
97+
scrollContentOverflow(area: area, contentFrames: rows + [header], isVertical: true), 5680)
98+
}
99+
92100
func testScrollOverflowIgnoresEmptyFrames() {
93101
let area = RectResponse(x: 0, y: 100, width: 400, height: 600)
94102
let document = RectResponse(x: 0, y: -400, width: 400, height: 2000)

0 commit comments

Comments
 (0)