diff options
author | James Booth <boothj5@gmail.com> | 2015-05-17 22:05:43 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-05-17 22:05:43 +0100 |
commit | 2c5b44421e1b3a163ce33249f9d0b1567d411b16 (patch) | |
tree | 5ba771ddcc003ef7d86e9585c87dd4b11af44f5a /stabbertests | |
parent | 97c5072f56b992d3bf2e4c3550a8010f9638b80a (diff) | |
download | profani-tty-2c5b44421e1b3a163ce33249f9d0b1567d411b16.tar.gz |
Added initial stabber test
Diffstat (limited to 'stabbertests')
-rw-r--r-- | stabbertests/proftest.c | 11 | ||||
-rw-r--r-- | stabbertests/proftest.h | 1 | ||||
-rw-r--r-- | stabbertests/test_connect.c | 31 | ||||
-rw-r--r-- | stabbertests/test_connect.h | 2 | ||||
-rw-r--r-- | stabbertests/testsuite.c | 2 |
5 files changed, 42 insertions, 5 deletions
diff --git a/stabbertests/proftest.c b/stabbertests/proftest.c index d15b9cbf..d5fdeb0a 100644 --- a/stabbertests/proftest.c +++ b/stabbertests/proftest.c @@ -25,10 +25,19 @@ #include "otr/otr.h" #endif - #define XDG_CONFIG_HOME "./stabbertests/files/xdg_config_home" #define XDG_DATA_HOME "./stabbertests/files/xdg_data_home" +void +prof_process_xmpp(void) +{ + int i = 0; + while (i < 20) { + jabber_process_events(10); + i++; + } +} + gboolean _create_dir(char *name) { diff --git a/stabbertests/proftest.h b/stabbertests/proftest.h index d35daae4..e0b6dded 100644 --- a/stabbertests/proftest.h +++ b/stabbertests/proftest.h @@ -1,2 +1,3 @@ void init_prof_test(void **state); void close_prof_test(void **state); +void prof_process_xmpp(void); diff --git a/stabbertests/test_connect.c b/stabbertests/test_connect.c index 1ddc9849..7a5c464a 100644 --- a/stabbertests/test_connect.c +++ b/stabbertests/test_connect.c @@ -4,9 +4,36 @@ #include <setjmp.h> #include <cmocka.h> #include <stdlib.h> +#include <string.h> + +#include <stabber.h> + +#include "proftest.h" +#include "xmpp/xmpp.h" +#include "ui/stub_ui.h" +#include "command/command.h" void -connect_with_no_jid(void **state) +connect_with_jid(void **state) { - assert_true(1); + char *connect = "/connect stabber@localhost port 5230"; + char *password = "password"; + + if (stbbr_start(5230) != 0) { + assert_true(FALSE); + return; + } + + stbbr_auth_passwd(password); + will_return(ui_ask_password, strdup(password)); + + expect_cons_show("Connecting as stabber@localhost"); + + cmd_process_input(strdup(connect)); + prof_process_xmpp(); + + jabber_conn_status_t status = jabber_get_connection_status(); + assert_true(status == JABBER_CONNECTED); + + stbbr_stop(); } diff --git a/stabbertests/test_connect.h b/stabbertests/test_connect.h index 887cec73..9716c6a9 100644 --- a/stabbertests/test_connect.h +++ b/stabbertests/test_connect.h @@ -1 +1 @@ -void connect_with_no_jid(void **state); +void connect_with_jid(void **state); diff --git a/stabbertests/testsuite.c b/stabbertests/testsuite.c index e4a220d7..467884ff 100644 --- a/stabbertests/testsuite.c +++ b/stabbertests/testsuite.c @@ -15,7 +15,7 @@ int main(int argc, char* argv[]) { const UnitTest all_tests[] = { - unit_test_setup_teardown(connect_with_no_jid, + unit_test_setup_teardown(connect_with_jid, init_prof_test, close_prof_test), }; |