X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=padding_effect_test.cpp;h=8c05a1e65c89f5b77c25c60e6d57ad94f54dc302;hb=e92a5ffa19eb67b4db5af1db8559630139073668;hp=c9c8ef1d7af1a0a9074697fb2d73f6d47ffe73e1;hpb=5c97329dd35909847e2120b0b368b2723ffe5a44;p=movit diff --git a/padding_effect_test.cpp b/padding_effect_test.cpp index c9c8ef1..8c05a1e 100644 --- a/padding_effect_test.cpp +++ b/padding_effect_test.cpp @@ -1,5 +1,6 @@ // Unit tests for AlphaMultiplicationEffect. +#include #include #include "effect_chain.h" @@ -10,6 +11,8 @@ #include "test_util.h" #include "util.h" +namespace movit { + TEST(PaddingEffectTest, SimpleCenter) { float data[2 * 2] = { 1.0f, 0.5f, @@ -205,6 +208,37 @@ TEST(PaddingEffectTest, Crop) { expect_equal(expected_data, out_data, 1, 1); } +TEST(PaddingEffectTest, CropFromBottom) { + float data[2 * 2] = { + 1.0f, 0.5f, + 0.8f, 0.3f, + }; + float expected_data[1 * 1] = { + 0.5f, + }; + float out_data[1 * 1]; + + EffectChainTester tester(NULL, 1, 1); + + ImageFormat format; + format.color_space = COLORSPACE_sRGB; + format.gamma_curve = GAMMA_LINEAR; + + FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, 2, 2); + input->set_pixel_data(data); + tester.get_chain()->add_input(input); + + Effect *effect = tester.get_chain()->add_effect(new PaddingEffect()); + CHECK(effect->set_int("width", 1)); + CHECK(effect->set_int("height", 1)); + CHECK(effect->set_float("left", -1.0f)); + CHECK(effect->set_float("top", -1.0f)); + CHECK(effect->set_int("pad_from_bottom", 1)); + + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR, OUTPUT_ALPHA_FORMAT_PREMULTIPLIED); + expect_equal(expected_data, out_data, 1, 1); +} + TEST(PaddingEffectTest, AlphaIsCorrectEvenWithNonLinearInputsAndOutputs) { float data[2 * 1] = { 1.0f, @@ -240,3 +274,5 @@ TEST(PaddingEffectTest, AlphaIsCorrectEvenWithNonLinearInputsAndOutputs) { tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_709, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED); expect_equal(expected_data, out_data, 4, 4); } + +} // namespace movit