[gtk+/quartz-integration: 414/563] Add some tests for selection handling
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/quartz-integration: 414/563] Add some tests for selection handling
- Date: Sat, 9 Jul 2011 06:40:49 +0000 (UTC)
commit 508ec65c5398a9b0cd57c50c0e4c21dcce9180c4
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 24 21:17:55 2011 -0400
Add some tests for selection handling
tests/a11y/text.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/tests/a11y/text.c b/tests/a11y/text.c
index b66da91..b2c3ab8 100644
--- a/tests/a11y/text.c
+++ b/tests/a11y/text.c
@@ -555,6 +555,51 @@ test_words (GtkWidget *widget)
}
static void
+select_region (GtkWidget *widget,
+ gint start,
+ gint end)
+{
+ if (GTK_IS_EDITABLE (widget))
+ gtk_editable_select_region (GTK_EDITABLE (widget), start, end);
+ else if (GTK_IS_LABEL (widget))
+ gtk_label_select_region (GTK_LABEL (widget), start, end);
+}
+
+static void
+test_selection (GtkWidget *widget)
+{
+ AtkText *atk_text;
+ const gchar *text = "Bla bla";
+ gint n;
+ gchar *ret;
+ gint start, end;
+
+ if (GTK_IS_LABEL (widget))
+ gtk_label_set_selectable (GTK_LABEL (widget), TRUE);
+
+ atk_text = ATK_TEXT (gtk_widget_get_accessible (widget));
+ set_text (widget, text);
+
+ n = atk_text_get_n_selections (atk_text);
+ g_assert_cmpint (n, ==, 0);
+
+ select_region (widget, 4, 7);
+
+ n = atk_text_get_n_selections (atk_text);
+ g_assert_cmpint (n, ==, 1);
+
+ ret = atk_text_get_selection (atk_text, 0, &start, &end);
+ g_assert_cmpstr (ret, ==, "bla");
+ g_assert_cmpint (start, ==, 4);
+ g_assert_cmpint (end, ==, 7);
+ g_free (ret);
+
+ atk_text_remove_selection (atk_text, 0);
+ n = atk_text_get_n_selections (atk_text);
+ g_assert_cmpint (n, ==, 0);
+}
+
+static void
setup_test (GtkWidget *widget)
{
set_text (widget, "");
@@ -584,6 +629,7 @@ add_text_tests (GtkWidget *widget)
add_text_test ("/text/basic", (GTestFixtureFunc) test_basic, widget);
add_text_test ("/text/words", (GTestFixtureFunc) test_words, widget);
add_text_test ("/text/changed", (GTestFixtureFunc) test_text_changed, widget);
+ add_text_test ("/text/selection", (GTestFixtureFunc) test_selection, widget);
g_object_unref (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]