AX: [ATK] Convert the get_text atktest.c unit tests to layout tests
authorjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Dec 2013 15:44:30 +0000 (15:44 +0000)
committerjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Dec 2013 15:44:30 +0000 (15:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125497

Reviewed by Mario Sanchez Prada.

Source/WebKit/gtk:

* tests/testatk.c: Remove the portions of the remaining tests which now exist as
layout tests.
(testWebkitAtkCaretOffsets):
(testWebkitAtkCaretOffsetsAndExtranousWhiteSpaces):
(testWebkitAtkComboBox):
(testWebkitAtkEmbeddedObjects):
(testWebkitAtkTextSelections):
(testWebkitAtkListsOfItems):
(main):

Tools:

* DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
(AccessibilityUIElement::stringForRange): Implemented.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::stringForRange): Implemented.

LayoutTests:

* platform/gtk/accessibility/text-for-range-combo-box-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-combo-box.html: Added.
* platform/gtk/accessibility/text-for-range-embedded-objects-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-embedded-objects.html: Added.
* platform/gtk/accessibility/text-for-range-entry-and-password-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-entry-and-password.html: Added.
* platform/gtk/accessibility/text-for-range-extraneous-whitespace-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-extraneous-whitespace.html: Added.
* platform/gtk/accessibility/text-for-range-formatted-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-formatted.html: Added.
* platform/gtk/accessibility/text-for-range-heading-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-heading.html: Added.
* platform/gtk/accessibility/text-for-range-list-items-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-list-items.html: Added.
* platform/gtk/accessibility/text-for-range-simple-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-simple.html: Added.
* platform/gtk/accessibility/text-for-range-table-cells-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-table-cells.html: Added.
* platform/gtk/accessibility/text-for-range-with-link-expected.txt: Added.
* platform/gtk/accessibility/text-for-range-with-link.html: Added.
* platform/gtk/accessibility/text-for-table-expected.txt: Added.
* platform/gtk/accessibility/text-for-table.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160365 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/accessibility/text-for-range-combo-box-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-combo-box.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-embedded-objects-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-embedded-objects.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-entry-and-password-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-entry-and-password.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-extraneous-whitespace-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-extraneous-whitespace.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-formatted-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-formatted.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-heading-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-heading.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-list-items-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-list-items.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-simple-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-simple.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-table-cells-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-table-cells.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-with-link-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-range-with-link.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-table-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/text-for-table.html [new file with mode: 0644]
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/tests/testatk.c
Tools/ChangeLog
Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

index 5dc3f77..32189c6 100644 (file)
@@ -1,3 +1,33 @@
+2013-12-10  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Convert the get_text atktest.c unit tests to layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=125497
+
+        Reviewed by Mario Sanchez Prada.
+
+        * platform/gtk/accessibility/text-for-range-combo-box-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-combo-box.html: Added.
+        * platform/gtk/accessibility/text-for-range-embedded-objects-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-embedded-objects.html: Added.
+        * platform/gtk/accessibility/text-for-range-entry-and-password-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-entry-and-password.html: Added.
+        * platform/gtk/accessibility/text-for-range-extraneous-whitespace-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-extraneous-whitespace.html: Added.
+        * platform/gtk/accessibility/text-for-range-formatted-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-formatted.html: Added.
+        * platform/gtk/accessibility/text-for-range-heading-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-heading.html: Added.
+        * platform/gtk/accessibility/text-for-range-list-items-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-list-items.html: Added.
+        * platform/gtk/accessibility/text-for-range-simple-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-simple.html: Added.
+        * platform/gtk/accessibility/text-for-range-table-cells-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-table-cells.html: Added.
+        * platform/gtk/accessibility/text-for-range-with-link-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-range-with-link.html: Added.
+        * platform/gtk/accessibility/text-for-table-expected.txt: Added.
+        * platform/gtk/accessibility/text-for-table.html: Added.
+
 2013-12-10  Krzysztof Czech  <k.czech@samsung.com>
 
         [ATK] accessibility/alt-tag-on-image-with-nonimage-role.html is failing after r160311
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-combo-box-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-combo-box-expected.txt
new file mode 100644 (file)
index 0000000..6364d4c
--- /dev/null
@@ -0,0 +1,19 @@
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS combobox.stringForRange(0, -1) is ''
+PASS popup.stringForRange(0, -1) is ''
+PASS option.stringForRange(0, -1) is 'An option in a combo box'
+PASS combobox.stringForRange(0, -1) is ''
+PASS popup.stringForRange(0, -1) is ''
+PASS option.stringForRange(0, -1) is 'foo'
+PASS option.stringForRange(0, 2) is 'fo'
+PASS option.stringForRange(0, -1) is 'bar'
+PASS option.stringForRange(1, 3) is 'ar'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-combo-box.html b/LayoutTests/platform/gtk/accessibility/text-for-range-combo-box.html
new file mode 100644 (file)
index 0000000..5c6fdd6
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<select><option selected value='foo'>An option in a combo box</option></select>
+<select><option selected value='foo'>foo</option><option value='bar'>bar</option></select>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var panel = webArea.childAtIndex(0);
+
+        var combobox = panel.childAtIndex(0);
+        var popup = combobox.childAtIndex(0);
+        var option = popup.childAtIndex(0);
+
+        shouldBe("combobox.stringForRange(0, -1)", "''");
+        shouldBe("popup.stringForRange(0, -1)", "''");
+        shouldBe("option.stringForRange(0, -1)", "'An option in a combo box'");
+
+        combobox = panel.childAtIndex(1);
+        popup = combobox.childAtIndex(0);
+        option = popup.childAtIndex(0);
+
+        shouldBe("combobox.stringForRange(0, -1)", "''");
+        shouldBe("popup.stringForRange(0, -1)", "''");
+        shouldBe("option.stringForRange(0, -1)", "'foo'");
+        shouldBe("option.stringForRange(0, 2)", "'fo'");
+
+        option = popup.childAtIndex(1);
+        shouldBe("option.stringForRange(0, -1)", "'bar'");
+        shouldBe("option.stringForRange(1, 3)", "'ar'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-embedded-objects-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-embedded-objects-expected.txt
new file mode 100644 (file)
index 0000000..4d38290
--- /dev/null
@@ -0,0 +1,18 @@
+Choose: foo bar (pick one)
+
+Choose:  (pick one)
+
+
+
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS paragraph1.stringForRange(0, -1) is 'Choose: ï¿¼foo ï¿¼bar (pick one)'
+PASS paragraph2.stringForRange(0, -1) is 'Choose: ï¿¼ (pick one)'
+PASS paragraph3.stringForRange(0, -1) is ''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-embedded-objects.html b/LayoutTests/platform/gtk/accessibility/text-for-range-embedded-objects.html
new file mode 100644 (file)
index 0000000..e217ddf
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+  <p>Choose: <input value='foo' type='checkbox'/>foo <input value='bar' type='checkbox'/>bar (pick one)</p>
+  <p>Choose: <select name='foo'><option>bar</option><option>baz</option></select> (pick one)</p>
+  <p><input name='foobarbutton' value='foobar' type='button'/></p>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+
+        var paragraph1 = webArea.childAtIndex(0);
+        var paragraph2 = webArea.childAtIndex(1);
+        var paragraph3 = webArea.childAtIndex(2);
+        shouldBe("paragraph1.stringForRange(0, -1)", "'Choose: \357\277\274foo \357\277\274bar (pick one)'");
+        shouldBe("paragraph2.stringForRange(0, -1)", "'Choose: \357\277\274 (pick one)'");
+        shouldBe("paragraph3.stringForRange(0, -1)", "'\357\277\274'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-entry-and-password-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-entry-and-password-expected.txt
new file mode 100644 (file)
index 0000000..f7b7b2b
--- /dev/null
@@ -0,0 +1,12 @@
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS entry.stringForRange(0, -1) is 'foo bar baz'
+PASS password.stringForRange(0, -1) is 'â\80¢â\80¢â\80¢â\80¢â\80¢â\80¢â\80¢â\80¢â\80¢â\80¢â\80¢'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-entry-and-password.html b/LayoutTests/platform/gtk/accessibility/text-for-range-entry-and-password.html
new file mode 100644 (file)
index 0000000..93eb669
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<input type='text' name='foo' value='foo bar baz' />
+<input type='password' name='bar' value='foo bar baz' />
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var panel = webArea.childAtIndex(0);
+        var entry = panel.childAtIndex(0);
+        var password = panel.childAtIndex(1);
+        shouldBe("entry.stringForRange(0, -1)", "'foo bar baz'");
+        shouldBe("password.stringForRange(0, -1)", "'\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242\342\200\242'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-extraneous-whitespace-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-extraneous-whitespace-expected.txt
new file mode 100644 (file)
index 0000000..71ebdf6
--- /dev/null
@@ -0,0 +1,12 @@
+This paragraph is borked!
+
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS paragraph.stringForRange(0, 25) is 'This paragraph is borked!'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-extraneous-whitespace.html b/LayoutTests/platform/gtk/accessibility/text-for-range-extraneous-whitespace.html
new file mode 100644 (file)
index 0000000..b02b4b5
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<p>This
+                          paragraph
+                                                      is
+                                                                                                                                                                                                                                                                                                                                                                            borked!</p>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var paragraph = webArea.childAtIndex(0);
+        shouldBe("paragraph.stringForRange(0, 25)", "'This paragraph is borked!'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-formatted-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-formatted-expected.txt
new file mode 100644 (file)
index 0000000..3abcc3c
--- /dev/null
@@ -0,0 +1,16 @@
+This is a test.
+
+Hello world.
+This sentence is green.
+This one is not.
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS paragraph.stringForRange(0, -1) is 'This is a test.'
+PASS block.stringForRange(0, 53) is 'Hello world.\nThis sentence is green.\nThis one is not.'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-formatted.html b/LayoutTests/platform/gtk/accessibility/text-for-range-formatted.html
new file mode 100644 (file)
index 0000000..2c3d6f3
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<p id="content">This is a test.</p>Hello world.<br /><font color='#00cc00'>This sentence is green.</font><br />This one is not.
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var paragraph = webArea.childAtIndex(0);
+        var block = webArea.childAtIndex(1);
+        shouldBe("paragraph.stringForRange(0, -1)", "'This is a test.'");
+        shouldBe("block.stringForRange(0, 53)", "'Hello world.\\nThis sentence is green.\\nThis one is not.'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-heading-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-heading-expected.txt
new file mode 100644 (file)
index 0000000..cd28e63
--- /dev/null
@@ -0,0 +1,20 @@
+A text header
+
+Block span in a link in a heading
+Inline span in a link in a heading
+
+Block span in a heading
+Inline span in a heading
+
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS heading1.stringForRange(0, -1) is 'A text header'
+PASS heading2.stringForRange(0, -1) is 'Block span in a link in a heading\nInline span in a link in a heading'
+PASS heading3.stringForRange(0, -1) is 'Block span in a heading\nInline span in a heading'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-heading.html b/LayoutTests/platform/gtk/accessibility/text-for-range-heading.html
new file mode 100644 (file)
index 0000000..f75cf73
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<h1>A text header</h1>
+<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></a></h4>
+<h4><span style='display:block;'>Block span in a heading</span><span>Inline span in a heading</span></h4>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+
+        var heading1 = webArea.childAtIndex(0);
+        var heading2 = webArea.childAtIndex(1);
+        var heading3 = webArea.childAtIndex(2);
+        shouldBe("heading1.stringForRange(0, -1)", "'A text header'");
+        shouldBe("heading2.stringForRange(0, -1)", "'Block span in a link in a heading\\nInline span in a link in a heading'");
+        shouldBe("heading3.stringForRange(0, -1)", "'Block span in a heading\\nInline span in a heading'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-list-items-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-list-items-expected.txt
new file mode 100644 (file)
index 0000000..015209f
--- /dev/null
@@ -0,0 +1,29 @@
+A list item
+Block span in a list item
+Inline span in a list item
+Block span in a link in a list item
+Inline span in a link in a list item
+text only
+link only
+text and a link
+text only
+link only
+text and a link
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS listitem1.stringForRange(0, -1) is '1. A list item'
+PASS listitem2.stringForRange(0, -1) is '2. Block span in a list item\nInline span in a list item'
+PASS listitem3.stringForRange(0, -1) is '3. Block span in a link in a list item\nInline span in a link in a list item'
+PASS listitem1.stringForRange(0, -1) is 'â\80¢ text only'
+PASS listitem2.stringForRange(0, -1) is 'â\80¢ link only'
+PASS listitem3.stringForRange(0, -1) is 'â\80¢ text and a link'
+PASS listitem1.stringForRange(0, -1) is '1. text only'
+PASS listitem2.stringForRange(0, -1) is '2. link only'
+PASS listitem3.stringForRange(0, -1) is '3. text and a link'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-list-items.html b/LayoutTests/platform/gtk/accessibility/text-for-range-list-items.html
new file mode 100644 (file)
index 0000000..ca9b648
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<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>
+<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>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+
+        var list = webArea.childAtIndex(0);
+        var listitem1 = list.childAtIndex(0);
+        var listitem2 = list.childAtIndex(1);
+        var listitem3 = list.childAtIndex(2);
+        shouldBe("listitem1.stringForRange(0, -1)", "'1. A list item'");
+        shouldBe("listitem2.stringForRange(0, -1)", "'2. Block span in a list item\\nInline span in a list item'");
+        shouldBe("listitem3.stringForRange(0, -1)", "'3. Block span in a link in a list item\\nInline span in a link in a list item'");
+
+        list = webArea.childAtIndex(1);
+        listitem1 = list.childAtIndex(0);
+        listitem2 = list.childAtIndex(1);
+        listitem3 = list.childAtIndex(2);
+        shouldBe("listitem1.stringForRange(0, -1)", "'\342\200\242 text only'");
+        shouldBe("listitem2.stringForRange(0, -1)", "'\342\200\242 link only'");
+        shouldBe("listitem3.stringForRange(0, -1)", "'\342\200\242 text and a link'");
+
+        list = webArea.childAtIndex(2);
+        listitem1 = list.childAtIndex(0);
+        listitem2 = list.childAtIndex(1);
+        listitem3 = list.childAtIndex(2);
+        shouldBe("listitem1.stringForRange(0, -1)", "'1. text only'");
+        shouldBe("listitem2.stringForRange(0, -1)", "'2. link only'");
+        shouldBe("listitem3.stringForRange(0, -1)", "'3. text and a link'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-simple-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-simple-expected.txt
new file mode 100644 (file)
index 0000000..b67c921
--- /dev/null
@@ -0,0 +1,14 @@
+This is a test.
+
+Hello world.
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS paragraph.stringForRange(0, -1) is 'This is a test.'
+PASS block.stringForRange(0, 12) is 'Hello world.'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-simple.html b/LayoutTests/platform/gtk/accessibility/text-for-range-simple.html
new file mode 100644 (file)
index 0000000..d5ed603
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<p id="content">This is a test.</p>Hello world.
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var paragraph = webArea.childAtIndex(0);
+        var block = webArea.childAtIndex(1);
+        shouldBe("paragraph.stringForRange(0, -1)", "'This is a test.'");
+        shouldBe("block.stringForRange(0, 12)", "'Hello world.'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-table-cells-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-table-cells-expected.txt
new file mode 100644 (file)
index 0000000..fd21d7e
--- /dev/null
@@ -0,0 +1,18 @@
+a table cell           
+Block span in a link in a table cell
+Inline span in a link in a table cell  
+Block span in a table cell
+Inline span in a table cell
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS cell1.stringForRange(0, -1) is 'a table cell'
+PASS cell2.stringForRange(0, -1) is ''
+PASS cell3.stringForRange(0, -1) is 'Block span in a link in a table cell\nInline span in a link in a table cell'
+PASS cell4.stringForRange(0, -1) is 'Block span in a table cell\nInline span in a table cell'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-table-cells.html b/LayoutTests/platform/gtk/accessibility/text-for-range-table-cells.html
new file mode 100644 (file)
index 0000000..9f8235f
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<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>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var table = webArea.childAtIndex(0);
+        var cell1 = table.childAtIndex(0);
+        var cell2 = table.childAtIndex(1);
+        var cell3 = table.childAtIndex(2);
+        var cell4 = table.childAtIndex(3);
+        shouldBe("cell1.stringForRange(0, -1)", "'a table cell'");
+        shouldBe("cell2.stringForRange(0, -1)", "''");
+        shouldBe("cell3.stringForRange(0, -1)", "'Block span in a link in a table cell\\nInline span in a link in a table cell'");
+        shouldBe("cell4.stringForRange(0, -1)", "'Block span in a table cell\\nInline span in a table cell'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-with-link-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-range-with-link-expected.txt
new file mode 100644 (file)
index 0000000..0742ed7
--- /dev/null
@@ -0,0 +1,13 @@
+A paragraph with a link in the middle
+
+This tests the ability to get element text for a specified range.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS paragraph.stringForRange(0, -1) is 'A paragraph with a link in the middle'
+PASS link.stringForRange(0, -1) is 'a link'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-range-with-link.html b/LayoutTests/platform/gtk/accessibility/text-for-range-with-link.html
new file mode 100644 (file)
index 0000000..813877f
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<p id="content">A paragraph with <a href='http://webkit.org'>a link</a> in the middle</p>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+
+        var paragraph = webArea.childAtIndex(0);
+        shouldBe("paragraph.stringForRange(0, -1)", "'A paragraph with a link in the middle'");
+
+        var link = paragraph.childAtIndex(0);
+        shouldBe("link.stringForRange(0, -1)", "'a link'");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-table-expected.txt b/LayoutTests/platform/gtk/accessibility/text-for-table-expected.txt
new file mode 100644 (file)
index 0000000..b21d2a4
--- /dev/null
@@ -0,0 +1,11 @@
+foo    bar
+This tests the ability to get element text for a specified range. No text should be obtainable for tables which should not implement the text interface.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS table.stringForRange(0, -1) is ''
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/gtk/accessibility/text-for-table.html b/LayoutTests/platform/gtk/accessibility/text-for-table.html
new file mode 100644 (file)
index 0000000..0877211
--- /dev/null
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<table id="content"><tr><td>foo</td><td>bar</td></tr></table>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests the ability to get element text for a specified range. No text should be obtainable for tables which should not implement the text interface.");
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var webArea = accessibilityController.focusedElement;
+        var table = webArea.childAtIndex(0);
+        shouldBe("table.stringForRange(0, -1)", "''");
+    }
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index ce289b2..cbdfe28 100644 (file)
@@ -1,3 +1,20 @@
+2013-12-10  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Convert the get_text atktest.c unit tests to layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=125497
+
+        Reviewed by Mario Sanchez Prada.
+
+        * tests/testatk.c: Remove the portions of the remaining tests which now exist as
+        layout tests.
+        (testWebkitAtkCaretOffsets):
+        (testWebkitAtkCaretOffsetsAndExtranousWhiteSpaces):
+        (testWebkitAtkComboBox):
+        (testWebkitAtkEmbeddedObjects):
+        (testWebkitAtkTextSelections):
+        (testWebkitAtkListsOfItems):
+        (main):
+
 2013-12-09  Joanmarie Diggs  <jdiggs@igalia.com>
 
         AX: [ATK] Convert the get_{string,text}_at_offset atktest.c unit tests to layout tests
index 0fd993c..bd04177 100644 (file)
@@ -31,12 +31,6 @@ static const char* centeredContents = "<html><body><p style='text-align: center;
 
 static const char* contents = "<html><body><p>This is a test. This is the second sentence. And this the third.</p></body></html>";
 
-static const char* contentsInParagraphAndBodySimple = "<html><body><p>This is a test.</p>Hello world.</body></html>";
-
-static const char* contentsInParagraphAndBodyModerate = "<html><body><p>This is a test.</p>Hello world.<br /><font color='#00cc00'>This sentence is green.</font><br />This one is not.</body></html>";
-
-static const char* contentsInTable = "<html><body><table><tr><td>foo</td><td>bar</td></tr></table></body></html>";
-
 static const char* contentsInTableWithHeaders = "<html><body><table><tr><th>foo</th><th>bar</th><th colspan='2'>baz</th></tr><tr><th>qux</th><td>1</td><td>2</td><td>3</td></tr><tr><th rowspan='2'>quux</th><td>4</td><td>5</td><td>6</td></tr><tr><td>6</td><td>7</td><td>8</td></tr><tr><th>corge</th><td>9</td><td>10</td><td>11</td></tr></table><table><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table></body></html>";
 
 static const char* contentsWithExtraneousWhiteSpaces = "<html><head><body><p>This\n                          paragraph\n                                                      is\n                                                                                                                                                                                                                                                                                                                                                                            borked!</p></body></html>";
@@ -108,10 +102,6 @@ static void testWebkitAtkCaretOffsets()
     g_assert(ATK_IS_TEXT(header));
     g_signal_connect(header, "text-caret-moved", G_CALLBACK(textCaretMovedCallback), 0);
 
-    gchar* text = atk_text_get_text(ATK_TEXT(header), 0, -1);
-    g_assert_cmpstr(text, ==, "A text header");
-    g_free (text);
-
     /* It should be possible to place the caret inside a header. */
     gboolean result = atk_text_set_caret_offset(ATK_TEXT(header), 5);
     g_assert_cmpint(result, ==, TRUE);
@@ -123,10 +113,6 @@ static void testWebkitAtkCaretOffsets()
     g_assert(ATK_IS_TEXT(paragraph));
     g_signal_connect(paragraph, "text-caret-moved", G_CALLBACK(textCaretMovedCallback), 0);
 
-    text = atk_text_get_text(ATK_TEXT(paragraph), 0, -1);
-    g_assert_cmpstr(text, ==, "A paragraph with a link in the middle");
-    g_free (text);
-
     /* It should be possible to place the caret inside a paragraph and a link. */
     result = atk_text_set_caret_offset(ATK_TEXT(paragraph), 5);
     g_assert_cmpint(result, ==, TRUE);
@@ -148,9 +134,6 @@ static void testWebkitAtkCaretOffsets()
 
     AtkObject* link = atk_object_ref_accessible_child(paragraph, 0);
     g_assert(ATK_IS_TEXT(link));
-    text = atk_text_get_text(ATK_TEXT(link), 0, -1);
-    g_assert_cmpstr(text, ==, "with a link");
-    g_free (text);
 
     result = atk_text_set_caret_offset(ATK_TEXT(link), 5);
     g_assert_cmpint(result, ==, TRUE);
@@ -165,24 +148,8 @@ static void testWebkitAtkCaretOffsets()
     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));
-    text = atk_text_get_text(ATK_TEXT(listItem), 0, -1);
-    g_assert_cmpstr(text, ==, "1. A list item");
-    g_free (text);
-    g_object_unref(listItem);
-
-    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);
-    g_object_unref(listItem);
-
     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);
@@ -200,21 +167,15 @@ 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);
     g_assert(ATK_IS_OBJECT(comboBoxOption));
     g_assert(atk_object_get_role(comboBoxOption) == ATK_ROLE_MENU_ITEM);
-    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);
@@ -223,10 +184,6 @@ static void testWebkitAtkCaretOffsets()
     AtkObject* textEntry = atk_object_ref_accessible_child(panel, 1);
     g_assert(ATK_IS_OBJECT(textEntry));
     g_assert(atk_object_get_role(textEntry) == ATK_ROLE_ENTRY);
-    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);
@@ -235,65 +192,18 @@ 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), ==, 4);
 
     AtkObject* tableCell = atk_object_ref_accessible_child(table, 0);
-    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, ==, "a table cell");
-    g_free(text);
-
     result = atk_text_set_caret_offset(ATK_TEXT(tableCell), 2);
     g_assert_cmpint(result, ==, TRUE);
     offset = atk_text_get_caret_offset(ATK_TEXT(tableCell));
     g_assert_cmpint(offset, ==, 2);
-    g_object_unref(tableCell);
-
-    /* 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);
-    g_object_unref(tableCell);
-
-    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);
-    g_object_unref(tableCell);
-
-    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);
-    g_object_unref(header);
-
-    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);
     g_object_unref(paragraph);
     g_object_unref(link);
     g_object_unref(list);
@@ -329,10 +239,6 @@ static void testWebkitAtkCaretOffsetsAndExtranousWhiteSpaces()
     AtkText* textObject = ATK_TEXT(object);
     g_assert(ATK_IS_TEXT(textObject));
 
-    gchar* text = atk_text_get_text(textObject, 0, -1);
-    g_assert_cmpstr(text, ==, "This paragraph is borked!");
-    g_free(text);
-
     gint characterCount = atk_text_get_character_count(textObject);
     g_assert_cmpint(characterCount, ==, 25);
 
@@ -427,25 +333,6 @@ static void testWebkitAtkComboBox()
     g_assert(selectedItem == item2);
     g_object_unref(selectedItem);
 
-    /* Check the implementation of the AtkText interface. */
-    g_assert(ATK_IS_TEXT(item1));
-    AtkText* atkText = ATK_TEXT(item1);
-    char *text = atk_text_get_text(atkText, 0, -1);
-    g_assert_cmpstr(text, ==, "foo");
-    g_free(text);
-    text = atk_text_get_text(atkText, 0, 2);
-    g_assert_cmpstr(text, ==, "fo");
-    g_free(text);
-
-    g_assert(ATK_IS_TEXT(item2));
-    atkText = ATK_TEXT(item2);
-    text = atk_text_get_text(atkText, 0, -1);
-    g_assert_cmpstr(text, ==, "bar");
-    g_free(text);
-    text = atk_text_get_text(atkText, 1, 3);
-    g_assert_cmpstr(text, ==, "ar");
-    g_free(text);
-
     g_object_unref(formObject);
     g_object_unref(comboBox);
     g_object_unref(menuPopup);
@@ -519,11 +406,6 @@ static void testWebkitAtkEmbeddedObjects()
     g_assert(ATK_IS_TEXT(paragraph1));
     g_assert(ATK_IS_HYPERTEXT(paragraph1));
 
-    const gchar* expectedText = "Choose: \357\277\274foo \357\277\274bar (pick one)";
-    char* text = atk_text_get_text(paragraph1, 0, -1);
-    g_assert_cmpstr(text, ==, expectedText);
-    g_free(text);
-
     gint nLinks = atk_hypertext_get_n_links(ATK_HYPERTEXT(paragraph1));
     g_assert_cmpint(nLinks, ==, 2);
 
@@ -538,14 +420,8 @@ static void testWebkitAtkEmbeddedObjects()
     g_assert_cmpstr(atk_hyperlink_get_uri(hLink, 0), ==, 0);
 
     AtkText* paragraph2 = ATK_TEXT(atk_object_ref_accessible_child(object, 1));
-    g_assert(ATK_IS_TEXT(paragraph2));
     g_assert(ATK_IS_HYPERTEXT(paragraph2));
 
-    expectedText = "Choose: \357\277\274 (pick one)";
-    text = atk_text_get_text(paragraph2, 0, -1);
-    g_assert_cmpstr(text, ==, expectedText);
-    g_free(text);
-
     nLinks = atk_hypertext_get_n_links(ATK_HYPERTEXT(paragraph2));
     g_assert_cmpint(nLinks, ==, 1);
 
@@ -560,14 +436,8 @@ static void testWebkitAtkEmbeddedObjects()
     g_assert_cmpstr(atk_hyperlink_get_uri(hLink, 0), ==, 0);
 
     AtkText* paragraph3 = ATK_TEXT(atk_object_ref_accessible_child(object, 2));
-    g_assert(ATK_IS_TEXT(paragraph3));
     g_assert(ATK_IS_HYPERTEXT(paragraph3));
 
-    expectedText = "\357\277\274";
-    text = atk_text_get_text(paragraph3, 0, -1);
-    g_assert_cmpstr(text, ==, expectedText);
-    g_free(text);
-
     nLinks = atk_hypertext_get_n_links(ATK_HYPERTEXT(paragraph3));
     g_assert_cmpint(nLinks, ==, 1);
 
@@ -587,124 +457,6 @@ static void testWebkitAtkEmbeddedObjects()
     g_object_unref(webView);
 }
 
-#if !ATK_CHECK_VERSION(2, 10, 0)
-typedef gchar* (*AtkGetTextFunction) (AtkText*, gint, AtkTextBoundary, gint*, gint*);
-
-static void testGetTextFunction(AtkText* textObject, AtkGetTextFunction fn, AtkTextBoundary boundary, gint offset, const char* textResult, gint startOffsetResult, gint endOffsetResult)
-{
-    gint startOffset;
-    gint endOffset;
-    char* text = fn(textObject, offset, boundary, &startOffset, &endOffset);
-    g_assert_cmpstr(text, ==, textResult);
-    g_assert_cmpint(startOffset, ==, startOffsetResult);
-    g_assert_cmpint(endOffset, ==, endOffsetResult);
-    g_free(text);
-}
-#else // !ATK_CHECK_VERSION(2, 10, 0)
-
-typedef gchar* (*AtkGetStringFunction) (AtkText*, gint, AtkTextGranularity, gint*, gint*);
-
-static void testGetStringFunction(AtkText* textObject, AtkGetStringFunction fn, AtkTextGranularity granularity, gint offset, const char* textResult, gint startOffsetResult, gint endOffsetResult)
-{
-    gint startOffset;
-    gint endOffset;
-    char* text = fn(textObject, offset, granularity, &startOffset, &endOffset);
-    g_assert_cmpstr(text, ==, textResult);
-    g_assert_cmpint(startOffset, ==, startOffsetResult);
-    g_assert_cmpint(endOffset, ==, endOffsetResult);
-    g_free(text);
-}
-
-#endif // !ATK_CHECK_VERSION(2, 10, 0)
-
-static void testWebkitAtkGetTextInParagraphAndBodySimple()
-{
-    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
-    g_object_ref_sink(webView);
-    GtkAllocation allocation = { 0, 0, 800, 600 };
-    gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation);
-    webkit_web_view_load_string(webView, contentsInParagraphAndBodySimple, 0, 0, 0);
-
-    /* Get to the inner AtkText object. */
-    AtkObject* object = getWebAreaObject(webView);
-    g_assert(object);
-    AtkObject* object1 = atk_object_ref_accessible_child(object, 0);
-    g_assert(object1);
-    AtkObject* object2 = atk_object_ref_accessible_child(object, 1);
-    g_assert(object2);
-
-    AtkText* textObject1 = ATK_TEXT(object1);
-    g_assert(ATK_IS_TEXT(textObject1));
-    AtkText* textObject2 = ATK_TEXT(object2);
-    g_assert(ATK_IS_TEXT(textObject2));
-
-    char *text = atk_text_get_text(textObject1, 0, -1);
-    g_assert_cmpstr(text, ==, "This is a test.");
-    g_free(text);
-
-    text = atk_text_get_text(textObject2, 0, 12);
-    g_assert_cmpstr(text, ==, "Hello world.");
-    g_free(text);
-
-    g_object_unref(object1);
-    g_object_unref(object2);
-    g_object_unref(webView);
-}
-
-static void testWebkitAtkGetTextInParagraphAndBodyModerate()
-{
-    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
-    g_object_ref_sink(webView);
-    GtkAllocation allocation = { 0, 0, 800, 600 };
-    gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation);
-    webkit_web_view_load_string(webView, contentsInParagraphAndBodyModerate, 0, 0, 0);
-
-    /* Get to the inner AtkText object. */
-    AtkObject* object = getWebAreaObject(webView);
-    g_assert(object);
-    AtkObject* object1 = atk_object_ref_accessible_child(object, 0);
-    g_assert(object1);
-    AtkObject* object2 = atk_object_ref_accessible_child(object, 1);
-    g_assert(object2);
-
-    AtkText* textObject1 = ATK_TEXT(object1);
-    g_assert(ATK_IS_TEXT(textObject1));
-    AtkText* textObject2 = ATK_TEXT(object2);
-    g_assert(ATK_IS_TEXT(textObject2));
-
-    char *text = atk_text_get_text(textObject1, 0, -1);
-    g_assert_cmpstr(text, ==, "This is a test.");
-    g_free(text);
-
-    text = atk_text_get_text(textObject2, 0, 53);
-    g_assert_cmpstr(text, ==, "Hello world.\nThis sentence is green.\nThis one is not.");
-    g_free(text);
-
-    g_object_unref(object1);
-    g_object_unref(object2);
-    g_object_unref(webView);
-}
-
-static void testWebkitAtkGetTextInTable()
-{
-    WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
-    g_object_ref_sink(webView);
-    GtkAllocation allocation = { 0, 0, 800, 600 };
-    gtk_widget_size_allocate(GTK_WIDGET(webView), &allocation);
-    webkit_web_view_load_string(webView, contentsInTable, 0, 0, 0);
-
-    AtkObject* object = getWebAreaObject(webView);
-    g_assert(object);
-    object = atk_object_ref_accessible_child(object, 0);
-    g_assert(object);
-
-    /* Tables should not implement AtkText. */
-    g_assert(!G_TYPE_INSTANCE_GET_INTERFACE(object, ATK_TYPE_TEXT, AtkTextIface));
-
-    g_object_unref(object);
-    g_object_unref(webView);
-}
-
 static void testWebkitAtkGetHeadersInTable()
 {
     WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
@@ -1093,10 +845,6 @@ static void testWebkitAtkTextSelections()
     g_assert(atk_object_get_role(list) == ATK_ROLE_LIST);
     g_assert_cmpint(atk_object_get_n_accessible_children(list), ==, 1);
 
-    gchar* text = atk_text_get_text(listItem, 0, -1);
-    g_assert_cmpstr(text, ==, "1. A list item");
-    g_free (text);
-
     /* It's not possible to select text inside an item's marker. */
     result = atk_text_set_selection (listItem, 0, 0, 9);
     g_assert(!result);
@@ -1470,26 +1218,13 @@ static void testWebkitAtkListsOfItems()
     g_assert_cmpint(atk_object_get_n_accessible_children(uList), ==, 3);
 
     AtkObject* item1 = atk_object_ref_accessible_child(uList, 0);
-    g_assert(ATK_IS_TEXT(item1));
     AtkObject* item2 = atk_object_ref_accessible_child(uList, 1);
-    g_assert(ATK_IS_TEXT(item2));
     AtkObject* item3 = atk_object_ref_accessible_child(uList, 2);
-    g_assert(ATK_IS_TEXT(item3));
 
     g_assert_cmpint(atk_object_get_n_accessible_children(item1), ==, 0);
     g_assert_cmpint(atk_object_get_n_accessible_children(item2), ==, 1);
     g_assert_cmpint(atk_object_get_n_accessible_children(item3), ==, 1);
 
-    char* text = atk_text_get_text(ATK_TEXT(item1), 0, -1);
-    g_assert_cmpstr(text, ==, "\342\200\242 text only");
-    g_free(text);
-    text = atk_text_get_text(ATK_TEXT(item2), 0, -1);
-    g_assert_cmpstr(text, ==, "\342\200\242 link only");
-    g_free(text);
-    text = atk_text_get_text(ATK_TEXT(item3), 0, -1);
-    g_assert_cmpstr(text, ==, "\342\200\242 text and a link");
-    g_free(text);
-
     g_object_unref(item1);
     g_object_unref(item2);
     g_object_unref(item3);
@@ -1502,21 +1237,8 @@ static void testWebkitAtkListsOfItems()
     g_assert_cmpint(atk_object_get_n_accessible_children(oList), ==, 3);
 
     item1 = atk_object_ref_accessible_child(oList, 0);
-    g_assert(ATK_IS_TEXT(item1));
     item2 = atk_object_ref_accessible_child(oList, 1);
-    g_assert(ATK_IS_TEXT(item2));
     item3 = atk_object_ref_accessible_child(oList, 2);
-    g_assert(ATK_IS_TEXT(item3));
-
-    text = atk_text_get_text(ATK_TEXT(item1), 0, -1);
-    g_assert_cmpstr(text, ==, "1. text only");
-    g_free(text);
-    text = atk_text_get_text(ATK_TEXT(item2), 0, -1);
-    g_assert_cmpstr(text, ==, "2. link only");
-    g_free(text);
-    text = atk_text_get_text(ATK_TEXT(item3), 0, -1);
-    g_assert_cmpstr(text, ==, "3. text and a link");
-    g_free(text);
 
     g_assert_cmpint(atk_object_get_n_accessible_children(item1), ==, 0);
     g_assert_cmpint(atk_object_get_n_accessible_children(item2), ==, 1);
@@ -1738,9 +1460,6 @@ int main(int argc, char** argv)
     g_test_add_func("/webkit/atk/comboBox", testWebkitAtkComboBox);
     g_test_add_func("/webkit/atk/documentLoadingEvents", testWebkitAtkDocumentLoadingEvents);
     g_test_add_func("/webkit/atk/embeddedObjects", testWebkitAtkEmbeddedObjects);
-    g_test_add_func("/webkit/atk/getTextInParagraphAndBodySimple", testWebkitAtkGetTextInParagraphAndBodySimple);
-    g_test_add_func("/webkit/atk/getTextInParagraphAndBodyModerate", testWebkitAtkGetTextInParagraphAndBodyModerate);
-    g_test_add_func("/webkit/atk/getTextInTable", testWebkitAtkGetTextInTable);
     g_test_add_func("/webkit/atk/getHeadersInTable", testWebkitAtkGetHeadersInTable);
     g_test_add_func("/webkit/atk/textAttributes", testWebkitAtkTextAttributes);
     g_test_add_func("/webkit/atk/textSelections", testWebkitAtkTextSelections);
index cd084c3..f684bb6 100644 (file)
@@ -1,3 +1,15 @@
+2013-12-10  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Convert the get_text atktest.c unit tests to layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=125497
+
+        Reviewed by Mario Sanchez Prada.
+
+        * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
+        (AccessibilityUIElement::stringForRange): Implemented.
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+        (WTR::AccessibilityUIElement::stringForRange): Implemented.
+
 2013-12-10  Martin Robinson  <mrobinson@igalia.com>
 
         Various fixes for the CMake GTK+ build
index 3700b4d..09f2766 100644 (file)
@@ -1080,10 +1080,13 @@ JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned l
     return JSStringCreateWithCharacters(0, 0);
 }
 
-JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned) 
+JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
 {
-    // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    if (!ATK_IS_TEXT(m_element))
+        return JSStringCreateWithCharacters(0, 0);
+
+    String string = atk_text_get_text(ATK_TEXT(m_element), location, location + length);
+    return JSStringCreateWithUTF8CString(string.utf8().data());
 } 
 
 JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
index 160167c..dbd9936 100644 (file)
@@ -1147,8 +1147,11 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned locatio
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
 {
-    // FIXME: implement
-    return JSStringCreateWithCharacters(0, 0);
+    if (!ATK_IS_TEXT(m_element.get()))
+        return JSStringCreateWithCharacters(0, 0);
+
+    String string = atk_text_get_text(ATK_TEXT(m_element.get()), location, location + length);
+    return JSStringCreateWithUTF8CString(string.utf8().data());
 }
 
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)