Phase S FB1 (r11): Sample-view recomposition — knob deck + elastic full-width hero + curve popup w/ right-click delete + post-mixer master gain (ComponentState v8)
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
// Standalone tests for reasampler::vst::curve_popup — no VST3, no REAPER, no framework. Same
|
||||
// fast assert loop as the sibling pure tests. Assert the r11 popup-sheet geometry at the size
|
||||
// clamps (the spec's width clamp(60%, 360..520) / height clamp(55%, 260..380)), the centering,
|
||||
// the title-row/close-button placement, the curve-box remainder, and the outside-sheet
|
||||
// dismissal test.
|
||||
|
||||
#include "../src/vst/curve_popup.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
using namespace reasampler::vst;
|
||||
|
||||
static int g_fail = 0;
|
||||
#define CHECK(cond) do { if(!(cond)) { \
|
||||
std::printf("FAIL line %d: %s\n", __LINE__, #cond); ++g_fail; } } while(0)
|
||||
|
||||
static void testDefaultWindowMidClamp() {
|
||||
// 840x620: 60% = 504 (inside 360..520), 55% = 341 (inside 260..380).
|
||||
const CurvePopupLayout pl = computeCurvePopup(840, 620);
|
||||
CHECK(pl.sheet.width() == 504);
|
||||
CHECK(pl.sheet.height() == 341);
|
||||
// Centered (within the integer-division pixel).
|
||||
CHECK(pl.sheet.left == (840 - 504) / 2);
|
||||
CHECK(pl.sheet.top == (620 - 341) / 2);
|
||||
}
|
||||
|
||||
static void testMinClamp() {
|
||||
// The 560x460 constraint floor: 60% = 336 -> clamps UP to 360; 55% = 253 -> up to 260.
|
||||
const CurvePopupLayout pl = computeCurvePopup(560, 460);
|
||||
CHECK(pl.sheet.width() == kCurvePopupMinW);
|
||||
CHECK(pl.sheet.height() == kCurvePopupMinH);
|
||||
CHECK(pl.sheet.left >= 0 && pl.sheet.right <= 560);
|
||||
CHECK(pl.sheet.top >= 0 && pl.sheet.bottom <= 460);
|
||||
}
|
||||
|
||||
static void testMaxClamp() {
|
||||
// A large window: 60% of 1600 = 960 -> clamps DOWN to 520; 55% of 900 = 495 -> down to 380.
|
||||
const CurvePopupLayout pl = computeCurvePopup(1600, 900);
|
||||
CHECK(pl.sheet.width() == kCurvePopupMaxW);
|
||||
CHECK(pl.sheet.height() == kCurvePopupMaxH);
|
||||
}
|
||||
|
||||
static void testDegenerateWindowNeverOverhangs() {
|
||||
// A window smaller than the min clamp: the sheet caps at the window dimension (defensive —
|
||||
// below checkSizeConstraint, but geometry must stay sane).
|
||||
const CurvePopupLayout pl = computeCurvePopup(300, 200);
|
||||
CHECK(pl.sheet.width() == 300);
|
||||
CHECK(pl.sheet.height() == 200);
|
||||
CHECK(pl.sheet.left == 0 && pl.sheet.top == 0);
|
||||
}
|
||||
|
||||
static void testTitleRowAndCurveBox() {
|
||||
const CurvePopupLayout pl = computeCurvePopup(840, 620);
|
||||
// Close: 18x18, right-anchored inside the title row.
|
||||
CHECK(pl.close.width() == kCurvePopupCloseSize && pl.close.height() == kCurvePopupCloseSize);
|
||||
CHECK(pl.close.right == pl.sheet.right - kCurvePopupPad);
|
||||
CHECK(pl.close.top >= pl.sheet.top);
|
||||
CHECK(pl.close.bottom <= pl.sheet.top + kCurvePopupTitleH);
|
||||
// Title text: left of the close button, in the title row.
|
||||
CHECK(pl.title.left == pl.sheet.left + kCurvePopupPad);
|
||||
CHECK(pl.title.right <= pl.close.left);
|
||||
// Curve box: fills the remainder below the title row, inside the sheet margins.
|
||||
CHECK(pl.curveBox.top >= pl.sheet.top + kCurvePopupTitleH);
|
||||
CHECK(pl.curveBox.left == pl.sheet.left + kCurvePopupPad);
|
||||
CHECK(pl.curveBox.right == pl.sheet.right - kCurvePopupPad);
|
||||
CHECK(pl.curveBox.bottom == pl.sheet.bottom - kCurvePopupPad);
|
||||
CHECK(pl.curveBox.width() > 0 && pl.curveBox.height() > 0);
|
||||
}
|
||||
|
||||
static void testOutsideSheetDismissTest() {
|
||||
const CurvePopupLayout pl = computeCurvePopup(840, 620);
|
||||
// On the wash: outside.
|
||||
CHECK(popupOutsideSheet(pl, 0, 0));
|
||||
CHECK(popupOutsideSheet(pl, pl.sheet.left - 1, pl.sheet.top + 10));
|
||||
CHECK(popupOutsideSheet(pl, pl.sheet.right, pl.sheet.top + 10)); // half-open right edge
|
||||
// On the sheet (title row, curve box, padding): inside.
|
||||
CHECK(!popupOutsideSheet(pl, pl.sheet.left, pl.sheet.top));
|
||||
CHECK(!popupOutsideSheet(pl, pl.curveBox.left + 5, pl.curveBox.top + 5));
|
||||
CHECK(!popupOutsideSheet(pl, pl.sheet.right - 1, pl.sheet.bottom - 1));
|
||||
}
|
||||
|
||||
int main() {
|
||||
testDefaultWindowMidClamp();
|
||||
testMinClamp();
|
||||
testMaxClamp();
|
||||
testDegenerateWindowNeverOverhangs();
|
||||
testTitleRowAndCurveBox();
|
||||
testOutsideSheetDismissTest();
|
||||
if (g_fail) {
|
||||
std::printf("%d FAILURE(S)\n", g_fail);
|
||||
return 1;
|
||||
}
|
||||
std::printf("curve_popup tests passed\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user