From e2014850b9ef032d922648cdc7ee644a3f9b8429 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 25 Nov 2017 08:37:03 +0100 Subject: tests: Add possibility to set invalid UTF-8 and clear clipboard --- tests/testclipboard2.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c index c333a0ff38..635e063682 100644 --- a/tests/testclipboard2.c +++ b/tests/testclipboard2.c @@ -160,7 +160,8 @@ add_provider_button (GtkWidget *box, button = gtk_button_new_with_label (name); g_signal_connect (button, "clicked", G_CALLBACK (provider_button_clicked_cb), clipboard); - g_object_set_data_full (G_OBJECT (button), "provider", provider, g_object_unref); + if (provider) + g_object_set_data_full (G_OBJECT (button), "provider", provider, g_object_unref); gtk_container_add (GTK_CONTAINER (box), button); } @@ -168,6 +169,9 @@ add_provider_button (GtkWidget *box, static GtkWidget * get_button_list (GdkClipboard *clipboard) { + static const guchar invalid_utf8[] = { 'L', 'i', 'b', 'e', 'r', 't', 0xe9, ',', ' ', + 0xc9, 'g', 'a', 'l', 'i', 't', 0xe9, ',', ' ', + 'F', 'r', 'a', 't', 'e', 'r', 'n', 'i', 't', 0xe9, 0 }; GtkWidget *box; GValue value = G_VALUE_INIT; @@ -175,6 +179,11 @@ get_button_list (GdkClipboard *clipboard) gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("Set Clipboard:")); + add_provider_button (box, + NULL, + clipboard, + "Empty"); + g_value_init (&value, GDK_TYPE_PIXBUF); g_value_take_object (&value, gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "utilities-terminal", @@ -200,6 +209,12 @@ get_button_list (GdkClipboard *clipboard) clipboard, "text/plain"); + add_provider_button (box, + gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8", + g_bytes_new_static (invalid_utf8, sizeof(invalid_utf8))), + clipboard, + "Invalid UTF-8"); + return box; } -- cgit v1.2.1