summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@gnome.org>2008-12-15 14:24:16 -0600
committerJonathon Jongsma <jjongsma@gnome.org>2008-12-15 14:24:16 -0600
commit60e51c30d975f7888ba9f561ff1ba22f6e7db939 (patch)
tree8b1b77b67bcc690ef547bc8015cbc90f916653a7 /tests
parent0fc70d99be2e5377c14853cbe9a6ab7d39c4af63 (diff)
Revert virtual ScaledFont destructor (no ABI break)
* cairomm/scaledfont.h: revert the virtual destructor since it's unnecessary and an ABI change. The ScaledFont subclasses don't have any virtual functions or any subclass-specific data that needs to be cleaned up, so a virtual destructor is not really necessary here. * tests/test-scaled-font.cc: a little paranoia test just to ensure that the base destructor is called correctly reducing the ref count when we delete a FtFontFace
Diffstat (limited to 'tests')
-rw-r--r--tests/test-scaled-font.cc45
1 files changed, 41 insertions, 4 deletions
diff --git a/tests/test-scaled-font.cc b/tests/test-scaled-font.cc
index 73a4c59..e1798b6 100644
--- a/tests/test-scaled-font.cc
+++ b/tests/test-scaled-font.cc
@@ -69,6 +69,40 @@ void test_get_font_face()
BOOST_REQUIRE_EQUAL(cairo_font_face_get_reference_count(face->cobj()), refcount);
}
+#ifdef CAIRO_HAS_FT_FONT
+void test_ft_scaled_font()
+{
+ FcPattern* invalid = FcPatternCreate();
+ Cairo::RefPtr<Cairo::FtFontFace> invalid_face;
+ BOOST_CHECK_THROW(invalid_face = Cairo::FtFontFace::create(invalid), std::bad_alloc);
+
+ // basically taken from the cairo test case -- we don't care what font we're
+ // using so just create an empty pattern and do the minimal substitution to
+ // get a valid pattern
+ FcPattern* pattern = FcPatternCreate();
+ FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+ FcDefaultSubstitute (pattern);
+ FcResult result;
+ FcPattern* resolved = FcFontMatch (NULL, pattern, &result);
+ Cairo::RefPtr<Cairo::FtFontFace> face = Cairo::FtFontFace::create(resolved);
+ BOOST_CHECK(face);
+
+ cairo_scaled_font_t* c_scaled_font = 0;
+ int refcount = 0;
+ {
+ Cairo::RefPtr<Cairo::FtScaledFont> scaled_font =
+ FtScaledFont::create(face,
+ Cairo::identity_matrix(),
+ Cairo::identity_matrix(),
+ FontOptions());
+ c_scaled_font = scaled_font->cobj();
+ refcount = cairo_scaled_font_get_reference_count(c_scaled_font);
+ }
+ // make sure that the base destructor is called
+ BOOST_CHECK_EQUAL(cairo_scaled_font_get_reference_count(c_scaled_font), refcount -1);
+}
+#endif // CAIRO_HAS_FT_FONT
+
test_suite*
init_unit_test_suite(int argc, char* argv[])
@@ -78,10 +112,13 @@ init_unit_test_suite(int argc, char* argv[])
test_suite* test= BOOST_TEST_SUITE( "Cairo::ScaledFont Tests" );
- test->add (BOOST_TEST_CASE (&test_construction));
- test->add (BOOST_TEST_CASE (&test_text_to_glyphs));
- test->add (BOOST_TEST_CASE (&test_scale_matrix));
- test->add (BOOST_TEST_CASE (&test_get_font_face));
+ test->add(BOOST_TEST_CASE(&test_construction));
+ test->add(BOOST_TEST_CASE(&test_text_to_glyphs));
+ test->add(BOOST_TEST_CASE(&test_scale_matrix));
+ test->add(BOOST_TEST_CASE(&test_get_font_face));
+#ifdef CAIRO_HAS_FT_FONT
+ test->add(BOOST_TEST_CASE(&test_ft_scaled_font));
+#endif // CAIRO_HAS_FT_FONT
return test;
}