From 0b6084a5916513d3f456a99dd3d3104e72942b79 Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Mon, 8 Jun 2009 22:32:16 -0500 Subject: [PATCH] Fix test breakage from reverting Matrix changes --- ChangeLog | 9 ++ configure.in | 6 +- tests/test-font-face.cc | 235 --------------------------------------------- tests/test-scaled-font.cc | 7 +- tests/test-user-font.cc | 16 ++- 5 files changed, 29 insertions(+), 244 deletions(-) diff --git a/ChangeLog b/ChangeLog index 571e9ee..3ba9949 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-06-08 Jonathon Jongsma + + Revert matrix ABI (and indirectly, API) breakage. Bug #22137 + + * configure.in: support newer boost version on debian + * tests/test-font-face.cc: + * tests/test-scaled-font.cc: + * tests/test-user-font.cc: fix tests that depended on Matrix changes + 2009-01-26 Jonathon Jongsma * NEWS: diff --git a/configure.in b/configure.in index c558a9a..5471963 100644 --- a/configure.in +++ b/configure.in @@ -234,12 +234,16 @@ if test x$ENABLE_TESTS = xyes ; then if test x$ac_boost_path != x; then unit_framework_lib_candidates="$ac_boost_path/lib/libboost_unit_test_framework.a $ac_boost_path/lib/libboost_unit_test_framework-st.a + $ac_boost_path/lib/libboost_unit_test_framework-mt.a $ac_boost_path/libboost_unit_test_framework.a - $ac_boost_path/libboost_unit_test_framework-st.a" + $ac_boost_path/libboost_unit_test_framework-st.a + $ac_boost_path/libboost_unit_test_framework-mt.a" else unit_framework_lib_candidates="/usr/lib/libboost_unit_test_framework-st.a + /usr/lib/libboost_unit_test_framework-mt.a /usr/lib/libboost_unit_test_framework.a /usr/lib64/libboost_unit_test_framework-st.a + /usr/lib64/libboost_unit_test_framework-mt.a /usr/lib64/libboost_unit_test_framework.a" fi for i in $unit_framework_lib_candidates ; do diff --git a/tests/test-font-face.cc b/tests/test-font-face.cc index 3282bdc..4d9ebd8 100644 --- a/tests/test-font-face.cc +++ b/tests/test-font-face.cc @@ -48,241 +48,6 @@ void test_toy_getters () BOOST_CHECK_EQUAL (Cairo::FONT_TYPE_TOY, toy->get_type()); } -void test_user_font_create() -{ - Cairo::RefPtr font = Cairo::UserFontFace::create(); - BOOST_CHECK_EQUAL (Cairo::FONT_TYPE_USER, font->get_type()); -} - -// create some dummy callbacks -static unsigned int init_call_count = 0; -Cairo::ErrorStatus my_init(const Cairo::RefPtr&, const Cairo::RefPtr&, Cairo::FontExtents&) -{ - init_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -static unsigned int unicode_to_glyph_call_count = 0; -Cairo::ErrorStatus my_unicode_to_glyph(const Cairo::RefPtr&, unsigned long, unsigned long&) -{ - unicode_to_glyph_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -static unsigned int render_glyph_call_count = 0; -Cairo::ErrorStatus my_render_glyph(const Cairo::RefPtr&, unsigned long, const Cairo::RefPtr&, Cairo::TextExtents&) -{ - render_glyph_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -static unsigned int text_to_glyphs_call_count = 0; -Cairo::ErrorStatus my_text_to_glyphs(const Cairo::RefPtr&, const std::string& utf8, std::vector& glyphs, std::vector& /*clusters*/, bool& /*backward*/) -{ - text_to_glyphs_call_count++; - if (glyphs.size()) - glyphs.clear(); - // just fill in some bogus glyph indexes - std::string::const_iterator str_iter = utf8.begin(); - for (; str_iter != utf8.end(); ++str_iter) - { - Cairo::Glyph g; - g.index = (unsigned long) *str_iter; - glyphs.push_back(g); - } - return CAIRO_STATUS_SUCCESS; -} - -void test_user_font_callbacks_ptr() -{ - render_glyph_call_count = 0; - unicode_to_glyph_call_count = 0; - init_call_count = 0; - Cairo::RefPtr font = Cairo::UserFontFace::create(); - BOOST_CHECK(font); - font->set_init_func(sigc::ptr_fun(my_init)); - font->set_unicode_to_glyph_func(sigc::ptr_fun(my_unicode_to_glyph)); - font->set_render_glyph_func(sigc::ptr_fun(my_render_glyph)); - Cairo::RefPtr scaled_font = - Cairo::ScaledFont::create(font, identity_matrix, identity_matrix, - Cairo::FontOptions()); - BOOST_CHECK (init_call_count > 0); - Cairo::RefPtr surface = - Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 100, 100); - Cairo::RefPtr cr = Cairo::Context::create(surface); - cr->set_font_face(font); - cr->show_text("Hello, world"); - BOOST_CHECK (unicode_to_glyph_call_count > 0); - BOOST_CHECK (render_glyph_call_count > 0); -} - -// since unicode_to_glyph_func and text_to_glyphs_func are mutually exclusive, -// we must test them separately. This test tests the text_to_glyphs_func -void test_user_font_callbacks_ptr_text() -{ - render_glyph_call_count = 0; - text_to_glyphs_call_count = 0; - init_call_count = 0; - Cairo::RefPtr font = Cairo::UserFontFace::create(); - BOOST_CHECK(font); - font->set_init_func(sigc::ptr_fun(my_init)); - font->set_render_glyph_func(sigc::ptr_fun(my_render_glyph)); - font->set_text_to_glyphs_func(sigc::ptr_fun(my_text_to_glyphs)); - Cairo::RefPtr scaled_font = - Cairo::ScaledFont::create(font, identity_matrix, identity_matrix, - Cairo::FontOptions()); - BOOST_CHECK (init_call_count > 0); - Cairo::RefPtr surface = - Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 100, 100); - Cairo::RefPtr cr = Cairo::Context::create(surface); - cr->set_font_face(font); - cr->show_text("Hello, world"); - BOOST_CHECK (render_glyph_call_count > 0); - BOOST_CHECK (text_to_glyphs_call_count > 0); -} - -struct UserFontCallbacks -{ -Cairo::ErrorStatus init(const Cairo::RefPtr&, const Cairo::RefPtr&, Cairo::FontExtents&) -{ - init_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -Cairo::ErrorStatus unicode_to_glyph(const Cairo::RefPtr&, unsigned long, unsigned long&) -{ - unicode_to_glyph_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -Cairo::ErrorStatus render_glyph(const Cairo::RefPtr&, unsigned long, const Cairo::RefPtr&, Cairo::TextExtents&) -{ - render_glyph_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -static unsigned int init_call_count; -static unsigned int unicode_to_glyph_call_count; -static unsigned int render_glyph_call_count; -}; - -unsigned int UserFontCallbacks::init_call_count = 0; -unsigned int UserFontCallbacks::unicode_to_glyph_call_count = 0; -unsigned int UserFontCallbacks::render_glyph_call_count = 0; - -void test_user_font_callbacks_mem() -{ - Cairo::RefPtr font = Cairo::UserFontFace::create(); - BOOST_CHECK(font); - UserFontCallbacks callbacks; - font->set_init_func(sigc::mem_fun(&callbacks, &UserFontCallbacks::init)); - font->set_unicode_to_glyph_func(sigc::mem_fun(&callbacks, - &UserFontCallbacks::unicode_to_glyph)); - font->set_render_glyph_func(sigc::mem_fun(&callbacks, - &UserFontCallbacks::render_glyph)); - Cairo::RefPtr scaled_font = - Cairo::ScaledFont::create(font, identity_matrix, identity_matrix, - Cairo::FontOptions()); - BOOST_CHECK (UserFontCallbacks::init_call_count > 0); - Cairo::RefPtr surface = - Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 100, 100); - Cairo::RefPtr cr = Cairo::Context::create(surface); - cr->set_font_face(font); - cr->show_text("Hello, world"); - BOOST_CHECK (UserFontCallbacks::unicode_to_glyph_call_count > 0); - BOOST_CHECK (UserFontCallbacks::render_glyph_call_count > 0); -} - -static unsigned int init_exception_call_count = 0; -Cairo::ErrorStatus my_init_exception(const Cairo::RefPtr&, const Cairo::RefPtr&, Cairo::FontExtents&) -{ - init_exception_call_count++; - throw std::logic_error("init exception"); -} - -static unsigned int unicode_to_glyph_exception_call_count = 0; -Cairo::ErrorStatus my_unicode_to_glyph_exception(const Cairo::RefPtr&, unsigned long, unsigned long&) -{ - unicode_to_glyph_exception_call_count++; - throw std::logic_error("unicode-to-glyph exception"); -} - -static unsigned int render_glyph_exception_call_count = 0; -Cairo::ErrorStatus my_render_glyph_exception(const Cairo::RefPtr&, unsigned long, const Cairo::RefPtr&, Cairo::TextExtents&) -{ - render_glyph_exception_call_count++; - throw std::logic_error("render-glyph exception"); -} - - -void test_user_font_callbacks_exception() -{ - Cairo::RefPtr font = Cairo::UserFontFace::create(); - BOOST_CHECK(font); - font->set_init_func(sigc::ptr_fun(my_init_exception)); - - // the init() callback will throw an exception, if this isn't handled in the - // callback wrapper, the program will abort since an exception can't unwind - // through C code. However, due to the exception being thrown, the create() - // function will fail and throw a new exception. So if the executable doesn't - // abort, we should get an exception here. - Cairo::RefPtr scaled_font; - BOOST_CHECK_THROW (scaled_font = Cairo::ScaledFont::create(font, - identity_matrix, - identity_matrix, - Cairo::FontOptions()), - Cairo::logic_error); - BOOST_CHECK (init_exception_call_count > 0); - - // now initialize a scaled font properly so we can test the other callbacks - font = Cairo::UserFontFace::create(); - font->set_init_func(sigc::ptr_fun(my_init)); - font->set_render_glyph_func(sigc::ptr_fun(my_render_glyph_exception)); - font->set_unicode_to_glyph_func(sigc::ptr_fun(my_unicode_to_glyph_exception)); - BOOST_CHECK_NO_THROW (scaled_font = Cairo::ScaledFont::create(font, - identity_matrix, - identity_matrix, - Cairo::FontOptions())) - Cairo::RefPtr surface = - Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 100, 100); - Cairo::RefPtr cr = Cairo::Context::create(surface); - cr->set_font_face(font); - // this call should throw an exception since the callback wrapper will return - // an error status (that will be translated into an exception) but the test - // shouldn't abort sindce the callback exceptions are handled by the callback - // wrapper - BOOST_REQUIRE_EQUAL (CAIRO_STATUS_SUCCESS, font->get_status()); - BOOST_CHECK_THROW(cr->show_text("Hello, world"), Cairo::logic_error); - BOOST_CHECK (UserFontCallbacks::unicode_to_glyph_call_count > 0); - BOOST_CHECK (UserFontCallbacks::render_glyph_call_count > 0); -} - -// create some dummy callbacks -static unsigned int init2_call_count = 0; -Cairo::ErrorStatus my_init2(const Cairo::RefPtr&, const Cairo::RefPtr&, Cairo::FontExtents&) -{ - init2_call_count++; - return CAIRO_STATUS_SUCCESS; -} - -void test_user_font_replace_callback() -{ - // reset - init_call_count = 0; - Cairo::RefPtr font = Cairo::UserFontFace::create(); - font->set_init_func(sigc::ptr_fun(my_init)); - // now replace the init function with my_init2 and make sure that the 2nd - // function is called, not the first - font->set_init_func(sigc::ptr_fun(my_init2)); - Cairo::RefPtr scaled_font; - BOOST_CHECK_NO_THROW (scaled_font = Cairo::ScaledFont::create(font, - identity_matrix, - identity_matrix, - Cairo::FontOptions())) - BOOST_CHECK (init2_call_count > 0); - BOOST_CHECK_EQUAL (init_call_count, 0); -} - #ifdef CAIRO_HAS_FT_FONT void test_ft_font_face() { diff --git a/tests/test-scaled-font.cc b/tests/test-scaled-font.cc index e1798b6..63469c3 100644 --- a/tests/test-scaled-font.cc +++ b/tests/test-scaled-font.cc @@ -87,13 +87,16 @@ void test_ft_scaled_font() Cairo::RefPtr face = Cairo::FtFontFace::create(resolved); BOOST_CHECK(face); + Matrix identity; + cairo_matrix_init_identity(&identity); + cairo_scaled_font_t* c_scaled_font = 0; int refcount = 0; { Cairo::RefPtr scaled_font = FtScaledFont::create(face, - Cairo::identity_matrix(), - Cairo::identity_matrix(), + identity, + identity, FontOptions()); c_scaled_font = scaled_font->cobj(); refcount = cairo_scaled_font_get_reference_count(c_scaled_font); diff --git a/tests/test-user-font.cc b/tests/test-user-font.cc index 75ae566..75c7cac 100644 --- a/tests/test-user-font.cc +++ b/tests/test-user-font.cc @@ -273,9 +273,13 @@ void test_user_font_exception() // function will fail and throw a new exception. So if the executable doesn't // abort, we should get an exception here. Cairo::RefPtr scaled_font; + Matrix identity; + cairo_matrix_init_identity(&identity); + Matrix scaled; + cairo_matrix_scale (&scaled, 10, 10); BOOST_CHECK_THROW (scaled_font = Cairo::ScaledFont::create(font, - Cairo::scaling_matrix(10, 10), - Cairo::identity_matrix(), + scaled, + identity, Cairo::FontOptions()), Cairo::logic_error); BOOST_CHECK (font->count_init > 0); @@ -283,8 +287,8 @@ void test_user_font_exception() // now test when an exception is thrown in unicode_to_glyph font = ExceptionUserFont::create(ExceptionUserFont::FLAG_UNICODE); BOOST_CHECK_NO_THROW (scaled_font = Cairo::ScaledFont::create(font, - Cairo::scaling_matrix(10, 10), - Cairo::identity_matrix(), + scaled, + identity, Cairo::FontOptions())); TestSetup setup; setup.cr->set_font_face(font); @@ -300,8 +304,8 @@ void test_user_font_exception() // now test when an exception is thrown in render_glyph font = ExceptionUserFont::create(ExceptionUserFont::FLAG_RENDER); BOOST_CHECK_NO_THROW (scaled_font = Cairo::ScaledFont::create(font, - Cairo::scaling_matrix(10, 10), - Cairo::identity_matrix(), + scaled, + identity, Cairo::FontOptions())); // need a new setup since the old cr is now in an error state, so attemtping // to use it will throw an exception -- 1.6.3.1