changeset 823:ea544a68f55d

Testcase for redrawing cached canvas
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 14 Sep 2010 05:44:48 +0800
parents 856c919659cc
children 93c54322d4d8
files src/redraw_man.c
diffstat 1 files changed, 34 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }