mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
fade unit tests #40
This commit is contained in:
parent
966239747c
commit
0e4080456c
@ -75,9 +75,9 @@ draw_borders(ncplane* w, unsigned nobordermask, const cell* attr,
|
||||
if(ncplane_rounded_box_cells(w, &ul, &ur, &ll, &lr, &hl, &vl)){
|
||||
return -1;
|
||||
}
|
||||
fprintf(stderr, "drawing borders %p %d/%d->%d/%d, mask: %04x, clipping: %c%c\n",
|
||||
/*fprintf(stderr, "drawing borders %p %d/%d->%d/%d, mask: %04x, clipping: %c%c\n",
|
||||
w, begx, begy, maxx, maxy, nobordermask,
|
||||
cliphead ? 'T' : 't', clipfoot ? 'F' : 'f');
|
||||
cliphead ? 'T' : 't', clipfoot ? 'F' : 'f');*/
|
||||
ul.attrword = attr->attrword; ul.channels = attr->channels;
|
||||
ur.attrword = attr->attrword; ur.channels = attr->channels;
|
||||
ll.attrword = attr->attrword; ll.channels = attr->channels;
|
||||
@ -227,7 +227,7 @@ panelreel_draw_tablet(const panelreel* pr, tablet* t, int frontiery,
|
||||
int lenx, leny, begy, begx;
|
||||
ncplane* fp = t->p;
|
||||
if(tablet_columns(pr, &begx, &begy, &lenx, &leny, frontiery, direction)){
|
||||
fprintf(stderr, "no room: %p:%p base %d/%d len %d/%d\n", t, fp, begx, begy, lenx, leny);
|
||||
//fprintf(stderr, "no room: %p:%p base %d/%d len %d/%d\n", t, fp, begx, begy, lenx, leny);
|
||||
// fprintf(stderr, "FRONTIER DONE!!!!!!\n");
|
||||
if(fp){
|
||||
// fprintf(stderr, "HIDING %p at frontier %d (dir %d) with %d\n", t, frontiery, direction, leny);
|
||||
@ -286,8 +286,8 @@ fprintf(stderr, "no room: %p:%p base %d/%d len %d/%d\n", t, fp, begx, begy, lenx
|
||||
// fprintf(stderr, "calling! lenx/leny: %d/%d cbx/cby: %d/%d cbmaxx/cbmaxy: %d/%d dir: %d\n",
|
||||
// lenx, leny, cbx, cby, cbmaxx, cbmaxy, direction);
|
||||
int ll = t->cbfxn(fp, cbx, cby, cbmaxx, cbmaxy, cbdir, t->curry);
|
||||
fprintf(stderr, "RETURNRETURNRETURN %p %d (%d, %d, %d) DIR %d\n",
|
||||
t, ll, cby, cbmaxy, leny, direction);
|
||||
//fprintf(stderr, "RETURNRETURNRETURN %p %d (%d, %d, %d) DIR %d\n",
|
||||
// t, ll, cby, cbmaxy, leny, direction);
|
||||
if(ll != leny){
|
||||
if(ll == leny - 1){ // only has one border visible (partially off-screen)
|
||||
++ll; // account for that border
|
||||
@ -295,17 +295,17 @@ fprintf(stderr, "RETURNRETURNRETURN %p %d (%d, %d, %d) DIR %d\n",
|
||||
if(direction < 0){
|
||||
cliphead = true;
|
||||
ncplane_move_yx(fp, begy + leny - ll, begx);
|
||||
fprintf(stderr, "MOVEDOWN CLIPPED RESIZED (-1) from %d to %d\n", leny, ll);
|
||||
//fprintf(stderr, "MOVEDOWN CLIPPED RESIZED (-1) from %d to %d\n", leny, ll);
|
||||
}else{
|
||||
clipfoot = true;
|
||||
fprintf(stderr, "RESIZED (-1) from %d to %d\n", leny, ll);
|
||||
//fprintf(stderr, "RESIZED (-1) from %d to %d\n", leny, ll);
|
||||
}
|
||||
}else{ // both borders are visible
|
||||
ll += 2; // account for both borders
|
||||
fprintf(stderr, "RESIZING (-2) from %d to %d\n", leny, ll);
|
||||
//fprintf(stderr, "RESIZING (-2) from %d to %d\n", leny, ll);
|
||||
wresize(fp, ll, lenx);
|
||||
if(direction < 0){
|
||||
fprintf(stderr, "MOVEDOWN UNCLIPPED (skip %d)\n", leny - ll);
|
||||
//fprintf(stderr, "MOVEDOWN UNCLIPPED (skip %d)\n", leny - ll);
|
||||
ncplane_move_yx(fp, begy + leny - ll, begx);
|
||||
}
|
||||
}
|
||||
@ -513,12 +513,12 @@ panelreel_arrange(panelreel* pr){
|
||||
otherend = draw_previous_tablets(pr, otherend);
|
||||
}
|
||||
// FIXME move them up to plug any holes in original direction?
|
||||
fprintf(stderr, "DONE ARRANGING\n");
|
||||
//fprintf(stderr, "DONE ARRANGING\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int panelreel_redraw(panelreel* pr){
|
||||
fprintf(stderr, "--------> BEGIN REDRAW <--------\n");
|
||||
//fprintf(stderr, "--------> BEGIN REDRAW <--------\n");
|
||||
int ret = 0;
|
||||
if(draw_panelreel_borders(pr)){
|
||||
return -1; // enforces specified dimensional minima
|
||||
@ -662,7 +662,7 @@ tablet* panelreel_add(panelreel* pr, tablet* after, tablet *before,
|
||||
if((t = malloc(sizeof(*t))) == NULL){
|
||||
return NULL;
|
||||
}
|
||||
fprintf(stderr, "--------->NEW TABLET %p\n", t);
|
||||
//fprintf(stderr, "--------->NEW TABLET %p\n", t);
|
||||
if(after){
|
||||
t->next = after->next;
|
||||
after->next = t;
|
||||
@ -795,8 +795,8 @@ int panelreel_move(panelreel* preel, int x, int y){
|
||||
tablet* panelreel_next(panelreel* pr){
|
||||
if(pr->tablets){
|
||||
pr->tablets = pr->tablets->next;
|
||||
fprintf(stderr, "---------------> moved to next, %p to %p <----------\n",
|
||||
pr->tablets->prev, pr->tablets);
|
||||
//fprintf(stderr, "---------------> moved to next, %p to %p <----------\n",
|
||||
// pr->tablets->prev, pr->tablets);
|
||||
pr->last_traveled_direction = 1;
|
||||
}
|
||||
panelreel_redraw(pr);
|
||||
@ -806,8 +806,8 @@ fprintf(stderr, "---------------> moved to next, %p to %p <----------\n",
|
||||
tablet* panelreel_prev(panelreel* pr){
|
||||
if(pr->tablets){
|
||||
pr->tablets = pr->tablets->prev;
|
||||
fprintf(stderr, "----------------> moved to prev, %p to %p <----------\n",
|
||||
pr->tablets->next, pr->tablets);
|
||||
//fprintf(stderr, "----------------> moved to prev, %p to %p <----------\n",
|
||||
// pr->tablets->next, pr->tablets);
|
||||
pr->last_traveled_direction = -1;
|
||||
}
|
||||
panelreel_redraw(pr);
|
||||
|
63
tests/fade.cpp
Normal file
63
tests/fade.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "main.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
class FadeTest : public :: testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
setlocale(LC_ALL, nullptr);
|
||||
if(getenv("TERM") == nullptr){
|
||||
GTEST_SKIP();
|
||||
}
|
||||
notcurses_options nopts{};
|
||||
nopts.inhibit_alternate_screen = true;
|
||||
nopts.retain_cursor = true;
|
||||
nopts.pass_through_esc = true;
|
||||
nopts.outfp = stdin;
|
||||
nc_ = notcurses_init(&nopts);
|
||||
ASSERT_NE(nullptr, nc_);
|
||||
n_ = notcurses_stdplane(nc_);
|
||||
ASSERT_NE(nullptr, n_);
|
||||
ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0));
|
||||
int dimy, dimx;
|
||||
ncplane_dim_yx(n_, &dimy, &dimx);
|
||||
cell c = CELL_TRIVIAL_INITIALIZER;
|
||||
c.gcluster = '*';
|
||||
cell_set_fg(&c, 0xff, 0xff, 0xff);
|
||||
unsigned rgb = 0xffffffu;
|
||||
for(int y = 0 ; y < dimy ; ++y){
|
||||
for(int x = 0 ; x < dimx ; ++x){
|
||||
rgb -= 32;
|
||||
if(rgb < 32){
|
||||
rgb = 0xffffffu;
|
||||
}
|
||||
cell_set_fg(&c, (rgb >> 16u) & 0xff, (rgb >> 8u) & 0xff, rgb & 0xff);
|
||||
EXPECT_LT(0, ncplane_putc(n_, &c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if(nc_){
|
||||
EXPECT_EQ(0, notcurses_stop(nc_));
|
||||
}
|
||||
}
|
||||
|
||||
struct notcurses* nc_{};
|
||||
struct ncplane* n_{};
|
||||
};
|
||||
|
||||
TEST_F(FadeTest, FadeOut) {
|
||||
EXPECT_EQ(0, notcurses_render(nc_));
|
||||
struct timespec ts;
|
||||
ts.tv_sec = 1;
|
||||
ts.tv_nsec = 0;
|
||||
ASSERT_EQ(0, ncplane_fadeout(n_, &ts));
|
||||
}
|
||||
|
||||
TEST_F(FadeTest, FadeIn) {
|
||||
struct timespec ts;
|
||||
ts.tv_sec = 1;
|
||||
ts.tv_nsec = 0;
|
||||
ASSERT_EQ(0, ncplane_fadein(n_, &ts));
|
||||
}
|
@ -39,7 +39,7 @@ TEST_F(LibavTest, LoadImage) {
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
ASSERT_NE(nullptr, frame);
|
||||
// EXPECT_EQ(AVERROR_EOF, averr);
|
||||
EXPECT_EQ(dimy, frame->height);
|
||||
EXPECT_EQ(dimy * 2, frame->height);
|
||||
EXPECT_EQ(dimx, frame->width);
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
@ -55,7 +55,7 @@ TEST_F(LibavTest, LoadVideo) {
|
||||
auto frame = ncvisual_decode(ncv, &averr);
|
||||
ASSERT_NE(nullptr, frame);
|
||||
// EXPECT_EQ(0, averr);
|
||||
EXPECT_EQ(dimy, frame->height);
|
||||
EXPECT_EQ(dimy * 2, frame->height);
|
||||
EXPECT_EQ(dimx, frame->width);
|
||||
ncvisual_destroy(ncv);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user