[glib/new-gsettings] Some notification tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/new-gsettings] Some notification tests
- Date: Thu, 15 Apr 2010 00:29:35 +0000 (UTC)
commit 1a4e7701b4164641c4ccf121c477f40251514b9d
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 14 19:52:42 2010 -0400
Some notification tests
gio/tests/gsettings.c | 100 ++++++++++++++++++++++++++++++++++++++++
gio/tests/org.gtk.test.gschema | 3 +
2 files changed, 103 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 4bbca54..621445f 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -232,6 +232,104 @@ test_complex_types (void)
g_variant_iter_free (iter);
}
+static gboolean changed_cb_called;
+
+static void
+changed_cb (GSettings *settings,
+ const gchar *key,
+ gpointer data)
+{
+ changed_cb_called = TRUE;
+
+ g_assert_cmpstr (key, ==, data);
+}
+
+void
+test_changes (void)
+{
+ GSettings *settings;
+ GSettings *settings2;
+
+ settings = g_settings_new ("org.gtk.test");
+
+ g_signal_connect (settings, "changed",
+ G_CALLBACK (changed_cb), "greeting");
+
+ changed_cb_called = FALSE;
+
+ g_settings_set (settings, "greeting", "s", "new greeting");
+ g_assert (changed_cb_called);
+
+ settings2 = g_settings_new ("org.gtk.test");
+
+ changed_cb_called = FALSE;
+
+ g_settings_set (settings2, "greeting", "s", "hi");
+ g_assert (changed_cb_called);
+
+}
+
+static gboolean changed_cb_called2;
+
+static void
+changed_cb2 (GSettings *settings,
+ const gchar *key,
+ gpointer data)
+{
+ gboolean *p = data;
+
+ *p = TRUE;
+}
+
+
+void
+test_delay (void)
+{
+ GSettings *settings;
+ GSettings *settings2;
+ gchar *str;
+
+ settings = g_settings_new ("org.gtk.test");
+ settings2 = g_settings_new ("org.gtk.test");
+
+ g_settings_set (settings2, "greeting", "s", "top o' the morning");
+
+ changed_cb_called = FALSE;
+ changed_cb_called2 = FALSE;
+
+ g_signal_connect (settings, "changed",
+ G_CALLBACK (changed_cb2), &changed_cb_called);
+ g_signal_connect (settings2, "changed",
+ G_CALLBACK (changed_cb2), &changed_cb_called2);
+
+ g_settings_set_delay_apply (settings, TRUE);
+
+ g_settings_set (settings, "greeting", "s", "greetings from test_delay");
+
+ g_assert (changed_cb_called);
+ g_assert (!changed_cb_called2);
+
+ g_settings_get (settings, "greeting", "s", &str);
+ g_assert_cmpstr (str, ==, "greetings from test_delay");
+
+ g_settings_get (settings2, "greeting", "s", &str);
+ g_assert_cmpstr (str, ==, "top o' the morning");
+
+ changed_cb_called = FALSE;
+ changed_cb_called2 = FALSE;
+
+ g_settings_apply (settings);
+
+ g_assert (!changed_cb_called);
+ g_assert (changed_cb_called2);
+
+ g_settings_get (settings, "greeting", "s", &str);
+ g_assert_cmpstr (str, ==, "greetings from test_delay");
+
+ g_settings_get (settings2, "greeting", "s", &str);
+ g_assert_cmpstr (str, ==, "greetings from test_delay");
+}
+
int
main (int argc, char *argv[])
{
@@ -250,6 +348,8 @@ main (int argc, char *argv[])
g_test_add_func ("/gsettings/wrong-type", test_wrong_type);
g_test_add_func ("/gsettings/basic-types", test_basic_types);
g_test_add_func ("/gsettings/complex-types", test_complex_types);
+ g_test_add_func ("/gsettings/changes", test_changes);
+ g_test_add_func ("/gsettings/delay", test_delay);
return g_test_run ();
}
diff --git a/gio/tests/org.gtk.test.gschema b/gio/tests/org.gtk.test.gschema
index c9209a7..ebf7a13 100644
--- a/gio/tests/org.gtk.test.gschema
+++ b/gio/tests/org.gtk.test.gschema
@@ -7,6 +7,9 @@
Greeting of the invading martians
</description>
</key>
+ <key name="farewell" type="s">
+ <default l10n="true">"So long"</default>
+ </key>
</schema>
<schema id="org.gtk.test.basic-types" path="/tests/basic_types/" gettext-domain="test">
<key name="test_boolean" type="b">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]