diff --git a/testsuite/a11y/inscription.c b/testsuite/a11y/inscription.c index 5f8b0970af..96844958bf 100644 --- a/testsuite/a11y/inscription.c +++ b/testsuite/a11y/inscription.c @@ -13,15 +13,24 @@ inscription_text_interface (void) GtkAccessibleTextRange *ranges = NULL; char **attr_names, **attr_values; const char *string; + unsigned int start, end; g_object_ref_sink (inscription); - gtk_inscription_set_markup (GTK_INSCRIPTION (inscription), "abc"); + gtk_inscription_set_markup (GTK_INSCRIPTION (inscription), "abc def"); bytes = gtk_accessible_text_get_contents (GTK_ACCESSIBLE_TEXT (inscription), 0, G_MAXINT); string = g_bytes_get_data (bytes, &len); - g_assert_cmpint (len, ==, 4); - g_assert_cmpstr (string, ==, "abc"); + g_assert_cmpint (len, ==, 8); + g_assert_cmpstr (string, ==, "abc def"); + g_bytes_unref (bytes); + + bytes = gtk_accessible_text_get_contents_at (GTK_ACCESSIBLE_TEXT (inscription), 1, GTK_ACCESSIBLE_TEXT_GRANULARITY_WORD, &start, &end); + string = g_bytes_get_data (bytes, &len); + g_assert_cmpint (len, ==, 5); + g_assert_cmpint (start, ==, 0); + g_assert_cmpint (end, ==, 4); + g_assert_cmpstr (string, ==, "abc "); g_bytes_unref (bytes); g_assert_cmpint (gtk_accessible_text_get_caret_position (GTK_ACCESSIBLE_TEXT (inscription)), ==, 0); diff --git a/testsuite/a11y/label.c b/testsuite/a11y/label.c index e7ab8bdb9a..5f296580ee 100644 --- a/testsuite/a11y/label.c +++ b/testsuite/a11y/label.c @@ -69,17 +69,26 @@ label_text_interface (void) GtkAccessibleTextRange *ranges = NULL; char **attr_names, **attr_values; const char *string; + unsigned int start, end; g_object_ref_sink (label); - gtk_label_set_markup (GTK_LABEL (label), "abc"); + gtk_label_set_markup (GTK_LABEL (label), "abc def"); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_label_select_region (GTK_LABEL (label), 1, 2); bytes = gtk_accessible_text_get_contents (GTK_ACCESSIBLE_TEXT (label), 0, G_MAXINT); string = g_bytes_get_data (bytes, &len); - g_assert_cmpint (len, ==, 4); - g_assert_cmpstr (string, ==, "abc"); + g_assert_cmpint (len, ==, 8); + g_assert_cmpstr (string, ==, "abc def"); + g_bytes_unref (bytes); + + bytes = gtk_accessible_text_get_contents_at (GTK_ACCESSIBLE_TEXT (label), 1, GTK_ACCESSIBLE_TEXT_GRANULARITY_WORD, &start, &end); + string = g_bytes_get_data (bytes, &len); + g_assert_cmpint (len, ==, 5); + g_assert_cmpint (start, ==, 0); + g_assert_cmpint (end, ==, 4); + g_assert_cmpstr (string, ==, "abc "); g_bytes_unref (bytes); g_assert_cmpint (gtk_accessible_text_get_caret_position (GTK_ACCESSIBLE_TEXT (label)), ==, 2); diff --git a/testsuite/a11y/text.c b/testsuite/a11y/text.c index e90ce425cc..8d30acf840 100644 --- a/testsuite/a11y/text.c +++ b/testsuite/a11y/text.c @@ -87,6 +87,7 @@ test_text_accessible_text (void) PangoAttribute *attr; GtkATContext *context; TestData td = { 0, }; + unsigned int start, end; g_object_ref_sink (text); @@ -99,13 +100,13 @@ test_text_accessible_text (void) test_data_clear (&td); - gtk_editable_set_text (GTK_EDITABLE (text), "abc"); + gtk_editable_set_text (GTK_EDITABLE (text), "abc def"); g_assert_cmpuint (td.update_text_contents_count, ==, 1); g_assert_cmpuint (td.change, ==, GTK_ACCESSIBLE_TEXT_CONTENT_CHANGE_INSERT); g_assert_cmpuint (td.start, ==, 0); - g_assert_cmpuint (td.end, ==, 3); - g_assert_cmpstr ("abc", ==, g_bytes_get_data (td.contents, NULL)); + g_assert_cmpuint (td.end, ==, 7); + g_assert_cmpstr ("abc def", ==, g_bytes_get_data (td.contents, NULL)); attrs = pango_attr_list_new (); attr = pango_attr_underline_new (PANGO_UNDERLINE_DOUBLE); @@ -124,8 +125,16 @@ test_text_accessible_text (void) bytes = gtk_accessible_text_get_contents (GTK_ACCESSIBLE_TEXT (text), 0, G_MAXINT); string = g_bytes_get_data (bytes, &len); - g_assert_cmpint (len, ==, 4); - g_assert_cmpstr (string, ==, "abc"); + g_assert_cmpint (len, ==, 8); + g_assert_cmpstr (string, ==, "abc def"); + g_bytes_unref (bytes); + + bytes = gtk_accessible_text_get_contents_at (GTK_ACCESSIBLE_TEXT (text), 1, GTK_ACCESSIBLE_TEXT_GRANULARITY_WORD, &start, &end); + string = g_bytes_get_data (bytes, &len); + g_assert_cmpint (len, ==, 5); + g_assert_cmpint (start, ==, 0); + g_assert_cmpint (end, ==, 4); + g_assert_cmpstr (string, ==, "abc "); g_bytes_unref (bytes); g_assert_cmpint (gtk_accessible_text_get_caret_position (GTK_ACCESSIBLE_TEXT (text)), ==, 2); diff --git a/testsuite/a11y/textview.c b/testsuite/a11y/textview.c index 8dc94cbde9..615dc41693 100644 --- a/testsuite/a11y/textview.c +++ b/testsuite/a11y/textview.c @@ -115,6 +115,7 @@ textview_accessible_text (void) GtkTextBuffer *buffer; GtkTextTag *tag; GtkTextIter start, end; + unsigned int start_index, end_index; g_object_ref_sink (widget); @@ -129,13 +130,13 @@ textview_accessible_text (void) test_data_clear (&td); - gtk_text_buffer_set_text (buffer, "abc", -1); + gtk_text_buffer_set_text (buffer, "abc def", -1); g_assert_cmpuint (td.update_text_contents_count, ==, 1); g_assert_cmpuint (td.change, ==, GTK_ACCESSIBLE_TEXT_CONTENT_CHANGE_INSERT); g_assert_cmpuint (td.start, ==, 0); - g_assert_cmpuint (td.end, ==, 3); - g_assert_cmpstr ("abc", ==, g_bytes_get_data (td.contents, NULL)); + g_assert_cmpuint (td.end, ==, 7); + g_assert_cmpstr ("abc def", ==, g_bytes_get_data (td.contents, NULL)); tag = gtk_text_tag_new ("uline"); g_object_set (tag, "underline", PANGO_UNDERLINE_DOUBLE, NULL); @@ -157,8 +158,16 @@ textview_accessible_text (void) bytes = gtk_accessible_text_get_contents (GTK_ACCESSIBLE_TEXT (widget), 0, G_MAXINT); string = g_bytes_get_data (bytes, &len); - g_assert_cmpint (len, ==, 4); - g_assert_cmpstr (string, ==, "abc"); + g_assert_cmpint (len, ==, 8); + g_assert_cmpstr (string, ==, "abc def"); + g_bytes_unref (bytes); + + bytes = gtk_accessible_text_get_contents_at (GTK_ACCESSIBLE_TEXT (widget), 1, GTK_ACCESSIBLE_TEXT_GRANULARITY_WORD, &start_index, &end_index); + string = g_bytes_get_data (bytes, &len); + g_assert_cmpint (len, ==, 5); + g_assert_cmpint (start_index, ==, 0); + g_assert_cmpint (end_index, ==, 4); + g_assert_cmpstr (string, ==, "abc "); g_bytes_unref (bytes); res = gtk_accessible_text_get_selection (GTK_ACCESSIBLE_TEXT (widget), &n_ranges, &ranges);