v2.3.0 release: onEditingEnded edit-ended callback on continuous controls
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
// OnEditingEndedTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable import LyrebirdUI
|
||||
import LyrebirdSynth
|
||||
|
||||
/// Coverage for the `.onEditingEnded` edit-reporting modifier on the continuous controls.
|
||||
///
|
||||
/// A SwiftUI gesture can't be driven from a unit test (same limitation noted in
|
||||
/// ``MultiSliderTests``), so these are structural smokes: they construct each control, attach
|
||||
/// `.onEditingEnded` with that control's payload shape, and confirm the builder returns a usable
|
||||
/// value of the same concrete type. Their real job is to **lock the public API** — the per-control
|
||||
/// closure signatures — so a later signature change breaks the build here rather than silently at a
|
||||
/// call site. The gesture → `(previous, new)` firing itself is covered by the control's own drag
|
||||
/// handler and is exercised in app use, not here.
|
||||
@MainActor
|
||||
@Suite("onEditingEnded")
|
||||
struct OnEditingEndedTests {
|
||||
|
||||
@Test func knobBuilderCarriesTheAction() {
|
||||
let node: UIParamNode = UIParamNode(0.5)
|
||||
var reported: (Double, Double)?
|
||||
let knob: ParameterKnob = ParameterKnob("Cutoff", node: node, range: 0...1)
|
||||
.onEditingEnded { previous, new in reported = (previous, new) }
|
||||
_ = knob
|
||||
// The closure has not been invoked (no gesture), so nothing is reported yet.
|
||||
#expect(reported == nil)
|
||||
}
|
||||
|
||||
@Test func sliderBuilderCarriesTheAction() {
|
||||
let node: UIParamNode = UIParamNode(0.25)
|
||||
let slider: ParameterSlider = ParameterSlider("Amp", node: node, range: 0...1)
|
||||
.onEditingEnded { _, _ in }
|
||||
_ = slider
|
||||
}
|
||||
|
||||
@Test func xyBuilderCarriesTheAction() {
|
||||
let xNode: UIParamNode = UIParamNode(0.0)
|
||||
let yNode: UIParamNode = UIParamNode(0.0)
|
||||
let pad: ParameterXY = ParameterXY(
|
||||
xLabel: "Pan", xNode: xNode, xRange: -1...1,
|
||||
yLabel: "Amp", yNode: yNode, yRange: 0...1
|
||||
)
|
||||
.onEditingEnded { previous, new in
|
||||
// Payload is a pair of (x, y) tuples — reference the members so a shape change breaks here.
|
||||
_ = (previous.x, previous.y, new.x, new.y)
|
||||
}
|
||||
_ = pad
|
||||
}
|
||||
|
||||
@Test func multiSliderBuilderCarriesTheAction() {
|
||||
let buffer: LyrebirdBuffer = LyrebirdBuffer(count: 8)
|
||||
buffer.fill(with: 0.3)
|
||||
let bars: MultiSlider = MultiSlider(buffer: buffer, count: 4, range: 0...1)
|
||||
.onEditingEnded { previous, new in
|
||||
// Payload is the cell-value arrays before / after the drag.
|
||||
_ = (previous.count, new.count)
|
||||
}
|
||||
_ = bars
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user