2019-12-02 08:26:37 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
TEST_CASE("Fade") {
|
|
|
|
if(getenv("TERM") == nullptr){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FILE* outfp_ = fopen("/dev/tty", "wb");
|
|
|
|
REQUIRE(outfp_);
|
|
|
|
notcurses_options nopts{};
|
2020-01-05 10:13:05 +00:00
|
|
|
nopts.suppress_banner = true;
|
2019-12-27 22:20:20 +00:00
|
|
|
nopts.inhibit_alternate_screen = true;
|
|
|
|
struct notcurses* nc_ = notcurses_init(&nopts, outfp_);
|
|
|
|
REQUIRE(nc_);
|
|
|
|
struct ncplane* n_ = notcurses_stdplane(nc_);
|
|
|
|
REQUIRE(n_);
|
|
|
|
if(!notcurses_canfade(nc_)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
REQUIRE(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_rgb(&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;
|
2019-12-02 08:26:37 +00:00
|
|
|
}
|
2019-12-27 22:20:20 +00:00
|
|
|
cell_set_fg_rgb(&c, (rgb >> 16u) & 0xff, (rgb >> 8u) & 0xff, rgb & 0xff);
|
|
|
|
cell_set_bg_rgb(&c, rgb & 0xff, (rgb >> 16u) & 0xff, (rgb >> 8u) & 0xff);
|
|
|
|
CHECK(0 < ncplane_putc(n_, &c));
|
2019-12-02 08:26:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
SUBCASE("FadeOut") {
|
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
struct timespec ts;
|
|
|
|
ts.tv_sec = 1;
|
|
|
|
ts.tv_nsec = 0;
|
|
|
|
REQUIRE(0 == ncplane_fadeout(n_, &ts, nullptr));
|
2019-12-02 08:26:37 +00:00
|
|
|
}
|
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
SUBCASE("FadeIn") {
|
|
|
|
struct timespec ts;
|
|
|
|
ts.tv_sec = 1;
|
|
|
|
ts.tv_nsec = 0;
|
|
|
|
REQUIRE(0 == ncplane_fadein(n_, &ts, nullptr));
|
|
|
|
}
|
2019-12-02 08:26:37 +00:00
|
|
|
|
2019-12-27 22:20:20 +00:00
|
|
|
CHECK(0 == notcurses_stop(nc_));
|
|
|
|
CHECK(0 == fclose(outfp_));
|
2019-12-02 08:26:37 +00:00
|
|
|
|
|
|
|
}
|