Commit f96de825e7

f96de825e76dfb6271e28ce5f6892fb379d7711c

parent: b4264f8b8c

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-23 01:26 UTC

Audit the sampan and crane; drag past a fold-and-unfold's peak

The audit walks all four models. Clipped text in a step-list row that
the list's edge cuts is not counted (R79). The UI drag helper carries
the drag that reaches a fold-and-unfold's peak on past it (R80).
crane.md records that shipped models come from debug foldc (R83).

Ref #7

Layout: unified · split

App/UITests/AccessibilityAuditTests.swift +22 −2
@@ -10,7 +10,7 @@ final class AccessibilityAuditTests: XCTestCase {
10 /// Elements that exist only under `-UITesting`. 10 /// Elements that exist only under `-UITesting`.
11 static let testHooks: Set<String> = ["fold.path", "paper.camera", "step.kind"] 11 static let testHooks: Set<String> = ["fold.path", "paper.camera", "step.kind"]
12 /// Every model in the list, by title, with its number of steps. 12 /// Every model in the list, by title, with its number of steps.
13 static let models = [("Cup", 6), ("Box", 12)] 13 static let models = [("Cup", 6), ("Box", 12), ("Sampan", 6), ("Crane", 16)]
14 14
15 private var sizeName = "" 15 private var sizeName = ""
16 16
@@ -108,9 +108,11 @@ final class AccessibilityAuditTests: XCTestCase {
108 let navigationBar = app.navigationBars.firstMatch 108 let navigationBar = app.navigationBars.firstMatch
109 let barFrame = navigationBar.exists ? navigationBar.frame : .null 109 let barFrame = navigationBar.exists ? navigationBar.frame : .null
110 let scrollFrames = app.scrollViews.allElementsBoundByIndex.map(\.frame) 110 let scrollFrames = app.scrollViews.allElementsBoundByIndex.map(\.frame)
111 let cutRows = rowsCutByTheStepList(app)
111 var clipped: [String] = [] 112 var clipped: [String] = []
112 try app.performAccessibilityAudit { issue in 113 try app.performAccessibilityAudit { issue in
113 if self.isExpected(issue, screen: screen, barFrame: barFrame, scrollFrames: scrollFrames) { return true } 114 if self.isExpected(issue, screen: screen, barFrame: barFrame, scrollFrames: scrollFrames) { return true }
115 if self.isCutStepRow(issue, cutRows) { return true }
114 // Clipping is re-checked below: it is reported now and then for text that is not clipped. 116 // Clipping is re-checked below: it is reported now and then for text that is not clipped.
115 if issue.auditType == .textClipped { 117 if issue.auditType == .textClipped {
116 clipped.append(issue.element?.label ?? "") 118 clipped.append(issue.element?.label ?? "")
@@ -122,7 +124,7 @@ final class AccessibilityAuditTests: XCTestCase {
122 guard !clipped.isEmpty else { return } 124 guard !clipped.isEmpty else { return }
123 sleep(1) 125 sleep(1)
124 try app.performAccessibilityAudit(for: .textClipped) { issue in 126 try app.performAccessibilityAudit(for: .textClipped) { issue in
125 guard clipped.contains(issue.element?.label ?? "") else { return true } 127 guard clipped.contains(issue.element?.label ?? ""), !self.isCutStepRow(issue, cutRows) else { return true }
126 self.report(issue, name) 128 self.report(issue, name)
127 return false 129 return false
128 } 130 }
@@ -145,6 +147,24 @@ final class AccessibilityAuditTests: XCTestCase {
145 return false 147 return false
146 } 148 }
147 149
150 /// The frames of the step list's rows (`step.N`) partly scrolled out of the list, whose text the
151 /// list's edge clips.
152 private func rowsCutByTheStepList(_ app: XCUIApplication) -> [CGRect] {
153 let list = app.collectionViews.firstMatch
154 guard list.exists else { return [] }
155 let edge = list.frame
156 let rows = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH 'step.'")).allElementsBoundByIndex
157 return rows.map(\.frame).filter { $0.intersects(edge) && !edge.contains($0) }
158 }
159
160 /// Whether `issue` is text clipped in a step-list row that the list's edge cuts. The audit
161 /// reports such text without an element at times, which matches only while a row is cut.
162 private func isCutStepRow(_ issue: XCUIAccessibilityAuditIssue, _ cutRows: [CGRect]) -> Bool {
163 guard issue.auditType == .textClipped, !cutRows.isEmpty else { return false }
164 guard let element = issue.element else { return true }
165 return cutRows.contains { $0.intersects(element.frame) }
166 }
167
148 private func report(_ issue: XCUIAccessibilityAuditIssue, _ name: String) { 168 private func report(_ issue: XCUIAccessibilityAuditIssue, _ name: String) {
149 print("AUDIT [\(sizeName)] [\(name)] \(issue.auditType.rawValue) \(issue.compactDescription) :: \(issue.element?.debugDescription.prefix(200) ?? "-")") 169 print("AUDIT [\(sizeName)] [\(name)] \(issue.auditType.rawValue) \(issue.compactDescription) :: \(issue.element?.debugDescription.prefix(200) ?? "-")")
150 } 170 }
App/UITests/FoldGestureTests.swift +16 −4
@@ -31,9 +31,10 @@ func completeCurrentFold(_ app: XCUIApplication) {
31 31
32/// Drags the current step's moving faces along their path, read from `fold.path` (the app must be 32/// Drags the current step's moving faces along their path, read from `fold.path` (the app must be
33/// launched with `-UITesting`), to `fraction` of it, then lifts. Each drag is one straight 33/// launched with `-UITesting`), to `fraction` of it, then lifts. Each drag is one straight
34/// press-and-drag through every 32nd sample, with short ones merged so each moves at least 34/// press-and-drag through every 32nd sample, and a fold-and-unfold's peak, with short ones merged
35/// `minimumChord` points: a DragGesture does not begin under 10. A drag to the end continues 30 35/// so each moves at least `minimumChord` points: a DragGesture does not begin under 10. A drag to
36/// points past it. Each holds before lifting, so its last position arrives before the lift. 36/// the peak continues 8 points past it, and a drag to the end 30. Each holds before lifting, so its
37/// last position arrives before the lift.
37func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) { 38func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) {
38 let paper = app.otherElements["fold.paper"] 39 let paper = app.otherElements["fold.paper"]
39 let marker = app.descendants(matching: .any)["fold.path"] 40 let marker = app.descendants(matching: .any)["fold.path"]
@@ -49,8 +50,16 @@ func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) {
49 } 50 }
50 func length(_ v: CGVector) -> Double { (v.dx * v.dx + v.dy * v.dy).squareRoot() } 51 func length(_ v: CGVector) -> Double { (v.dx * v.dx + v.dy * v.dy).squareRoot() }
51 let last = Int((fraction * Double(samples.count - 1)).rounded()) 52 let last = Int((fraction * Double(samples.count - 1)).rounded())
53 // a fold-and-unfold turns back at its peak, the sample farthest from the start; the drag that
54 // reaches it carries on past it, since the drag after it starts back down the way it came
55 let peak = stepKind(app) == "foldAndUnfold" && last > 1
56 ? (1..<last).max { length(chord(0, $0)) < length(chord(0, $1)) } : nil
52 var stops = [0] 57 var stops = [0]
53 for i in stride(from: 32, through: last, by: 32) where length(chord(stops.last!, i)) >= minimumChord { 58 for i in (Array(stride(from: 32, through: last, by: 32)) + (peak.map { [$0] } ?? [])).sorted()
59 where i == peak || (length(chord(stops.last!, i)) >= minimumChord && abs(i - (peak ?? -99)) >= 8) {
60 if i == peak {
61 while stops.count > 1 && length(chord(stops.last!, i)) < minimumChord { stops.removeLast() }
62 }
54 stops.append(i) 63 stops.append(i)
55 } 64 }
56 if stops.last != last { 65 if stops.last != last {
@@ -65,6 +74,9 @@ func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) {
65 if b == samples.count - 1 { 74 if b == samples.count - 1 {
66 let d = chord(a, b), l = max(length(d), 1) 75 let d = chord(a, b), l = max(length(d), 1)
67 end = end.withOffset(CGVector(dx: d.dx / l * 30, dy: d.dy / l * 30)) 76 end = end.withOffset(CGVector(dx: d.dx / l * 30, dy: d.dy / l * 30))
77 } else if b == peak {
78 let d = chord(a, b), l = max(length(d), 1)
79 end = end.withOffset(CGVector(dx: d.dx / l * 8, dy: d.dy / l * 8))
68 } 80 }
69 paper.coordinate(withNormalizedOffset: samples[a]) 81 paper.coordinate(withNormalizedOffset: samples[a])
70 .press(forDuration: 0.1, thenDragTo: end, withVelocity: .default, thenHoldForDuration: 0.3) 82 .press(forDuration: 0.1, thenDragTo: end, withVelocity: .default, thenHoldForDuration: 0.3)
docs/authoring/crane.md +9 −8
@@ -22,10 +22,10 @@ swift run --package-path Packages/FoldKit foldc Models/crane.foldscript \
22`everyShippedModelRegeneratesFromItsScript` checks that the shipped file is what the script 22`everyShippedModelRegeneratesFromItsScript` checks that the shipped file is what the script
23compiles to. 23compiles to.
24 24
25- The shipped file is built in debug, as the command above builds it. 25Shipped `.fold` files come from the debug build, as `swift run foldc` above builds it. A
26- A release build of `foldc` differs in step 4's solved curves by up to 9e-7°. Those curves come 26release build of `foldc` can differ, by up to 9e-7°, in the solved curves of a step whose
27 from the null-space step of a three-degree-of-freedom vertex, which amplifies rounding. 27spare freedom R69 holds near its linear angles. That is the crane's step 4, the collapse.
28- Both builds are deterministic. 28Both builds are deterministic.
29 29
30## Crease pattern and its source 30## Crease pattern and its source
31 31
@@ -141,7 +141,8 @@ For the drag, at each step's authored viewpoint:
141 141
142- the neck's and the tail's pops move a covering axis's centroid at least 8 points on screen, 142- the neck's and the tail's pops move a covering axis's centroid at least 8 points on screen,
143 so the drag follows them; 143 so the drag follows them;
144- the head's pop moves less, so its segment is the straight line down. 144- the head's pop moves less, so its segment is the straight line down, at most half the paper
145 view's height for the pop (R81).
145 146
146## Layer-order overrides 147## Layer-order overrides
147 148
@@ -159,7 +160,7 @@ rest.
159No other order is overridden. The guess passes the validator, the interpenetration check and 160No other order is overridden. The guess passes the validator, the interpenetration check and
160`layerMotionDefects` everywhere else. 161`layerMotionDefects` everywhere else.
161 162
162## Not checked by eye 163## Checked by eye
163 164
164The golden images (`crane-1` … `crane-16`) were looked at in a contact sheet only. The app run 165The golden images (`crane-1` … `crane-16`) and the app's screenshots of every step were
165and the screenshots are recorded in the task report. 166inspected.