[gtk+] testsuite: Add a clipboard test
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] testsuite: Add a clipboard test
- Date: Fri, 23 Aug 2013 16:27:27 +0000 (UTC)
commit 772aed19f72a9bef8a313b8c01ee80d095268656
Author: Benjamin Otte <otte redhat com>
Date: Fri Aug 23 13:00:37 2013 +0200
testsuite: Add a clipboard test
I'm not sure I like it yet because it deadlocked once and I haven't
figured out why that is.
testsuite/gtk/Makefile.am | 1 +
testsuite/gtk/clipboard.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/gtk/Makefile.am b/testsuite/gtk/Makefile.am
index 55eebee..1e87b3d 100644
--- a/testsuite/gtk/Makefile.am
+++ b/testsuite/gtk/Makefile.am
@@ -32,6 +32,7 @@ TEST_PROGS += \
bitmask \
builder \
cellarea \
+ clipboard \
defaultvalue \
entry \
expander \
diff --git a/testsuite/gtk/clipboard.c b/testsuite/gtk/clipboard.c
new file mode 100644
index 0000000..83f1667
--- /dev/null
+++ b/testsuite/gtk/clipboard.c
@@ -0,0 +1,50 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2013 Benjamin Otte <otte gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include <string.h>
+
+#define SOME_TEXT "Hello World"
+
+static void
+test_text (void)
+{
+ GtkClipboard *clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
+ char *text;
+
+ gtk_clipboard_set_text (clipboard, SOME_TEXT, -1);
+ text = gtk_clipboard_wait_for_text (clipboard);
+ g_assert_cmpstr (text, ==, SOME_TEXT);
+ g_free (text);
+
+ gtk_clipboard_set_text (clipboard, SOME_TEXT SOME_TEXT, strlen (SOME_TEXT));
+ text = gtk_clipboard_wait_for_text (clipboard);
+ g_assert_cmpstr (text, ==, SOME_TEXT);
+ g_free (text);
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ gtk_test_init (&argc, &argv);
+
+ g_test_add_func ("/clipboard/test_text", test_text);
+
+ return g_test_run();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]