mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
ReelsGap unit test #901
This commit is contained in:
parent
fd9ff4ebe6
commit
0cee9bdb5c
@ -2495,7 +2495,9 @@ API int ncreel_tabletcount(const struct ncreel* pr);
|
||||
// -1 if the tablet cannot be found.
|
||||
API int ncreel_del(struct ncreel* pr, struct nctablet* t);
|
||||
|
||||
// Redraw the ncreel in its entirety.
|
||||
// Redraw the ncreel in its entirety. The reel will be cleared, and tablets
|
||||
// will be lain out, using the focused tablet as a fulcrum. Tablet drawing
|
||||
// callbacks will be invoked for each visible tablet.
|
||||
API int ncreel_redraw(struct ncreel* pr);
|
||||
|
||||
// Offer the input to the ncreel. If it's relevant, this function returns
|
||||
|
115
tests/reel.cpp
115
tests/reel.cpp
@ -421,6 +421,121 @@ TEST_CASE("Reels") {
|
||||
}
|
||||
CHECK(0 == ncreel_destroy(nr));
|
||||
}
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
}
|
||||
|
||||
int t1_tablet_cb(struct nctablet* t, bool drawfromtop){
|
||||
REQUIRE(nullptr != t);
|
||||
CHECK(drawfromtop);
|
||||
return 6;
|
||||
}
|
||||
|
||||
int t2_tablet_cb(struct nctablet* t, bool drawfromtop){
|
||||
REQUIRE(nullptr != t);
|
||||
CHECK(drawfromtop);
|
||||
return 24;
|
||||
}
|
||||
|
||||
int t3_tablet_cb(struct nctablet* t, bool drawfromtop){
|
||||
REQUIRE(nullptr != t);
|
||||
CHECK(drawfromtop);
|
||||
return 6;
|
||||
}
|
||||
|
||||
int t4_tablet_cb(struct nctablet* t, bool drawfromtop){
|
||||
REQUIRE(nullptr != t);
|
||||
CHECK(drawfromtop);
|
||||
return 17;
|
||||
}
|
||||
|
||||
int t5_tablet_cb(struct nctablet* t, bool drawfromtop){
|
||||
REQUIRE(nullptr != t);
|
||||
CHECK(drawfromtop);
|
||||
return 3;
|
||||
}
|
||||
|
||||
int t6_tablet_cb(struct nctablet* t, bool drawfromtop){
|
||||
REQUIRE(nullptr != t);
|
||||
CHECK(drawfromtop);
|
||||
return 3;
|
||||
}
|
||||
|
||||
TEST_CASE("ReelGaps") {
|
||||
auto nc_ = testing_notcurses();
|
||||
if(!nc_){
|
||||
return;
|
||||
}
|
||||
struct ncplane* n_ = notcurses_stdplane(nc_);
|
||||
REQUIRE(n_);
|
||||
|
||||
// https://github.com/dankamongmen/notcurses/issues/901
|
||||
SUBCASE("ReelsGapping") {
|
||||
ncreel_options r{};
|
||||
r.bordermask = 0xf;
|
||||
channels_set_bg_alpha(&r.bgchannel, 3);
|
||||
struct ncreel* nr = ncreel_create(n_, &r);
|
||||
REQUIRE(nr);
|
||||
CHECK_EQ(0, ncreel_redraw(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
CHECK(ncreel_validate(nr));
|
||||
auto t1 = ncreel_add(nr, NULL, NULL, t1_tablet_cb, NULL);
|
||||
CHECK(nullptr != t1);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t2 = ncreel_add(nr, NULL, NULL, t2_tablet_cb, NULL);
|
||||
CHECK(nullptr != t2);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t3 = ncreel_add(nr, NULL, NULL, t3_tablet_cb, NULL);
|
||||
CHECK(nullptr != t3);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t4 = ncreel_add(nr, NULL, NULL, t4_tablet_cb, NULL);
|
||||
CHECK(nullptr != t4);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t5 = ncreel_add(nr, NULL, NULL, t5_tablet_cb, NULL);
|
||||
CHECK(nullptr != t5);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t6 = ncreel_add(nr, NULL, NULL, t6_tablet_cb, NULL);
|
||||
CHECK(nullptr != t6);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr);
|
||||
ncreel_redraw(nr);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr);
|
||||
}
|
||||
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user