Title: [211322] trunk/Tools
Revision
211322
Author
aes...@apple.com
Date
2017-01-27 21:05:37 -0800 (Fri, 27 Jan 2017)

Log Message

[iOS] Add a test for _WKNSFileManagerExtras
https://bugs.webkit.org/show_bug.cgi?id=167478

Reviewed by Andreas Kling.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/NSFileManagerExtras.mm: Added.
(expectAttributes):
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (211321 => 211322)


--- trunk/Tools/ChangeLog	2017-01-28 04:50:48 UTC (rev 211321)
+++ trunk/Tools/ChangeLog	2017-01-28 05:05:37 UTC (rev 211322)
@@ -1,3 +1,15 @@
+2017-01-27  Andy Estes  <aes...@apple.com>
+
+        [iOS] Add a test for _WKNSFileManagerExtras
+        https://bugs.webkit.org/show_bug.cgi?id=167478
+
+        Reviewed by Andreas Kling.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/NSFileManagerExtras.mm: Added.
+        (expectAttributes):
+        (TEST):
+
 2017-01-27  Keith Miller  <keith_mil...@apple.com>
 
         run-benchmarks should make sure it passes the test url to the right application

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (211321 => 211322)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-01-28 04:50:48 UTC (rev 211321)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-01-28 05:05:37 UTC (rev 211322)
@@ -457,6 +457,7 @@
 		9BD4239A1E04BD9800200395 /* AttributedSubstringForProposedRangeWithImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BD423991E04BD9800200395 /* AttributedSubstringForProposedRangeWithImage.mm */; };
 		9BD4239C1E04C01C00200395 /* chinese-character-with-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */; };
 		9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */; };
+		A10F047E1E3AD29C00C95E19 /* NSFileManagerExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10F047C1E3AD29C00C95E19 /* NSFileManagerExtras.mm */; };
 		A1146A8D1D2D7115000FE710 /* ContentFiltering.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1146A8A1D2D704F000FE710 /* ContentFiltering.mm */; };
 		A125478F1DB18B9400358564 /* LoadDataWithNilMIMEType.mm in Sources */ = {isa = PBXBuildFile; fileRef = A125478D1DB18B9400358564 /* LoadDataWithNilMIMEType.mm */; };
 		A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */; };
@@ -1155,6 +1156,7 @@
 		9BD423991E04BD9800200395 /* AttributedSubstringForProposedRangeWithImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AttributedSubstringForProposedRangeWithImage.mm; sourceTree = "<group>"; };
 		9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "chinese-character-with-image.html"; sourceTree = "<group>"; };
 		9C64DC311D76198A004B598E /* YouTubePluginReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YouTubePluginReplacement.cpp; sourceTree = "<group>"; };
+		A10F047C1E3AD29C00C95E19 /* NSFileManagerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSFileManagerExtras.mm; sourceTree = "<group>"; };
 		A1146A8A1D2D704F000FE710 /* ContentFiltering.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentFiltering.mm; sourceTree = "<group>"; };
 		A125478D1DB18B9400358564 /* LoadDataWithNilMIMEType.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadDataWithNilMIMEType.mm; sourceTree = "<group>"; };
 		A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestWebKitAPI.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1527,6 +1529,7 @@
 				46C519D81D355A7300DAA51A /* LocalStorageNullEntries.mm */,
 				7A6A2C6F1DCCF87B00C0D085 /* LocalStorageQuirkTest.mm */,
 				51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
+				A10F047C1E3AD29C00C95E19 /* NSFileManagerExtras.mm */,
 				1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
 				2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */,
 				37A22AA51DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm */,
@@ -2523,6 +2526,7 @@
 				7C3965061CDD74F90094DBB8 /* Color.cpp in Sources */,
 				7C3DB8E41D12129B00AE8CC3 /* CommandBackForward.mm in Sources */,
 				7CB184C61AA3F2100066EDFD /* ContentExtensions.cpp in Sources */,
+				A10F047E1E3AD29C00C95E19 /* NSFileManagerExtras.mm in Sources */,
 				A1146A8D1D2D7115000FE710 /* ContentFiltering.mm in Sources */,
 				A14FC5881B8991BF00D107EB /* ContentFiltering.mm in Sources */,
 				7CCE7EB81A411A7E00447C4C /* ContextMenuCanCopyURL.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NSFileManagerExtras.mm (0 => 211322)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NSFileManagerExtras.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NSFileManagerExtras.mm	2017-01-28 05:05:37 UTC (rev 211322)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if PLATFORM(IOS)
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import <WebCore/NSFileManagerSPI.h>
+#import <WebKit/_WKNSFileManagerExtras.h>
+
+static void expectAttributes(NSDictionary *attributes, NSNumber *expectedPermissions, NSString *expectedFileType)
+{
+    EXPECT_NOT_NULL(attributes);
+    EXPECT_WK_STREQ(NSUserName(), attributes[NSFileOwnerAccountName]);
+    EXPECT_WK_STREQ([expectedPermissions stringValue], [attributes[NSFilePosixPermissions] stringValue]);
+    EXPECT_WK_STREQ(expectedFileType, attributes[NSFileType]);
+}
+
+TEST(WebKit2, _WKNSFileManagerExtras)
+{
+    NSString *fileName = @"test.pdf";
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+
+    NSString *filePath = [NSFileManager _web_createTemporaryFileForQuickLook:fileName];
+    EXPECT_WK_STREQ(fileName, filePath.lastPathComponent);
+    EXPECT_EQ(YES, [fileManager fileExistsAtPath:filePath]);
+
+    NSDictionary *fileAttributes = [fileManager attributesOfItemAtPath:filePath error:nil];
+    expectAttributes(fileAttributes, [NSNumber numberWithInteger:(WEB_UREAD | WEB_UWRITE)], NSFileTypeRegular);
+
+    NSDictionary *directoryAttributes = [fileManager attributesOfItemAtPath:filePath.stringByDeletingLastPathComponent error:nil];
+    expectAttributes(directoryAttributes, [NSNumber numberWithInteger:(WEB_UREAD | WEB_UWRITE | WEB_UEXEC)], NSFileTypeDirectory);
+
+    [fileManager removeItemAtPath:filePath error:nil];
+}
+
+#endif // PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to