| Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
|
| diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
|
| index e00bc138a5c98d88acbce5c508aeb846e947f515..bbfa54b05bb8fb30a9474ac56b757d7c65028515 100644
|
| --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
|
| +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
|
| @@ -36,8 +36,6 @@ import org.chromium.content.browser.ChildProcessConnection;
|
| import org.chromium.content.browser.ChildProcessLauncher;
|
| import org.chromium.content.browser.test.util.CallbackHelper;
|
| import org.chromium.content.common.ContentSwitches;
|
| -import org.chromium.content_public.browser.AccessibilitySnapshotCallback;
|
| -import org.chromium.content_public.browser.AccessibilitySnapshotNode;
|
| import org.chromium.net.test.util.TestWebServer;
|
|
|
| import java.io.InputStream;
|
| @@ -619,306 +617,4 @@ public class AwContentsTest extends AwTestBase {
|
| mContentsClient.getOnEvaluateJavaScriptResultHelper(), "21 + 21"));
|
| }
|
|
|
| - private static class AccessibilityCallbackHelper extends CallbackHelper {
|
| -
|
| - private AccessibilitySnapshotNode mRoot;
|
| -
|
| - public void notifyCalled(AccessibilitySnapshotNode root) {
|
| - mRoot = root;
|
| - super.notifyCalled();
|
| - }
|
| -
|
| - public AccessibilitySnapshotNode getValue() {
|
| - return mRoot;
|
| - }
|
| - }
|
| -
|
| - private float mPageScale;
|
| -
|
| - private AccessibilitySnapshotNode receiveAccessibilitySnapshot(String data, String js)
|
| - throws Throwable {
|
| - final AwTestContainerView testView = createAwTestContainerViewOnMainSync(mContentsClient);
|
| - final AwContents awContents = testView.getAwContents();
|
| - final CallbackHelper loadHelper = mContentsClient.getOnPageFinishedHelper();
|
| - AwSettings awSettings = getAwSettingsOnUiThread(awContents);
|
| - awSettings.setJavaScriptEnabled(true);
|
| - if (data != null) {
|
| - loadDataSync(awContents, loadHelper, data, "text/html", false);
|
| - }
|
| - if (js != null) {
|
| - executeJavaScriptAndWaitForResult(awContents, mContentsClient, js);
|
| - }
|
| -
|
| - final AccessibilityCallbackHelper callbackHelper = new AccessibilityCallbackHelper();
|
| - final AccessibilitySnapshotCallback callback = new AccessibilitySnapshotCallback() {
|
| - @Override
|
| - public void onAccessibilitySnapshot(AccessibilitySnapshotNode root) {
|
| - callbackHelper.notifyCalled(root);
|
| - }
|
| - };
|
| - // read the callbackcount before executing the call on UI thread, since it may
|
| - // synchronously complete.
|
| - final int callbackCount = callbackHelper.getCallCount();
|
| - runTestOnUiThread(new Runnable() {
|
| - @Override
|
| - public void run() {
|
| - awContents.requestAccessibilitySnapshot(callback);
|
| - mPageScale = awContents.getScale();
|
| - }
|
| - });
|
| - callbackHelper.waitForCallback(callbackCount);
|
| - return callbackHelper.getValue();
|
| - }
|
| -
|
| - /**
|
| - * Verifies that AX tree is returned.
|
| - */
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshot() throws Throwable {
|
| - final String data = "<button>Click</button>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - assertEquals(1, child.children.size());
|
| - assertEquals("", child.text);
|
| - AccessibilitySnapshotNode grandChild = child.children.get(0);
|
| - assertEquals(0, grandChild.children.size());
|
| - assertEquals("Click", grandChild.text);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotColors() throws Throwable {
|
| - final String data = "<p style=\"color:#123456;background:#abcdef\">color</p>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - assertEquals("color", child.text);
|
| - assertTrue(child.hasStyle);
|
| - assertEquals("ff123456", Integer.toHexString(child.color));
|
| - assertEquals("ffabcdef", Integer.toHexString(child.bgcolor));
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotFontSize() throws Throwable {
|
| - final String data =
|
| - "<html><head><style> "
|
| - + " body { font-size:11px; }"
|
| - + " </style></head><body><p>foo</p></body></html>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - assertTrue(child.hasStyle);
|
| - assertEquals("foo", child.text);
|
| - assertEquals(11.0 * mPageScale, child.textSize, 0.01);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotStyles() throws Throwable {
|
| - final String data =
|
| - "<html><head><style> "
|
| - + " body { font: italic bold 12px Courier; }"
|
| - + " </style></head><body><p>foo</p></body></html>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - assertEquals("foo", child.text);
|
| - assertTrue(child.hasStyle);
|
| - assertTrue(child.bold);
|
| - assertTrue(child.italic);
|
| - assertFalse(child.lineThrough);
|
| - assertFalse(child.underline);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotStrongStyle() throws Throwable {
|
| - final String data = "<html><body><p>foo</p><p><strong>bar</strong></p></body></html>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(2, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child1 = root.children.get(0);
|
| - assertEquals("foo", child1.text);
|
| - assertTrue(child1.hasStyle);
|
| - assertFalse(child1.bold);
|
| - AccessibilitySnapshotNode child2 = root.children.get(1);
|
| - AccessibilitySnapshotNode child2child = child2.children.get(0);
|
| - assertEquals("bar", child2child.text);
|
| - assertEquals(child1.textSize, child2child.textSize);
|
| - assertTrue(child2child.bold);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotItalicStyle() throws Throwable {
|
| - final String data = "<html><body><i>foo</i></body></html>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("foo", grandchild.text);
|
| - assertTrue(grandchild.hasStyle);
|
| - assertTrue(grandchild.italic);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotBoldStyle() throws Throwable {
|
| - final String data = "<html><body><b>foo</b></body></html>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("foo", grandchild.text);
|
| - assertTrue(grandchild.hasStyle);
|
| - assertTrue(grandchild.bold);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotNoStyle() throws Throwable {
|
| - final String data = "<table><thead></thead></table>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode grandChild = root.children.get(0).children.get(0);
|
| - assertFalse(grandChild.hasStyle);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotAboutBlank() throws Throwable {
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(null, null);
|
| - assertEquals(null, root);
|
| - }
|
| -
|
| - private String getSelectionScript(String node1, int start, String node2, int end) {
|
| - return "var element1 = document.getElementById('" + node1 + "');"
|
| - + "var node1 = element1.childNodes.item(0);"
|
| - + "var range=document.createRange();"
|
| - + "range.setStart(node1," + start + ");"
|
| - + "var element2 = document.getElementById('" + node2 + "');"
|
| - + "var node2 = element2.childNodes.item(0);"
|
| - + "range.setEnd(node2," + end + ");"
|
| - + "var selection=window.getSelection();"
|
| - + "selection.removeAllRanges();"
|
| - + "selection.addRange(range);";
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotOneCharacterSelection() throws Throwable {
|
| - final String data = "<html><body><b id='node'>foo</b></body></html>";
|
| -
|
| - AccessibilitySnapshotNode root =
|
| - receiveAccessibilitySnapshot(data, getSelectionScript("node", 0, "node", 1));
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("foo", grandchild.text);
|
| - assertEquals(0, grandchild.startSelection);
|
| - assertEquals(1, grandchild.endSelection);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotOneNodeSelection() throws Throwable {
|
| - final String data = "<html><body><b id='node'>foo</b></body></html>";
|
| -
|
| - AccessibilitySnapshotNode root =
|
| - receiveAccessibilitySnapshot(data, getSelectionScript("node", 0, "node", 3));
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("foo", grandchild.text);
|
| - assertEquals(0, grandchild.startSelection);
|
| - assertEquals(3, grandchild.endSelection);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotSubsequentNodeSelection() throws Throwable {
|
| - final String data = "<html><body><b id='node1'>foo</b><b id='node2'>bar</b></body></html>";
|
| -
|
| - AccessibilitySnapshotNode root =
|
| - receiveAccessibilitySnapshot(data, getSelectionScript("node1", 1, "node2", 1));
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("foo", grandchild.text);
|
| - assertEquals(1, grandchild.startSelection);
|
| - assertEquals(3, grandchild.endSelection);
|
| - grandchild = child.children.get(1);
|
| - assertEquals("bar", grandchild.text);
|
| - assertEquals(0, grandchild.startSelection);
|
| - assertEquals(1, grandchild.endSelection);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotMultiNodeSelection() throws Throwable {
|
| - final String data =
|
| - "<html><body><b id='node1'>foo</b><b>middle</b><b id='node2'>bar</b></body></html>";
|
| -
|
| - AccessibilitySnapshotNode root =
|
| - receiveAccessibilitySnapshot(data, getSelectionScript("node1", 1, "node2", 1));
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("foo", grandchild.text);
|
| - assertEquals(1, grandchild.startSelection);
|
| - assertEquals(3, grandchild.endSelection);
|
| - grandchild = child.children.get(1);
|
| - assertEquals("middle", grandchild.text);
|
| - assertEquals(0, grandchild.startSelection);
|
| - assertEquals(6, grandchild.endSelection);
|
| - grandchild = child.children.get(2);
|
| - assertEquals("bar", grandchild.text);
|
| - assertEquals(0, grandchild.startSelection);
|
| - assertEquals(1, grandchild.endSelection);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotInputSelection() throws Throwable {
|
| - final String data = "<html><body><input id='input' value='Hello, world'></body></html>";
|
| - final String js = "var input = document.getElementById('input');"
|
| - + "input.select();"
|
| - + "input.selectionStart = 0;"
|
| - + "input.selectionEnd = 5;";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, js);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("Hello, world", grandchild.text);
|
| - assertEquals(0, grandchild.startSelection);
|
| - assertEquals(5, grandchild.endSelection);
|
| - }
|
| -
|
| - @Feature({"AndroidWebView"})
|
| - @SmallTest
|
| - public void testRequestAccessibilitySnapshotPasswordField() throws Throwable {
|
| - final String data =
|
| - "<html><body><input id='input' type='password' value='foo'></body></html>";
|
| - AccessibilitySnapshotNode root = receiveAccessibilitySnapshot(data, null);
|
| - assertEquals(1, root.children.size());
|
| - assertEquals("", root.text);
|
| - AccessibilitySnapshotNode child = root.children.get(0);
|
| - AccessibilitySnapshotNode grandchild = child.children.get(0);
|
| - assertEquals("•••", grandchild.text);
|
| - }
|
| }
|
|
|