comparison src/shape_stext.c @ 412:a456e267279a

Test cases for shape_stext. Even not all testcases are passed, but it is still there waiting to be done.
author Thinker K.F. Li <thinker@branda.to>
date Fri, 24 Jul 2009 22:23:51 +0800
parents 1633551e495d
children 35712e4bad0e
comparison
equal deleted inserted replaced
411:1633551e495d 412:a456e267279a
66 66
67 /*! \brief Find out a font pattern. 67 /*! \brief Find out a font pattern.
68 * 68 *
69 * This function use fontconfig to decide a font file in pattern. It can 69 * This function use fontconfig to decide a font file in pattern. It can
70 * replaced by other mechanism if you think it is not what you want. 70 * replaced by other mechanism if you think it is not what you want.
71 *
72 * \param slant make font prune if it it non-zero.
73 * \param weight make font normal if it is 100.
71 */ 74 */
72 static 75 static
73 FcPattern *query_font_pattern(const char *family, int slant, int weight) { 76 FcPattern *query_font_pattern(const char *family, int slant, int weight) {
74 FcPattern *ptn, *p; 77 FcPattern *ptn, *p;
75 FcValue val; 78 FcValue val;
462 return OK; 465 return OK;
463 } 466 }
464 467
465 #ifdef UNITTEST 468 #ifdef UNITTEST
466 469
470 #include <CUnit/Basic.h>
471
472 static
473 void test_query_font_face(void) {
474 mb_font_face_t *face;
475
476 face = query_font_face("serif", 0, 100);
477 CU_ASSERT(face != NULL);
478 mb_font_face_free(face);
479 }
480
481 static
482 void test_make_scaled_font_face_matrix(void) {
483 co_aix matrix[6] = {5, 0, 0, 5, 0, 0};
484 mb_font_face_t *face;
485 mb_scaled_font_t *scaled;
486
487 face = query_font_face("serif", 0, 100);
488 scaled = make_scaled_font_face_matrix(face, matrix);
489 CU_ASSERT(scaled != NULL);
490 scaled_font_free(scaled);
491 }
492
467 static 493 static
468 void test_compute_text_extents(void) { 494 void test_compute_text_extents(void) {
495 co_aix matrix[6] = {0.2, 0, 0, 0, 0.2, 0};
496 mb_font_face_t *face;
497 mb_scaled_font_t *scaled;
498 mb_text_extents_t ext;
499
500 face = query_font_face("serif", 0, 100);
501 scaled = make_scaled_font_face_matrix(face, matrix);
502 CU_ASSERT(scaled != NULL);
503
504 compute_text_extents(scaled, "test", &ext);
505 CU_ASSERT(ext.height == 5);
506 CU_ASSERT(ext.width == 20);
507
508 scaled_font_free(scaled);
469 } 509 }
470 510
471 #include <CUnit/Basic.h> 511 #include <CUnit/Basic.h>
472 CU_pSuite get_stext_suite(void) { 512 CU_pSuite get_stext_suite(void) {
473 CU_pSuite suite; 513 CU_pSuite suite;
474 514
475 suite = CU_add_suite("Suite_stext", NULL, NULL); 515 suite = CU_add_suite("Suite_stext", NULL, NULL);
516 CU_ADD_TEST(suite, test_query_font_face);
517 CU_ADD_TEST(suite, test_make_scaled_font_face_matrix);
476 CU_ADD_TEST(suite, test_compute_text_extents); 518 CU_ADD_TEST(suite, test_compute_text_extents);
519 CU_ADD_TEST(suite, test_compute_text_extents);
477 520
478 return suite; 521 return suite;
479 } 522 }
480 523
481 #endif /* UNITTEST */ 524 #endif /* UNITTEST */