mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
testsuite: test for implementation of accessible_text_get_contents_at
Signed-off-by: Markus Göllnitz <camelcasenick@bewares.it>
This commit is contained in:
parent
ff6451a77e
commit
ab9106ac89
@ -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), "<markup>a<span overline='single'>b</span>c</markup>");
|
||||
gtk_inscription_set_markup (GTK_INSCRIPTION (inscription), "<markup>a<span overline='single'>b</span>c</markup> 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);
|
||||
|
@ -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), "<markup>a<span underline='single'>b</span>c</markup>");
|
||||
gtk_label_set_markup (GTK_LABEL (label), "<markup>a<span underline='single'>b</span>c def</markup>");
|
||||
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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user