[iOS WK2] API test DataInteractionTests.ExternalSourceDataTransferItemGetFolderAsEntr...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jan 2018 19:17:56 +0000 (19:17 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jan 2018 19:17:56 +0000 (19:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182339
<rdar://problem/36041396>

Reviewed by Andy Estes.

This API test wasn't meant to be dependent on the size of an image generated using UIImagePNGRepresentation().
To make this test robust against changes to image encoding, write the raw data to the test folder instead and
check against the length of the data written.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(testIconImageData):
(runTestWithTemporaryFolder):
(TestWebKitAPI::TEST):

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

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

index 73f5cca..08a1c28 100644 (file)
@@ -1,3 +1,20 @@
+2018-01-31  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS WK2] API test DataInteractionTests.ExternalSourceDataTransferItemGetFolderAsEntry is failing after an SDK update
+        https://bugs.webkit.org/show_bug.cgi?id=182339
+        <rdar://problem/36041396>
+
+        Reviewed by Andy Estes.
+
+        This API test wasn't meant to be dependent on the size of an image generated using UIImagePNGRepresentation().
+        To make this test robust against changes to image encoding, write the raw data to the test folder instead and
+        check against the length of the data written.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (testIconImageData):
+        (runTestWithTemporaryFolder):
+        (TestWebKitAPI::TEST):
+
 2018-01-31  Dan Bernstein  <mitz@apple.com>
 
         [macOS] MiniBrowser isn’t app-sandboxed
index 4de7fc3..4085fab 100644 (file)
@@ -184,6 +184,11 @@ static void checkJSONWithLogging(NSString *jsonString, NSDictionary *expected)
         NSLog(@"Expected JSON: %@ to match values: %@", jsonString, expected);
 }
 
+static NSData *testIconImageData()
+{
+    return [NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"icon" withExtension:@"png" subdirectory:@"TestWebKitAPI.resources"]];
+}
+
 static void runTestWithTemporaryTextFile(void(^runTest)(NSURL *fileURL))
 {
     NSString *fileName = [NSString stringWithFormat:@"drag-drop-text-file-%@.txt", [NSUUID UUID].UUIDString];
@@ -212,7 +217,7 @@ static void runTestWithTemporaryFolder(void(^runTest)(NSURL *folderURL))
     NSError *error = nil;
     NSFileManager *defaultManager = [NSFileManager defaultManager];
     [defaultManager createDirectoryAtURL:temporaryFolder.get() withIntermediateDirectories:NO attributes:nil error:&error];
-    [UIImagePNGRepresentation(testIconImage()) writeToURL:[temporaryFolder.get() URLByAppendingPathComponent:@"icon.png" isDirectory:NO] atomically:YES];
+    [testIconImageData() writeToURL:[temporaryFolder.get() URLByAppendingPathComponent:@"icon.png" isDirectory:NO] atomically:YES];
     [testZIPArchive() writeToURL:[temporaryFolder.get() URLByAppendingPathComponent:@"archive.zip" isDirectory:NO] atomically:YES];
 
     NSURL *firstSubdirectory = [temporaryFolder.get() URLByAppendingPathComponent:@"subdirectory1" isDirectory:YES];
@@ -1016,8 +1021,8 @@ TEST(DataInteractionTests, ExternalSourceDataTransferItemGetFolderAsEntry)
         @"DIR: /somedirectory",
         @"DIR: /somedirectory/subdirectory1",
         @"DIR: /somedirectory/subdirectory2",
-        @"FILE: /somedirectory/archive.zip ('application/zip', 988 bytes)",
-        @"FILE: /somedirectory/icon.png ('image/png', 42130 bytes)",
+        [NSString stringWithFormat:@"FILE: /somedirectory/archive.zip ('application/zip', %tu bytes)", testZIPArchive().length],
+        [NSString stringWithFormat:@"FILE: /somedirectory/icon.png ('image/png', %tu bytes)", testIconImageData().length],
         @"FILE: /somedirectory/subdirectory1/text-file-1.txt ('text/plain', 43 bytes)",
         @"FILE: /somedirectory/subdirectory2/text-file-2.txt ('text/plain', 44 bytes)"
     ];