[calls] tests: ui-call: Test property equality
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] tests: ui-call: Test property equality
- Date: Tue, 1 Feb 2022 23:55:09 +0000 (UTC)
commit d5ccb40e6817bde0876b99f696b5b529aedfe771
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Tue Feb 1 22:24:39 2022 +0100
tests: ui-call: Test property equality
And especially if properties get updated on both sides.
tests/meson.build | 8 ++++++--
tests/test-ui-call.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index 3f9255a1..dc45c328 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -115,10 +115,14 @@ t = executable('util', test_sources,
)
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,
c_args : test_cflags,
- link_args : test_link_args,
+ link_args : mock_link_args,
pie: true,
link_with : [calls_vala, libcalls],
dependencies : calls_deps,
diff --git a/tests/test-ui-call.c b/tests/test-ui-call.c
index 30267ece..98048de9 100644
--- a/tests/test-ui-call.c
+++ b/tests/test-ui-call.c
@@ -8,9 +8,18 @@
*/
#include "calls-ui-call-data.h"
+#include "mock-call.h"
+#include "mock-contacts-provider.h"
#include <gtk/gtk.h>
+CallsContactsProvider *
+__wrap_calls_contacts_provider_new (CallsSettings *settings)
+{
+ return NULL;
+}
+
+
static 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
main (int argc,
char *argv[])
@@ -39,6 +92,7 @@ main (int argc,
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/call_properties", (GTestFunc) test_cui_call_properties);
g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]