diff --git a/.gitignore b/.gitignore
index 6be27ed5..c3d9a977 100644
--- a/.gitignore
+++ b/.gitignore
@@ -69,4 +69,5 @@ callgrind.out.*
gen_docs.sh
main_fragment.html
toc_fragment.html
-stabbertests/testsuite.trs
+stabbertests/stabbertestsuite
+stabbertests/stabbertestsuite.trs
diff --git a/Makefile.am b/Makefile.am
index d3aed4e9..cae3a268 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -131,7 +131,7 @@ stabbertest_sources = \
stabbertests/ui/stub_ui.c \
stabbertests/proftest.c stabbertests/proftest.h \
stabbertests/test_connect.c stabbertests/test_connect.h \
- stabbertests/testsuite.c
+ stabbertests/stabbertestsuite.c
main_source = src/main.c
@@ -174,12 +174,12 @@ if INCLUDE_GIT_VERSION
BUILT_SOURCES = $(git_include)
endif
-TESTS = tests/testsuite stabbertests/testsuite
-check_PROGRAMS = tests/testsuite stabbertests/testsuite
+TESTS = tests/testsuite stabbertests/stabbertestsuite
+check_PROGRAMS = tests/testsuite stabbertests/stabbertestsuite
tests_testsuite_SOURCES = $(test_sources)
tests_testsuite_LDADD = -lcmocka
-stabbertests_testsuite_SOURCES = $(stabbertest_sources)
-stabbertests_testsuite_LDADD = -lcmocka -lstabber -lpthread
+stabbertests_stabbertestsuite_SOURCES = $(stabbertest_sources)
+stabbertests_stabbertestsuite_LDADD = -lcmocka -lstabber -lpthread
man_MANS = $(man_sources)
diff --git a/src/common.c b/src/common.c
index 772e24d3..4fa45608 100644
--- a/src/common.c
+++ b/src/common.c
@@ -57,6 +57,8 @@ struct curl_data_t
size_t size;
};
+static unsigned long unique_id = 0;
+
static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data);
// taken from glib 2.30.3
@@ -469,7 +471,6 @@ xdg_get_data_home(void)
char *
create_unique_id(char *prefix)
{
- static unsigned long unique_id;
char *result = NULL;
GString *result_str = g_string_new("");
@@ -485,6 +486,12 @@ create_unique_id(char *prefix)
return result;
}
+void
+reset_unique_id(void)
+{
+ unique_id = 0;
+}
+
char *
p_sha1_hash(char *str)
{
diff --git a/src/common.h b/src/common.h
index 9521a701..c1aa532d 100644
--- a/src/common.h
+++ b/src/common.h
@@ -127,6 +127,7 @@ contact_presence_t contact_presence_from_resource_presence(resource_presence_t r
char * p_sha1_hash(char *str);
char * create_unique_id(char *prefix);
+void reset_unique_id(void);
int cmp_win_num(gconstpointer a, gconstpointer b);
int get_next_available_win_num(GList *used);
diff --git a/stabbertests/proftest.c b/stabbertests/proftest.c
index d20e9f3a..e3f7f6a6 100644
--- a/stabbertests/proftest.c
+++ b/stabbertests/proftest.c
@@ -212,6 +212,7 @@ close_prof_test(void **state)
accounts_close();
cmd_uninit();
log_close();
+ reset_unique_id();
_cleanup_dirs();
diff --git a/stabbertests/testsuite.c b/stabbertests/stabbertestsuite.c
similarity index 66%
rename from stabbertests/testsuite.c
rename to stabbertests/stabbertestsuite.c
index 6905aeec..03b751ae 100644
--- a/stabbertests/testsuite.c
+++ b/stabbertests/stabbertestsuite.c
@@ -15,9 +15,19 @@
int main(int argc, char* argv[]) {
const UnitTest all_tests[] = {
+
unit_test_setup_teardown(connect_jid,
init_prof_test,
close_prof_test),
+ unit_test_setup_teardown(connect_jid_requests_roster,
+ init_prof_test,
+ close_prof_test),
+ unit_test_setup_teardown(connect_jid_sends_presence_after_receiving_roster,
+ init_prof_test,
+ close_prof_test),
+ unit_test_setup_teardown(connect_jid_requests_bookmarks,
+ init_prof_test,
+ close_prof_test),
unit_test_setup_teardown(connect_bad_password,
init_prof_test,
close_prof_test),
diff --git a/stabbertests/test_connect.c b/stabbertests/test_connect.c
index bfc8c69a..1176a71f 100644
--- a/stabbertests/test_connect.c
+++ b/stabbertests/test_connect.c
@@ -18,7 +18,6 @@ void
connect_jid(void **state)
{
will_return(ui_ask_password, strdup("password"));
-
expect_cons_show("Connecting as stabber@localhost");
cmd_process_input(strdup("/connect stabber@localhost port 5230"));
@@ -28,6 +27,63 @@ connect_jid(void **state)
assert_true(status == JABBER_CONNECTED);
}
+void
+connect_jid_requests_roster(void **state)
+{
+ will_return(ui_ask_password, strdup("password"));
+ expect_any_cons_show();
+
+ cmd_process_input(strdup("/connect stabber@localhost port 5230"));
+ prof_process_xmpp(20);
+
+ assert_true(stbbr_verify(
+ ""
+ ));
+}
+
+void
+connect_jid_sends_presence_after_receiving_roster(void **state)
+{
+ will_return(ui_ask_password, strdup("password"));
+ expect_any_cons_show();
+
+ stbbr_for("roster",
+ ""
+ ""
+ "- "
+ "
- "
+ "
"
+ ""
+ );
+
+ cmd_process_input(strdup("/connect stabber@localhost port 5230"));
+ prof_process_xmpp(20);
+
+ assert_true(stbbr_verify(
+ ""
+ ""
+ ""
+ ));
+}
+
+void
+connect_jid_requests_bookmarks(void **state)
+{
+ will_return(ui_ask_password, strdup("password"));
+ expect_any_cons_show();
+
+ cmd_process_input(strdup("/connect stabber@localhost port 5230"));
+ prof_process_xmpp(20);
+
+ assert_true(stbbr_verify(
+ ""
+ ""
+ ""
+ ""
+ ""
+ ));
+}
+
void
connect_bad_password(void **state)
{
@@ -43,6 +99,26 @@ connect_bad_password(void **state)
assert_true(status == JABBER_DISCONNECTED);
}
+//void
+//connect_loads_roster(void **state)
+//{
+// will_return(ui_ask_password, strdup("password"));
+//
+// expect_any_cons_show();
+//
+// stbbr_for("roster",
+// ""
+// ""
+// "- "
+// "
- "
+// "
"
+// ""
+// );
+//
+// cmd_process_input(strdup("/connect stabber@localhost port 5230"));
+// prof_process_xmpp(20);
+//}
+
void
sends_rooms_iq(void **state)
{
diff --git a/stabbertests/test_connect.h b/stabbertests/test_connect.h
index 0bf018cd..df66da05 100644
--- a/stabbertests/test_connect.h
+++ b/stabbertests/test_connect.h
@@ -1,5 +1,7 @@
void connect_jid(void **state);
+void connect_jid_requests_roster(void **state);
+void connect_jid_sends_presence_after_receiving_roster(void **state);
+void connect_jid_requests_bookmarks(void **state);
void connect_bad_password(void **state);
void sends_rooms_iq(void **state);
void multiple_pings(void **state);
-