[gtk+] Fix the textbuffer test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Fix the textbuffer test
- Date: Wed, 27 Dec 2017 04:34:53 +0000 (UTC)
commit 90b016ef73d2acc1b176a173add08f2cb0ddfc53
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 26 23:15:30 2017 -0500
Fix the textbuffer test
The test was assuming that gtk_text_buffer_paste_clipboard is
synchronous, which is no longer the case.
testsuite/gtk/textbuffer.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/gtk/textbuffer.c b/testsuite/gtk/textbuffer.c
index f0817bb..d4bb416 100644
--- a/testsuite/gtk/textbuffer.c
+++ b/testsuite/gtk/textbuffer.c
@@ -1363,6 +1363,19 @@ check_buffer_contents (GtkTextBuffer *buffer,
}
static void
+wait_for_changed (GtkTextBuffer *buffer)
+{
+ GMainLoop *loop;
+ gulong id;
+
+ loop = g_main_loop_new (NULL, FALSE);
+ id = g_signal_connect_swapped (buffer, "changed", G_CALLBACK (g_main_loop_quit), loop);
+ g_main_loop_run (loop);
+ g_signal_handler_disconnect (buffer, id);
+ g_main_loop_unref (loop);
+}
+
+static void
test_clipboard (void)
{
GdkClipboard *clipboard;
@@ -1386,6 +1399,8 @@ test_clipboard (void)
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_paste_clipboard (buffer, clipboard, &end, TRUE);
+ wait_for_changed (buffer);
+
check_buffer_contents (buffer, "defabc");
/* Simple copy & paste */
@@ -1396,6 +1411,8 @@ test_clipboard (void)
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_paste_clipboard (buffer, clipboard, &start, TRUE);
+ wait_for_changed (buffer);
+
check_buffer_contents (buffer, "abcdefabc");
/* Replace the selection when pasting */
@@ -1410,6 +1427,8 @@ test_clipboard (void)
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_select_range (buffer, &start, &end);
gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
+ wait_for_changed (buffer);
+
check_buffer_contents (buffer, "abcabc");
/* Copy & paste text with tags.
@@ -1428,6 +1447,8 @@ test_clipboard (void)
gtk_text_buffer_select_range (buffer, &start, &end);
gtk_text_buffer_copy_clipboard (buffer, clipboard);
gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
+ wait_for_changed (buffer);
+
check_buffer_contents (buffer, "abcdef");
gtk_text_buffer_get_iter_at_offset (buffer, &start, 3);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]