appinfo \
icons \
contenttype \
+ file \
$(NULL)
endif
contenttype_SOURCES = contenttype.c
contenttype_LDADD = $(progs_ldadd)
+file_SOURCES = file.c
+file_LDADD = $(progs_ldadd)
+
schema_tests = \
schema-tests/array-default-not-in-choices.gschema.xml \
schema-tests/bad-choice.gschema.xml \
de.po \
$(schema_tests) \
appinfo-test.desktop \
+ appinfo-test2.desktop \
+ appinfo-test-gnome.desktop \
+ appinfo-test-notgnome.desktop \
gdbus-testserver.py
MISC_STUFF = test.mo
test_launch (void)
{
GAppInfo *appinfo;
+ GError *error;
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
g_assert (appinfo != NULL);
- g_assert (g_app_info_launch (appinfo, NULL, NULL, NULL));
+ error = NULL;
+ g_assert (g_app_info_launch (appinfo, NULL, NULL, &error));
+ g_assert_no_error (error);
+
+ g_assert (g_app_info_launch_uris (appinfo, NULL, NULL, &error));
+ g_assert_no_error (error);
}
static void
test_basic (void)
{
GAppInfo *appinfo;
+ GAppInfo *appinfo2;
GIcon *icon, *icon2;
appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test.desktop");
g_assert (g_icon_equal (icon, icon2));
g_object_unref (icon2);
+ appinfo2 = g_app_info_dup (appinfo);
+ g_assert (g_app_info_get_id (appinfo) == g_app_info_get_id (appinfo2));
+ g_assert_cmpstr (g_app_info_get_commandline (appinfo), ==, g_app_info_get_commandline (appinfo2));
+
g_object_unref (appinfo);
+ g_object_unref (appinfo2);
}
static void
g_object_unref (context);
}
+static void
+test_tryexec (void)
+{
+ GAppInfo *appinfo;
+
+ appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (SRCDIR "/appinfo-test2.desktop");
+
+ g_assert (appinfo == NULL);
+}
+
int
main (int argc, char *argv[])
{
g_type_init ();
g_test_init (&argc, &argv, NULL);
-
g_test_add_func ("/appinfo/basic", test_basic);
g_test_add_func ("/appinfo/text", test_text);
g_test_add_func ("/appinfo/launch", test_launch);
g_test_add_func ("/appinfo/show-in", test_show_in);
g_test_add_func ("/appinfo/commandline", test_commandline);
g_test_add_func ("/appinfo/launch-context", test_launch_context);
+ g_test_add_func ("/appinfo/tryexec", test_tryexec);
+
return g_test_run ();
}
type = g_content_type_from_mime_type ("text/plain");
g_assert (g_content_type_can_be_executable (type));
g_free (type);
+
+ type = g_content_type_from_mime_type ("image/png");
+ g_assert (!g_content_type_can_be_executable (type));
+ g_free (type);
}
static void
--- /dev/null
+#include <gio/gio.h>
+
+static void
+test_basic (void)
+{
+ GFile *file;
+ gchar *s;
+
+ file = g_file_new_for_path ("./some/directory/testfile");
+
+ s = g_file_get_basename (file);
+ g_assert_cmpstr (s, ==, "testfile");
+ g_free (s);
+
+ s = g_file_get_uri (file);
+ g_assert (g_str_has_prefix (s, "file://"));
+ g_assert (g_str_has_suffix (s, "/some/directory/testfile"));
+ g_free (s);
+
+ g_assert (g_file_has_uri_scheme (file, "file"));
+ s = g_file_get_uri_scheme (file);
+ g_assert_cmpstr (s, ==, "file");
+ g_free (s);
+
+ g_object_unref (file);
+}
+
+static void
+test_parent (void)
+{
+ GFile *file;
+ GFile *file2;
+ GFile *parent;
+ GFile *root;
+
+ file = g_file_new_for_path ("./some/directory/testfile");
+ file2 = g_file_new_for_path ("./some/directory");
+ root = g_file_new_for_path ("/");
+
+ g_assert (g_file_has_parent (file, file2));
+
+ parent = g_file_get_parent (file);
+ g_assert (g_file_equal (parent, file2));
+ g_object_unref (parent);
+
+ g_assert (g_file_get_parent (root) == NULL);
+
+ g_object_unref (file);
+ g_object_unref (file2);
+ g_object_unref (root);
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_type_init ();
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/file/basic", test_basic);
+ g_test_add_func ("/file/parent", test_parent);
+
+ return g_test_run ();
+}
guint64 u64;
gdouble d;
gchar *s;
+ GVariant *value;
settings = g_settings_new ("org.gtk.test.binding");
obj = test_object_new ();
g_assert_cmpstr (s, ==, "bla bla");
g_free (s);
+ g_settings_bind (settings, "chararray", obj, "string", G_SETTINGS_BIND_DEFAULT);
+
+ g_object_set (obj, "string", "non-unicode:\315", NULL);
+ value = g_settings_get_value (settings, "chararray");
+ g_assert_cmpstr (g_variant_get_byte_array (value, NULL), ==, "non-unicode:\315");
+ g_variant_unref (value);
+
g_settings_bind (settings, "double", obj, "double", G_SETTINGS_BIND_DEFAULT);
g_object_set (obj, "double", G_MAXFLOAT, NULL);
g_settings_set_double (settings, "double", -G_MINDOUBLE);
g_object_get (obj, "double", &d, NULL);
g_assert_cmpfloat (d, ==, -G_MINDOUBLE);
+
+ g_object_unref (obj);
+ g_object_unref (settings);
+}
+
+static void
+test_unbind (void)
+{
+ TestObject *obj;
+ GSettings *settings;
+
+ settings = g_settings_new ("org.gtk.test.binding");
+ obj = test_object_new ();
+
+ g_settings_bind (settings, "int", obj, "int", G_SETTINGS_BIND_DEFAULT);
+
+ g_object_set (obj, "int", 12345, NULL);
+ g_assert_cmpint (g_settings_get_int (settings, "int"), ==, 12345);
+
+ g_settings_unbind (obj, "int");
+
+ g_object_set (obj, "int", 54321, NULL);
+ g_assert_cmpint (g_settings_get_int (settings, "int"), ==, 12345);
+
+ g_object_unref (obj);
+ g_object_unref (settings);
+}
+
+static void
+test_bind_writable (void)
+{
+ TestObject *obj;
+ GSettings *settings;
+ gboolean b;
+
+ settings = g_settings_new ("org.gtk.test.binding");
+ obj = test_object_new ();
+
+ g_object_set (obj, "bool", FALSE, NULL);
+
+ g_settings_bind_writable (settings, "int", obj, "bool", G_SETTINGS_BIND_DEFAULT);
+
+ g_object_get (obj, "bool", &b, NULL);
+ g_assert (b);
+
g_object_unref (obj);
g_object_unref (settings);
}
g_test_add_func ("/gsettings/delay-apply", test_delay_apply);
g_test_add_func ("/gsettings/delay-revert", test_delay_revert);
g_test_add_func ("/gsettings/atomic", test_atomic);
+
g_test_add_func ("/gsettings/simple-binding", test_simple_binding);
g_test_add_func ("/gsettings/directional-binding", test_directional_binding);
g_test_add_func ("/gsettings/custom-binding", test_custom_binding);
g_test_add_func ("/gsettings/no-change-binding", test_no_change_binding);
+ g_test_add_func ("/gsettings/unbinding", test_unbind);
+ g_test_add_func ("/gsettings/writable-binding", test_bind_writable);
if (!backend_set)
{
g_assert (enumerator != NULL);
g_assert_no_error (error);
+ g_assert (g_file_enumerator_get_container (enumerator) == parent);
+
error = NULL;
info = g_file_enumerator_next_file (enumerator, NULL, &error);
while ((info) && (!error))
res = g_file_enumerator_close (enumerator, NULL, &error);
g_assert_cmpint (res, ==, TRUE);
g_assert_no_error (error);
+ g_assert (g_file_enumerator_is_closed (enumerator));
+
+ g_object_unref (enumerator);
}
static void
res = g_file_enumerator_close (enumerator, NULL, &error);
g_assert_cmpint (res, ==, TRUE);
g_assert_no_error (error);
+
+ g_object_unref (enumerator);
}
g_object_unref (child);
}
res = g_file_enumerator_close (enumerator, NULL, &error);
g_assert_cmpint (res, ==, TRUE);
g_assert_no_error (error);
+
+ g_object_unref (enumerator);
}
static void
<key name="string" type="s">
<default>""</default>
</key>
+ <key name="chararray" type="ay">
+ <default>[48, 49]</default>
+ </key>
</schema>
<schema id='org.gtk.test.enums' path='/tests/enums/'>