Chat room windows now created only after successful join

This commit is contained in:
James Booth
2014-04-21 00:37:04 +01:00
parent 9a55d8ad19
commit 2c15aba92a
17 changed files with 89 additions and 102 deletions

View File

@@ -248,7 +248,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details(void **state)
gchar *args[] = { "add", NULL };
muc_init();
muc_join_room(jid, nick, NULL);
muc_join_room(jid, nick, NULL, TRUE);
mock_connection_status(JABBER_CONNECTED);
mock_current_win_type(WIN_MUC);
@@ -275,7 +275,7 @@ void cmd_bookmark_add_adds_bookmark_with_room_details_autojoin(void **state)
gchar *args[] = { "add", "autojoin", NULL };
muc_init();
muc_join_room(jid, nick, NULL);
muc_join_room(jid, nick, NULL, TRUE);
mock_connection_status(JABBER_CONNECTED);
mock_current_win_type(WIN_MUC);

View File

@@ -109,7 +109,6 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
mock_presence_join_room();
presence_join_room_expect(expected_room, nick, NULL);
ui_room_join_expect(expected_room, TRUE);
gboolean result = cmd_join(args, *help);
assert_true(result);
@@ -136,7 +135,6 @@ void cmd_join_uses_supplied_nick(void **state)
mock_presence_join_room();
presence_join_room_expect(room, nick, NULL);
ui_room_join_expect(room, TRUE);
gboolean result = cmd_join(args, *help);
assert_true(result);
@@ -147,7 +145,7 @@ void cmd_join_uses_supplied_nick(void **state)
void cmd_join_uses_account_nick_when_not_supplied(void **state)
{
char *account_name = "an_account";
char *room = "room@conf.server.org";
char *room = "room2@conf.server.org";
char *account_nick = "a_nick";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { room, NULL };
@@ -163,7 +161,6 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
mock_presence_join_room();
presence_join_room_expect(room, account_nick, NULL);
ui_room_join_expect(room, TRUE);
gboolean result = cmd_join(args, *help);
assert_true(result);
@@ -193,7 +190,6 @@ void cmd_join_uses_password_when_supplied(void **state)
mock_presence_join_room();
presence_join_room_expect(expected_room, account_nick, password);
ui_room_join_expect(expected_room, TRUE);
gboolean result = cmd_join(args, *help);
assert_true(result);

View File

@@ -70,7 +70,7 @@ void test_muc_room_is_active(void **state)
{
char *room = "room@server.org";
char *nick = "bob";
muc_join_room(room, nick, NULL);
muc_join_room(room, nick, NULL, FALSE);
gboolean room_is_active = muc_room_is_active(room);

View File

@@ -172,58 +172,7 @@ void handle_presence_error_when_no_recipient(void **state)
handle_presence_error(from, type, err_msg);
}
void handle_presence_error_when_no_recipient_and_conflict(void **state)
{
char *err_msg = "conflict";
char *from = NULL;
char *type = NULL;
expect_ui_handle_error(err_msg);
handle_presence_error(from, type, err_msg);
}
void handle_presence_error_when_nick_conflict_shows_recipient_error(void **state)
{
char *err_msg = "conflict";
char *from = "room@rooms.org/nick";
char *barejid = "room@rooms.org";
char *nick = "nick";
char *type = NULL;
muc_init();
muc_join_room(barejid, nick, NULL);
expect_ui_handle_recipient_error(barejid, err_msg);
handle_presence_error(from, type, err_msg);
muc_close();
}
void handle_presence_error_when_nick_conflict_does_not_join_room(void **state)
{
char *err_msg = "conflict";
char *from = "room@rooms.org/nick";
char *barejid = "room@rooms.org";
char *nick = "nick";
char *type = NULL;
Jid *jidp = jid_create(from);
stub_ui_handle_recipient_error();
muc_init();
muc_join_room(barejid, nick, NULL);
handle_presence_error(from, type, err_msg);
gboolean room_is_active = muc_room_is_active(jidp->barejid);
assert_false(room_is_active);
muc_close();
jid_destroy(jidp);
}
void handle_presence_error_when_from_recipient_not_conflict(void **state)
void handle_presence_error_when_from_recipient(void **state)
{
char *err_msg = "Some error.";
char *from = "bob@server.com";

View File

@@ -5,11 +5,8 @@ void console_doesnt_show_dnd_presence_when_set_none(void **state);
void console_doesnt_show_dnd_presence_when_set_online(void **state);
void console_shows_dnd_presence_when_set_all(void **state);
void handle_message_error_when_no_recipient(void **state);
void handle_message_error_when_recipient_cancel(void **stanza);
void handle_message_error_when_recipient_cancel_disables_chat_session(void **stanza);
void handle_message_error_when_recipient_cancel(void **state);
void handle_message_error_when_recipient_cancel_disables_chat_session(void **state);
void handle_message_error_when_recipient_and_no_type(void **state);
void handle_presence_error_when_no_recipient(void **state);
void handle_presence_error_when_no_recipient_and_conflict(void **state);
void handle_presence_error_when_nick_conflict_shows_recipient_error(void **state);
void handle_presence_error_when_nick_conflict_does_not_join_room(void **state);
void handle_presence_error_when_from_recipient_not_conflict(void **state);
void handle_presence_error_when_from_recipient(void **state);

View File

@@ -389,10 +389,7 @@ int main(int argc, char* argv[]) {
close_preferences),
unit_test(handle_message_error_when_recipient_and_no_type),
unit_test(handle_presence_error_when_no_recipient),
unit_test(handle_presence_error_when_no_recipient_and_conflict),
unit_test(handle_presence_error_when_nick_conflict_shows_recipient_error),
unit_test(handle_presence_error_when_nick_conflict_does_not_join_room),
unit_test(handle_presence_error_when_from_recipient_not_conflict),
unit_test(handle_presence_error_when_from_recipient),
unit_test(cmd_alias_add_shows_usage_when_no_args),
unit_test(cmd_alias_add_shows_usage_when_no_value),

View File

@@ -166,7 +166,7 @@ gboolean _mock_ui_current_win_is_otr(void)
}
static
void _mock_ui_room_join(char *room, gboolean focus)
void _mock_ui_room_join(const char * const room, gboolean focus)
{
check_expected(room);
check_expected(focus);