[gtk+] Pretty print non-matching signals in filter model test suite
- From: Kristian Rietveld <kristian src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Pretty print non-matching signals in filter model test suite
- Date: Wed, 30 Sep 2009 08:36:34 +0000 (UTC)
commit 3a69f6772bfa8a560e3fef557d292851a5da45a4
Author: Kristian Rietveld <kris gtk org>
Date: Tue Sep 29 17:12:37 2009 +0200
Pretty print non-matching signals in filter model test suite
gtk/tests/filtermodel.c | 64 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/gtk/tests/filtermodel.c b/gtk/tests/filtermodel.c
index 91420c4..ecc0db2 100644
--- a/gtk/tests/filtermodel.c
+++ b/gtk/tests/filtermodel.c
@@ -105,6 +105,34 @@ typedef enum
}
SignalName;
+static const char *
+signal_name_to_string (SignalName signal)
+{
+ switch (signal)
+ {
+ case ROW_INSERTED:
+ return "row-inserted";
+
+ case ROW_DELETED:
+ return "row-deleted";
+
+ case ROW_CHANGED:
+ return "row-changed";
+
+ case ROW_HAS_CHILD_TOGGLED:
+ return "row-has-child-toggled";
+
+ case ROWS_REORDERED:
+ return "rows-reordered";
+
+ default:
+ /* Fall through */
+ break;
+ }
+
+ return "(unknown)";
+}
+
typedef struct
{
SignalName signal;
@@ -152,21 +180,45 @@ signal_monitor_generic_handler (SignalMonitor *m,
{
Signal *s;
- g_return_if_fail (m->client == model);
- g_return_if_fail (!g_queue_is_empty (m->queue));
+ if (g_queue_is_empty (m->queue))
+ {
+ g_error ("Signal queue empty\n");
+ g_assert_not_reached ();
+ }
+
+ if (m->client != model)
+ {
+ g_error ("Model mismatch; expected %p, got %p\n",
+ m->client, model);
+ g_assert_not_reached ();
+ }
+
+ s = g_queue_peek_tail (m->queue);
#if 0
/* For debugging: output signals that are coming in. Leaks memory. */
g_print ("signal=%d path=%s\n", signal, gtk_tree_path_to_string (path));
#endif
- s = g_queue_peek_tail (m->queue);
+ if (s->signal != signal
+ || gtk_tree_path_compare (s->path, path) != 0)
+ {
+ gchar *path_str, *s_path_str;
- g_return_if_fail (s->signal == signal);
+ s_path_str = gtk_tree_path_to_string (s->path);
+ path_str = gtk_tree_path_to_string (path);
- s = g_queue_pop_tail (m->queue);
+ g_error ("Signals don't match; expected signal %s path %s, got signal %s path %s\n",
+ signal_name_to_string (s->signal), s_path_str,
+ signal_name_to_string (signal), path_str);
+
+ g_free (s_path_str);
+ g_free (path_str);
- g_return_if_fail (!gtk_tree_path_compare (path, s->path));
+ g_assert_not_reached ();
+ }
+
+ s = g_queue_pop_tail (m->queue);
signal_free (s);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]