[gnome-builder/wip/kat: 36/36] tests: add test to check if navigate-to is called
- From: Ekaterina Gerasimova <egerasimov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/kat: 36/36] tests: add test to check if navigate-to is called
- Date: Sun, 15 Feb 2015 15:28:47 +0000 (UTC)
commit ed609631194458d5a7b4ba86f0e43166020b14b4
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 | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-ide-back-forward-list.c b/tests/test-ide-back-forward-list.c
index 9a52ed6..300c786 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;
+} counter_state_t;
+
static IdeBackForwardItem *
parse_item (test_state_t *state,
const gchar *str)
@@ -74,6 +79,16 @@ parse_item (test_state_t *state,
}
static void
+test_navigate_to_cb (IdeBackForwardList *list,
+ IdeBackForwardItem *item,
+ gpointer user_data)
+{
+ counter_state_t *state = user_data;
+
+ state->counter++;
+}
+
+static void
exercise1 (test_state_t *state,
IdeBackForwardList *list)
{
@@ -86,6 +101,11 @@ exercise1 (test_state_t *state,
};
gsize i;
+ counter_state_t state = { 0 };
+
+ g_signal_connect (list, "navigate-to", G_CALLBACK (test_navigate_to_cb),
+ &state);
+
for (i = 0; i < G_N_ELEMENTS (items); i++)
{
IdeBackForwardItem *item;
@@ -103,23 +123,27 @@ exercise1 (test_state_t *state,
{
g_assert (ide_back_forward_list_get_can_go_backward (list));
ide_back_forward_list_go_backward (list);
+ g_assert_cmpint (i, ==, state.counter);
}
g_assert (!ide_back_forward_list_get_can_go_backward (list));
g_test_expect_message ("ide-back-forward-list", G_LOG_LEVEL_WARNING,
"Cannot go backward, no more items in queue.");
ide_back_forward_list_go_backward (list);
+ g_assert_cmpint (5, ==, state.counter);
for (i = 0; i < G_N_ELEMENTS (items) - 1; i++)
{
g_assert (ide_back_forward_list_get_can_go_forward (list));
ide_back_forward_list_go_forward (list);
+ g_assert_cmpint (i+5, ==, state.counter);
}
g_assert (!ide_back_forward_list_get_can_go_forward (list));
g_test_expect_message ("ide-back-forward-list", G_LOG_LEVEL_WARNING,
"Cannot go forward, no more items in queue.");
ide_back_forward_list_go_forward (list);
+ g_assert_cmpint (10, ==, state.counter);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]