about summary refs log tree commit diff stats
path: root/src/ui/inputwin.h
blob: b36ae68d4c42bfea21bff5ef46f3977ba581e9e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * inputwin.c
 *
 * Copyright (C) 2012 - 2016 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Profanity is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Profanity.  If not, see <https://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give permission to
 * link the code of portions of this program with the OpenSSL library under
 * certain conditions as described in each individual source file, and
 * distribute linked combinations including the two.
 *
 * You must obey the GNU General Public License in all respects for all of the
 * code used other than OpenSSL. If you modify file(s) with this exception, you
 * may extend this exception to your version of the file(s), but you are not
 * obligated to do so. If you do not wish to do so, delete this exception
 * statement from your version. If you delete this exception statement from all
 * source files in the program, then also delete it here.
 *
 */

#ifndef UI_INPUTWIN_H
#define UI_INPUTWIN_H

#include <glib.h>

#define INP_WIN_MAX 1000

void create_input_window(void);
void inp_close(void);
void inp_win_resize(void);
void inp_put_back(void);
char* inp_get_password(void);
char* inp_get_line(void);

#endif
ral.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/commands.h"

#include "ui/stub_ui.h"

#ifdef HAVE_LIBGPGME
void cmd_pgp_shows_usage_when_no_args(void **state)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "Some usage";
    gchar *args[] = { NULL };

    expect_cons_show("Usage: Some usage");

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

    free(help);
}

void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "Some usage";
    gchar *args[] = { "start", NULL };
    ProfWin window;
    window.type = WIN_CHAT;

    will_return(jabber_get_connection_status, conn_status);

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

    gboolean result = cmd_pgp(&window, args, *help);
    assert_true(result);

    free(help);
}

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_undefined(void **state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_UNDEFINED);
}

void cmd_pgp_start_shows_message_when_started(void **state)
{
    cmd_pgp_start_shows_message_when_connection(JABBER_STARTED);
}

void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    help->usage = "Some usage";
    gchar *args[] = { "start", NULL };
    ProfWin window;
    window.type = wintype;

    will_return(jabber_get_connection_status, JABBER_CONNECTED);

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

    gboolean result = cmd_pgp(&window, args, *help);
    assert_true(result);

    free(help);
}

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_mucconf(void **state)
{
    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC_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)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "gen", NULL };

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

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

    free(help);
}
#endif