about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/pgp/stub_gpg.c2
-rw-r--r--tests/unittests/test_autocomplete.c41
-rw-r--r--tests/unittests/test_autocomplete.h1
-rw-r--r--tests/unittests/test_roster_list.c28
-rw-r--r--tests/unittests/ui/stub_ui.c2
-rw-r--r--tests/unittests/unittests.c1
-rw-r--r--tests/unittests/xmpp/stub_xmpp.c8
7 files changed, 51 insertions, 32 deletions
diff --git a/tests/unittests/pgp/stub_gpg.c b/tests/unittests/pgp/stub_gpg.c
index 02ccb4c8..edaab4e0 100644
--- a/tests/unittests/pgp/stub_gpg.c
+++ b/tests/unittests/pgp/stub_gpg.c
@@ -56,7 +56,7 @@ void p_gpg_free_keys(GHashTable *keys) {}
 
 void p_gpg_autocomplete_key_reset(void) {}
 
-char * p_gpg_autocomplete_key(const char * const search_str)
+char * p_gpg_autocomplete_key(const char * const search_str, gboolean previous)
 {
     return NULL;
 }
diff --git a/tests/unittests/test_autocomplete.c b/tests/unittests/test_autocomplete.c
index 755e01c9..519973c4 100644
--- a/tests/unittests/test_autocomplete.c
+++ b/tests/unittests/test_autocomplete.c
@@ -24,7 +24,7 @@ void reset_after_create(void **state)
 void find_after_create(void **state)
 {
     Autocomplete ac = autocomplete_new();
-    autocomplete_complete(ac, "hello", TRUE);
+    autocomplete_complete(ac, "hello", TRUE, FALSE);
     autocomplete_clear(ac);
 }
 
@@ -43,7 +43,7 @@ void add_one_and_complete(void **state)
 {
     Autocomplete ac = autocomplete_new();
     autocomplete_add(ac, "Hello");
-    char *result = autocomplete_complete(ac, "Hel", TRUE);
+    char *result = autocomplete_complete(ac, "Hel", TRUE, FALSE);
 
     assert_string_equal("Hello", result);
 
@@ -55,7 +55,7 @@ void add_two_and_complete_returns_first(void **state)
     Autocomplete ac = autocomplete_new();
     autocomplete_add(ac, "Hello");
     autocomplete_add(ac, "Help");
-    char *result = autocomplete_complete(ac, "Hel", TRUE);
+    char *result = autocomplete_complete(ac, "Hel", TRUE, FALSE);
 
     assert_string_equal("Hello", result);
 
@@ -67,8 +67,8 @@ void add_two_and_complete_returns_second(void **state)
     Autocomplete ac = autocomplete_new();
     autocomplete_add(ac, "Hello");
     autocomplete_add(ac, "Help");
-    char *result1 = autocomplete_complete(ac, "Hel", TRUE);
-    char *result2 = autocomplete_complete(ac, result1, TRUE);
+    char *result1 = autocomplete_complete(ac, "Hel", TRUE, FALSE);
+    char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE);
 
     assert_string_equal("Help", result2);
 
@@ -123,7 +123,7 @@ void complete_accented_with_accented(void **state)
     Autocomplete ac = autocomplete_new();
     autocomplete_add(ac, "èâîô");
 
-    char *result = autocomplete_complete(ac, "èâ", TRUE);
+    char *result = autocomplete_complete(ac, "èâ", TRUE, FALSE);
 
     assert_string_equal("èâîô", result);
 
@@ -135,7 +135,7 @@ void complete_accented_with_base(void **state)
     Autocomplete ac = autocomplete_new();
     autocomplete_add(ac, "èâîô");
 
-    char *result = autocomplete_complete(ac, "ea", TRUE);
+    char *result = autocomplete_complete(ac, "ea", TRUE, FALSE);
 
     assert_string_equal("èâîô", result);
 
@@ -148,8 +148,8 @@ void complete_both_with_accented(void **state)
     autocomplete_add(ac, "eaooooo");
     autocomplete_add(ac, "èâîô");
 
-    char *result1 = autocomplete_complete(ac, "èâ", TRUE);
-    char *result2 = autocomplete_complete(ac, result1, TRUE);
+    char *result1 = autocomplete_complete(ac, "èâ", TRUE, FALSE);
+    char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE);
 
     assert_string_equal("èâîô", result2);
 
@@ -162,8 +162,8 @@ void complete_both_with_base(void **state)
     autocomplete_add(ac, "eaooooo");
     autocomplete_add(ac, "èâîô");
 
-    char *result1 = autocomplete_complete(ac, "ea", TRUE);
-    char *result2 = autocomplete_complete(ac, result1, TRUE);
+    char *result1 = autocomplete_complete(ac, "ea", TRUE, FALSE);
+    char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE);
 
     assert_string_equal("èâîô", result2);
 
@@ -175,9 +175,26 @@ void complete_ignores_case(void **state)
     Autocomplete ac = autocomplete_new();
     autocomplete_add(ac, "MyBuddy");
 
-    char *result = autocomplete_complete(ac, "myb", TRUE);
+    char *result = autocomplete_complete(ac, "myb", TRUE, FALSE);
 
     assert_string_equal("MyBuddy", result);
 
     autocomplete_clear(ac);
 }
+
+void complete_previous(void **state)
+{
+    Autocomplete ac = autocomplete_new();
+    autocomplete_add(ac, "MyBuddy1");
+    autocomplete_add(ac, "MyBuddy2");
+    autocomplete_add(ac, "MyBuddy3");
+
+    char *result1 = autocomplete_complete(ac, "myb", TRUE, FALSE);
+    char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE);
+    char *result3 = autocomplete_complete(ac, result2, TRUE, FALSE);
+    char *result4 = autocomplete_complete(ac, result3, TRUE, TRUE);
+
+    assert_string_equal("MyBuddy2", result4);
+
+    autocomplete_clear(ac);
+}
diff --git a/tests/unittests/test_autocomplete.h b/tests/unittests/test_autocomplete.h
index a9dd34cb..746ea2af 100644
--- a/tests/unittests/test_autocomplete.h
+++ b/tests/unittests/test_autocomplete.h
@@ -13,3 +13,4 @@ void complete_accented_with_base(void **state);
 void complete_both_with_accented(void **state);
 void complete_both_with_base(void **state);
 void complete_ignores_case(void **state);
+void complete_previous(void **state);
diff --git a/tests/unittests/test_roster_list.c b/tests/unittests/test_roster_list.c
index c2c63a6b..5352e420 100644
--- a/tests/unittests/test_roster_list.c
+++ b/tests/unittests/test_roster_list.c
@@ -158,7 +158,7 @@ void find_first_exists(void **state)
 
     char *search = strdup("B");
 
-    char *result = roster_contact_autocomplete(search);
+    char *result = roster_contact_autocomplete(search, FALSE);
     assert_string_equal("Bob", result);
     free(result);
     free(search);
@@ -172,7 +172,7 @@ void find_second_exists(void **state)
     roster_add("Dave", NULL, NULL, NULL, FALSE);
     roster_add("Bob", NULL, NULL, NULL, FALSE);
 
-    char *result = roster_contact_autocomplete("Dav");
+    char *result = roster_contact_autocomplete("Dav", FALSE);
     assert_string_equal("Dave", result);
     free(result);
     roster_destroy();
@@ -185,7 +185,7 @@ void find_third_exists(void **state)
     roster_add("Dave", NULL, NULL, NULL, FALSE);
     roster_add("Bob", NULL, NULL, NULL, FALSE);
 
-    char *result = roster_contact_autocomplete("Ja");
+    char *result = roster_contact_autocomplete("Ja", FALSE);
     assert_string_equal("James", result);
     free(result);
     roster_destroy();
@@ -198,7 +198,7 @@ void find_returns_null(void **state)
     roster_add("Dave", NULL, NULL, NULL, FALSE);
     roster_add("Bob", NULL, NULL, NULL, FALSE);
 
-    char *result = roster_contact_autocomplete("Mike");
+    char *result = roster_contact_autocomplete("Mike", FALSE);
     assert_null(result);
     roster_destroy();
 }
@@ -206,7 +206,7 @@ void find_returns_null(void **state)
 void find_on_empty_returns_null(void **state)
 {
     roster_create();
-    char *result = roster_contact_autocomplete("James");
+    char *result = roster_contact_autocomplete("James", FALSE);
     assert_null(result);
     roster_destroy();
 }
@@ -218,8 +218,8 @@ void find_twice_returns_second_when_two_match(void **state)
     roster_add("Jamie", NULL, NULL, NULL, FALSE);
     roster_add("Bob", NULL, NULL, NULL, FALSE);
 
-    char *result1 = roster_contact_autocomplete("Jam");
-    char *result2 = roster_contact_autocomplete(result1);
+    char *result1 = roster_contact_autocomplete("Jam", FALSE);
+    char *result2 = roster_contact_autocomplete(result1, FALSE);
     assert_string_equal("Jamie", result2);
     free(result1);
     free(result2);
@@ -240,11 +240,11 @@ void find_five_times_finds_fifth(void **state)
     roster_add("Jamy", NULL, NULL, NULL, FALSE);
     roster_add("Jamz", NULL, NULL, NULL, FALSE);
 
-    char *result1 = roster_contact_autocomplete("Jam");
-    char *result2 = roster_contact_autocomplete(result1);
-    char *result3 = roster_contact_autocomplete(result2);
-    char *result4 = roster_contact_autocomplete(result3);
-    char *result5 = roster_contact_autocomplete(result4);
+    char *result1 = roster_contact_autocomplete("Jam", FALSE);
+    char *result2 = roster_contact_autocomplete(result1, FALSE);
+    char *result3 = roster_contact_autocomplete(result2, FALSE);
+    char *result4 = roster_contact_autocomplete(result3, FALSE);
+    char *result5 = roster_contact_autocomplete(result4, FALSE);
     assert_string_equal("Jamo", result5);
     free(result1);
     free(result2);
@@ -261,9 +261,9 @@ void find_twice_returns_first_when_two_match_and_reset(void **state)
     roster_add("Jamie", NULL, NULL, NULL, FALSE);
     roster_add("Bob", NULL, NULL, NULL, FALSE);
 
-    char *result1 = roster_contact_autocomplete("Jam");
+    char *result1 = roster_contact_autocomplete("Jam", FALSE);
     roster_reset_search_attempts();
-    char *result2 = roster_contact_autocomplete(result1);
+    char *result2 = roster_contact_autocomplete(result1, FALSE);
     assert_string_equal("James", result2);
     free(result1);
     free(result2);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 7452e581..f2d8c5d7 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -408,7 +408,7 @@ void cons_check_version(gboolean not_available_msg) {}
 void cons_show_typing(const char * const barejid) {}
 void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, GList *triggers, int unread) {}
 void cons_show_incoming_message(const char * const short_from, const int win_index, int unread) {}
-void cons_show_room_invites(GSList *invites) {}
+void cons_show_room_invites(GList *invites) {}
 void cons_show_received_subs(void) {}
 void cons_show_sent_subs(void) {}
 void cons_alert(void) {}
diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c
index 5c411ab6..2938b9ff 100644
--- a/tests/unittests/unittests.c
+++ b/tests/unittests/unittests.c
@@ -95,6 +95,7 @@ int main(int argc, char* argv[]) {
         unit_test(complete_both_with_accented),
         unit_test(complete_both_with_base),
         unit_test(complete_ignores_case),
+        unit_test(complete_previous),
 
         unit_test(create_jid_from_null_returns_null),
         unit_test(create_jid_from_empty_string_returns_null),
diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c
index 38f7428e..630c0b19 100644
--- a/tests/unittests/xmpp/stub_xmpp.c
+++ b/tests/unittests/xmpp/stub_xmpp.c
@@ -128,7 +128,7 @@ void message_send_invite(const char * const room, const char * const contact,
 // presence functions
 void presence_subscription(const char * const jid, const jabber_subscr_t action) {}
 
-GSList* presence_get_subscription_requests(void)
+GList* presence_get_subscription_requests(void)
 {
     return NULL;
 }
@@ -140,7 +140,7 @@ gint presence_sub_request_count(void)
 
 void presence_reset_sub_request_search(void) {}
 
-char * presence_sub_request_find(const char * const search_str)
+char * presence_sub_request_find(const char * const search_str, gboolean previous)
 {
     return  NULL;
 }
@@ -250,7 +250,7 @@ GList * bookmark_get_list(void)
     return (GList *)mock();
 }
 
-char * bookmark_find(const char * const search_str)
+char * bookmark_find(const char * const search_str, gboolean previous)
 {
     return NULL;
 }
@@ -298,7 +298,7 @@ gboolean blocked_remove(char *jid)
     return TRUE;
 }
 
-char* blocked_ac_find(const char *const search_str)
+char* blocked_ac_find(const char *const search_str, gboolean previous)
 {
     return NULL;
 }