7 /* These tests rely on the schemas in org.gtk.test.gschema.xml
8 * to be compiled and installed in the same directory.
11 /* Just to get warmed up: Read and set a string, and
12 * verify that can read the changed string back
20 settings = g_settings_new ("org.gtk.test");
22 g_settings_get (settings, "greeting", "s", &str);
23 g_assert_cmpstr (str, ==, "Hello, earthlings");
25 g_settings_set (settings, "greeting", "s", "goodbye world");
26 g_settings_get (settings, "greeting", "s", &str);
27 g_assert_cmpstr (str, ==, "goodbye world");
31 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
33 settings = g_settings_new ("org.gtk.test");
34 g_settings_set (settings, "greeting", "i", 555);
37 g_test_trap_assert_failed ();
38 g_test_trap_assert_stderr ("*correct_type*");
40 g_settings_get (settings, "greeting", "s", &str);
41 g_assert_cmpstr (str, ==, "goodbye world");
45 g_settings_set (settings, "greeting", "s", "this is the end");
46 g_object_unref (settings);
49 /* Check that we get an error when getting a key
50 * that is not in the schema
53 test_unknown_key (void)
55 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
60 settings = g_settings_new ("org.gtk.test");
61 value = g_settings_get_value (settings, "no_such_key");
63 g_assert (value == NULL);
65 g_object_unref (settings);
67 g_test_trap_assert_failed ();
68 g_test_trap_assert_stderr ("*does not contain*");
71 /* Check that we get an error when the schema
72 * has not been installed
77 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
81 settings = g_settings_new ("no.such.schema");
83 g_assert (settings == NULL);
86 g_test_trap_assert_failed ();
87 g_test_trap_assert_stderr ("*Settings schema 'no.such.schema' is not installed*");
90 /* Check that we get an error when passing a type string
91 * that does not match the schema
94 test_wrong_type (void)
96 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
101 settings = g_settings_new ("org.gtk.test");
103 g_settings_get (settings, "greeting", "o", &str);
105 g_assert (str == NULL);
107 g_test_trap_assert_failed ();
108 g_test_trap_assert_stderr ("*CRITICAL*");
110 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
114 settings = g_settings_new ("org.gtk.test");
116 g_settings_set (settings, "greetings", "o", "/a/path");
118 g_test_trap_assert_failed ();
119 g_test_trap_assert_stderr ("*CRITICAL*");
122 /* Check that we can successfully read and set the full
123 * range of all basic types
126 test_basic_types (void)
140 settings = g_settings_new ("org.gtk.test.basic-types");
142 g_settings_get (settings, "test-boolean", "b", &b);
143 g_assert_cmpint (b, ==, 1);
145 g_settings_set (settings, "test-boolean", "b", 0);
146 g_settings_get (settings, "test-boolean", "b", &b);
147 g_assert_cmpint (b, ==, 0);
149 g_settings_get (settings, "test-byte", "y", &byte);
150 g_assert_cmpint (byte, ==, 25);
152 g_settings_set (settings, "test-byte", "y", G_MAXUINT8);
153 g_settings_get (settings, "test-byte", "y", &byte);
154 g_assert_cmpint (byte, ==, G_MAXUINT8);
156 g_settings_get (settings, "test-int16", "n", &i16);
157 g_assert_cmpint (i16, ==, -1234);
159 g_settings_set (settings, "test-int16", "n", G_MININT16);
160 g_settings_get (settings, "test-int16", "n", &i16);
161 g_assert_cmpint (i16, ==, G_MININT16);
163 g_settings_set (settings, "test-int16", "n", G_MAXINT16);
164 g_settings_get (settings, "test-int16", "n", &i16);
165 g_assert_cmpint (i16, ==, G_MAXINT16);
167 g_settings_get (settings, "test-uint16", "q", &u16);
168 g_assert_cmpuint (u16, ==, 1234);
170 g_settings_set (settings, "test-uint16", "q", G_MAXUINT16);
171 g_settings_get (settings, "test-uint16", "q", &u16);
172 g_assert_cmpuint (u16, ==, G_MAXUINT16);
174 g_settings_get (settings, "test-int32", "i", &i32);
175 g_assert_cmpint (i32, ==, -123456);
177 g_settings_set (settings, "test-int32", "i", G_MININT32);
178 g_settings_get (settings, "test-int32", "i", &i32);
179 g_assert_cmpint (i32, ==, G_MININT32);
181 g_settings_set (settings, "test-int32", "i", G_MAXINT32);
182 g_settings_get (settings, "test-int32", "i", &i32);
183 g_assert_cmpint (i32, ==, G_MAXINT32);
185 g_settings_get (settings, "test-uint32", "u", &u32);
186 g_assert_cmpuint (u32, ==, 123456);
188 g_settings_set (settings, "test-uint32", "u", G_MAXUINT32);
189 g_settings_get (settings, "test-uint32", "u", &u32);
190 g_assert_cmpuint (u32, ==, G_MAXUINT32);
192 g_settings_get (settings, "test-int64", "x", &i64);
193 g_assert_cmpuint (i64, ==, -123456789);
195 g_settings_set (settings, "test-int64", "x", G_MININT64);
196 g_settings_get (settings, "test-int64", "x", &i64);
197 g_assert_cmpuint (i64, ==, G_MININT64);
199 g_settings_set (settings, "test-int64", "x", G_MAXINT64);
200 g_settings_get (settings, "test-int64", "x", &i64);
201 g_assert_cmpuint (i64, ==, G_MAXINT64);
203 g_settings_get (settings, "test-uint64", "t", &u64);
204 g_assert_cmpuint (u64, ==, 123456789);
206 g_settings_set (settings, "test-uint64", "t", G_MAXUINT64);
207 g_settings_get (settings, "test-uint64", "t", &u64);
208 g_assert_cmpuint (u64, ==, G_MAXUINT64);
210 g_settings_get (settings, "test-double", "d", &d);
211 g_assert_cmpfloat (d, ==, 123.456);
213 g_settings_set (settings, "test-double", "d", G_MINDOUBLE);
214 g_settings_get (settings, "test-double", "d", &d);
215 g_assert_cmpfloat (d, ==, G_MINDOUBLE);
217 g_settings_set (settings, "test-double", "d", G_MAXDOUBLE);
218 g_settings_get (settings, "test-double", "d", &d);
219 g_assert_cmpfloat (d, ==, G_MAXDOUBLE);
221 g_settings_get (settings, "test-string", "s", &str);
222 g_assert_cmpstr (str, ==, "a string, it seems");
226 g_settings_get (settings, "test-objectpath", "o", &str);
227 g_assert_cmpstr (str, ==, "/a/object/path");
228 g_object_unref (settings);
233 /* Check that we can read an set complex types like
234 * tuples, arrays and dictionaries
237 test_complex_types (void)
242 GVariantIter *iter = NULL;
244 settings = g_settings_new ("org.gtk.test.complex-types");
246 g_settings_get (settings, "test-tuple", "(s(ii))", &s, &i1, &i2);
247 g_assert_cmpstr (s, ==, "one");
248 g_assert_cmpint (i1,==, 2);
249 g_assert_cmpint (i2,==, 3);
253 g_settings_set (settings, "test-tuple", "(s(ii))", "none", 0, 0);
254 g_settings_get (settings, "test-tuple", "(s(ii))", &s, &i1, &i2);
255 g_assert_cmpstr (s, ==, "none");
256 g_assert_cmpint (i1,==, 0);
257 g_assert_cmpint (i2,==, 0);
261 g_settings_get (settings, "test-array", "ai", &iter);
262 g_assert_cmpint (g_variant_iter_n_children (iter), ==, 6);
263 g_assert (g_variant_iter_next (iter, "i", &i1));
264 g_assert_cmpint (i1, ==, 0);
265 g_assert (g_variant_iter_next (iter, "i", &i1));
266 g_assert_cmpint (i1, ==, 1);
267 g_assert (g_variant_iter_next (iter, "i", &i1));
268 g_assert_cmpint (i1, ==, 2);
269 g_assert (g_variant_iter_next (iter, "i", &i1));
270 g_assert_cmpint (i1, ==, 3);
271 g_assert (g_variant_iter_next (iter, "i", &i1));
272 g_assert_cmpint (i1, ==, 4);
273 g_assert (g_variant_iter_next (iter, "i", &i1));
274 g_assert_cmpint (i1, ==, 5);
275 g_assert (!g_variant_iter_next (iter, "i", &i1));
276 g_variant_iter_free (iter);
278 g_object_unref (settings);
281 static gboolean changed_cb_called;
284 changed_cb (GSettings *settings,
288 changed_cb_called = TRUE;
290 g_assert_cmpstr (key, ==, data);
293 /* Test that basic change notification with the changed signal works.
299 GSettings *settings2;
301 settings = g_settings_new ("org.gtk.test");
303 g_signal_connect (settings, "changed",
304 G_CALLBACK (changed_cb), "greeting");
306 changed_cb_called = FALSE;
308 g_settings_set (settings, "greeting", "s", "new greeting");
309 g_assert (changed_cb_called);
311 settings2 = g_settings_new ("org.gtk.test");
313 changed_cb_called = FALSE;
315 g_settings_set (settings2, "greeting", "s", "hi");
316 g_assert (changed_cb_called);
318 g_object_unref (settings2);
319 g_object_unref (settings);
322 static gboolean changed_cb_called2;
325 changed_cb2 (GSettings *settings,
334 /* Test that changes done to a delay-mode instance
335 * don't appear to the outside world until apply. Also
336 * check that we get change notification when they are
338 * Also test that the has-unapplied property is properly
342 test_delay_apply (void)
345 GSettings *settings2;
348 settings = g_settings_new ("org.gtk.test");
349 settings2 = g_settings_new ("org.gtk.test");
351 g_settings_set (settings2, "greeting", "s", "top o' the morning");
353 changed_cb_called = FALSE;
354 changed_cb_called2 = FALSE;
356 g_signal_connect (settings, "changed",
357 G_CALLBACK (changed_cb2), &changed_cb_called);
358 g_signal_connect (settings2, "changed",
359 G_CALLBACK (changed_cb2), &changed_cb_called2);
361 g_settings_delay (settings);
363 g_settings_set (settings, "greeting", "s", "greetings from test_delay_apply");
365 g_assert (changed_cb_called);
366 g_assert (!changed_cb_called2);
368 g_settings_get (settings, "greeting", "s", &str);
369 g_assert_cmpstr (str, ==, "greetings from test_delay_apply");
373 g_settings_get (settings2, "greeting", "s", &str);
374 g_assert_cmpstr (str, ==, "top o' the morning");
378 g_assert (g_settings_get_has_unapplied (settings));
379 g_assert (!g_settings_get_has_unapplied (settings2));
381 changed_cb_called = FALSE;
382 changed_cb_called2 = FALSE;
384 g_settings_apply (settings);
386 g_assert (!changed_cb_called);
387 g_assert (changed_cb_called2);
389 g_settings_get (settings, "greeting", "s", &str);
390 g_assert_cmpstr (str, ==, "greetings from test_delay_apply");
394 g_settings_get (settings2, "greeting", "s", &str);
395 g_assert_cmpstr (str, ==, "greetings from test_delay_apply");
399 g_assert (!g_settings_get_has_unapplied (settings));
400 g_assert (!g_settings_get_has_unapplied (settings2));
402 g_object_unref (settings2);
403 g_object_unref (settings);
406 /* Test that reverting unapplied changes in a delay-apply
407 * settings instance works.
410 test_delay_revert (void)
413 GSettings *settings2;
416 settings = g_settings_new ("org.gtk.test");
417 settings2 = g_settings_new ("org.gtk.test");
419 g_settings_set (settings2, "greeting", "s", "top o' the morning");
421 g_settings_delay (settings);
423 g_settings_set (settings, "greeting", "s", "greetings from test_delay_revert");
425 g_settings_get (settings, "greeting", "s", &str);
426 g_assert_cmpstr (str, ==, "greetings from test_delay_revert");
430 g_settings_get (settings2, "greeting", "s", &str);
431 g_assert_cmpstr (str, ==, "top o' the morning");
435 g_assert (g_settings_get_has_unapplied (settings));
437 g_settings_revert (settings);
439 g_assert (g_settings_get_has_unapplied (settings));
441 g_settings_get (settings, "greeting", "s", &str);
442 g_assert_cmpstr (str, ==, "top o' the morning");
446 g_settings_get (settings2, "greeting", "s", &str);
447 g_assert_cmpstr (str, ==, "top o' the morning");
451 g_object_unref (settings2);
452 g_object_unref (settings);
456 keys_changed_cb (GSettings *settings,
462 g_assert_cmpint (n_keys, ==, 2);
464 g_assert ((keys[0] == g_quark_from_static_string ("greeting") &&
465 keys[1] == g_quark_from_static_string ("farewell")) ||
466 (keys[1] == g_quark_from_static_string ("greeting") &&
467 keys[0] == g_quark_from_static_string ("farewell")));
469 g_settings_get (settings, "greeting", "s", &str);
470 g_assert_cmpstr (str, ==, "greetings from test_atomic");
474 g_settings_get (settings, "farewell", "s", &str);
475 g_assert_cmpstr (str, ==, "atomic bye-bye");
480 /* Check that delay-applied changes appear atomically.
481 * More specifically, verify that all changed keys appear
482 * with their new value while handling the change-event signal.
488 GSettings *settings2;
491 settings = g_settings_new ("org.gtk.test");
492 settings2 = g_settings_new ("org.gtk.test");
494 g_settings_set (settings2, "greeting", "s", "top o' the morning");
496 changed_cb_called = FALSE;
497 changed_cb_called2 = FALSE;
499 g_signal_connect (settings2, "change-event",
500 G_CALLBACK (keys_changed_cb), NULL);
502 g_settings_delay (settings);
504 g_settings_set (settings, "greeting", "s", "greetings from test_atomic");
505 g_settings_set (settings, "farewell", "s", "atomic bye-bye");
507 g_settings_apply (settings);
509 g_settings_get (settings, "greeting", "s", &str);
510 g_assert_cmpstr (str, ==, "greetings from test_atomic");
514 g_settings_get (settings, "farewell", "s", &str);
515 g_assert_cmpstr (str, ==, "atomic bye-bye");
519 g_settings_get (settings2, "greeting", "s", &str);
520 g_assert_cmpstr (str, ==, "greetings from test_atomic");
524 g_settings_get (settings2, "farewell", "s", &str);
525 g_assert_cmpstr (str, ==, "atomic bye-bye");
529 g_object_unref (settings2);
530 g_object_unref (settings);
533 /* Test that translations work for schema defaults.
535 * This test relies on the de.po file in the same directory
536 * to be compiled into ./de/LC_MESSAGES/test.mo
545 bindtextdomain ("test", ".");
546 bind_textdomain_codeset ("test", "UTF-8");
548 locale = g_strdup (setlocale (LC_MESSAGES, NULL));
550 settings = g_settings_new ("org.gtk.test.localized");
552 setlocale (LC_MESSAGES, "C");
553 str = g_settings_get_string (settings, "error-message");
554 setlocale (LC_MESSAGES, locale);
556 g_assert_cmpstr (str, ==, "Unnamed");
560 setlocale (LC_MESSAGES, "de_DE");
561 str = g_settings_get_string (settings, "error-message");
562 setlocale (LC_MESSAGES, locale);
564 g_assert_cmpstr (str, ==, "Unbenannt");
565 g_object_unref (settings);
572 /* Test that message context works as expected with translated
573 * schema defaults. Also, verify that non-ASCII UTF-8 content
576 * This test relies on the de.po file in the same directory
577 * to be compiled into ./de/LC_MESSAGES/test.mo
580 test_l10n_context (void)
586 bindtextdomain ("test", ".");
587 bind_textdomain_codeset ("test", "UTF-8");
589 locale = g_strdup (setlocale (LC_MESSAGES, NULL));
591 settings = g_settings_new ("org.gtk.test.localized");
593 setlocale (LC_MESSAGES, "C");
594 g_settings_get (settings, "backspace", "s", &str);
595 setlocale (LC_MESSAGES, locale);
597 g_assert_cmpstr (str, ==, "BackSpace");
601 setlocale (LC_MESSAGES, "de_DE");
602 g_settings_get (settings, "backspace", "s", &str);
603 setlocale (LC_MESSAGES, locale);
605 g_assert_cmpstr (str, ==, "Löschen");
606 g_object_unref (settings);
624 GObject parent_instance;
634 GObjectClass parent_class;
637 G_DEFINE_TYPE (TestObject, test_object, G_TYPE_OBJECT)
640 test_object_init (TestObject *object)
645 test_object_finalize (GObject *object)
647 TestObject *testo = (TestObject*)object;
648 g_free (testo->string_prop);
649 G_OBJECT_CLASS (test_object_parent_class)->finalize (object);
653 test_object_get_property (GObject *object,
658 TestObject *test_object = (TestObject *)object;
663 g_value_set_boolean (value, test_object->bool_prop);
666 g_value_set_int (value, test_object->int_prop);
669 g_value_set_double (value, test_object->double_prop);
672 g_value_set_string (value, test_object->string_prop);
675 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
681 test_object_set_property (GObject *object,
686 TestObject *test_object = (TestObject *)object;
691 test_object->bool_prop = g_value_get_boolean (value);
694 test_object->int_prop = g_value_get_int (value);
697 test_object->double_prop = g_value_get_double (value);
700 g_free (test_object->string_prop);
701 test_object->string_prop = g_value_dup_string (value);
704 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
710 test_object_class_init (TestObjectClass *class)
712 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
714 gobject_class->get_property = test_object_get_property;
715 gobject_class->set_property = test_object_set_property;
716 gobject_class->finalize = test_object_finalize;
718 g_object_class_install_property (gobject_class, PROP_BOOL,
719 g_param_spec_boolean ("bool", "", "", FALSE, G_PARAM_READWRITE));
720 g_object_class_install_property (gobject_class, PROP_INT,
721 g_param_spec_int ("int", "", "", -G_MAXINT, G_MAXINT, 0, G_PARAM_READWRITE));
722 g_object_class_install_property (gobject_class, PROP_DOUBLE,
723 g_param_spec_double ("double", "", "", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE));
724 g_object_class_install_property (gobject_class, PROP_STRING,
725 g_param_spec_string ("string", "", "", NULL, G_PARAM_READWRITE));
729 test_object_new (void)
731 return (TestObject*)g_object_new (test_object_get_type (), NULL);
734 /* Test basic binding functionality for simple types.
735 * Verify that with bidirectional bindings, changes on either side
736 * are notified on the other end.
739 test_simple_binding (void)
748 settings = g_settings_new ("org.gtk.test.binding");
749 obj = test_object_new ();
751 g_settings_bind (settings, "bool", obj, "bool", G_SETTINGS_BIND_DEFAULT);
753 g_object_set (obj, "bool", TRUE, NULL);
754 g_assert_cmpint (g_settings_get_boolean (settings, "bool"), ==, TRUE);
756 g_settings_set_boolean (settings, "bool", FALSE);
757 g_object_get (obj, "bool", &b, NULL);
758 g_assert_cmpint (b, ==, FALSE);
760 g_settings_bind (settings, "int", obj, "int", G_SETTINGS_BIND_DEFAULT);
762 g_object_set (obj, "int", 12345, NULL);
763 g_assert_cmpint (g_settings_get_int (settings, "int"), ==, 12345);
765 g_settings_set_int (settings, "int", 54321);
766 g_object_get (obj, "int", &i, NULL);
767 g_assert_cmpint (i, ==, 54321);
769 g_settings_bind (settings, "string", obj, "string", G_SETTINGS_BIND_DEFAULT);
771 g_object_set (obj, "string", "bu ba", NULL);
772 s = g_settings_get_string (settings, "string");
773 g_assert_cmpstr (s, ==, "bu ba");
776 g_settings_set_string (settings, "string", "bla bla");
777 g_object_get (obj, "string", &s, NULL);
778 g_assert_cmpstr (s, ==, "bla bla");
781 g_settings_bind (settings, "double", obj, "double", G_SETTINGS_BIND_DEFAULT);
783 g_object_set (obj, "double", 203e7, NULL);
784 g_assert_cmpfloat (g_settings_get_double (settings, "double"), ==, 203e7);
786 g_settings_set_double (settings, "double", 207e3);
787 g_object_get (obj, "double", &d, NULL);
788 g_assert_cmpfloat (d, ==, 207e3);
790 g_object_unref (obj);
791 g_object_unref (settings);
794 /* Test one-way bindings.
795 * Verify that changes on one side show up on the other,
799 test_directional_binding (void)
806 settings = g_settings_new ("org.gtk.test.binding");
807 obj = test_object_new ();
809 g_object_set (obj, "bool", FALSE, NULL);
810 g_settings_set_boolean (settings, "bool", FALSE);
812 g_settings_bind (settings, "bool", obj, "bool", G_SETTINGS_BIND_GET);
814 g_settings_set_boolean (settings, "bool", TRUE);
815 g_object_get (obj, "bool", &b, NULL);
816 g_assert_cmpint (b, ==, TRUE);
818 g_object_set (obj, "bool", FALSE, NULL);
819 g_assert_cmpint (g_settings_get_boolean (settings, "bool"), ==, TRUE);
821 g_object_set (obj, "int", 20, NULL);
822 g_settings_set_int (settings, "int", 20);
824 g_settings_bind (settings, "int", obj, "int", G_SETTINGS_BIND_SET);
826 g_object_set (obj, "int", 32, NULL);
827 g_assert_cmpint (g_settings_get_int (settings, "int"), ==, 32);
829 g_settings_set_int (settings, "int", 20);
830 g_object_get (obj, "int", &i, NULL);
831 g_assert_cmpint (i, ==, 32);
833 g_object_unref (obj);
834 g_object_unref (settings);
837 /* Test that type mismatch is caught when creating a binding
840 test_typesafe_binding (void)
842 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
847 settings = g_settings_new ("org.gtk.test.binding");
848 obj = test_object_new ();
850 g_settings_bind (settings, "string", obj, "int", G_SETTINGS_BIND_DEFAULT);
852 g_object_unref (obj);
853 g_object_unref (settings);
855 g_test_trap_assert_failed ();
856 g_test_trap_assert_stderr ("*not compatible*");
860 string_to_bool (GValue *value,
866 s = g_variant_get_string (variant, NULL);
867 g_value_set_boolean (value, g_strcmp0 (s, "true") == 0);
873 bool_to_string (const GValue *value,
874 const GVariantType *expected_type,
877 if (g_value_get_boolean (value))
878 return g_variant_new_string ("true");
880 return g_variant_new_string ("false");
883 /* Test custom bindings.
884 * Translate strings to booleans and back
887 test_custom_binding (void)
894 settings = g_settings_new ("org.gtk.test.binding");
895 obj = test_object_new ();
897 g_settings_set_string (settings, "string", "true");
899 g_settings_bind_with_mapping (settings, "string",
901 G_SETTINGS_BIND_DEFAULT,
906 g_settings_set_string (settings, "string", "false");
907 g_object_get (obj, "bool", &b, NULL);
908 g_assert_cmpint (b, ==, FALSE);
910 g_settings_set_string (settings, "string", "not true");
911 g_object_get (obj, "bool", &b, NULL);
912 g_assert_cmpint (b, ==, FALSE);
914 g_object_set (obj, "bool", TRUE, NULL);
915 s = g_settings_get_string (settings, "string");
916 g_assert_cmpstr (s, ==, "true");
918 g_object_unref (obj);
919 g_object_unref (settings);
922 /* Test that with G_SETTINGS_BIND_NO_CHANGES, the
923 * initial settings value is transported to the object
924 * side, but later settings changes do not affect the
928 test_no_change_binding (void)
934 settings = g_settings_new ("org.gtk.test.binding");
935 obj = test_object_new ();
937 g_object_set (obj, "bool", TRUE, NULL);
938 g_settings_set_boolean (settings, "bool", FALSE);
940 g_settings_bind (settings, "bool", obj, "bool", G_SETTINGS_BIND_GET_NO_CHANGES);
942 g_object_get (obj, "bool", &b, NULL);
943 g_assert_cmpint (b, ==, FALSE);
945 g_settings_set_boolean (settings, "bool", TRUE);
946 g_object_get (obj, "bool", &b, NULL);
947 g_assert_cmpint (b, ==, FALSE);
949 g_settings_set_boolean (settings, "bool", FALSE);
950 g_object_set (obj, "bool", TRUE, NULL);
951 b = g_settings_get_boolean (settings, "bool");
952 g_assert_cmpint (b, ==, TRUE);
954 g_object_unref (obj);
955 g_object_unref (settings);
959 main (int argc, char *argv[])
961 g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE);
962 g_setenv ("GSETTINGS_BACKEND", "memory", TRUE);
964 g_remove ("./store");
967 g_test_init (&argc, &argv, NULL);
969 g_test_add_func ("/gsettings/basic", test_basic);
970 g_test_add_func ("/gsettings/no-schema", test_no_schema);
971 g_test_add_func ("/gsettings/unknown-key", test_unknown_key);
972 g_test_add_func ("/gsettings/wrong-type", test_wrong_type);
973 g_test_add_func ("/gsettings/basic-types", test_basic_types);
974 g_test_add_func ("/gsettings/complex-types", test_complex_types);
975 g_test_add_func ("/gsettings/changes", test_changes);
976 g_test_add_func ("/gsettings/l10n", test_l10n);
977 g_test_add_func ("/gsettings/l10n-context", test_l10n_context);
978 g_test_add_func ("/gsettings/delay-apply", test_delay_apply);
979 g_test_add_func ("/gsettings/delay-revert", test_delay_revert);
980 g_test_add_func ("/gsettings/atomic", test_atomic);
981 g_test_add_func ("/gsettings/simple-binding", test_simple_binding);
982 g_test_add_func ("/gsettings/directional-binding", test_directional_binding);
983 g_test_add_func ("/gsettings/typesafe-binding", test_typesafe_binding);
984 g_test_add_func ("/gsettings/custom-binding", test_custom_binding);
985 g_test_add_func ("/gsettings/no-change-binding", test_no_change_binding);
987 return g_test_run ();