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 unit tests for modification of callbacks during the middle of a callback
chain execution.
Fix callback position adjustment when a callback type is modified during
execution.

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/callback/ewl_callback.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_callback.c      21 Nov 2007 05:10:02 -0000      1.3
+++ ewl_callback.c      21 Nov 2007 06:41:04 -0000      1.4
@@ -17,9 +17,13 @@
 static int clear_test_call(char *buf, int len);
 static int append_test_call(char *buf, int len);
 static int prepend_test_call(char *buf, int len);
+static int append_in_chain_test_call(char *buf, int len);
+static int prepend_in_chain_test_call(char *buf, int len);
 
 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 Ewl_Unit_Test callback_unit_tests[] = {
                {"append/get id", append_test_id, NULL, -1, 0},
@@ -31,6 +35,8 @@
                {"clear/call", clear_test_call, NULL, -1, 0},
                {"append/call", append_test_call, NULL, -1, 0},
                {"prepend/call", prepend_test_call, NULL, -1, 0},
+               {"append during call", append_in_chain_test_call, NULL, -1, 0},
+               {"prepend during call", prepend_in_chain_test_call, NULL, -1, 
0},
                {NULL, NULL, NULL, -1, 0}
        };
 
@@ -276,6 +282,56 @@
        return ret;
 }
 
+/*
+ * Append a callback while in the callback chain and verify that calling the
+ * chain triggers the callback.
+ */
+static int
+append_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_append(w, EWL_CALLBACK_CONFIGURE, append_callback, NULL);
+       ewl_callback_call(w, EWL_CALLBACK_CONFIGURE);
+
+       if ((long)ewl_widget_data_get(w, w) == 1)
+               ret = 1;
+       else
+               snprintf(buf, len, "callback function not called");
+
+       ewl_widget_destroy(w);
+
+       return ret;
+}
+
+/*
+ * Prepend a callback while in the callback chain and verify that calling the
+ * chain does not trigger the callback.
+ */
+static int
+prepend_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, prepend_callback, NULL);
+       ewl_callback_call(w, EWL_CALLBACK_CONFIGURE);
+
+       if ((long)ewl_widget_data_get(w, w) != 1)
+               ret = 1;
+       else
+               snprintf(buf, len, "callback function called");
+
+       ewl_widget_destroy(w);
+
+       return ret;
+}
+
 static void
 base_callback(Ewl_Widget *w, void *event, void *data)
 {
@@ -288,6 +344,24 @@
 differing_callback(Ewl_Widget *w, void *event, void *data)
 {
        ewl_widget_data_set(w, w, (void *)(long)2);
+       event = data = NULL;
+       return;
+}
+
+static void
+append_callback(Ewl_Widget *w, void *event, void *data)
+{
+       ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, base_callback, NULL);
+
+       event = data = NULL;
+       return;
+}
+
+static void
+prepend_callback(Ewl_Widget *w, void *event, void *data)
+{
+       ewl_callback_prepend(w, EWL_CALLBACK_CONFIGURE, base_callback, NULL);
+
        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
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to