[gtksourceview] Fix tests when gtksourceview is not installed



commit 1970223669e512e126e8ed2dc39f456c056c518d
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat May 31 14:30:54 2014 +0200

    Fix tests when gtksourceview is not installed
    
    When running test-search-context when gtksourceview is not installed,
    there was this error:
    GtkSourceView-WARNING **: search-match style not available.
    
    The fix is the same as in test-languagemanager.c (but for the style
    scheme manager).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731039

 tests/test-search-context.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-search-context.c b/tests/test-search-context.c
index e8d9160..71ece13 100644
--- a/tests/test-search-context.c
+++ b/tests/test-search-context.c
@@ -41,6 +41,35 @@ static void check_async_search_results (GtkSourceSearchContext *context,
                                        gboolean                forward,
                                        gboolean                start_check);
 
+/* If we are running from the source dir (e.g. during make check)
+ * we override the path to read from the data dir.
+ */
+static void
+init_style_scheme_manager (void)
+{
+       gchar *dir;
+
+       dir = g_build_filename (TOP_SRCDIR, "data", "styles", NULL);
+
+       if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+       {
+               GtkSourceStyleSchemeManager *manager;
+               gchar **dirs;
+
+               manager = gtk_source_style_scheme_manager_get_default ();
+
+               dirs = g_new0 (gchar *, 2);
+               dirs[0] = dir;
+
+               gtk_source_style_scheme_manager_set_search_path (manager, dirs);
+               g_strfreev (dirs);
+       }
+       else
+       {
+               g_free (dir);
+       }
+}
+
 static void
 flush_queue (void)
 {
@@ -1000,6 +1029,8 @@ main (int argc, char **argv)
 {
        gtk_test_init (&argc, &argv);
 
+       init_style_scheme_manager ();
+
        g_test_add_func ("/Search/occurrences-count/simple", test_occurrences_count_simple);
        g_test_add_func ("/Search/occurrences-count/with-insert", test_occurrences_count_with_insert);
        g_test_add_func ("/Search/occurrences-count/with-delete", test_occurrences_count_with_delete);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]