summaryrefslogtreecommitdiff
path: root/tests/test-context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-context.cc')
-rw-r--r--tests/test-context.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test-context.cc b/tests/test-context.cc
index d2c359b..4d0a959 100644
--- a/tests/test-context.cc
+++ b/tests/test-context.cc
@@ -84,6 +84,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::FORMAT_ARGB32, 1, 1);
cr->set_source (solid_pattern);
{
@@ -101,6 +102,13 @@ BOOST_AUTO_TEST_CASE(test_source)
auto retrieved_solid2 =
Cairo::RefPtr<const Cairo::SolidPattern>::cast_dynamic(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);
@@ -127,6 +135,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 =
@@ -139,6 +148,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::FILTER_NEAREST);
+ BOOST_CHECK_EQUAL (Cairo::FILTER_NEAREST, surface_pattern->get_filter());
+ }
}
BOOST_AUTO_TEST_CASE(test_tolerance)