[gtk/test-text-buffer-undo] Add a test for text buffer history
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/test-text-buffer-undo] Add a test for text buffer history
- Date: Wed, 26 May 2021 10:10:05 +0000 (UTC)
commit f5d34c054c03d8ee7b68bac103719761fad2a4bb
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 26 06:07:46 2021 -0400
Add a test for text buffer history
Check that things can be undone.
testsuite/gtk/textbuffer.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/testsuite/gtk/textbuffer.c b/testsuite/gtk/textbuffer.c
index ff6d3c95f2..63be4e8e1d 100644
--- a/testsuite/gtk/textbuffer.c
+++ b/testsuite/gtk/textbuffer.c
@@ -1581,6 +1581,31 @@ test_get_iter (void)
g_object_unref (buffer);
}
+static void
+test_undo (void)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_buffer_new (NULL);
+
+ g_assert_true (gtk_text_buffer_get_enable_undo (buffer));
+
+ gtk_text_buffer_set_text (buffer, "text before", -1);
+
+ gtk_text_buffer_begin_user_action (buffer);
+
+ gtk_text_buffer_insert_at_cursor (buffer, "add1", 4);
+ gtk_text_buffer_insert_at_cursor (buffer, "add2", 4);
+
+ gtk_text_buffer_end_user_action (buffer);
+
+ gtk_text_buffer_undo (buffer);
+
+ check_buffer_contents (buffer, "text before");
+
+ g_object_unref (buffer);
+}
+
int
main (int argc, char** argv)
{
@@ -1600,6 +1625,7 @@ main (int argc, char** argv)
g_test_add_func ("/TextBuffer/Tag", test_tag);
g_test_add_func ("/TextBuffer/Clipboard", test_clipboard);
g_test_add_func ("/TextBuffer/Get iter", test_get_iter);
+ g_test_add_func ("/TextBuffer/Undo", test_undo);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]