about summary refs log blame commit diff stats
path: root/cannot_write_tests_for
blob: 23562574546280b94b411e6ff88eaf27b1d10926 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11






                                                



                                                                 
1. assertion failures or errors inside scenarios
2. screen background color
3. has-more-events?
4. hide/show screen
5. more touch event types
6. sandbox isolation
7. read/write files

termbox issues are implementation-specific and not worth testing:
  whether we clear junk from other processes
  latency in interpreting low-level escape characters
.kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-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
ping_server(void **state)
{
    stbbr_for_id("prof_disco_info_onconnect_2",
        "<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
            "<query xmlns='http://jabber.org/protocol/disco#info'>"
                "<identity category='server' type='im' name='Prosody'/>"
                "<feature var='urn:xmpp:ping'/>"
            "</query>"
        "</iq>"
    );

    stbbr_for_id("prof_ping_4",
        "<iq id='prof_ping_4' type='result' to='stabber@localhost/profanity'/>"
    );
    stbbr_for_id("prof_ping_5",
        "<iq id='prof_ping_5' type='result' to='stabber@localhost/profanity'/>"
    );

    prof_connect();

    prof_input("/ping");
    assert_true(stbbr_received(
        "<iq id='prof_ping_4' type='get'>"
            "<ping xmlns='urn:xmpp:ping'/>"
        "</iq>"
    ));
    assert_true(prof_output_exact("Ping response from server"));

    prof_input("/ping");
    assert_true(stbbr_received(
        "<iq id='prof_ping_5' type='get'>"
            "<ping xmlns='urn:xmpp:ping'/>"
        "</iq>"
    ));
    assert_true(prof_output_exact("Ping response from server"));
}

void
ping_server_not_supported(void **state)
{
    stbbr_for_id("prof_disco_info_onconnect_2",
        "<iq id='prof_disco_info_onconnect_2' to='stabber@localhost/profanity' type='result' from='localhost'>"
            "<query xmlns='http://jabber.org/protocol/disco#info'>"
                "<identity category='server' type='im' name='Stabber'/>"
            "</query>"
        "</iq>"
    );

    prof_connect();

    prof_input("/ping");
    assert_true(prof_output_exact("Server does not support ping requests."));
}

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

    stbbr_send(
        "<iq id='pingtest1' type='get' to='stabber@localhost/profanity' from='localhost'>"
            "<ping xmlns='urn:xmpp:ping'/>"
        "</iq>"
    );

    assert_true(stbbr_received(
        "<iq id='pingtest1' type='result' from='stabber@localhost/profanity' to='localhost'/>"
    ));
}

void ping_jid(void **state)
{
    stbbr_for_id("prof_caps_4",
        "<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
            "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
                "<identity category='client' type='console' name='Profanity0.6.0'/>"
                "<feature var='urn:xmpp:ping'/>"
                "<feature var='http://jabber.org/protocol/disco#info'/>"
                "<feature var='http://jabber.org/protocol/caps'/>"
            "</query>"
        "</iq>"
    );

    prof_connect();

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
            "<status>I'm here</status>"
            "<c "
                "hash='sha-1' "
                "xmlns='http://jabber.org/protocol/caps' "
                "node='http://profanity-im.github.io' "
                "ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
            "/>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));

    assert_true(stbbr_received(
        "<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>"
            "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
        "</iq>"
    ));

    stbbr_for_id("prof_ping_5",
        "<iq from='buddy1@localhost/mobile' to='stabber@localhost' id='prof_ping_5' type='result'/>"
    );

    prof_input("/ping buddy1@localhost/mobile");

    assert_true(stbbr_received(
        "<iq id='prof_ping_5' type='get' to='buddy1@localhost/mobile'>"
            "<ping xmlns='urn:xmpp:ping'/>"
        "</iq>"
    ));
    assert_true(prof_output_exact("Ping response from buddy1@localhost/mobile"));
}

void ping_jid_not_supported(void **state)
{
    stbbr_for_id("prof_caps_4",
        "<iq id='prof_caps_4' to='stabber@localhost/profanity' type='result' from='buddy1@localhost/mobile'>"
            "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='>"
                "<identity category='client' type='console' name='Profanity0.6.0'/>"
                "<feature var='http://jabber.org/protocol/disco#info'/>"
                "<feature var='http://jabber.org/protocol/caps'/>"
            "</query>"
        "</iq>"
    );

    prof_connect();

    stbbr_send(
        "<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
            "<priority>10</priority>"
            "<status>I'm here</status>"
            "<c "
                "hash='sha-1' "
                "xmlns='http://jabber.org/protocol/caps' "
                "node='http://profanity-im.github.io' "
                "ver='LpT2xs3nun7jC2sq4gg3WRDQFZ4='"
            "/>"
        "</presence>"
    );
    assert_true(prof_output_exact("Buddy1 (mobile) is online, \"I'm here\""));

    assert_true(stbbr_received(
        "<iq id='prof_caps_4' to='buddy1@localhost/mobile' type='get'>"
            "<query xmlns='http://jabber.org/protocol/disco#info' node='http://profanity-im.github.io#LpT2xs3nun7jC2sq4gg3WRDQFZ4='/>"
        "</iq>"
    ));

    prof_input("/ping buddy1@localhost/mobile");
    assert_true(prof_output_exact("buddy1@localhost/mobile does not support ping requests."));
}