From 20ea3a3345621a55a0fd441536b8826ce1b48698 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 22 May 2021 17:27:42 -0400 Subject: [PATCH] new unit test, ImageFileChildScaling #1675 --- src/tests/visual.cpp | 47 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/tests/visual.cpp b/src/tests/visual.cpp index 3761de85c..63c0533ce 100644 --- a/src/tests/visual.cpp +++ b/src/tests/visual.cpp @@ -557,7 +557,7 @@ TEST_CASE("Visual") { } } - // test NCVISUAL_OPTIONS_CHILDPLANE + stretch + (null) alignment + // test NCVISUAL_OPTIONS_CHILDPLANE + stretch + null alignment SUBCASE("ImageChildScaling") { struct ncplane_options opts = { .y = 0, .x = 0, @@ -574,14 +574,12 @@ TEST_CASE("Visual") { struct ncvisual_options vopts = { .n = parent, .scaling = NCSCALE_STRETCH, - .y = NCALIGN_CENTER, - .x = NCALIGN_CENTER, + .y = 0, + .x = 0, .begy = 0, .begx = 0, .leny = 0, .lenx = 0, .blitter = NCBLIT_1x1, - .flags = NCVISUAL_OPTION_CHILDPLANE | - NCVISUAL_OPTION_HORALIGNED | - NCVISUAL_OPTION_VERALIGNED, + .flags = NCVISUAL_OPTION_CHILDPLANE, .transcolor = 0, }; const uint32_t pixels[1] = { htole(0xffffffff) }; @@ -598,6 +596,43 @@ TEST_CASE("Visual") { CHECK(0 == ncplane_destroy(child)); } + // test NCVISUAL_OPTIONS_CHILDPLANE + stretch + null alignment, using a file + SUBCASE("ImageFileChildScaling") { + struct ncplane_options opts = { + .y = 0, .x = 0, + .rows = 5, .cols = 5, + .userptr = nullptr, + .name = "parent", + .resizecb = nullptr, + .flags = 0, + .margin_b = 0, + .margin_r = 0, + }; + auto parent = ncplane_create(n_, &opts); + REQUIRE(parent); + struct ncvisual_options vopts = { + .n = parent, + .scaling = NCSCALE_STRETCH, + .y = 0, .x = 0, + .begy = 0, .begx = 0, + .leny = 0, .lenx = 0, + .blitter = NCBLIT_1x1, + .flags = NCVISUAL_OPTION_CHILDPLANE, + .transcolor = 0, + }; + auto ncv = ncvisual_from_file(find_data("onedot.png")); + REQUIRE(ncv); + auto child = ncvisual_render(nc_, ncv, &vopts); + REQUIRE(child); + CHECK(5 == ncplane_dim_y(child)); + CHECK(5 == ncplane_dim_x(child)); + CHECK(0 == ncplane_y(child)); + CHECK(0 == ncplane_x(child)); + ncvisual_destroy(ncv); + CHECK(0 == ncplane_destroy(parent)); + CHECK(0 == ncplane_destroy(child)); + } + SUBCASE("ImageChildAlignment") { struct ncplane_options opts = { .y = 0, .x = 0,