[iOS WK2] ExternalSourceDataTransferItemGetAsEntry tests produce inconsistent results...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Sep 2017 23:34:03 +0000 (23:34 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Sep 2017 23:34:03 +0000 (23:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176736

Reviewed by Andy Estes and Megan Gardner.

The test output dumped when dropping a file in DataTransferItem-getAsEntry.html should adhere to some deterministic order.
Currently, this is not enforced, so on some systems, these tests fail due to expected test output being out of order. To
fix this, simply have the test harness alphabetically sort the output before writing to the textarea.

* TestWebKitAPI/Tests/WebKitCocoa/DataTransferItem-getAsEntry.html:
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

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

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/DataTransferItem-getAsEntry.html
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

index cd6f71ef433b6562eaaa4b52e80b363b513cd14c..9c7e4618499919ce44a4a9763657cd9f6ea95aab 100644 (file)
@@ -1,3 +1,18 @@
+2017-09-11  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS WK2] ExternalSourceDataTransferItemGetAsEntry tests produce inconsistent results on test automation bots
+        https://bugs.webkit.org/show_bug.cgi?id=176736
+
+        Reviewed by Andy Estes and Megan Gardner.
+
+        The test output dumped when dropping a file in DataTransferItem-getAsEntry.html should adhere to some deterministic order.
+        Currently, this is not enforced, so on some systems, these tests fail due to expected test output being out of order. To
+        fix this, simply have the test harness alphabetically sort the output before writing to the textarea.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/DataTransferItem-getAsEntry.html:
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+
 2017-09-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         webkitbot should recognize commands even when colon is omitted
index ac90c15d188f389cb82bf3a87332a2bc4a851737..2b1163de04e6ff260f27d91dc2aca68cd0791713 100644 (file)
@@ -69,16 +69,16 @@ html, body {
 
     async function representationForFileSystemEntry(entry)
     {
-        let representation = "";
+        let lines = [];
         if (entry.isDirectory) {
-            representation += `DIR: ${entry.fullPath}\n`;
+            lines.push(`DIR: ${entry.fullPath}`);
             for (let child of await getChildEntries(entry))
-                representation += await representationForFileSystemEntry(child);
+                lines = lines.concat(await representationForFileSystemEntry(child));
         } else if (entry.isFile) {
             let file = await fileFromFileSystemFileEntry(entry);
-            representation += `FILE: ${entry.fullPath} ('${file.type}', ${file.size} bytes)\n`;
+            lines.push(`FILE: ${entry.fullPath} ('${file.type}', ${file.size} bytes)`);
         }
-        return representation;
+        return lines;
     }
 
     async function logItemAndFileEntryInformation(items)
@@ -89,7 +89,7 @@ html, body {
             output.value += `Found data transfer item (kind: '${item.kind}', type: '${item.type}')\n`;
             let entry = item.webkitGetAsEntry();
             if (entry)
-                output.value += await representationForFileSystemEntry(entry);
+                output.value += (await representationForFileSystemEntry(entry)).sort().join("\n");
         }
     }
 </script>
index 634126c88204f82d7d554274464d379b0a3cbcd4..38384e09d8ae05c7bb58b2c738b1eb9b18c55c16 100644 (file)
@@ -953,17 +953,18 @@ static RetainPtr<TestWKWebView> setUpTestWebViewForDataTransferItems()
 
 TEST(DataInteractionTests, ExternalSourceDataTransferItemGetFolderAsEntry)
 {
+    // The expected output is sorted by alphabetical order here for consistent behavior across different test environments.
+    // See DataTransferItem-getAsEntry.html for more details.
     NSArray<NSString *> *expectedOutput = @[
         @"Found data transfer item (kind: 'string', type: 'text/plain')",
         @"Found data transfer item (kind: 'file', type: '')",
         @"DIR: /somedirectory",
-        @"FILE: /somedirectory/icon.png ('image/png', 42130 bytes)",
         @"DIR: /somedirectory/subdirectory1",
-        @"FILE: /somedirectory/subdirectory1/text-file-1.txt ('text/plain', 43 bytes)",
-        @"FILE: /somedirectory/archive.zip ('application/zip', 988 bytes)",
         @"DIR: /somedirectory/subdirectory2",
-        @"FILE: /somedirectory/subdirectory2/text-file-2.txt ('text/plain', 44 bytes)",
-        @""
+        @"FILE: /somedirectory/archive.zip ('application/zip', 988 bytes)",
+        @"FILE: /somedirectory/icon.png ('image/png', 42130 bytes)",
+        @"FILE: /somedirectory/subdirectory1/text-file-1.txt ('text/plain', 43 bytes)",
+        @"FILE: /somedirectory/subdirectory2/text-file-2.txt ('text/plain', 44 bytes)"
     ];
 
     auto webView = setUpTestWebViewForDataTransferItems();
@@ -994,8 +995,7 @@ TEST(DataInteractionTests, ExternalSourceDataTransferItemGetPlainTextFileAsEntry
     NSArray<NSString *> *expectedOutput = @[
         @"Found data transfer item (kind: 'string', type: 'text/plain')",
         @"Found data transfer item (kind: 'file', type: 'text/plain')",
-        @"FILE: /foo.txt ('text/plain', 28 bytes)",
-        @""
+        @"FILE: /foo.txt ('text/plain', 28 bytes)"
     ];
 
     auto webView = setUpTestWebViewForDataTransferItems();