[gtk+/wip/otte/clipboard: 69/102] tests: Add possibility to set invalid UTF-8 and clear clipboard
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/clipboard: 69/102] tests: Add possibility to set invalid UTF-8 and clear clipboard
- Date: Sat, 2 Dec 2017 15:34:24 +0000 (UTC)
commit d047ae8b5b3c901911f47ae347780e74ca33c7c4
Author: Benjamin Otte <otte redhat com>
Date: Sat Nov 25 08:37:03 2017 +0100
tests: Add possibility to set invalid UTF-8 and clear clipboard
tests/testclipboard2.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index c333a0f..635e063 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]