From 57bd4e89ca4dda00d50fec4735e2d58317616ecf Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 13 Jan 2020 17:00:42 +0800 Subject: tests: Fix building tests with FreeType but no FontConfig Cairo could have been built with FreeType support but has no FontConfig support, so we need to check for that too. Also allow building the tests on Windows even if FontConfig is not found, as a result. --- meson.build | 3 ++- meson_options.txt | 2 +- tests/test-font-face.cc | 6 +++--- tests/test-scaled-font.cc | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 88d2fd7..03da81a 100644 --- a/meson.build +++ b/meson.build @@ -146,7 +146,8 @@ boost_unit_test_framework_dep = dependency('boost', modules: 'unit_test_framewor static: true, version: '>=1.33.1', required: false) fontconfig_dep = dependency('fontconfig', required: false) test_dep = [ boost_unit_test_framework_dep, fontconfig_dep] -can_test = boost_unit_test_framework_dep.found() and fontconfig_dep.found() +can_test = boost_unit_test_framework_dep.found() and \ + (fontconfig_dep.found() or host_machine.system() == 'windows') build_tests = build_tests_opt == 'true' or \ (build_tests_opt == 'if-dependencies-found' and can_test) if build_tests and not can_test diff --git a/meson_options.txt b/meson_options.txt index 52d1d52..1ee49a6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -13,4 +13,4 @@ option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-m option('build-examples', type: 'boolean', value: true, description: 'Build example programs') option('build-tests', type: 'combo', choices: ['false', 'if-dependencies-found', 'true'], - value: 'if-dependencies-found', description: 'Build test programs (requires Boost Test and Fontconfig)') + value: 'if-dependencies-found', description: 'Build test programs (requires Boost Test and Fontconfig or Windows)') diff --git a/tests/test-font-face.cc b/tests/test-font-face.cc index 15f7bf3..2788a5c 100644 --- a/tests/test-font-face.cc +++ b/tests/test-font-face.cc @@ -49,7 +49,7 @@ void test_toy_getters () BOOST_CHECK_EQUAL (Cairo::FONT_TYPE_TOY, toy->get_type()); } -#ifdef CAIRO_HAS_FT_FONT +#if defined (CAIRO_HAS_FT_FONT) && defined (CAIRO_HAS_FC_FONT) void test_ft_font_face() { // Does not throw an exception. Skip this test for now. /Kjell Ahlstedt 2020-04-21 @@ -70,7 +70,7 @@ void test_ft_font_face() // FIXME: test creating from a FT_Face } -#endif // CAIRO_HAS_FT_FONT +#endif // CAIRO_HAS_FT_FONT && CAIRO_HAS_FC_FONT #ifdef CAIRO_HAS_WIN32_FONT void test_win32_font_face() @@ -113,7 +113,7 @@ init_unit_test_suite(int argc, char* argv[]) test->add (BOOST_TEST_CASE (&test_create_toy)); test->add (BOOST_TEST_CASE (&test_toy_getters)); -#ifdef CAIRO_HAS_FT_FONT +#if defined (CAIRO_HAS_FT_FONT) && defined (CAIRO_HAS_FC_FONT) test->add (BOOST_TEST_CASE (&test_ft_font_face)); #endif // CAIRO_HAS_FT_FONT #ifdef CAIRO_HAS_WIN32_FONT diff --git a/tests/test-scaled-font.cc b/tests/test-scaled-font.cc index 3847be9..1dc4314 100644 --- a/tests/test-scaled-font.cc +++ b/tests/test-scaled-font.cc @@ -69,7 +69,7 @@ void test_get_font_face() BOOST_REQUIRE_EQUAL(cairo_font_face_get_reference_count(face->cobj()), refcount); } -#ifdef CAIRO_HAS_FT_FONT +#if defined (CAIRO_HAS_FT_FONT) && defined (CAIRO_HAS_FC_FONT) void test_ft_scaled_font() { // Does not throw an exception. Skip this test for now. /Kjell Ahlstedt 2020-04-21 @@ -102,7 +102,7 @@ void test_ft_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 +#endif // CAIRO_HAS_FT_FONT && CAIRO_HAS_FC_FONT test_suite* @@ -117,7 +117,7 @@ init_unit_test_suite(int argc, char* argv[]) 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 +#if defined (CAIRO_HAS_FT_FONT) && defined (CAIRO_HAS_FC_FONT) test->add(BOOST_TEST_CASE(&test_ft_scaled_font)); #endif // CAIRO_HAS_FT_FONT -- cgit v1.2.3