notcurses/tests/reel.cpp

409 lines
12 KiB
C++
Raw Normal View History

2020-02-05 22:29:42 +00:00
#include "main.h"
#include <iostream>
2020-08-28 16:10:14 +00:00
auto ncreel_validate(const ncreel* n) -> bool {
if(n->tablets == NULL){
return true;
}
const nctablet* t = n->tablets;
int cury = -1;
bool wentaround = false;
do{
const ncplane* np = t->p;
if(np){
int y, x;
ncplane_yx(np, &y, &x);
//fprintf(stderr, "forvart: %p (%p) @ %d\n", t, np, y);
if(y < cury + 1){
if(wentaround){
return false;
}
wentaround = true;
}else if(y == cury){
return false;
}
int ylen, xlen;
ncplane_dim_yx(np, &ylen, &xlen);
cury = y + ylen - 1;
}
}while((t = t->next) != n->tablets);
cury = INT_MAX;
wentaround = false;
do{
const ncplane* np = t->p;
if(np){
int y, x, ylen, xlen;
ncplane_yx(np, &y, &x);
ncplane_dim_yx(np, &ylen, &xlen);
//fprintf(stderr, "backwards: %p (%p) @ %d\n", t, np, y);
if(y + ylen - 1 > cury - 1){
if(wentaround){
return false;
}
wentaround = true;
}else if(y == cury){
return false;
}
cury = y;
}
}while((t = t->prev) != n->tablets);
return true;
}
2020-08-28 16:10:14 +00:00
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;
}
2020-05-07 19:06:07 +00:00
TEST_CASE("Reels") {
auto nc_ = testing_notcurses();
if(!nc_){
return;
}
2020-02-05 22:29:42 +00:00
struct ncplane* n_ = notcurses_stdplane(nc_);
REQUIRE(n_);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
SUBCASE("InitLinear") {
ncreel_options r = { };
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("InitLinearInfinite") {
ncreel_options r{};
2020-05-29 18:53:53 +00:00
r.flags = NCREEL_OPTION_INFINITESCROLL;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("InitCircular") {
ncreel_options r{};
2020-05-29 18:53:53 +00:00
r.flags = NCREEL_OPTION_INFINITESCROLL | NCREEL_OPTION_CIRCULAR;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK(ncreel_validate(nr));
CHECK(0 == notcurses_render(nc_));
2020-02-05 22:29:42 +00:00
REQUIRE(0 == ncreel_destroy(nr));
}
// circular is not allowed to be true when infinitescroll is false
SUBCASE("FiniteCircleRejected") {
ncreel_options r{};
2020-05-29 18:53:53 +00:00
r.flags = NCREEL_OPTION_CIRCULAR;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(!nr);
CHECK(0 == notcurses_render(nc_));
REQUIRE(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
// We ought be able to invoke ncreel_next() and ncreel_prev() safely,
// even if there are no tablets. They both ought return nullptr.
SUBCASE("MovementWithoutTablets") {
ncreel_options r{};
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK(!ncreel_next(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
2020-02-05 22:29:42 +00:00
CHECK(!ncreel_prev(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
REQUIRE(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("OneTablet") {
ncreel_options r{};
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
struct nctablet* t = ncreel_add(nr, nullptr, nullptr, panelcb, nullptr);
2020-02-05 22:29:42 +00:00
REQUIRE(t);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
2020-02-05 22:29:42 +00:00
CHECK(0 == ncreel_del(nr, t));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
REQUIRE(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("MovementWithOneTablet") {
ncreel_options r{};
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
struct nctablet* t = ncreel_add(nr, nullptr, nullptr, panelcb, nullptr);
2020-02-05 22:29:42 +00:00
REQUIRE(t);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
2020-02-05 22:29:42 +00:00
CHECK(ncreel_next(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
2020-02-05 22:29:42 +00:00
CHECK(ncreel_prev(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
2020-02-05 22:29:42 +00:00
CHECK(0 == ncreel_del(nr, t));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
REQUIRE(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("DeleteActiveTablet") {
ncreel_options r{};
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
struct nctablet* t = ncreel_add(nr, nullptr, nullptr, panelcb, nullptr);
2020-02-05 22:29:42 +00:00
REQUIRE(t);
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
CHECK(0 == ncreel_del(nr, ncreel_focused(nr)));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
REQUIRE(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("NoBorder") {
ncreel_options r{};
r.bordermask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT |
NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK_EQ(0, ncreel_redraw(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("BadBorderBitsRejected") {
ncreel_options r{};
r.bordermask = NCBOXMASK_LEFT * 2;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(!nr);
}
SUBCASE("NoTabletBorder") {
ncreel_options r{};
r.tabletmask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT |
NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK_EQ(0, ncreel_redraw(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("NoTopBottomBorder") {
ncreel_options r{};
r.bordermask = NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK_EQ(0, ncreel_redraw(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("NoSideBorders") {
ncreel_options r{};
r.bordermask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK_EQ(0, ncreel_redraw(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
SUBCASE("BadTabletBorderBitsRejected") {
ncreel_options r{};
r.tabletmask = NCBOXMASK_LEFT * 2;
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(!nr);
}
SUBCASE("TransparentBackground") {
2020-02-05 22:29:42 +00:00
ncreel_options r{};
2020-09-13 18:18:42 +00:00
int dimy, dimx;
notcurses_term_dim_yx(nc_, &dimy, &dimx);
uint64_t channels = 0;
channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
auto ncp = ncplane_new(n_, dimy, dimx, 0, 0, nullptr, nullptr);
2020-09-13 18:18:42 +00:00
REQUIRE(nullptr != ncp);
CHECK(0 == ncplane_set_base(ncp, "", 0, channels));
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));
CHECK(0 == ncreel_destroy(nr));
}
2020-02-05 22:29:42 +00:00
// Layout tests. Add some tablets, move around, and verify that they all
// have the expected locations/contents/geometries.
SUBCASE("ThreeCycleDown") {
2020-02-05 22:29:42 +00:00
ncreel_options r{};
Tons of work on ncreel (#776) Tons of work on ncreel (#627, #749, #694) Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627 * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * more terminal environment variable notes * TERMS.md: add Sakura, st * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * ncreel: give each tablet an index, and print it #749 * reel: eliminate FIXME + param to insert_tabler() #749 * ncreel: label tablets with their adress to correlate against debugging logs #749 * ncreel: move legend out of reel proper * ncreel_options: dump min/max_supported_rows/cols #627 * ncreel: remove weird one-off input layer #627 * ncreel: add ncreel_offer_input() * reel demo: call demo_getc() * reel demo: rig up input to demo main * ncreel: drop ncreel_del_focused(), properly bind tablets * reel demo: don't free up necessary plane * ncreel: don't pull absolute locations of tablets * ncreel: place tablets correctly in boundrel * reel demo: add back support for left/right * reel demo: restore thread movement * ncreel: remove a great deal of complexity * reel demo: stay out of FPS graph's way * reel: tighten up reel following redraw * reel: fix upper-left corner of topless perimeter * ncreel: print linecount, return clipped value * reel: draw focused tablet relative to reel * reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
struct ncreel* nr = ncreel_create(n_, &r);
2020-02-05 22:29:42 +00:00
REQUIRE(nr);
CHECK_EQ(0, ncreel_redraw(nr));
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
int order[3];
nctablet* tabs[3];
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
order[n] = -1;
tabs[n] = ncreel_add(nr, nullptr, nullptr, cbfxn, &order[n]);
REQUIRE(tabs[n]);
CHECK(tabs[0] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
}
int expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(0, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 7;
}
ncreel_next(nr);
CHECK(tabs[1] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(1, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 7;
}
ncreel_next(nr);
CHECK(tabs[2] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(2, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 7;
}
ncreel_prev(nr);
CHECK(tabs[1] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(3, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 7;
}
ncreel_prev(nr);
CHECK(tabs[0] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(4, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 7;
}
CHECK(0 == ncreel_destroy(nr));
2020-02-05 22:29:42 +00:00
}
// Layout tests. Add some tablets, move around, and verify that they all
// have the expected locations/contents/geometries.
SUBCASE("ThreeCycleDownNoTabletBorders") {
ncreel_options r{};
r.tabletmask = 0xf;
struct ncreel* nr = ncreel_create(n_, &r);
REQUIRE(nr);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
int order[3];
nctablet* tabs[3];
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
order[n] = -1;
tabs[n] = ncreel_add(nr, nullptr, nullptr, cbfxn, &order[n]);
REQUIRE(tabs[n]);
CHECK(tabs[0] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
}
int expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(-1, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 5;
}
ncreel_next(nr);
CHECK(tabs[1] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(1, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 5;
}
ncreel_next(nr);
CHECK(tabs[2] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(2, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 5;
}
ncreel_prev(nr);
CHECK(tabs[1] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(3, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 5;
}
ncreel_prev(nr);
CHECK(tabs[0] == nr->tablets);
CHECK_EQ(0, notcurses_render(nc_));
CHECK(ncreel_validate(nr));
expectedy = 1;
for(size_t n = 0 ; n < sizeof(order) / sizeof(*order) ; ++n){
CHECK_LE(4, order[n]);
int y;
ncplane_yx(ncplane_parent(nctablet_ncplane(tabs[n])), &y, nullptr);
CHECK(y == expectedy);
expectedy += 5;
}
CHECK(0 == ncreel_destroy(nr));
}
2020-08-27 16:22:35 +00:00
CHECK(0 == notcurses_stop(nc_));
}