2014-02-16 14:14:15 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
2014-05-19 16:15:17 -04:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2014-05-19 15:41:19 -04:00
|
|
|
#ifdef HAVE_LIBOTR
|
2014-02-16 14:14:15 -05:00
|
|
|
#include "otr/otr.h"
|
2014-05-19 15:41:19 -04:00
|
|
|
#endif
|
2014-02-16 14:14:15 -05:00
|
|
|
#include "config/account.h"
|
|
|
|
|
2014-05-19 15:41:19 -04:00
|
|
|
#ifdef HAVE_LIBOTR
|
2014-02-16 14:14:15 -05:00
|
|
|
static void
|
|
|
|
_mock_otr_keygen(ProfAccount *account)
|
|
|
|
{
|
|
|
|
check_expected(account);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_mock_otr_libotr_version(void)
|
|
|
|
{
|
|
|
|
return (char *)mock();
|
|
|
|
}
|
|
|
|
|
2014-02-17 16:52:42 -05:00
|
|
|
static char *
|
|
|
|
_mock_otr_get_my_fingerprint(void)
|
2014-02-16 14:14:15 -05:00
|
|
|
{
|
2014-02-17 16:52:42 -05:00
|
|
|
return (char *)mock();
|
2014-02-16 14:14:15 -05:00
|
|
|
}
|
|
|
|
|
2014-02-17 18:10:00 -05:00
|
|
|
static char *
|
|
|
|
_mock_otr_get_their_fingerprint(const char * const recipient)
|
|
|
|
{
|
|
|
|
check_expected(recipient);
|
|
|
|
return (char *)mock();
|
|
|
|
}
|
|
|
|
|
2014-02-23 15:34:27 -05:00
|
|
|
static gboolean
|
|
|
|
_mock_otr_key_loaded(void)
|
|
|
|
{
|
|
|
|
return (gboolean)mock();
|
|
|
|
}
|
|
|
|
|
2014-02-23 16:20:41 -05:00
|
|
|
static char *
|
|
|
|
_mock_otr_start_query(void)
|
|
|
|
{
|
|
|
|
return (char *)mock();
|
|
|
|
}
|
|
|
|
|
2014-02-16 14:14:15 -05:00
|
|
|
void
|
|
|
|
otr_keygen_expect(ProfAccount *account)
|
|
|
|
{
|
2014-02-16 14:35:40 -05:00
|
|
|
otr_keygen = _mock_otr_keygen;
|
2014-02-16 14:14:15 -05:00
|
|
|
expect_memory(_mock_otr_keygen, account, account, sizeof(ProfAccount));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
otr_libotr_version_returns(char *version)
|
|
|
|
{
|
2014-02-17 16:52:42 -05:00
|
|
|
otr_libotr_version = _mock_otr_libotr_version;
|
2014-02-16 14:14:15 -05:00
|
|
|
will_return(_mock_otr_libotr_version, version);
|
|
|
|
}
|
2014-02-17 16:52:42 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
otr_get_my_fingerprint_returns(char *fingerprint)
|
|
|
|
{
|
|
|
|
otr_get_my_fingerprint = _mock_otr_get_my_fingerprint;
|
|
|
|
will_return(_mock_otr_get_my_fingerprint, fingerprint);
|
|
|
|
}
|
2014-02-17 18:10:00 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
otr_get_their_fingerprint_expect_and_return(char *recipient, char *fingerprint)
|
|
|
|
{
|
|
|
|
otr_get_their_fingerprint = _mock_otr_get_their_fingerprint;
|
|
|
|
expect_string(_mock_otr_get_their_fingerprint, recipient, recipient);
|
|
|
|
will_return(_mock_otr_get_their_fingerprint, fingerprint);
|
|
|
|
}
|
2014-02-23 15:34:27 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
otr_key_loaded_returns(gboolean loaded)
|
|
|
|
{
|
|
|
|
otr_key_loaded = _mock_otr_key_loaded;
|
|
|
|
will_return(_mock_otr_key_loaded, loaded);
|
|
|
|
}
|
2014-02-23 16:20:41 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
otr_start_query_returns(char *query)
|
|
|
|
{
|
|
|
|
otr_start_query = _mock_otr_start_query;
|
|
|
|
will_return(_mock_otr_start_query, query);
|
|
|
|
}
|
2014-05-19 15:41:19 -04:00
|
|
|
#endif
|