Fix waveform_view comment accuracy, cut duplicate comments, align xToFrame to OverlayArea
This commit is contained in:
@@ -26,8 +26,6 @@ static int g_fail = 0;
|
||||
#define CHECK(cond) do { if(!(cond)) { \
|
||||
std::printf("FAIL line %d: %s\n", __LINE__, #cond); ++g_fail; } } while(0)
|
||||
|
||||
// frameToX/markerAtPoint/resolveDragFrame take the overlay type, not a bare Rect (the
|
||||
// distinct-type enforcement in editor_geometry.h) — this wraps a plain test Rect for them.
|
||||
static OverlayArea overlayOf(const Rect& r) { return OverlayArea{r}; }
|
||||
|
||||
// A comfortable waveform area: 1000px wide, offset so left != 0 (catches origin bugs).
|
||||
@@ -57,16 +55,16 @@ static void testFrameToXDegenerate() {
|
||||
|
||||
static void testXToFrameInverse() {
|
||||
const Rect a = wideArea();
|
||||
CHECK(xToFrame(a, 1000, a.x) == 0);
|
||||
CHECK(xToFrame(a, 1000, a.right()) == 1000);
|
||||
CHECK(xToFrame(a, 1000, a.x + 250) == 250); // 1:1 map here
|
||||
CHECK(xToFrame(overlayOf(a), 1000, a.x) == 0);
|
||||
CHECK(xToFrame(overlayOf(a), 1000, a.right()) == 1000);
|
||||
CHECK(xToFrame(overlayOf(a), 1000, a.x + 250) == 250); // 1:1 map here
|
||||
}
|
||||
|
||||
static void testXToFrameClampsOutside() {
|
||||
const Rect a = wideArea();
|
||||
CHECK(xToFrame(a, 1000, a.x - 100) == 0); // left of area -> 0
|
||||
CHECK(xToFrame(a, 1000, a.right() + 100) == 1000); // right of area -> frameCount
|
||||
CHECK(xToFrame(a, 0, a.x + 10) == 0); // no frames -> 0
|
||||
CHECK(xToFrame(overlayOf(a), 1000, a.x - 100) == 0); // left of area -> 0
|
||||
CHECK(xToFrame(overlayOf(a), 1000, a.right() + 100) == 1000); // right of area -> frameCount
|
||||
CHECK(xToFrame(overlayOf(a), 0, a.x + 10) == 0); // no frames -> 0
|
||||
}
|
||||
|
||||
static void testFrameToXRoundTrip() {
|
||||
@@ -75,7 +73,7 @@ static void testFrameToXRoundTrip() {
|
||||
const Rect a = Rect::ltrb(0, 0, 800, 60);
|
||||
for (std::int64_t f = 0; f <= 2000; f += 137) {
|
||||
const int x = frameToX(overlayOf(a), 2000, f);
|
||||
const std::int64_t back = xToFrame(a, 2000, x);
|
||||
const std::int64_t back = xToFrame(overlayOf(a), 2000, x);
|
||||
CHECK(back >= f - 3 && back <= f + 3);
|
||||
}
|
||||
}
|
||||
@@ -269,6 +267,15 @@ static void testSurfaceDegenerateBandDrawsNothing() {
|
||||
CHECK(waveformOverlayArea(Rect{10, 10, 0, 0}).rect.empty());
|
||||
}
|
||||
|
||||
static void testSurfaceThinBandRoundsLowerLaneEmpty() {
|
||||
// Height 3 is the edge where the stereo split's integer division rounds the lower lane to
|
||||
// empty even though the band itself isn't degenerate — pins the laneCount derivation.
|
||||
const WaveformSurface s = waveformSurface(Rect{0, 0, 100, 3}, true, 2);
|
||||
CHECK(s.laneCount == 1);
|
||||
CHECK(!s.upper.empty());
|
||||
CHECK(s.lower.empty());
|
||||
}
|
||||
|
||||
// --- Hit-testing across the stacked lanes -------------------------------------
|
||||
|
||||
static void testMarkerGrabReachesTheLowerStereoLane() {
|
||||
@@ -367,6 +374,7 @@ int main() {
|
||||
testSurfaceMonoSourceInStereoModeStaysOneLane();
|
||||
testSurfaceOverlayIsFullStackedHeightInBothModes();
|
||||
testSurfaceDegenerateBandDrawsNothing();
|
||||
testSurfaceThinBandRoundsLowerLaneEmpty();
|
||||
|
||||
testMarkerGrabReachesTheLowerStereoLane();
|
||||
testMarkerGrabInMonoSpansTheBand();
|
||||
|
||||
Reference in New Issue
Block a user