diff options
author | James Booth <boothj5@gmail.com> | 2015-05-24 20:31:18 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-24 20:31:18 +0100 |
commit | e295a474dcbf1633d3b7e4e8403bbcf3e84adc90 (patch) | |
tree | 095df24f6497b749877b5ed953f8be61df896bc7 /stabbertests | |
parent | 79ecff1c52dccf93db451635c596dedf49bf8609 (diff) | |
download | profani-tty-e295a474dcbf1633d3b7e4e8403bbcf3e84adc90.tar.gz |
Added more connect tests
Diffstat (limited to 'stabbertests')
-rw-r--r-- | stabbertests/proftest.c | 1 | ||||
-rw-r--r-- | stabbertests/stabbertestsuite.c (renamed from stabbertests/testsuite.c) | 10 | ||||
-rw-r--r-- | stabbertests/test_connect.c | 78 | ||||
-rw-r--r-- | stabbertests/test_connect.h | 4 |
4 files changed, 91 insertions, 2 deletions
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 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")); @@ -29,6 +28,63 @@ connect_jid(void **state) } 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( + "<iq id=\"roster\" type=\"get\"><query xmlns=\"jabber:iq:roster\"/></iq>" + )); +} + +void +connect_jid_sends_presence_after_receiving_roster(void **state) +{ + will_return(ui_ask_password, strdup("password")); + expect_any_cons_show(); + + stbbr_for("roster", + "<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">" + "<query xmlns=\"jabber:iq:roster\" ver=\"362\">" + "<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>" + "<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>" + "</query>" + "</iq>" + ); + + cmd_process_input(strdup("/connect stabber@localhost port 5230")); + prof_process_xmpp(20); + + assert_true(stbbr_verify( + "<presence id=\"prof_presence_1\">" + "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"EIpsmHyMRmfAoWbsX7Q2y9zibMM=\" node=\"http://www.profanity.im\"/>" + "</presence>" + )); +} + +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( + "<iq id=\"bookmark_init_request\" type=\"get\">" + "<query xmlns=\"jabber:iq:private\">" + "<storage xmlns=\"storage:bookmarks\"/>" + "</query>" + "</iq>" + )); +} + +void connect_bad_password(void **state) { will_return(ui_ask_password, strdup("badpassword")); @@ -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", +// "<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">" +// "<query xmlns=\"jabber:iq:roster\" ver=\"362\">" +// "<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>" +// "<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>" +// "</query>" +// "</iq>" +// ); +// +// 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); - |