summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-25 08:37:03 +0100
committerBenjamin Otte <otte@redhat.com>2017-12-03 05:46:47 +0100
commite2014850b9ef032d922648cdc7ee644a3f9b8429 (patch)
treef55fb7f435657e3b8fe734b37408f2e4066bd38e /tests
parentc66a61d896f9f26cfab8f5eb4349830a6e24b141 (diff)
downloadgtk+-e2014850b9ef032d922648cdc7ee644a3f9b8429.tar.gz
tests: Add possibility to set invalid UTF-8 and clear clipboard
Diffstat (limited to 'tests')
-rw-r--r--tests/testclipboard2.c17
1 files changed, 16 insertions, 1 deletions
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;
}