about summary refs log tree commit diff stats
path: root/101run_sandboxed.cc
Commit message (Expand)AuthorAgeFilesLines
* 3730Kartik K. Agaram2017-01-061-0/+8
* 3705 - switch to tested file-system primitivesKartik K. Agaram2016-12-111-1/+1
* 3561Kartik K. Agaram2016-10-221-2/+2
* 3409Kartik K. Agaram2016-09-221-0/+4
* 3408Kartik K. Agaram2016-09-221-11/+1
* 3390Kartik K. Agaram2016-09-171-5/+5
* 3389Kartik K. Agaram2016-09-171-3/+3
* 3388Kartik K. Agaram2016-09-171-1/+1
* 3385Kartik K. Agaram2016-09-171-16/+16
* 3379Kartik K. Agaram2016-09-171-4/+4
* 3377Kartik K. Agaram2016-09-171-25/+25
* 3374Kartik K. Agaram2016-09-161-10/+10
* 3367Kartik K. Agaram2016-09-151-8/+24
* 3269Kartik K. Agaram2016-08-281-1/+0
* 3230Kartik K. Agaram2016-08-201-0/+518
*/ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .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 <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#include "config.h"

#include "command/cmd_funcs.h"
#include "xmpp/xmpp.h"

#include "ui/stub_ui.h"

#define CMD_PGP "/pgp"

#ifdef HAVE_LIBGPGME
void
cmd_pgp_shows_usage_when_no_args(void** state)
{
    gchar* args[] = { NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_PGP);

    gboolean result = cmd_pgp(NULL, CMD_PGP, args);
    assert_true(result);
}

void
cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
{
    gchar* args[] = { "start", NULL };
    ProfWin window;
    window.type = WIN_CHAT;

    will_return(connection_get_status, conn_status);

    expect_cons_show("You must be connected to start PGP encrpytion.");

    gboolean result = cmd_pgp(&window, CMD_PGP, args);
    assert_true(result);
}

void
cmd_pgp_start_shows_message_when_disconnected(void** state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED);
}

void
cmd_pgp_start_shows_message_when_disconnecting(void** state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING);
}

void
cmd_pgp_start_shows_message_when_connecting(void** state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
{
    gchar* args[] = { "start", NULL };
    ProfWin window;
    window.type = wintype;

    will_return(connection_get_status, JABBER_CONNECTED);

    expect_cons_show("You must be in a regular chat window to start PGP encrpytion.");

    gboolean result = cmd_pgp(&window, CMD_PGP, args);
    assert_true(result);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_console(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONFIG);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_private(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE);
}

void
cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML);
}

#else
void
cmd_pgp_shows_message_when_pgp_unsupported(void** state)
{
    gchar* args[] = { "gen", NULL };

    expect_cons_show("This version of Profanity has not been built with PGP support enabled");

    gboolean result = cmd_pgp(NULL, CMD_PGP, args);
    assert_true(result);
}
#endif