[gtksourceview/wip/regex-search] Test programs: re-add search highlighting



commit 5e7818f9fead996b6589460183ec18c5e067e8b3
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Aug 1 16:23:35 2013 +0200

    Test programs: re-add search highlighting

 tests/test-search-context.c |   27 ++++++++++++++++++++++++++-
 tests/test-search.c         |    3 ++-
 2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/tests/test-search-context.c b/tests/test-search-context.c
index aafc63d..359913e 100644
--- a/tests/test-search-context.c
+++ b/tests/test-search-context.c
@@ -731,7 +731,32 @@ test_async_backward_search_wrap_around (void)
 static void
 test_highlight (void)
 {
-       /* TODO */
+       GtkSourceBuffer *source_buffer = gtk_source_buffer_new (NULL);
+       GtkSourceSearchContext *context1 = gtk_source_search_context_new (source_buffer, NULL);
+       GtkSourceSearchContext *context2 = gtk_source_search_context_new (source_buffer, NULL);
+       gboolean highlight;
+
+       gtk_source_search_context_set_highlight (context1, TRUE);
+       highlight = gtk_source_search_context_get_highlight (context1);
+       g_assert (highlight);
+
+       gtk_source_search_context_set_highlight (context2, FALSE);
+       highlight = gtk_source_search_context_get_highlight (context2);
+       g_assert (!highlight);
+
+       gtk_source_search_context_set_highlight (context2, TRUE);
+       highlight = gtk_source_search_context_get_highlight (context2);
+       g_assert (highlight);
+
+       gtk_source_buffer_disable_search_highlighting (source_buffer);
+       highlight = gtk_source_search_context_get_highlight (context1);
+       g_assert (!highlight);
+       highlight = gtk_source_search_context_get_highlight (context2);
+       g_assert (!highlight);
+
+       g_object_unref (source_buffer);
+       g_object_unref (context1);
+       g_object_unref (context2);
 }
 
 static void
diff --git a/tests/test-search.c b/tests/test-search.c
index a7b584b..e1bc03b 100644
--- a/tests/test-search.c
+++ b/tests/test-search.c
@@ -328,7 +328,8 @@ static void
 highlight_toggled_cb (TestSearch      *search,
                      GtkToggleButton *button)
 {
-       /* TODO */
+       gtk_source_search_context_set_highlight (search->priv->search_context,
+                                                gtk_toggle_button_get_active (button));
 }
 
 static void


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