1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-17 15:55:58 +00:00

tests: ui-call: Test property equality

And especially if properties get updated on both sides.
This commit is contained in:
Evangelos Ribeiro Tzaras 2022-02-01 22:24:39 +01:00
parent 1ca83bc2bc
commit d5ccb40e68
2 changed files with 60 additions and 2 deletions

View file

@ -115,10 +115,14 @@ t = executable('util', test_sources,
) )
test('util', t, env: test_env) test('util', t, env: test_env)
test_sources = [ 'test-ui-call.c' ] mock_link_args = [ test_link_args,
'-Wl,--wrap=calls_contacts_provider_new',
]
test_sources = [ 'test-ui-call.c', 'mock-call.c', 'mock-call.h' ]
t = executable('ui-call', test_sources, t = executable('ui-call', test_sources,
c_args : test_cflags, c_args : test_cflags,
link_args : test_link_args, link_args : mock_link_args,
pie: true, pie: true,
link_with : [calls_vala, libcalls], link_with : [calls_vala, libcalls],
dependencies : calls_deps, dependencies : calls_deps,

View file

@ -8,9 +8,18 @@
*/ */
#include "calls-ui-call-data.h" #include "calls-ui-call-data.h"
#include "mock-call.h"
#include "mock-contacts-provider.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
CallsContactsProvider *
__wrap_calls_contacts_provider_new (CallsSettings *settings)
{
return NULL;
}
static void static void
test_cui_call_state_mapping (void) test_cui_call_state_mapping (void)
{ {
@ -32,6 +41,50 @@ test_cui_call_state_mapping (void)
} }
static void
test_cui_call_properties (void)
{
CallsMockCall *mock_call = calls_mock_call_new ();
CallsCall *call; /* so we can avoid having to cast all the time */
CallsUiCallData *ui_call;
CuiCall *cui_call; /* so we can avoid having to cast all the time */
gboolean inbound;
g_assert_true (CALLS_IS_CALL (mock_call));
call = CALLS_CALL (mock_call);
ui_call = calls_ui_call_data_new (call);
g_assert_true (CUI_IS_CALL (ui_call));
cui_call = CUI_CALL (ui_call);
g_assert_true (calls_call_get_id (call) == cui_call_get_id (cui_call));
g_assert_true (calls_call_get_name (call) == cui_call_get_display_name (cui_call));
g_assert_true (calls_call_state_to_cui_call_state (calls_call_get_state (call)) ==
cui_call_get_state (cui_call));
g_object_get (cui_call, "inbound", &inbound, NULL);
g_assert_true (calls_call_get_inbound (call) == inbound);
/* Test if properties get updated */
calls_call_answer (call);
g_assert_true (calls_call_state_to_cui_call_state (calls_call_get_state (call)) ==
cui_call_get_state (cui_call));
calls_call_hang_up (call);
g_assert_true (calls_call_state_to_cui_call_state (calls_call_get_state (call)) ==
cui_call_get_state (cui_call));
calls_call_set_id (call, "0123456789");
g_assert_true (calls_call_get_id (call) == cui_call_get_id (cui_call));
g_assert_cmpstr (cui_call_get_id (cui_call), ==, "0123456789");
calls_call_set_name (call, "Jane Doe");
g_assert_true (calls_call_get_name (call) == cui_call_get_display_name (cui_call));
g_assert_cmpstr (cui_call_get_display_name (cui_call), ==, "Jane Doe");
}
int int
main (int argc, main (int argc,
char *argv[]) char *argv[])
@ -39,6 +92,7 @@ main (int argc,
gtk_test_init (&argc, &argv, NULL); gtk_test_init (&argc, &argv, NULL);
g_test_add_func ("/Calls/UI/state_mapping", (GTestFunc) test_cui_call_state_mapping); g_test_add_func ("/Calls/UI/state_mapping", (GTestFunc) test_cui_call_state_mapping);
g_test_add_func ("/Calls/UI/call_properties", (GTestFunc) test_cui_call_properties);
g_test_run (); g_test_run ();
} }