diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2020-08-12 16:42:20 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2020-08-12 16:42:20 +0200 |
commit | 96e52ecd9fc1906a5d9f50a985f7c56d771f53fb (patch) | |
tree | 9344ed43208106d34cea54c4d8637adca87f063d /tests/test-context.cc | |
parent | 699c018a4c8b2d4e3bdf29a2bd5c642ef0b1f54f (diff) |
Add Context::get_source_for_surface()
Fixes #5
Diffstat (limited to 'tests/test-context.cc')
-rw-r--r-- | tests/test-context.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test-context.cc b/tests/test-context.cc index 8dad675..910eb3a 100644 --- a/tests/test-context.cc +++ b/tests/test-context.cc @@ -88,6 +88,7 @@ BOOST_AUTO_TEST_CASE(test_source) Cairo::SolidPattern::create_rgb (1.0, 0.5, 0.25); auto gradient_pattern = Cairo::LinearGradient::create (0.0, 0.0, 1.0, 1.0); + auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, 1, 1); cr->set_source (solid_pattern); { @@ -105,6 +106,13 @@ BOOST_AUTO_TEST_CASE(test_source) auto retrieved_solid2 = std::dynamic_pointer_cast<const Cairo::SolidPattern>(cr2->get_source ()); BOOST_REQUIRE (retrieved_solid2); + + // Check that get_source_for_surface() returns an empty RefPtr, + // when the source is not a surface. + auto surface_pattern = cr->get_source_for_surface(); + BOOST_CHECK(!surface_pattern); + auto surface_pattern2 = cr2->get_source_for_surface(); + BOOST_CHECK(!surface_pattern2); } cr->set_source (gradient_pattern); @@ -131,6 +139,7 @@ BOOST_AUTO_TEST_CASE(test_source) BOOST_CHECK_EQUAL (0.5, gx); BOOST_CHECK_EQUAL (0.25, bx); } + cr->set_source_rgba (0.1, 0.3, 0.5, 0.7); { auto solid = @@ -143,6 +152,14 @@ BOOST_AUTO_TEST_CASE(test_source) BOOST_CHECK_EQUAL (0.5, bx); BOOST_CHECK_EQUAL (0.7, ax); } + + cr->set_source (surface, 0.0, 0.0); + { + auto surface_pattern = cr->get_source_for_surface(); + BOOST_REQUIRE (surface_pattern); + surface_pattern->set_filter(Cairo::SurfacePattern::Filter::NEAREST); + BOOST_CHECK_EQUAL (to_int(Cairo::SurfacePattern::Filter::NEAREST), to_int(surface_pattern->get_filter())); + } } BOOST_AUTO_TEST_CASE(test_tolerance) |