Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Unified Diff: Source/core/fileapi/FileTest.cpp

Issue 660763004: Fix the hasBackingFile flag for File backed by a file system URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git/+/master
Patch Set: Add test. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/fileapi/File.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fileapi/FileTest.cpp
diff --git a/Source/core/fileapi/FileTest.cpp b/Source/core/fileapi/FileTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a7f409b3a1eb293ff2888a988c1dbc3fb52668db
--- /dev/null
+++ b/Source/core/fileapi/FileTest.cpp
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "File.h"
+
+#include <gtest/gtest.h>
+
+namespace blink {
+
+TEST(FileTest, nativeFile)
+{
+ File* const file = File::create("/native/path");
+ EXPECT_TRUE(file->hasBackingFile());
+ EXPECT_EQ("/native/path", file->path());
+ EXPECT_TRUE(file->fileSystemURL().isEmpty());
+}
+
+TEST(FileTest, blobBackingFile)
+{
+ const RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create();
+ File* const file = File::create("name", 0.0, blobDataHandle);
+ EXPECT_FALSE(file->hasBackingFile());
+ EXPECT_TRUE(file->path().isEmpty());
+ EXPECT_TRUE(file->fileSystemURL().isEmpty());
+}
+
+TEST(FileTest, fileSystemFileWithNativeSnapshot)
+{
+ FileMetadata metadata;
+ metadata.platformPath = "/native/snapshot";
+ File* const file = File::createForFileSystemFile("name", metadata, File::IsUserVisible);
+ EXPECT_TRUE(file->hasBackingFile());
+ EXPECT_EQ("/native/snapshot", file->path());
+ EXPECT_TRUE(file->fileSystemURL().isEmpty());
+}
+
+TEST(FileTest, fileSystemFileWithoutNativeSnapshot)
+{
+ KURL url(ParsedURLStringTag(), "filesystem:http://example.com/isolated/hash/non-native-file");
+ FileMetadata metadata;
+ File* const file = File::createForFileSystemFile(url, metadata);
+ EXPECT_FALSE(file->hasBackingFile());
+ EXPECT_TRUE(file->path().isEmpty());
+ EXPECT_EQ(url, file->fileSystemURL());
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/fileapi/File.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698