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:
@@ -1,4 +1,4 @@
|
||||
// Standalone tests for reasampler::vst::browser_scroll — no VST3, no REAPER, no framework.
|
||||
// Standalone tests for reasampler::instrument::ui::browser_scroll — no VST3, no REAPER, no framework.
|
||||
// Same fast assert loop as the sibling pure editor tests: assert the S12 scroll-window +
|
||||
// scrollbar-thumb + type-to-filter-search geometry LAYERED over the S10 capture_browser.
|
||||
//
|
||||
@@ -11,13 +11,14 @@
|
||||
// (case-insensitive substring, empty-query identity, no-match); filterNameIndices preserving order
|
||||
// and returning every index for an empty query.
|
||||
|
||||
#include "../src/vst/browser_scroll.h"
|
||||
#include "../src/core/instrument/ui/browser_scroll.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace reasampler::vst;
|
||||
using namespace reasampler;
|
||||
using namespace reasampler::instrument::ui;
|
||||
|
||||
static int g_fail = 0;
|
||||
#define CHECK(cond) do { if(!(cond)) { \
|
||||
@@ -45,7 +46,7 @@ static void testMaxOffsetFitsAndOverflows() {
|
||||
CHECK(scrollMaxOffset(L, L.columns) == 0);
|
||||
// Many rows overflow -> max = content - gridHeight.
|
||||
const int many = L.columns * 20;
|
||||
const int expect = scrollContentHeight(L, many) - L.grid.height();
|
||||
const int expect = scrollContentHeight(L, many) - L.grid.height;
|
||||
CHECK(scrollMaxOffset(L, many) == expect);
|
||||
CHECK(expect > 0);
|
||||
}
|
||||
@@ -67,7 +68,7 @@ static void testVisibleRangeTop() {
|
||||
const VisibleRange vr = visibleCardRange(L, many, 0);
|
||||
CHECK(vr.first == 0);
|
||||
// At offset 0, the last visible row is the one containing (gridH-1).
|
||||
const int expectedLastRow = (L.grid.height() - 1) / kBrowserCardHeight + 1;
|
||||
const int expectedLastRow = (L.grid.height - 1) / kBrowserCardHeight + 1;
|
||||
CHECK(vr.last == expectedLastRow * L.columns);
|
||||
}
|
||||
|
||||
@@ -89,30 +90,30 @@ static void testScrolledCellShiftsUp() {
|
||||
const BrowserLayout L = wideLayout();
|
||||
const Rect base = cardCellRect(L, 3);
|
||||
const Rect shifted = scrolledCardCellRect(L, 3, 40);
|
||||
CHECK(shifted.top == base.top - 40);
|
||||
CHECK(shifted.bottom == base.bottom - 40);
|
||||
CHECK(shifted.left == base.left);
|
||||
CHECK(shifted.y == base.y - 40);
|
||||
CHECK(shifted.bottom() == base.bottom() - 40);
|
||||
CHECK(shifted.x == base.x);
|
||||
}
|
||||
|
||||
// --- scrollbar thumb ----------------------------------------------------------
|
||||
|
||||
static void testThumbEmptyWhenFits() {
|
||||
const BrowserLayout L = wideLayout();
|
||||
CHECK(scrollThumbRect(L, L.columns, 0).height() == 0); // one row fits -> no thumb
|
||||
CHECK(scrollThumbRect(L, L.columns, 0).height == 0); // one row fits -> no thumb
|
||||
}
|
||||
|
||||
static void testThumbProportionalAndClamped() {
|
||||
const BrowserLayout L = wideLayout();
|
||||
const int many = L.columns * 20;
|
||||
const Rect atTop = scrollThumbRect(L, many, 0);
|
||||
CHECK(atTop.height() > 0);
|
||||
CHECK(atTop.top == L.grid.top); // at offset 0 the thumb starts at the track top
|
||||
CHECK(atTop.width() == kScrollbarWidth);
|
||||
CHECK(atTop.right == L.grid.right);
|
||||
CHECK(atTop.height > 0);
|
||||
CHECK(atTop.y == L.grid.y); // at offset 0 the thumb starts at the track top
|
||||
CHECK(atTop.width == kScrollbarWidth);
|
||||
CHECK(atTop.right() == L.grid.right());
|
||||
// At max offset, the thumb bottom reaches the grid bottom (pinned to the end).
|
||||
const int maxOff = scrollMaxOffset(L, many);
|
||||
const Rect atMax = scrollThumbRect(L, many, maxOff);
|
||||
CHECK(atMax.bottom == L.grid.top + L.grid.height());
|
||||
CHECK(atMax.bottom() == L.grid.y + L.grid.height);
|
||||
}
|
||||
|
||||
static void testThumbDragIsInverse() {
|
||||
@@ -126,7 +127,7 @@ static void testThumbDragIsInverse() {
|
||||
CHECK(thumbDragToOffset(L, many, maxOff, -100000) == 0);
|
||||
// Dragging the thumb by the whole track span from top reaches (near) max.
|
||||
const Rect thumb = scrollThumbRect(L, many, 0);
|
||||
const int trackSpan = L.grid.height() - thumb.height();
|
||||
const int trackSpan = L.grid.height - thumb.height;
|
||||
const int off = thumbDragToOffset(L, many, 0, trackSpan);
|
||||
CHECK(off >= maxOff - 2 && off <= maxOff);
|
||||
}
|
||||
@@ -135,8 +136,8 @@ static void testThumbDragIsInverse() {
|
||||
|
||||
static void testSearchBoxRect() {
|
||||
const Rect r = searchBoxRect(200);
|
||||
CHECK(r.left == 0 && r.top == 0 && r.right == 200 && r.height() == kSearchBoxHeight);
|
||||
CHECK(searchBoxRect(0).width() == 0);
|
||||
CHECK(r.x == 0 && r.y == 0 && r.right() == 200 && r.height == kSearchBoxHeight);
|
||||
CHECK(searchBoxRect(0).width == 0);
|
||||
}
|
||||
|
||||
static void testNameMatch() {
|
||||
|
||||
Reference in New Issue
Block a user