| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/fileapi/File.h" | 5 #include "core/fileapi/File.h" |
| 6 | 6 |
| 7 #include "platform/FileMetadata.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 namespace blink { | 10 namespace blink { |
| 10 | 11 |
| 11 TEST(FileTest, nativeFile) { | 12 TEST(FileTest, nativeFile) { |
| 12 File* const file = File::create("/native/path"); | 13 File* const file = File::create("/native/path"); |
| 13 EXPECT_TRUE(file->hasBackingFile()); | 14 EXPECT_TRUE(file->hasBackingFile()); |
| 14 EXPECT_EQ("/native/path", file->path()); | 15 EXPECT_EQ("/native/path", file->path()); |
| 15 EXPECT_TRUE(file->fileSystemURL().isEmpty()); | 16 EXPECT_TRUE(file->fileSystemURL().isEmpty()); |
| 16 } | 17 } |
| 17 | 18 |
| 18 TEST(FileTest, blobBackingFile) { | 19 TEST(FileTest, blobBackingFile) { |
| 19 const RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(); | 20 const RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(); |
| 20 File* const file = File::create("name", 0.0, blobDataHandle); | 21 File* const file = File::create("name", 0.0, blobDataHandle); |
| 21 EXPECT_FALSE(file->hasBackingFile()); | 22 EXPECT_FALSE(file->hasBackingFile()); |
| 22 EXPECT_TRUE(file->path().isEmpty()); | 23 EXPECT_TRUE(file->path().isEmpty()); |
| 23 EXPECT_TRUE(file->fileSystemURL().isEmpty()); | 24 EXPECT_TRUE(file->fileSystemURL().isEmpty()); |
| 24 } | 25 } |
| 25 | 26 |
| 26 TEST(FileTest, fileSystemFileWithNativeSnapshot) { | 27 TEST(FileTest, fileSystemFileWithNativeSnapshot) { |
| 27 FileMetadata metadata; | 28 FileMetadata metadata; |
| 28 metadata.platformPath = "/native/snapshot"; | 29 metadata.platformPath = "/native/snapshot"; |
| 29 File* const file = | 30 File* const file = |
| 30 File::createForFileSystemFile("name", metadata, File::IsUserVisible); | 31 File::createForFileSystemFile("name", metadata, File::IsUserVisible); |
| 31 EXPECT_TRUE(file->hasBackingFile()); | 32 EXPECT_TRUE(file->hasBackingFile()); |
| 32 EXPECT_EQ("/native/snapshot", file->path()); | 33 EXPECT_EQ("/native/snapshot", file->path()); |
| 33 EXPECT_TRUE(file->fileSystemURL().isEmpty()); | 34 EXPECT_TRUE(file->fileSystemURL().isEmpty()); |
| 34 } | 35 } |
| 35 | 36 |
| 37 TEST(FileTest, fileSystemFileWithNativeSnapshotAndSize) { |
| 38 FileMetadata metadata; |
| 39 metadata.length = 1024ll; |
| 40 metadata.platformPath = "/native/snapshot"; |
| 41 File* const file = |
| 42 File::createForFileSystemFile("name", metadata, File::IsUserVisible); |
| 43 EXPECT_TRUE(file->hasBackingFile()); |
| 44 EXPECT_EQ("/native/snapshot", file->path()); |
| 45 EXPECT_TRUE(file->fileSystemURL().isEmpty()); |
| 46 } |
| 47 |
| 36 TEST(FileTest, fileSystemFileWithoutNativeSnapshot) { | 48 TEST(FileTest, fileSystemFileWithoutNativeSnapshot) { |
| 37 KURL url(ParsedURLStringTag(), | 49 KURL url(ParsedURLStringTag(), |
| 38 "filesystem:http://example.com/isolated/hash/non-native-file"); | 50 "filesystem:http://example.com/isolated/hash/non-native-file"); |
| 39 FileMetadata metadata; | 51 FileMetadata metadata; |
| 40 File* const file = | 52 File* const file = |
| 41 File::createForFileSystemFile(url, metadata, File::IsUserVisible); | 53 File::createForFileSystemFile(url, metadata, File::IsUserVisible); |
| 42 EXPECT_FALSE(file->hasBackingFile()); | 54 EXPECT_FALSE(file->hasBackingFile()); |
| 43 EXPECT_TRUE(file->path().isEmpty()); | 55 EXPECT_TRUE(file->path().isEmpty()); |
| 44 EXPECT_EQ(url, file->fileSystemURL()); | 56 EXPECT_EQ(url, file->fileSystemURL()); |
| 45 } | 57 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 EXPECT_TRUE(blobFileA1->hasSameSource(*blobFileA1)); | 90 EXPECT_TRUE(blobFileA1->hasSameSource(*blobFileA1)); |
| 79 EXPECT_TRUE(blobFileA1->hasSameSource(*blobFileA2)); | 91 EXPECT_TRUE(blobFileA1->hasSameSource(*blobFileA2)); |
| 80 EXPECT_FALSE(blobFileA1->hasSameSource(*blobFileB)); | 92 EXPECT_FALSE(blobFileA1->hasSameSource(*blobFileB)); |
| 81 | 93 |
| 82 EXPECT_TRUE(fileSystemFileA1->hasSameSource(*fileSystemFileA1)); | 94 EXPECT_TRUE(fileSystemFileA1->hasSameSource(*fileSystemFileA1)); |
| 83 EXPECT_TRUE(fileSystemFileA1->hasSameSource(*fileSystemFileA2)); | 95 EXPECT_TRUE(fileSystemFileA1->hasSameSource(*fileSystemFileA2)); |
| 84 EXPECT_FALSE(fileSystemFileA1->hasSameSource(*fileSystemFileB)); | 96 EXPECT_FALSE(fileSystemFileA1->hasSameSource(*fileSystemFileB)); |
| 85 } | 97 } |
| 86 | 98 |
| 87 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |