[gtksourceview] tests: add test that simply tests loading buffers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] tests: add test that simply tests loading buffers
- Date: Tue, 20 Jul 2021 00:20:58 +0000 (UTC)
commit 739bdcadd039fd8f4d79d73c4b9e7775b0e2baa0
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 19 17:20:49 2021 -0700
tests: add test that simply tests loading buffers
tests/meson.build | 1 +
tests/test-load.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
---
diff --git a/tests/meson.build b/tests/meson.build
index 222dbc83..7c4a72bd 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -10,6 +10,7 @@ tests_sources = {
'search-performances': ['test-search-performances.c'],
'snippets': ['test-snippets.c'],
'space-drawing': ['test-space-drawing.c'],
+ 'load': ['test-load.c'],
'widget': ['test-widget.c'],
}
diff --git a/tests/test-load.c b/tests/test-load.c
new file mode 100644
index 00000000..033ec274
--- /dev/null
+++ b/tests/test-load.c
@@ -0,0 +1,48 @@
+#include <gtksourceview/gtksource.h>
+#include <stdlib.h>
+
+static void
+finished_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ g_autoptr(GError) error = NULL;
+ GMainLoop *loop = user_data;
+
+ if (!gtk_source_file_loader_load_finish (GTK_SOURCE_FILE_LOADER (object), result, &error))
+ g_printerr ("Error loading file: %s\n", error->message);
+
+ g_main_loop_quit (loop);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ g_autoptr(GFile) file = NULL;
+ g_autoptr(GMainLoop) loop = NULL;
+ g_autoptr(GtkSourceBuffer) buffer = NULL;
+ g_autoptr(GtkSourceFile) sfile = NULL;
+ g_autoptr(GtkSourceFileLoader) loader = NULL;
+
+ if (argc != 2)
+ {
+ g_printerr ("usage: %s FILENAME\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ gtk_source_init ();
+
+ loop = g_main_loop_new (NULL, FALSE);
+ file = g_file_new_for_commandline_arg (argv[1]);
+ buffer = gtk_source_buffer_new (NULL);
+ sfile = gtk_source_file_new ();
+ gtk_source_file_set_location (sfile, file);
+ loader = gtk_source_file_loader_new (buffer, sfile);
+
+ gtk_source_file_loader_load_async (loader, G_PRIORITY_DEFAULT, NULL, NULL, NULL, NULL, finished_cb, loop);
+
+ g_main_loop_run (loop);
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]