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 {
1010 /// Elements that exist only under `-UITesting`.
1111 static let testHooks: Set<String> = ["fold.path", "paper.camera", "step.kind"]
1212 /// 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)]
1414
1515 private var sizeName = ""
1616
@@ -108,9 +108,11 @@ final class AccessibilityAuditTests: XCTestCase {
108108 let navigationBar = app.navigationBars.firstMatch
109109 let barFrame = navigationBar.exists ? navigationBar.frame : .null
110110 let scrollFrames = app.scrollViews.allElementsBoundByIndex.map(\.frame)
111 let cutRows = rowsCutByTheStepList(app)
111112 var clipped: [String] = []
112113 try app.performAccessibilityAudit { issue in
113114 if self.isExpected(issue, screen: screen, barFrame: barFrame, scrollFrames: scrollFrames) { return true }
115 if self.isCutStepRow(issue, cutRows) { return true }
114116 // Clipping is re-checked below: it is reported now and then for text that is not clipped.
115117 if issue.auditType == .textClipped {
116118 clipped.append(issue.element?.label ?? "")
@@ -122,7 +124,7 @@ final class AccessibilityAuditTests: XCTestCase {
122124 guard !clipped.isEmpty else { return }
123125 sleep(1)
124126 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 }
126128 self.report(issue, name)
127129 return false
128130 }
@@ -145,6 +147,24 @@ final class AccessibilityAuditTests: XCTestCase {
145147 return false
146148 }
147149
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
148168 private func report(_ issue: XCUIAccessibilityAuditIssue, _ name: String) {
149169 print("AUDIT [\(sizeName)] [\(name)] \(issue.auditType.rawValue) \(issue.compactDescription) :: \(issue.element?.debugDescription.prefix(200) ?? "-")")
150170 }
App/UITests/FoldGestureTests.swift +16 −4
@@ -31,9 +31,10 @@ func completeCurrentFold(_ app: XCUIApplication) {
3131
3232/// Drags the current step's moving faces along their path, read from `fold.path` (the app must be
3333/// 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
35/// `minimumChord` points: a DragGesture does not begin under 10. A drag to the end continues 30
36/// points past it. Each holds before lifting, so its last position arrives before the lift.
34/// press-and-drag through every 32nd sample, and a fold-and-unfold's peak, with short ones merged
35/// so each moves at least `minimumChord` points: a DragGesture does not begin under 10. A drag to
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.
3738func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) {
3839 let paper = app.otherElements["fold.paper"]
3940 let marker = app.descendants(matching: .any)["fold.path"]
@@ -49,8 +50,16 @@ func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) {
4950 }
5051 func length(_ v: CGVector) -> Double { (v.dx * v.dx + v.dy * v.dy).squareRoot() }
5152 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
5257 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 }
5463 stops.append(i)
5564 }
5665 if stops.last != last {
@@ -65,6 +74,9 @@ func dragCurrentFold(_ app: XCUIApplication, to fraction: Double) {
6574 if b == samples.count - 1 {
6675 let d = chord(a, b), l = max(length(d), 1)
6776 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))
6880 }
6981 paper.coordinate(withNormalizedOffset: samples[a])
7082 .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 \
2222`everyShippedModelRegeneratesFromItsScript` checks that the shipped file is what the script
2323compiles to.
2424
25- The shipped file is built in debug, as the command above builds it.
26- A release build of `foldc` differs in step 4's solved curves by up to 9e-7°. Those curves come
27 from the null-space step of a three-degree-of-freedom vertex, which amplifies rounding.
28- Both builds are deterministic.
25Shipped `.fold` files come from the debug build, as `swift run foldc` above builds it. A
26release build of `foldc` can differ, by up to 9e-7°, in the solved curves of a step whose
27spare freedom R69 holds near its linear angles. That is the crane's step 4, the collapse.
28Both builds are deterministic.
2929
3030## Crease pattern and its source
3131
@@ -141,7 +141,8 @@ For the drag, at each step's authored viewpoint:
141141
142142- the neck's and the tail's pops move a covering axis's centroid at least 8 points on screen,
143143 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).
145146
146147## Layer-order overrides
147148
@@ -159,7 +160,7 @@ rest.
159160No other order is overridden. The guess passes the validator, the interpenetration check and
160161`layerMotionDefects` everywhere else.
161162
162## Not checked by eye
163## Checked by eye
163164
164The golden images (`crane-1` … `crane-16`) were looked at in a contact sheet only. The app run
165and the screenshots are recorded in the task report.
165The golden images (`crane-1` … `crane-16`) and the app's screenshots of every step were
166inspected.