[gtksourceview/gnome-3-14] SearchContext: unit test when buffer destroyed during search



commit 521a9e645001af8f4ea2720d6ab38cb266f72036
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Mar 5 11:17:00 2015 +0100

    SearchContext: unit test when buffer destroyed during search
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745519

 tests/test-search-context.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-search-context.c b/tests/test-search-context.c
index 8e3782b..8a2cafe 100644
--- a/tests/test-search-context.c
+++ b/tests/test-search-context.c
@@ -1059,6 +1059,29 @@ test_regex_at_word_boundaries (void)
        g_object_unref (context);
 }
 
+static void
+test_destroy_buffer_during_search (void)
+{
+       GtkSourceBuffer *source_buffer = gtk_source_buffer_new (NULL);
+       GtkTextBuffer *text_buffer = GTK_TEXT_BUFFER (source_buffer);
+       GtkSourceSearchSettings *settings = gtk_source_search_settings_new ();
+       GtkSourceSearchContext *context = gtk_source_search_context_new (source_buffer, settings);
+
+       gtk_text_buffer_set_text (text_buffer, "y", -1);
+       gtk_source_search_settings_set_search_text (settings, "y");
+
+       /* Destroy buffer during search. */
+       g_object_unref (source_buffer);
+       flush_queue ();
+
+       /* Test also a new search when buffer already destroyed. */
+       gtk_source_search_settings_set_search_text (settings, "x");
+       flush_queue ();
+
+       g_object_unref (settings);
+       g_object_unref (context);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -1085,6 +1108,7 @@ main (int argc, char **argv)
        g_test_add_func ("/Search/replace", test_replace_all);
        g_test_add_func ("/Search/regex", test_regex);
        g_test_add_func ("/Search/regex-at-word-boundaries", test_regex_at_word_boundaries);
+       g_test_add_func ("/Search/destroy-buffer-during-search", test_destroy_buffer_during_search);
 
        return g_test_run ();
 }


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