Simplified expect tests

This commit is contained in:
James Booth
2015-05-27 01:06:17 +01:00
parent 7507e4ecfa
commit db9376d82b
5 changed files with 104 additions and 110 deletions

View File

@@ -11,11 +11,31 @@
#include "proftest.h"
#define CONNECT_CMD "/connect stabber@localhost port 5230\r"
#define PASSWORD "password\r"
void
connect_jid(void **state)
{
prof_input("/connect stabber@localhost port 5230");
prof_input("password");
assert_true(prof_output("Connecting as stabber@localhost"));
assert_true(prof_output("stabber@localhost logged in successfully"));
}
void
connect_jid_requests_roster(void **state)
{
prof_input("/connect stabber@localhost port 5230");
prof_input("password");
sleep(1);
assert_true(stbbr_verify(
"<iq id=\"*\" type=\"get\"><query xmlns=\"jabber:iq:roster\"/></iq>"
));
}
void
connect_jid_sends_presence_after_receiving_roster(void **state)
{
stbbr_for("roster",
"<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">"
@@ -26,27 +46,11 @@ connect_jid(void **state)
"</iq>"
);
int res = 0;
int fd = exp_spawnl("./profanity", NULL);
FILE *fp = fdopen(fd, "r+");
if (fp == NULL) {
assert_true(FALSE);
}
setbuf(fp, (char *)0);
write(fd, CONNECT_CMD, strlen(CONNECT_CMD));
res = exp_expectl(fd, exp_exact, "Enter password:", 11, exp_end);
assert_true(res == 11);
write(fd, PASSWORD, strlen(PASSWORD));
res = exp_expectl(fd, exp_exact, "Connecting as stabber@localhost", 12, exp_end);
assert_true(res == 12);
res = exp_expectl(fd, exp_exact, "stabber@localhost logged in successfully", 13, exp_end);
assert_true(res == 13);
prof_input("/connect stabber@localhost port 5230");
prof_input("password");
sleep(1);
assert_true(stbbr_verify(
"<presence id=\"*\">"
"<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>"
@@ -54,78 +58,32 @@ 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=\"*\" 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=\"*\">"
// "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" 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=\"*\" 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"));
//
// expect_cons_show("Connecting as stabber@localhost");
// expect_cons_show_error("Login failed.");
//
// cmd_process_input(strdup("/connect stabber@localhost port 5230"));
// prof_process_xmpp(20);
//
// jabber_conn_status_t status = jabber_get_connection_status();
// assert_true(status == JABBER_DISCONNECTED);
//}
//
void
connect_jid_requests_bookmarks(void **state)
{
prof_input("/connect stabber@localhost port 5230");
prof_input("password");
sleep(1);
assert_true(stbbr_verify(
"<iq id=\"*\" type=\"get\">"
"<query xmlns=\"jabber:iq:private\">"
"<storage xmlns=\"storage:bookmarks\"/>"
"</query>"
"</iq>"
));
}
void
connect_bad_password(void **state)
{
prof_input("/connect stabber@localhost port 5230");
prof_input("badpassword");
assert_true(prof_output("Login failed."));
}
//void
//show_presence_updates(void **state)
//{