[calls] tests: Add primitive contact tests



commit f0cd344072598b2b95d5e1f4713d6223b44e789c
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Fri Feb 18 09:08:55 2022 +0100

    tests: Add primitive contact tests
    
    This makes sure that a NULL id will return a NULL contact and additionally
    asserts that even a NULL contact will give us sensible primary/secondary display
    information.

 tests/meson.build     | 13 +++++++++++++
 tests/test-contacts.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
---
diff --git a/tests/meson.build b/tests/meson.build
index d08c15ec..97a22a48 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -164,4 +164,17 @@ if cmocka.found ()
     test('ringer', t, env: test_env)
 endif
 
+test_sources = [ 'test-contacts.c' ]
+t = executable('contacts', test_sources,
+               c_args : test_cflags,
+               link_args: test_link_args,
+               pie: true,
+               link_with : [calls_vala, libcalls],
+               dependencies: calls_deps,
+               include_directories : [
+                   calls_includes,
+                 ]
+               )
+test('contacts', t, env: test_env)
+
 endif
diff --git a/tests/test-contacts.c b/tests/test-contacts.c
new file mode 100644
index 00000000..2b43ffc2
--- /dev/null
+++ b/tests/test-contacts.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2022 Purism SPC
+ *
+ * SPDX-License-Identifier: GPL-3.0+
+ *
+ * Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
+ */
+
+#include "calls-best-match.h"
+#include "calls-contacts-provider.h"
+
+#include <gtk/gtk.h>
+
+static void
+test_contacts_null_contact (void)
+{
+  g_autoptr (CallsSettings) settings = calls_settings_new ();
+  g_autoptr (CallsContactsProvider) contacts_provider =
+    calls_contacts_provider_new (settings);
+  CallsBestMatch *best_match;
+
+  best_match = calls_contacts_provider_lookup_id (contacts_provider, NULL);
+  g_assert_null (best_match);
+
+  g_assert_cmpstr (calls_best_match_get_primary_info (best_match), ==, "Anonymous caller");
+  g_assert_cmpstr (calls_best_match_get_secondary_info (best_match), ==, "");
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+  gtk_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/Calls/contacts/null", (GTestFunc) test_contacts_null_contact);
+
+  g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]