Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/bin/tests/mvc Modified Files: ewl_mvc.c Log Message: - fill in some mvc unit tests - fix some mvc selected bugs =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/mvc/ewl_mvc.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ewl_mvc.c 17 Oct 2006 05:21:37 -0000 1.1 +++ ewl_mvc.c 17 Oct 2006 15:35:37 -0000 1.2 @@ -8,9 +8,13 @@ static int selected_get(char *buf, int len); static int selected_list_set(char *buf, int len); static int selected_list_get(char *buf, int len); -static int selected_range_add(char *buf, int len); +static int selected_range_single_add(char *buf, int len); +static int selected_range_multi_add(char *buf, int len); static int selected_count_get(char *buf, int len); -static int selected_is(char *buf, int len); +static int selected_is_index(char *buf, int len); +static int selected_is_not_index(char *buf, int len); +static int selected_is_range(char *buf, int len); +static int selected_is_not_range(char *buf, int len); static int selected_clear(char *buf, int len); static int selected_rm_idx(char *buf, int len); @@ -27,9 +31,13 @@ {"Get selected", selected_get}, {"List set selected", selected_list_set}, {"List get selected", selected_list_get}, - {"Range add", selected_range_add}, + {"Range (single select) add", selected_range_single_add}, + {"Range (multi select) add", selected_range_multi_add}, {"Count get", selected_count_get}, - {"Is selected", selected_is}, + {"Is selected (index)", selected_is_index}, + {"Is not selected (index)", selected_is_not_index}, + {"Is selected (range)", selected_is_range}, + {"Is not selected (range)", selected_is_not_range}, {"Selected clear", selected_clear}, {"Remove index", selected_rm_idx}, {"Remove from range, top left point", @@ -62,13 +70,60 @@ static int selected_set(char *buf, int len) { - return FALSE; + Ewl_Widget *t; + Ewl_MVC *m; + Ewl_Selection_Idx *idx; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selected_set(m, 1, 2); + idx = ecore_list_goto_first(m->selected); + + if (idx->sel.type != EWL_SELECTION_TYPE_INDEX) + { + snprintf(buf, len, "Incorrect selection type"); + return FALSE; + } + + if ((idx->row != 1) || (idx->column != 2)) + { + snprintf(buf, len, "Incorrect row/column setting"); + return FALSE; + } + + return TRUE; } static int selected_get(char *buf, int len) { - return FALSE; + Ewl_Widget *t; + Ewl_MVC *m; + Ewl_Selection_Idx *idx; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selected_set(m, 6, 8); + ewl_mvc_selected_add(m, 3, 0); + ewl_mvc_selected_add(m, 9, 1); + ewl_mvc_selected_add(m, 1, 2); + idx = ewl_mvc_selected_get(m); + + if (idx->sel.type != EWL_SELECTION_TYPE_INDEX) + { + snprintf(buf, len, "Incorrect selection type"); + return FALSE; + } + + if ((idx->row != 1) || (idx->column != 2)) + { + snprintf(buf, len, "Incorrect row/column setting"); + return FALSE; + } + + return TRUE; } static int @@ -84,27 +139,202 @@ } static int -selected_range_add(char *buf, int len) +selected_range_single_add(char *buf, int len) { - return FALSE; + Ewl_Widget *t; + Ewl_MVC *m; + Ewl_Selection_Idx *idx; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selected_range_add(m, 6, 8, 1, 2); + idx = ecore_list_goto_first(m->selected); + + if (idx->sel.type != EWL_SELECTION_TYPE_INDEX) + { + snprintf(buf, len, "Incorrect selection type"); + return FALSE; + } + + if ((idx->row != 1) || (idx->column != 2)) + { + snprintf(buf, len, "Incorrect start row/column setting"); + return FALSE; + } + + return TRUE; +} + +static int +selected_range_multi_add(char *buf, int len) +{ + Ewl_Widget *t; + Ewl_MVC *m; + Ewl_Selection_Range *idx; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI); + ewl_mvc_selected_range_add(m, 6, 8, 1, 2); + idx = ecore_list_goto_first(m->selected); + + if (idx->sel.type != EWL_SELECTION_TYPE_RANGE) + { + snprintf(buf, len, "Incorrect selection type"); + return FALSE; + } + + if ((idx->start.row != 1) || (idx->start.column != 2)) + { + snprintf(buf, len, "Incorrect start row/column setting"); + return FALSE; + } + + if ((idx->end.row != 6) || (idx->end.column != 8)) + { + snprintf(buf, len, "Incorrect end row/column setting"); + return FALSE; + } + + return TRUE; } static int selected_count_get(char *buf, int len) { - return FALSE; + Ewl_Widget *t; + Ewl_MVC *m; + int count, expected = 46; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI); + ewl_mvc_selected_set(m, 6, 8); + ewl_mvc_selected_add(m, 3, 0); + ewl_mvc_selected_add(m, 9, 1); + ewl_mvc_selected_add(m, 1, 2); + ewl_mvc_selected_range_add(m, 6, 8, 1, 2); + + count = ewl_mvc_selected_count_get(m); + if (count != expected) + { + snprintf(buf, len, "Incorrect count (%d instead of %d)", + count, expected); + return FALSE; + } + + return TRUE; } static int -selected_is(char *buf, int len) +selected_is_index(char *buf, int len) { - return FALSE; + Ewl_Widget *t; + Ewl_MVC *m; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selected_set(m, 6, 8); + + if (!ewl_mvc_selected_is(m, 6, 8)) + { + snprintf(buf, len, "Not selected"); + return FALSE; + } + + return TRUE; +} + +static int +selected_is_not_index(char *buf, int len) +{ + Ewl_Widget *t; + Ewl_MVC *m; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selected_set(m, 6, 8); + + if (ewl_mvc_selected_is(m, 7, 7)) + { + snprintf(buf, len, "Item selected"); + return FALSE; + } + + return TRUE; +} + +static int +selected_is_range(char *buf, int len) +{ + Ewl_Widget *t; + Ewl_MVC *m; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI); + ewl_mvc_selected_range_add(m, 6, 8, 1, 2); + + if (!ewl_mvc_selected_is(m, 4, 5)) + { + snprintf(buf, len, "Not selected"); + return FALSE; + } + + return TRUE; +} + +static int +selected_is_not_range(char *buf, int len) +{ + Ewl_Widget *t; + Ewl_MVC *m; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI); + ewl_mvc_selected_range_add(m, 6, 8, 1, 2); + + if (ewl_mvc_selected_is(m, 1, 1)) + { + snprintf(buf, len, "Item selected selected"); + return FALSE; + } + + return TRUE; } static int selected_clear(char *buf, int len) { - return FALSE; + Ewl_Widget *t; + Ewl_MVC *m; + + t = ewl_tree2_new(); + m = EWL_MVC(t); + + ewl_mvc_selection_mode_set(m, EWL_SELECTION_MODE_MULTI); + ewl_mvc_selected_set(m, 6, 8); + ewl_mvc_selected_add(m, 3, 0); + ewl_mvc_selected_add(m, 9, 1); + ewl_mvc_selected_add(m, 1, 2); + ewl_mvc_selected_range_add(m, 6, 8, 1, 2); + ewl_mvc_selected_clear(m); + + if (ewl_mvc_selected_count_get(m) != 0) + { + snprintf(buf, len, "Selected list not empty."); + return FALSE; + } + + return TRUE; } static int ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs