# HG changeset patch # User Thinker K.F. Li # Date 1248445431 -28800 # Node ID a456e267279a107474c48ac476b94dd8d50b4c39 # Parent 1633551e495dbc756fb8791bf7e0f0097c01c1c6 Test cases for shape_stext. Even not all testcases are passed, but it is still there waiting to be done. diff -r 1633551e495d -r a456e267279a src/shape_stext.c --- a/src/shape_stext.c Wed Jul 08 22:16:54 2009 +0800 +++ b/src/shape_stext.c Fri Jul 24 22:23:51 2009 +0800 @@ -68,6 +68,9 @@ * * This function use fontconfig to decide a font file in pattern. It can * replaced by other mechanism if you think it is not what you want. + * + * \param slant make font prune if it it non-zero. + * \param weight make font normal if it is 100. */ static FcPattern *query_font_pattern(const char *family, int slant, int weight) { @@ -464,8 +467,45 @@ #ifdef UNITTEST +#include + +static +void test_query_font_face(void) { + mb_font_face_t *face; + + face = query_font_face("serif", 0, 100); + CU_ASSERT(face != NULL); + mb_font_face_free(face); +} + +static +void test_make_scaled_font_face_matrix(void) { + co_aix matrix[6] = {5, 0, 0, 5, 0, 0}; + mb_font_face_t *face; + mb_scaled_font_t *scaled; + + face = query_font_face("serif", 0, 100); + scaled = make_scaled_font_face_matrix(face, matrix); + CU_ASSERT(scaled != NULL); + scaled_font_free(scaled); +} + static void test_compute_text_extents(void) { + co_aix matrix[6] = {0.2, 0, 0, 0, 0.2, 0}; + mb_font_face_t *face; + mb_scaled_font_t *scaled; + mb_text_extents_t ext; + + face = query_font_face("serif", 0, 100); + scaled = make_scaled_font_face_matrix(face, matrix); + CU_ASSERT(scaled != NULL); + + compute_text_extents(scaled, "test", &ext); + CU_ASSERT(ext.height == 5); + CU_ASSERT(ext.width == 20); + + scaled_font_free(scaled); } #include @@ -473,6 +513,9 @@ CU_pSuite suite; suite = CU_add_suite("Suite_stext", NULL, NULL); + CU_ADD_TEST(suite, test_query_font_face); + CU_ADD_TEST(suite, test_make_scaled_font_face_matrix); + CU_ADD_TEST(suite, test_compute_text_extents); CU_ADD_TEST(suite, test_compute_text_extents); return suite;