<https://webkit.org/b/120032> Add DRT test to ensure that AccessibilityObject::stringValue()
of <input type="file"> is meaningful

Reviewed by Chris Fleizach.

Adds a DRT test to ensure that AccessibilityObject::stringValue() returns a meaningful string
for a single file- and multiple files-file upload control.

* accessibility/file-upload-button-stringvalue.html: Added.
* platform/mac-wk2/accessibility/file-upload-button-stringvalue-expected.txt: Added.
* platform/mac/accessibility/file-upload-button-stringvalue-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154332 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 2a0b909..bfe1639 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2013-08-20  Daniel Bates  <dabates@apple.com>
+
+        <https://webkit.org/b/120032> Add DRT test to ensure that AccessibilityObject::stringValue()
+        of <input type="file"> is meaningful
+
+        Reviewed by Chris Fleizach.
+
+        Adds a DRT test to ensure that AccessibilityObject::stringValue() returns a meaningful string
+        for a single file- and multiple files-file upload control.
+
+        * accessibility/file-upload-button-stringvalue.html: Added.
+        * platform/mac-wk2/accessibility/file-upload-button-stringvalue-expected.txt: Added.
+        * platform/mac/accessibility/file-upload-button-stringvalue-expected.txt: Added.
+
 2013-08-20  Antti Koivisto  <antti@apple.com>
 
         <https://webkit.org/b/120025> REGRESSION (r154254): fast/frames/frameset-frameborder-inheritance.html failing on Apple MountainLion Debug WK1 (Tests)
diff --git a/LayoutTests/accessibility/file-upload-button-stringvalue.html b/LayoutTests/accessibility/file-upload-button-stringvalue.html
new file mode 100644
index 0000000..d3a0567
--- /dev/null
+++ b/LayoutTests/accessibility/file-upload-button-stringvalue.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<body>
+<form id="form">
+    <input id="singleFileUpload" type="file">
+    <input id="multipleFileUpload" type="file" multiple>
+</form>
+<p>This tests the value of stringValue for a single file- and multiple files-&lt;input type=&quot;file&quot;&gt; control.</p>
+<pre id="console"></pre>
+<script>
+if (window.testRunner && window.accessibilityController) {
+    testRunner.dumpAsText();
+    runTest();
+} else
+    log("This test must be run with DumpRenderTree and an implemented AccessibilityController.");
+
+function runTest()
+{
+    var elementIds = ["singleFileUpload", "multipleFileUpload"];
+    var form = document.getElementById("form");
+
+    form.reset();
+    log(""); // Add an empty line; make the expected results pretty.
+    log("Default value (no files selected):");
+    for (var i = 0; i < elementIds.length; ++i)
+        logAccessibilityStringValueForElement(elementIds[i]);
+
+    form.reset();
+    log(""); // Add an empty line; make the expected results pretty.
+    log("Drag and drop a single file:");
+    for (var i = 0; i < elementIds.length; ++i) {
+        dragAndDropFauxFilesOnElement(["file1.txt"], elementIds[i]);
+        logAccessibilityStringValueForElement(elementIds[i]);
+    }
+
+    form.reset();
+    log(""); // Add an empty line; make the expected results pretty.
+    log("Drag and drop two files:");
+    for (var i = 0; i < elementIds.length; ++i) {
+        dragAndDropFauxFilesOnElement(["file1.txt", "file2.txt"], elementIds[i]);
+        logAccessibilityStringValueForElement(elementIds[i]);
+    }
+}
+
+function log(message)
+{
+    document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
+}
+
+function logAccessibilityStringValueForElement(elementId)
+{
+    log('accessibilityController.accessibleElementById("' + elementId + '").stringValue: ' + accessibilityController.accessibleElementById(elementId).stringValue);
+}
+
+function dragAndDropFauxFilesOnElement(files, elementId)
+{
+    if (!window.eventSender || !eventSender.beginDragWithFiles)
+        return;
+    var element = document.getElementById(elementId);
+    eventSender.beginDragWithFiles(files);
+    eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop);
+    eventSender.mouseUp();
+}
+</script>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac-wk2/accessibility/file-upload-button-stringvalue-expected.txt b/LayoutTests/platform/mac-wk2/accessibility/file-upload-button-stringvalue-expected.txt
new file mode 100644
index 0000000..684abbe
--- /dev/null
+++ b/LayoutTests/platform/mac-wk2/accessibility/file-upload-button-stringvalue-expected.txt
@@ -0,0 +1,16 @@
+  
+This tests the value of stringValue for a single file- and multiple files-<input type="file"> control.
+
+
+Default value (no files selected):
+accessibilityController.accessibleElementById("singleFileUpload").stringValue: AXValue: no file selected
+accessibilityController.accessibleElementById("multipleFileUpload").stringValue: AXValue: no files selected
+
+Drag and drop a single file:
+accessibilityController.accessibleElementById("singleFileUpload").stringValue: AXValue: no file selected
+accessibilityController.accessibleElementById("multipleFileUpload").stringValue: AXValue: no files selected
+
+Drag and drop two files:
+accessibilityController.accessibleElementById("singleFileUpload").stringValue: AXValue: no file selected
+accessibilityController.accessibleElementById("multipleFileUpload").stringValue: AXValue: no files selected
+
diff --git a/LayoutTests/platform/mac/accessibility/file-upload-button-stringvalue-expected.txt b/LayoutTests/platform/mac/accessibility/file-upload-button-stringvalue-expected.txt
new file mode 100644
index 0000000..9f9ea78
--- /dev/null
+++ b/LayoutTests/platform/mac/accessibility/file-upload-button-stringvalue-expected.txt
@@ -0,0 +1,16 @@
+  
+This tests the value of stringValue for a single file- and multiple files-<input type="file"> control.
+
+
+Default value (no files selected):
+accessibilityController.accessibleElementById("singleFileUpload").stringValue: AXValue: no file selected
+accessibilityController.accessibleElementById("multipleFileUpload").stringValue: AXValue: no files selected
+
+Drag and drop a single file:
+accessibilityController.accessibleElementById("singleFileUpload").stringValue: AXValue: file1.txt
+accessibilityController.accessibleElementById("multipleFileUpload").stringValue: AXValue: file1.txt
+
+Drag and drop two files:
+accessibilityController.accessibleElementById("singleFileUpload").stringValue: AXValue: no file selected
+accessibilityController.accessibleElementById("multipleFileUpload").stringValue: AXValue: 2 files
+