2015-01-06 16:22:09 -05:00
|
|
|
#include <stdarg.h>
|
2020-07-07 07:53:30 -04:00
|
|
|
#include <string.h>
|
2015-01-06 16:22:09 -05:00
|
|
|
#include <stddef.h>
|
2020-07-07 07:53:30 -04:00
|
|
|
#include <setjmp.h>
|
|
|
|
#include <cmocka.h>
|
2015-01-06 16:22:09 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-07-24 09:23:55 -04:00
|
|
|
#include "xmpp/chat_session.h"
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
returns_false_when_chat_session_does_not_exist(void** state)
|
2015-01-06 16:22:09 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
ChatSession* session = chat_session_get("somejid@server.org");
|
2015-01-09 19:25:27 -05:00
|
|
|
assert_null(session);
|
2015-01-06 16:22:09 -05:00
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
creates_chat_session_on_recipient_activity(void** state)
|
2015-01-06 16:22:09 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
char* barejid = "myjid@server.org";
|
|
|
|
char* resource = "tablet";
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2015-01-11 18:09:07 -05:00
|
|
|
chat_session_recipient_active(barejid, resource, FALSE);
|
2020-07-07 08:18:57 -04:00
|
|
|
ChatSession* session = chat_session_get(barejid);
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2015-01-09 19:25:27 -05:00
|
|
|
assert_non_null(session);
|
|
|
|
assert_string_equal(session->resource, resource);
|
2015-01-06 16:22:09 -05:00
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
replaces_chat_session_on_recipient_activity_with_different_resource(void** state)
|
2015-01-06 16:22:09 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
char* barejid = "myjid@server.org";
|
|
|
|
char* resource1 = "tablet";
|
|
|
|
char* resource2 = "mobile";
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2015-01-11 18:09:07 -05:00
|
|
|
chat_session_recipient_active(barejid, resource1, FALSE);
|
|
|
|
chat_session_recipient_active(barejid, resource2, FALSE);
|
2020-07-07 08:18:57 -04:00
|
|
|
ChatSession* session = chat_session_get(barejid);
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2015-01-09 19:25:27 -05:00
|
|
|
assert_string_equal(session->resource, resource2);
|
2015-01-06 16:22:09 -05:00
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
void
|
|
|
|
removes_chat_session(void** state)
|
2015-01-06 16:22:09 -05:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
char* barejid = "myjid@server.org";
|
|
|
|
char* resource1 = "laptop";
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2015-01-11 18:09:07 -05:00
|
|
|
chat_session_recipient_active(barejid, resource1, FALSE);
|
2015-01-09 19:25:27 -05:00
|
|
|
chat_session_remove(barejid);
|
2020-07-07 08:18:57 -04:00
|
|
|
ChatSession* session = chat_session_get(barejid);
|
2015-01-06 16:22:09 -05:00
|
|
|
|
2015-01-09 19:25:27 -05:00
|
|
|
assert_null(session);
|
2016-07-24 09:23:55 -04:00
|
|
|
}
|