[gnome-builder/wip/kat] tests: add test to check if navigate-to is called



commit 8eaa3cd849aed6efc33c0d7276454a1e3b4c7dbf
Author: Ekaterina Gerasimova <kittykat3756 gmail com>
Date:   Sat Feb 14 22:51:06 2015 +0000

    tests: add test to check if navigate-to is called

 tests/test-ide-back-forward-list.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-ide-back-forward-list.c b/tests/test-ide-back-forward-list.c
index 9a52ed6..21e893b 100644
--- a/tests/test-ide-back-forward-list.c
+++ b/tests/test-ide-back-forward-list.c
@@ -27,6 +27,11 @@ typedef struct
   GError       *error;
 } test_state_t;
 
+typedef struct
+{
+  guint counter;
+} exercise2_state_t;
+
 static IdeBackForwardItem *
 parse_item (test_state_t *state,
             const gchar  *str)
@@ -123,6 +128,36 @@ exercise1 (test_state_t       *state,
 }
 
 static void
+test_navigate_to_cb (IdeBackForwardList *list,
+                     IdeBackForwardItem *item,
+                     gpointer            user_data)
+{
+  exercise2_state_t *state = user_data;
+
+  state->counter++;
+}
+
+static void
+exercise2 (IdeBackForwardList *list)
+{
+  exercise2_state_t state = { 0 };
+
+  g_signal_connect (list, "navigate-to", G_CALLBACK (test_navigate_to_cb),
+                    &state);
+
+  ide_back_forward_list_go_backward (list);
+  ide_back_forward_list_go_backward (list);
+  g_assert_cmpint (2, ==, state.counter);
+
+  ide_back_forward_list_go_forward (list);
+  ide_back_forward_list_go_forward (list);
+  g_assert_cmpint (4, ==, state.counter);
+
+  ide_back_forward_list_go_backward (list);
+  g_assert_cmpint (5, ==, state.counter);
+}
+
+static void
 test_basic_cb (GObject      *object,
                GAsyncResult *result,
                gpointer      user_data)
@@ -137,6 +172,7 @@ test_basic_cb (GObject      *object,
 
       list = ide_context_get_back_forward_list (state->context);
       exercise1 (state, list);
+      exercise2 (list);
     }
 
   g_main_loop_quit (state->main_loop);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]