finish out ReelGaps unit test

pull/968/head
nick black 4 years ago committed by Nick Black
parent a7411c080f
commit 5b6868abee

@ -12,5 +12,6 @@
auto find_data(const char* datum) -> char*;
auto enforce_utf8() -> bool;
auto testing_notcurses() -> struct notcurses*;
auto ncreel_validate(const ncreel* n) -> bool;
#endif

@ -1,23 +1,7 @@
#include "main.h"
#include <iostream>
auto panelcb(struct nctablet* t, bool toptobottom) -> int {
CHECK(nctablet_ncplane(t));
CHECK(!nctablet_userptr(t));
CHECK(toptobottom);
// FIXME verify geometry is as expected
return 0;
}
auto cbfxn(struct nctablet* t, bool toptobottom) -> int {
(void)toptobottom;
int* userptr = static_cast<int*>(nctablet_userptr(t));
++*userptr;
return 4;
}
// debugging
bool ncreel_validate(const ncreel* n){
auto ncreel_validate(const ncreel* n) -> bool {
if(n->tablets == NULL){
return true;
}
@ -66,6 +50,21 @@ bool ncreel_validate(const ncreel* n){
return true;
}
auto panelcb(struct nctablet* t, bool toptobottom) -> int {
CHECK(nctablet_ncplane(t));
CHECK(!nctablet_userptr(t));
CHECK(toptobottom);
// FIXME verify geometry is as expected
return 0;
}
auto cbfxn(struct nctablet* t, bool toptobottom) -> int {
(void)toptobottom;
int* userptr = static_cast<int*>(nctablet_userptr(t));
++*userptr;
return 4;
}
TEST_CASE("Reels") {
auto nc_ = testing_notcurses();
if(!nc_){
@ -423,119 +422,3 @@ TEST_CASE("Reels") {
}
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_));
}

@ -0,0 +1,151 @@
#include "main.h"
// ahci-1
int t1_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 6;
}
// mpt3sas-0
int t2_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 24;
}
// ahci-0
int t3_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 6;
}
// virtual
int t4_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 17;
}
// nvme-0
int t5_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 3;
}
// nvme-1
int t6_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 3;
}
// nvme-2
int t7_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 3;
}
// xhci_pci-0
int t8_tablet_cb(struct nctablet* t, bool drawfromtop){
REQUIRE(nullptr != t);
(void)drawfromtop;
return 5;
}
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); // move to t2
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
ncreel_next(nr); // move to t3
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
ncreel_next(nr); // move to t4
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
ncreel_next(nr); // move to t5
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
ncreel_next(nr); // move to t6
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
ncreel_next(nr); // move to t7
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
ncreel_next(nr); // move to t8
ncreel_redraw(nr);
CHECK(ncreel_validate(nr));
CHECK_EQ(0, notcurses_render(nc_));
sleep(1);
}
CHECK(0 == notcurses_stop(nc_));
}
Loading…
Cancel
Save