mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-12-04 20:07:36 +00:00
test-contacts: Add more test cases
Testing lookup of both empty string and NULL ensures we won't regress.
This commit is contained in:
parent
23ee0475dd
commit
cf52fbba67
1 changed files with 36 additions and 1 deletions
|
@ -25,13 +25,48 @@ test_contacts_null_contact (void)
|
||||||
g_assert_cmpstr (calls_best_match_get_secondary_info (best_match), ==, "");
|
g_assert_cmpstr (calls_best_match_get_secondary_info (best_match), ==, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_contacts_empty_contact (void)
|
||||||
|
{
|
||||||
|
g_autoptr (CallsContactsProvider) contacts_provider =
|
||||||
|
calls_contacts_provider_new ();
|
||||||
|
g_autoptr (CallsBestMatch) best_match = NULL;
|
||||||
|
|
||||||
|
best_match = calls_contacts_provider_lookup_id (contacts_provider, "");
|
||||||
|
g_assert_nonnull (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), ==, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_contacts_unknown_contact (void)
|
||||||
|
{
|
||||||
|
g_autoptr (CallsContactsProvider) contacts_provider =
|
||||||
|
calls_contacts_provider_new ();
|
||||||
|
g_autoptr (CallsBestMatch) best_match = NULL;
|
||||||
|
const char *id = "111222333444555666";
|
||||||
|
|
||||||
|
best_match = calls_contacts_provider_lookup_id (contacts_provider, id);
|
||||||
|
g_assert_nonnull (best_match);
|
||||||
|
|
||||||
|
g_assert_cmpstr (calls_best_match_get_primary_info (best_match), ==, id);
|
||||||
|
g_assert_cmpstr (calls_best_match_get_secondary_info (best_match), ==, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO set up folks keyfile backend to test "known" contact */
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
gtk_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
g_test_add_func ("/Calls/contacts/null", (GTestFunc) test_contacts_null_contact);
|
g_test_add_func ("/Calls/contacts/null", (GTestFunc) test_contacts_null_contact);
|
||||||
|
g_test_add_func ("/Calls/contacts/empty", (GTestFunc) test_contacts_empty_contact);
|
||||||
|
g_test_add_func ("/Calls/contacts/unknown", (GTestFunc) test_contacts_unknown_contact);
|
||||||
|
|
||||||
g_test_run ();
|
g_test_run ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue