From e052201553b9d36e7dfd7e5d21bf78a869bab5c1 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Wed, 11 May 2022 09:54:13 +0200 Subject: [PATCH] tests: Add testing for sideeffects of using CallsSettings When setting up a binding between GSettings and GObject properties the CallsSetting used to set the value from the GSetting to the property and back to the GSetting. While the value was still the default value it was marked as non default because it had explicitly been set without any user interaction. --- tests/meson.build | 13 +++++++++++++ tests/test-settings.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/test-settings.c diff --git a/tests/meson.build b/tests/meson.build index a2335e5..9171ce8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -193,4 +193,17 @@ t = executable('contacts', test_sources, ) test('contacts', t, env: test_env) +test_sources = [ 'test-settings.c' ] +t = executable('settings', 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('settings', t, env: test_env) + endif diff --git a/tests/test-settings.c b/tests/test-settings.c new file mode 100644 index 0000000..4934d01 --- /dev/null +++ b/tests/test-settings.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 Purism SPC + * + * SPDX-License-Identifier: GPL-3.0+ + */ + +#include "calls-settings.h" + +#define G_SETTINGS_ENABLE_BACKEND +#include + +#include + +static void +test_default (void) +{ + g_autoptr (GSettings) gsettings = g_settings_new ("org.gnome.Calls"); + g_autoptr (CallsSettings) calls_settings = NULL; + + g_assert_null (g_settings_get_user_value (gsettings, "autoload-plugins")); + g_assert_null (g_settings_get_user_value (gsettings, "preferred-audio-codecs")); + + /* we're testing if CallsSettings has the sideeffect of writing to the settings */ + calls_settings = calls_settings_get_default (); + + g_assert_null (g_settings_get_user_value (gsettings, "autoload-plugins")); + g_assert_null (g_settings_get_user_value (gsettings, "preferred-audio-codecs")); +} + + +int +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + g_test_add_func ("/Calls/Settings/default", test_default); + + return g_test_run (); +}