Mercurial > MadButterfly
comparison src/redraw_man.c @ 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 | 86f2c59cef09 |
children | 93c54322d4d8 |
comparison
equal
deleted
inserted
replaced
819:856c919659cc | 823:ea544a68f55d |
---|---|
2810 /* Parent cached coord must be updated */ | 2810 /* Parent cached coord must be updated */ |
2811 CU_ASSERT(geo_get_area(coord2)->x == 100); | 2811 CU_ASSERT(geo_get_area(coord2)->x == 100); |
2812 CU_ASSERT(geo_get_area(coord2)->y == 100); | 2812 CU_ASSERT(geo_get_area(coord2)->y == 100); |
2813 CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19); | 2813 CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19); |
2814 CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19); | 2814 CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19); |
2815 | |
2816 redraw_man_destroy(rdman); | |
2815 } | 2817 } |
2816 | 2818 |
2817 static void | 2819 static void |
2818 test_own_canvas(void) { | 2820 test_own_canvas(void) { |
2819 redraw_man_t *rdman; | 2821 redraw_man_t *rdman; |
2845 CU_ASSERT(geo_get_area(coord2)->x == 0); | 2847 CU_ASSERT(geo_get_area(coord2)->x == 0); |
2846 CU_ASSERT(geo_get_area(coord2)->y == 0); | 2848 CU_ASSERT(geo_get_area(coord2)->y == 0); |
2847 CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19); | 2849 CU_ASSERT(geo_get_area(coord2)->w <= 22 && geo_get_area(coord2)->w >= 19); |
2848 CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19); | 2850 CU_ASSERT(geo_get_area(coord2)->h <= 22 && geo_get_area(coord2)->h >= 19); |
2849 | 2851 |
2850 CU_ASSERT(geo_get_area(coord1)->x == 100); | 2852 redraw_man_destroy(rdman); |
2851 CU_ASSERT(geo_get_area(coord1)->y == 100); | 2853 } |
2852 CU_ASSERT(geo_get_area(coord1)->w <= 22 && geo_get_area(coord1)->w >= 19); | 2854 |
2853 CU_ASSERT(geo_get_area(coord1)->h <= 22 && geo_get_area(coord1)->h >= 19); | 2855 static void |
2856 test_own_canvas_redraw(void) { | |
2857 redraw_man_t *rdman; | |
2858 redraw_man_t _rdman; | |
2859 coord_t *coord1, *coord2; | |
2860 sh_dummy_t *sh; | |
2861 | |
2862 redraw_man_init(&_rdman, NULL, NULL); | |
2863 rdman = &_rdman; | |
2864 | |
2865 coord1 = rdman_coord_new(rdman, rdman->root_coord); | |
2866 CU_ASSERT(coord1->parent == rdman->root_coord); | |
2867 | |
2868 coord2 = rdman_coord_new(rdman, coord1); | |
2869 CU_ASSERT(coord2->parent == coord1); | |
2870 | |
2871 coord_set_opacity(coord2, 0.9); | |
2872 rdman_coord_changed(rdman, coord2); | |
2873 | |
2874 sh = (shape_t *)sh_dummy_new(rdman, 100, 100, 20, 20); | |
2875 rdman_add_shape(rdman, (shape_t *)sh, coord2); | |
2876 rdman_shape_changed(rdman, (shape_t *)sh); | |
2877 | |
2878 rdman_redraw_changed(rdman); | |
2879 | |
2880 CU_ASSERT(sh->draw_cnt == 1); | |
2881 | |
2882 redraw_man_destroy(rdman); | |
2854 } | 2883 } |
2855 | 2884 |
2856 CU_pSuite get_redraw_man_suite(void) { | 2885 CU_pSuite get_redraw_man_suite(void) { |
2857 CU_pSuite suite; | 2886 CU_pSuite suite; |
2858 | 2887 |
2860 CU_ADD_TEST(suite, test_rdman_redraw_changed); | 2889 CU_ADD_TEST(suite, test_rdman_redraw_changed); |
2861 CU_ADD_TEST(suite, test_rdman_free_objs); | 2890 CU_ADD_TEST(suite, test_rdman_free_objs); |
2862 CU_ADD_TEST(suite, test_setup_canvas_info); | 2891 CU_ADD_TEST(suite, test_setup_canvas_info); |
2863 CU_ADD_TEST(suite, test_own_canvas_area); | 2892 CU_ADD_TEST(suite, test_own_canvas_area); |
2864 CU_ADD_TEST(suite, test_own_canvas); | 2893 CU_ADD_TEST(suite, test_own_canvas); |
2894 CU_ADD_TEST(suite, test_own_canvas_redraw); | |
2865 | 2895 |
2866 return suite; | 2896 return suite; |
2867 } | 2897 } |
2868 | 2898 |
2869 #endif /* UNITTEST */ | 2899 #endif /* UNITTEST */ |