summaryrefslogtreecommitdiff
path: root/Source/WebKit/gtk/tests/testatk.c
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/gtk/tests/testatk.c')
-rw-r--r--Source/WebKit/gtk/tests/testatk.c59
1 files changed, 56 insertions, 3 deletions
diff --git a/Source/WebKit/gtk/tests/testatk.c b/Source/WebKit/gtk/tests/testatk.c
index 2463c74a5..759da1771 100644
--- a/Source/WebKit/gtk/tests/testatk.c
+++ b/Source/WebKit/gtk/tests/testatk.c
@@ -65,7 +65,7 @@ static const char* linksWithInlineImages = "<html><head><style>a.http:before {co
static const char* listsOfItems = "<html><body><ul><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ul><ol><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ol></body></html>";
-static const char* textForCaretBrowsing = "<html><body><h1>A text header</h1><p>A paragraph <a href='http://foo.bar.baz/'>with a link</a> in the middle</p><ol><li>A list item</li></ol><select><option selected value='foo'>An option in a combo box</option></select><input type='text'' name='foo'' value='foo bar baz' /><table><tr><td>a table cell</td></tr></table></body></html>";
+static const char* textForCaretBrowsing = "<html><body><h1>A text header</h1><p>A paragraph <a href='http://foo.bar.baz/'>with a link</a> in the middle</p><ol><li>A list item</li><li><span style='display:block;'>Block span in a list item</span><span>Inline span in a list item</span></li><li><a href='foo'><span style='display:block;'>Block span in a link in a list item</span><span>Inline span in a link in a list item</span></a></li></ol><select><option selected value='foo'>An option in a combo box</option></select><input type='text' name='foo' value='foo bar baz' /><table><tr><td>a table cell</td><td></td><td><a href='foo'><span style='display:block;'>Block span in a link in a table cell</span><span>Inline span in a link in a table cell</span></a></td><td><span style='display:block;'>Block span in a table cell</span><span>Inline span in a table cell</span></td></tr></table><h4><a href='foo'><span style='display:block;'>Block span in a link in a heading</span><span>Inline span in a link in a heading</span></h4><h4><span style='display:block;'>Block span in a heading</span><span>Inline span in a heading</span></h4></body></html>";
static const char* textForSelections = "<html><body><p>A paragraph with plain text</p><p>A paragraph with <a href='http://webkit.org'>a link</a> in the middle</p><ol><li>A list item</li></ol><select></body></html>";
@@ -336,7 +336,7 @@ static void testWebkitAtkCaretOffsets()
AtkObject* list = atk_object_ref_accessible_child(object, 2);
g_assert(ATK_OBJECT(list));
g_assert(atk_object_get_role(list) == ATK_ROLE_LIST);
- g_assert_cmpint(atk_object_get_n_accessible_children(list), ==, 1);
+ g_assert_cmpint(atk_object_get_n_accessible_children(list), ==, 3);
AtkObject* listItem = atk_object_ref_accessible_child(list, 0);
g_assert(ATK_IS_TEXT(listItem));
@@ -344,6 +344,18 @@ static void testWebkitAtkCaretOffsets()
g_assert_cmpstr(text, ==, "1. A list item");
g_free (text);
+ listItem = atk_object_ref_accessible_child(list, 1);
+ g_assert(ATK_IS_TEXT(listItem));
+ text = atk_text_get_text(ATK_TEXT(listItem), 0, -1);
+ g_assert_cmpstr(text, ==, "2. Block span in a list item\nInline span in a list item");
+ g_free (text);
+
+ listItem = atk_object_ref_accessible_child(list, 2);
+ g_assert(ATK_IS_TEXT(listItem));
+ text = atk_text_get_text(ATK_TEXT(listItem), 0, -1);
+ g_assert_cmpstr(text, ==, "3. Block span in a link in a list item\nInline span in a link in a list item");
+ g_free (text);
+
/* It's not possible to place the caret inside an item's marker. */
result = atk_text_set_caret_offset(ATK_TEXT(listItem), 1);
g_assert_cmpint(result, ==, FALSE);
@@ -360,10 +372,12 @@ static void testWebkitAtkCaretOffsets()
AtkObject* comboBox = atk_object_ref_accessible_child(panel, 0);
g_assert(ATK_IS_OBJECT(comboBox));
+ g_assert(!ATK_IS_TEXT(comboBox));
g_assert(atk_object_get_role(comboBox) == ATK_ROLE_COMBO_BOX);
AtkObject* menuPopup = atk_object_ref_accessible_child(comboBox, 0);
g_assert(ATK_IS_OBJECT(menuPopup));
+ g_assert(!ATK_IS_TEXT(menuPopup));
g_assert(atk_object_get_role(menuPopup) == ATK_ROLE_MENU);
AtkObject* comboBoxOption = atk_object_ref_accessible_child(menuPopup, 0);
@@ -372,6 +386,7 @@ static void testWebkitAtkCaretOffsets()
g_assert(ATK_IS_TEXT(comboBoxOption));
text = atk_text_get_text(ATK_TEXT(comboBoxOption), 0, -1);
g_assert_cmpstr(text, ==, "An option in a combo box");
+ g_free(text);
/* It's not possible to place the caret inside an option for a combobox. */
result = atk_text_set_caret_offset(ATK_TEXT(comboBoxOption), 1);
@@ -383,6 +398,7 @@ static void testWebkitAtkCaretOffsets()
g_assert(ATK_IS_TEXT(textEntry));
text = atk_text_get_text(ATK_TEXT(textEntry), 0, -1);
g_assert_cmpstr(text, ==, "foo bar baz");
+ g_free(text);
result = atk_text_set_caret_offset(ATK_TEXT(textEntry), 5);
g_assert_cmpint(result, ==, TRUE);
@@ -391,8 +407,9 @@ static void testWebkitAtkCaretOffsets()
AtkObject* table = atk_object_ref_accessible_child(object, 4);
g_assert(ATK_IS_OBJECT(table));
+ g_assert(!ATK_IS_TEXT(table));
g_assert(atk_object_get_role(table) == ATK_ROLE_TABLE);
- g_assert_cmpint(atk_object_get_n_accessible_children(table), ==, 1);
+ g_assert_cmpint(atk_object_get_n_accessible_children(table), ==, 4);
AtkObject* tableCell = atk_object_ref_accessible_child(table, 0);
g_assert(ATK_IS_TEXT(tableCell));
@@ -406,6 +423,42 @@ static void testWebkitAtkCaretOffsets()
offset = atk_text_get_caret_offset(ATK_TEXT(tableCell));
g_assert_cmpint(offset, ==, 2);
+ /* Even empty table cells should implement AtkText, but report an empty string */
+ tableCell = atk_object_ref_accessible_child(table, 1);
+ g_assert(ATK_IS_TEXT(tableCell));
+ g_assert(atk_object_get_role(tableCell) == ATK_ROLE_TABLE_CELL);
+ text = atk_text_get_text(ATK_TEXT(tableCell), 0, -1);
+ g_assert_cmpstr(text, ==, "");
+ g_free(text);
+
+ tableCell = atk_object_ref_accessible_child(table, 2);
+ g_assert(ATK_IS_TEXT(tableCell));
+ g_assert(atk_object_get_role(tableCell) == ATK_ROLE_TABLE_CELL);
+ text = atk_text_get_text(ATK_TEXT(tableCell), 0, -1);
+ g_assert_cmpstr(text, ==, "Block span in a link in a table cell\nInline span in a link in a table cell");
+ g_free(text);
+
+ tableCell = atk_object_ref_accessible_child(table, 3);
+ g_assert(ATK_IS_TEXT(tableCell));
+ g_assert(atk_object_get_role(tableCell) == ATK_ROLE_TABLE_CELL);
+ text = atk_text_get_text(ATK_TEXT(tableCell), 0, -1);
+ g_assert_cmpstr(text, ==, "Block span in a table cell\nInline span in a table cell");
+ g_free(text);
+
+ header = atk_object_ref_accessible_child(object, 5);
+ g_assert(ATK_IS_TEXT(header));
+ g_assert(atk_object_get_role(header) == ATK_ROLE_HEADING);
+ text = atk_text_get_text(ATK_TEXT(header), 0, -1);
+ g_assert_cmpstr(text, ==, "Block span in a link in a heading\nInline span in a link in a heading");
+ g_free(text);
+
+ header = atk_object_ref_accessible_child(object, 6);
+ g_assert(ATK_IS_TEXT(header));
+ g_assert(atk_object_get_role(header) == ATK_ROLE_HEADING);
+ text = atk_text_get_text(ATK_TEXT(header), 0, -1);
+ g_assert_cmpstr(text, ==, "Block span in a heading\nInline span in a heading");
+ g_free(text);
+
g_free(textCaretMovedResult);
g_object_unref(header);