[gtk+/a11y] Add some texts for text selection signals
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/a11y] Add some texts for text selection signals
- Date: Sun, 26 Jun 2011 02:57:47 +0000 (UTC)
commit 643a0d0d7ebdaed63fe2e51e7f6f03c74be65187
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 25 22:44:46 2011 -0400
Add some texts for text selection signals
Test that we do emit ::text_caret_moved and ::text_selection_changed
as expected.
tests/a11y/text.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/tests/a11y/text.c b/tests/a11y/text.c
index 73041bc..d5cdcd2 100644
--- a/tests/a11y/text.c
+++ b/tests/a11y/text.c
@@ -575,6 +575,27 @@ select_region (GtkWidget *widget,
gtk_label_select_region (GTK_LABEL (widget), start, end);
}
+typedef struct {
+ gint count;
+ gint position;
+ gint bound;
+} SelectionData;
+
+static void
+caret_moved_cb (AtkText *text, gint position, SelectionData *data)
+{
+ data->count++;
+ data->position = position;
+}
+
+static void
+selection_changed_cb (AtkText *text, SelectionData *data)
+{
+ data->count++;
+
+ atk_text_get_selection (text, 0, &data->bound, &data->position);
+}
+
static void
test_selection (GtkWidget *widget)
{
@@ -583,18 +604,37 @@ test_selection (GtkWidget *widget)
gint n;
gchar *ret;
gint start, end;
+ SelectionData data1;
+ SelectionData data2;
if (GTK_IS_LABEL (widget))
gtk_label_set_selectable (GTK_LABEL (widget), TRUE);
atk_text = ATK_TEXT (gtk_widget_get_accessible (widget));
+
+ data1.count = 0;
+ data2.count = 0;
+ g_signal_connect (atk_text, "text_caret_moved",
+ G_CALLBACK (caret_moved_cb), &data1);
+ g_signal_connect (atk_text, "text_selection_changed",
+ G_CALLBACK (selection_changed_cb), &data2);
+
set_text (widget, text);
n = atk_text_get_n_selections (atk_text);
g_assert_cmpint (n, ==, 0);
+ g_assert_cmpint (data1.count, ==, 0);
+ g_assert_cmpint (data2.count, ==, 0);
+
select_region (widget, 4, 7);
+ g_assert_cmpint (data1.count, ==, 1);
+ g_assert_cmpint (data1.position, ==, 7);
+ g_assert_cmpint (data2.count, >=, 1);
+ g_assert_cmpint (data2.bound, ==, 4);
+ g_assert_cmpint (data2.position, ==, 7);
+
n = atk_text_get_n_selections (atk_text);
g_assert_cmpint (n, ==, 1);
@@ -607,6 +647,11 @@ test_selection (GtkWidget *widget)
atk_text_remove_selection (atk_text, 0);
n = atk_text_get_n_selections (atk_text);
g_assert_cmpint (n, ==, 0);
+
+ g_assert_cmpint (data1.count, ==, 1);
+ g_assert_cmpint (data2.count, >=, 2);
+ g_assert_cmpint (data2.position, ==, 7);
+ g_assert_cmpint (data2.bound, ==, 7);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]