about summary refs log tree commit diff stats
path: root/054static_dispatch.cc
Commit message (Expand)AuthorAgeFilesLines
* 3522Kartik K. Agaram2016-10-191-25/+25
* 3393Kartik K. Agaram2016-09-171-4/+3
* 3390Kartik K. Agaram2016-09-171-1/+1
* 3389Kartik K. Agaram2016-09-171-7/+7
* 3385Kartik K. Agaram2016-09-171-50/+50
* 3381Kartik K. Agaram2016-09-171-8/+8
* 3379Kartik K. Agaram2016-09-171-5/+5
* 3376 - start maximally using all type abbreviationsKartik K. Agaram2016-09-171-2/+2
* 3350Kartik K. Agaram2016-09-141-3/+5
* 3348Kartik K. Agaram2016-09-141-4/+20
* 3309Kartik K. Agaram2016-09-091-3/+2
* 3120Kartik K. Agaram2016-07-211-1/+1
* 3108Kartik K. Agaram2016-07-101-1/+0
* 3050Kartik K. Agaram2016-06-111-6/+6
* 3022Kartik K. Agaram2016-05-271-0/+1
* 3006Kartik K. Agaram2016-05-241-8/+2
* 3003Kartik K. Agaram2016-05-241-2/+2
* 3001Kartik K. Agaram2016-05-241-1/+3
* 2999Kartik K. Agaram2016-05-241-2/+2
* 2990Kartik K. Agaram2016-05-201-1/+1
* 2987Kartik K. Agaram2016-05-201-0/+620
ckground-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include <glib.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>

#include <stabber.h>
#include <expect.h>

#include "proftest.h"

void
sends_new_item(void **state)
{
    prof_connect();

    stbbr_for_query("jabber:iq:roster",
        "<iq type='set' from='stabber@localhost'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='bob@localhost' subscription='none' name=''/>"
            "</query>"
        "</iq>"
    );

    prof_input("/roster add bob@localhost");

    assert_true(stbbr_received(
        "<iq type='set' id='*'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='bob@localhost' name=''/>"
            "</query>"
        "</iq>"
    ));

    assert_true(prof_output_exact("Roster item added: bob@localhost"));
}

void
sends_new_item_nick(void **state)
{
    prof_connect();

    stbbr_for_query("jabber:iq:roster",
        "<iq type='set' from='stabber@localhost'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='bob@localhost' subscription='none' name='Bobby'/>"
            "</query>"
        "</iq>"
    );

    prof_input("/roster add bob@localhost Bobby");

    assert_true(stbbr_received(
        "<iq type='set' id='*'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='bob@localhost' name='Bobby'/>"
            "</query>"
        "</iq>"
    ));

    assert_true(prof_output_exact("Roster item added: bob@localhost (Bobby)"));
}

void
sends_remove_item(void **state)
{
    prof_connect_with_roster(
        "<item jid='buddy1@localhost' subscription='both'/>"
        "<item jid='buddy2@localhost' subscription='both'/>"
    );

    stbbr_for_query("jabber:iq:roster",
        "<iq id='*' type='set'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='buddy1@localhost' subscription='remove'/>"
            "</query>"
        "</iq>"
    );

    prof_input("/roster remove buddy1@localhost");

    assert_true(stbbr_received(
        "<iq type='set' id='*'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='buddy1@localhost' subscription='remove'/>"
            "</query>"
        "</iq>"
    ));

    assert_true(prof_output_exact("Roster item removed: buddy1@localhost"));
}

void
sends_nick_change(void **state)
{
    prof_connect_with_roster(
        "<item jid='buddy1@localhost' subscription='both'/>"
    );

    prof_input("/roster nick buddy1@localhost Buddy1");

    assert_true(prof_output_exact("Nickname for buddy1@localhost set to: Buddy1."));

    assert_true(stbbr_received(
        "<iq type='set' id='*'>"
            "<query xmlns='jabber:iq:roster'>"
                "<item jid='buddy1@localhost' name='Buddy1'/>"
            "</query>"
        "</iq>"
    ));
}