Пример #1
0
void
expect_cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity)
{
    expect_memory(_mock_cons_show_contact_online, contact, contact, sizeof(contact));
    expect_memory(_mock_cons_show_contact_online, resource, resource, sizeof(Resource));
    if (last_activity == NULL) {
        expect_value(_mock_cons_show_contact_online, last_activity, NULL);
    } else {
        expect_memory(_mock_cons_show_contact_online, last_activity, last_activity, sizeof(last_activity));
    }
}
Пример #2
0
void console_shows_dnd_presence_when_set_all(void **state)
{
    prefs_set_string(PREF_STATUSES_CONSOLE, "all");
    roster_init();
    char *barejid = "test1@server";
    roster_add(barejid, "bob", NULL, "both", FALSE);
    Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);

    expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid));
    expect_memory(ui_contact_online, resource, resource, sizeof(resource));
    expect_value(ui_contact_online, last_activity, NULL);

    sv_ev_contact_online(barejid, resource, NULL, NULL);

    roster_clear();
}
Пример #3
0
void
jabber_connect_with_account_expect_and_return(ProfAccount *account,
    jabber_conn_status_t result)
{
    expect_memory(_mock_jabber_connect_with_account, account, account, sizeof(ProfAccount));
    will_return(_mock_jabber_connect_with_account, result);
}
Пример #4
0
void
roster_send_name_change_expect(char *jid, char *nick, GSList *groups)
{
    expect_string(_mock_roster_send_name_change, barejid, jid);
    if (nick == NULL) {
        expect_value(_mock_roster_send_name_change, new_name, NULL);
    } else {
        expect_string(_mock_roster_send_name_change, new_name, nick);
    }
    expect_memory(_mock_roster_send_name_change, groups, groups, sizeof(GSList));
}
Пример #5
0
void cmd_account_show_shows_account_when_exists(void **state)
{
    gchar *args[] = { "show", "account_name", NULL };
    ProfAccount *account = account_new("jabber_org", "*****@*****.**", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_memory(cons_show_account, account, account, sizeof(account));

    gboolean result = cmd_account_show(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
Пример #6
0
void cmd_account_shows_account_when_connected_and_no_args(void **state)
{
    ProfAccount *account = account_new("jabber_org", "*****@*****.**", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    gchar *args[] = { NULL };

    will_return(connection_get_status, JABBER_CONNECTED);
    will_return(session_get_account_name, "account_name");
    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_memory(cons_show_account, account, account, sizeof(ProfAccount));

    gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
Пример #7
0
void cmd_account_list_shows_accounts(void **state)
{
    gchar *args[] = { "list", NULL };

    gchar **accounts = malloc(sizeof(gchar *) * 4);
    accounts[0] = strdup("account1");
    accounts[1] = strdup("account2");
    accounts[2] = strdup("account3");
    accounts[3] = NULL;

    will_return(accounts_get_list, accounts);

    expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));

    gboolean result = cmd_account_list(NULL, CMD_ACCOUNT, args);
    assert_true(result);
}
Пример #8
0
void cmd_otr_gen_generates_key_for_connected_account(void **state)
{
    gchar *args[] = { "gen", NULL };
    char *account_name = "myaccount";
    ProfAccount *account = account_new(account_name, "*****@*****.**", NULL, NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    will_return(jabber_get_connection_status, JABBER_CONNECTED);
    will_return(jabber_get_account_name, account_name);

    expect_string(accounts_get_account, name, account_name);

    will_return(accounts_get_account, account);

    expect_memory(otr_keygen, account, account, sizeof(ProfAccount));

    gboolean result = cmd_otr(NULL, CMD_OTR, args);
    assert_true(result);
}
Пример #9
0
void cmd_connect_connects_with_account(void **state)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "jabber_org", NULL };
    ProfAccount *account = account_new("jabber_org", "*****@*****.**", "password", NULL,
        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    will_return(jabber_get_connection_status, JABBER_DISCONNECTED);

    expect_any(accounts_get_account, name);
    will_return(accounts_get_account, account);

    expect_cons_show("Connecting with account jabber_org as [email protected]");

    expect_memory(jabber_connect_with_account, account, account, sizeof(account));
    will_return(jabber_connect_with_account, JABBER_CONNECTING);

    gboolean result = cmd_connect(NULL, args, *help);
    assert_true(result);

    free(help);
}
Пример #10
0
void
expect_cons_show_account_list(gchar **accounts)
{
    expect_memory(_mock_cons_show_account_list, accounts, accounts, sizeof(accounts));
}
Пример #11
0
void
expect_cons_show_account(ProfAccount *account)
{
    expect_memory(_mock_cons_show_account, account, account, sizeof(ProfAccount));
}