# HG changeset patch # User Thinker K.F. Li # Date 1284414288 -28800 # Node ID ea544a68f55d2b8ae1e65a3b6b50dede296ff671 # Parent 856c919659cc2f3db9d0bfe0915b69a58c795b6e Testcase for redrawing cached canvas diff -r 856c919659cc -r ea544a68f55d src/redraw_man.c --- a/src/redraw_man.c Mon Sep 13 20:41:07 2010 +0800 +++ b/src/redraw_man.c Tue Sep 14 05:44:48 2010 +0800 @@ -2812,6 +2812,8 @@ CU_ASSERT(geo_get_area(coord2)->y == 100); CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19); CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19); + + redraw_man_destroy(rdman); } static void @@ -2847,10 +2849,37 @@ CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19); CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19); - CU_ASSERT(geo_get_area(coord1)->x == 100); - CU_ASSERT(geo_get_area(coord1)->y == 100); - CU_ASSERT(geo_get_area(coord1)->w <= 22 && geo_get_area(coord1)->w >= 19); - CU_ASSERT(geo_get_area(coord1)->h <= 22 && geo_get_area(coord1)->h >= 19); + redraw_man_destroy(rdman); +} + +static void +test_own_canvas_redraw(void) { + redraw_man_t *rdman; + redraw_man_t _rdman; + coord_t *coord1, *coord2; + sh_dummy_t *sh; + + redraw_man_init(&_rdman, NULL, NULL); + rdman = &_rdman; + + coord1 = rdman_coord_new(rdman, rdman->root_coord); + CU_ASSERT(coord1->parent == rdman->root_coord); + + coord2 = rdman_coord_new(rdman, coord1); + CU_ASSERT(coord2->parent == coord1); + + coord_set_opacity(coord2, 0.9); + rdman_coord_changed(rdman, coord2); + + sh = (shape_t *)sh_dummy_new(rdman, 100, 100, 20, 20); + rdman_add_shape(rdman, (shape_t *)sh, coord2); + rdman_shape_changed(rdman, (shape_t *)sh); + + rdman_redraw_changed(rdman); + + CU_ASSERT(sh->draw_cnt == 1); + + redraw_man_destroy(rdman); } CU_pSuite get_redraw_man_suite(void) { @@ -2862,6 +2891,7 @@ CU_ADD_TEST(suite, test_setup_canvas_info); CU_ADD_TEST(suite, test_own_canvas_area); CU_ADD_TEST(suite, test_own_canvas); + CU_ADD_TEST(suite, test_own_canvas_redraw); return suite; }