Enlightenment CVS committal

Author  : ningerso
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/bin/tests/callback


Modified Files:
        ewl_callback.c 


Log Message:
Add tests for deleting callbacks in the middle of a call chain.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/callback/ewl_callback.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_callback.c      21 Nov 2007 07:06:09 -0000      1.5
+++ ewl_callback.c      27 Nov 2007 04:22:39 -0000      1.6
@@ -21,13 +21,19 @@
 static int prepend_in_chain_test_call(char *buf, int len);
 static int insert_after_in_chain_test_call(char *buf, int len);
 static int insert_before_in_chain_test_call(char *buf, int len);
+static int delete_after_in_chain_test_call(char *buf, int len);
+static int delete_before_in_chain_test_call(char *buf, int len);
 
+/*
+ * Callbacks for manipulating the tests.
+ */
 static void base_callback(Ewl_Widget *w, void *event, void *data);
 static void differing_callback(Ewl_Widget *w, void *event, void *data);
 static void append_callback(Ewl_Widget *w, void *event, void *data);
 static void prepend_callback(Ewl_Widget *w, void *event, void *data);
 static void insert_after_callback(Ewl_Widget *w, void *event, void *data);
 static void insert_before_callback(Ewl_Widget *w, void *event, void *data);
+static void delete_callback(Ewl_Widget *w, void *event, void *data);
 
 static Ewl_Unit_Test callback_unit_tests[] = {
                {"append/get id", append_test_id, NULL, -1, 0},
@@ -43,6 +49,8 @@
                {"prepend during call", prepend_in_chain_test_call, NULL, -1, 
0},
                {"insert after during call", insert_after_in_chain_test_call, 
NULL, -1, 0},
                {"insert before during call", insert_before_in_chain_test_call, 
NULL, -1, 0},
+               {"delete after during call", delete_after_in_chain_test_call, 
NULL, -1, 0},
+               {"delete before during call", delete_before_in_chain_test_call, 
NULL, -1, 0},
                {NULL, NULL, NULL, -1, 0}
        };
 
@@ -384,7 +392,67 @@
                        NULL);
        ewl_callback_call(w, EWL_CALLBACK_CONFIGURE);
 
-       if ((long)ewl_widget_data_get(w, w) != 1)
+       if ((long)ewl_widget_data_get(w, w) == 2)
+               ret = 1;
+       else
+               snprintf(buf, len, "callback function called");
+
+       ewl_widget_destroy(w);
+
+       return ret;
+}
+
+/*
+ * Delete a callback before the current one, while in the callback chain and
+ * verify that calling the chain continues properly.
+ */
+static int
+delete_before_in_chain_test_call(char *buf, int len)
+{
+       Ewl_Widget *w;
+       int ret = 0;
+
+       w = ewl_widget_new();
+       ewl_callback_del_type(w, EWL_CALLBACK_CONFIGURE);
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, differing_callback,
+                       NULL);
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, delete_callback,
+                       NULL);
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, base_callback,
+                       NULL);
+       ewl_callback_call(w, EWL_CALLBACK_CONFIGURE);
+
+       if ((long)ewl_widget_data_get(w, w) == 2)
+               ret = 1;
+       else
+               snprintf(buf, len, "callback function not called");
+
+       ewl_widget_destroy(w);
+
+       return ret;
+}
+
+/*
+ * Delete a callback afer the current one, while in the callback chain and
+ * verify that calling the chain does not call the removed callback.
+ */
+static int
+delete_after_in_chain_test_call(char *buf, int len)
+{
+       Ewl_Widget *w;
+       int ret = 0;
+
+       w = ewl_widget_new();
+       ewl_callback_del_type(w, EWL_CALLBACK_CONFIGURE);
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, base_callback,
+                       NULL);
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, delete_callback,
+                       NULL);
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, differing_callback,
+                       NULL);
+       ewl_callback_call(w, EWL_CALLBACK_CONFIGURE);
+
+       if ((long)ewl_widget_data_get(w, w) == 2)
                ret = 1;
        else
                snprintf(buf, len, "callback function called");
@@ -444,6 +512,14 @@
        ewl_callback_insert_after(w, EWL_CALLBACK_CONFIGURE, base_callback,
                        NULL, differing_callback, NULL);
 
+       event = data = NULL;
+       return;
+}
+
+static void
+delete_callback(Ewl_Widget *w, void *event, void *data)
+{
+       ewl_callback_del(w, EWL_CALLBACK_CONFIGURE, base_callback);
        event = data = NULL;
        return;
 }



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to