2020-03-07 23:36:49 +00:00
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
TEST_CASE("Resize") {
|
2020-06-16 03:58:43 +00:00
|
|
|
auto nc_ = testing_notcurses();
|
2020-05-17 11:57:21 +00:00
|
|
|
if(!nc_){
|
|
|
|
return;
|
|
|
|
}
|
2020-03-07 23:36:49 +00:00
|
|
|
int dimy, dimx;
|
|
|
|
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
|
|
|
|
REQUIRE(n_);
|
|
|
|
uint64_t ul, ur, ll, lr;
|
|
|
|
ul = ur = ll = lr = 0;
|
2020-09-17 19:34:28 +00:00
|
|
|
channels_set_fg_rgb(&ul, 0x40f040);
|
|
|
|
channels_set_bg_rgb(&ul, 0x40f040);
|
|
|
|
channels_set_fg_rgb(&ll, 0xf040f0);
|
|
|
|
channels_set_bg_rgb(&ll, 0xf040f0);
|
|
|
|
channels_set_fg_rgb(&ur, 0x40f040);
|
|
|
|
channels_set_bg_rgb(&ur, 0x40f040);
|
|
|
|
channels_set_fg_rgb(&lr, 0xf040f0);
|
|
|
|
channels_set_bg_rgb(&lr, 0xf040f0);
|
2020-03-07 23:36:49 +00:00
|
|
|
|
|
|
|
// start at full size, and shrink to a nothing
|
|
|
|
SUBCASE("ResizeShrink") {
|
|
|
|
int y = dimy;
|
|
|
|
int x = dimx;
|
2020-11-14 22:21:20 +00:00
|
|
|
struct ncplane_options nopts = {
|
|
|
|
.y = 0,
|
2020-11-15 02:42:37 +00:00
|
|
|
.x = 0,
|
2020-11-14 22:21:20 +00:00
|
|
|
.rows = y,
|
|
|
|
.cols = x,
|
|
|
|
nullptr, nullptr, nullptr, 0,
|
|
|
|
};
|
|
|
|
struct ncplane* testn = ncplane_create(n_, &nopts);
|
2020-03-07 23:36:49 +00:00
|
|
|
REQUIRE(nullptr != testn);
|
2020-03-29 09:26:56 +00:00
|
|
|
REQUIRE(0 < ncplane_gradient_sized(testn, "V", 0, ul, ur, ll, lr, y, x));
|
2020-03-07 23:36:49 +00:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
while(y > 1 || x > 1){
|
|
|
|
y = y > 1 ? y - 1 : y;
|
|
|
|
x = x > 1 ? x - 1 : x;
|
|
|
|
CHECK(0 == ncplane_resize(testn, 0, 0, y, x, 0, 0, y, x));
|
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
}
|
|
|
|
CHECK(0 == ncplane_destroy(testn));
|
|
|
|
}
|
|
|
|
|
|
|
|
// start at 1x1, and enlarge to fill the screen
|
|
|
|
SUBCASE("ResizeEnlarge") {
|
|
|
|
int y = 2;
|
|
|
|
int x = 2;
|
2020-11-14 22:21:20 +00:00
|
|
|
struct ncplane_options nopts = {
|
|
|
|
.y = 0,
|
2020-11-15 02:42:37 +00:00
|
|
|
.x = 0,
|
2020-11-14 22:21:20 +00:00
|
|
|
.rows = y,
|
|
|
|
.cols = x,
|
|
|
|
nullptr, nullptr, nullptr, 0,
|
|
|
|
};
|
|
|
|
struct ncplane* testn = ncplane_create(n_, &nopts);
|
2020-03-07 23:36:49 +00:00
|
|
|
REQUIRE(nullptr != testn);
|
2020-03-29 09:26:56 +00:00
|
|
|
REQUIRE(0 < ncplane_gradient_sized(testn, "V", 0, ul, ur, ll, lr, y, x));
|
2020-03-07 23:36:49 +00:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
while(y < dimy || x < dimx){
|
|
|
|
y = y < dimy ? y + 1 : y;
|
|
|
|
x = x < dimx ? x + 1 : x;
|
|
|
|
CHECK(0 == ncplane_resize(testn, 0, 0, 0, 0, 0, 0, y, x));
|
2020-03-29 09:26:56 +00:00
|
|
|
REQUIRE(0 < ncplane_gradient_sized(testn, "V", 0, ul, ur, ll, lr, y, x));
|
2020-03-07 23:36:49 +00:00
|
|
|
CHECK(0 == notcurses_render(nc_));
|
|
|
|
}
|
|
|
|
CHECK(0 == ncplane_destroy(testn));
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK(0 == notcurses_stop(nc_));
|
|
|
|
|
|
|
|
}
|