Q-W1 pt2: core/shell/app relocation + sub-namespaces; one concrete ui::Rect (LTRB fork retired); slot_map split from bank_book; BankIndex→BankModel; 59/59 green
This commit is contained in:
+33
-32
@@ -1,14 +1,15 @@
|
||||
// Standalone tests for reasampler::vst::curve_popup — no VST3, no REAPER, no framework. Same
|
||||
// Standalone tests for reasampler::instrument::ui::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 "../src/core/instrument/ui/curve_popup.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
using namespace reasampler::vst;
|
||||
using namespace reasampler;
|
||||
using namespace reasampler::instrument::ui;
|
||||
|
||||
static int g_fail = 0;
|
||||
#define CHECK(cond) do { if(!(cond)) { \
|
||||
@@ -17,66 +18,66 @@ static int g_fail = 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);
|
||||
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);
|
||||
CHECK(pl.sheet.x == (840 - 504) / 2);
|
||||
CHECK(pl.sheet.y == (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);
|
||||
CHECK(pl.sheet.width == kCurvePopupMinW);
|
||||
CHECK(pl.sheet.height == kCurvePopupMinH);
|
||||
CHECK(pl.sheet.x >= 0 && pl.sheet.right() <= 560);
|
||||
CHECK(pl.sheet.y >= 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);
|
||||
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);
|
||||
CHECK(pl.sheet.width == 300);
|
||||
CHECK(pl.sheet.height == 200);
|
||||
CHECK(pl.sheet.x == 0 && pl.sheet.y == 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);
|
||||
CHECK(pl.close.width == kCurvePopupCloseSize && pl.close.height == kCurvePopupCloseSize);
|
||||
CHECK(pl.close.right() == pl.sheet.right() - kCurvePopupPad);
|
||||
CHECK(pl.close.y >= pl.sheet.y);
|
||||
CHECK(pl.close.bottom() <= pl.sheet.y + 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);
|
||||
CHECK(pl.title.x == pl.sheet.x + kCurvePopupPad);
|
||||
CHECK(pl.title.right() <= pl.close.x);
|
||||
// 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);
|
||||
CHECK(pl.curveBox.y >= pl.sheet.y + kCurvePopupTitleH);
|
||||
CHECK(pl.curveBox.x == pl.sheet.x + 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
|
||||
CHECK(popupOutsideSheet(pl, pl.sheet.x - 1, pl.sheet.y + 10));
|
||||
CHECK(popupOutsideSheet(pl, pl.sheet.right(), pl.sheet.y + 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));
|
||||
CHECK(!popupOutsideSheet(pl, pl.sheet.x, pl.sheet.y));
|
||||
CHECK(!popupOutsideSheet(pl, pl.curveBox.x + 5, pl.curveBox.y + 5));
|
||||
CHECK(!popupOutsideSheet(pl, pl.sheet.right() - 1, pl.sheet.bottom() - 1));
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
Reference in New Issue
Block a user