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

Unified Diff: webkit/fileapi/isolated_context_unittest.cc

Issue 10713007: Make isolated file system works for a device root (e.g. X:\\) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 5 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 | « webkit/fileapi/isolated_context.cc ('k') | webkit/fileapi/isolated_file_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/isolated_context_unittest.cc
diff --git a/webkit/fileapi/isolated_context_unittest.cc b/webkit/fileapi/isolated_context_unittest.cc
index 5a828f58d98d917dc8dfdb6e104eeed7fc05cd91..ee54557f68b68dfde51fe98d09e4e7af738a68fa 100644
--- a/webkit/fileapi/isolated_context_unittest.cc
+++ b/webkit/fileapi/isolated_context_unittest.cc
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/fileapi/isolated_context.h"
#define FPL(x) FILE_PATH_LITERAL(x)
@@ -20,15 +21,23 @@
namespace fileapi {
+typedef IsolatedContext::FileInfo FileInfo;
+
namespace {
const FilePath kTestPaths[] = {
- FilePath(DRIVE FPL("/a/b")),
+ FilePath(DRIVE FPL("/a/b.txt")),
FilePath(DRIVE FPL("/c/d/e")),
FilePath(DRIVE FPL("/h/")),
+ FilePath(DRIVE FPL("/")),
#if defined(FILE_PATH_USES_WIN_SEPARATORS)
FilePath(DRIVE FPL("\\foo\\bar")),
+ FilePath(DRIVE FPL("\\")),
#endif
+ // For duplicated base name test.
+ FilePath(DRIVE FPL("/")),
+ FilePath(DRIVE FPL("/f/e")),
+ FilePath(DRIVE FPL("/f/b.txt")),
};
} // namespace
@@ -41,12 +50,15 @@ class IsolatedContextTest : public testing::Test {
}
void SetUp() {
- id_ = IsolatedContext::GetInstance()->RegisterIsolatedFileSystem(fileset_);
+ IsolatedContext::FileInfoSet files;
+ for (size_t i = 0; i < arraysize(kTestPaths); ++i)
+ names_.push_back(files.AddPath(kTestPaths[i].NormalizePathSeparators()));
+ id_ = IsolatedContext::GetInstance()->RegisterFileSystem(files);
ASSERT_FALSE(id_.empty());
}
void TearDown() {
- IsolatedContext::GetInstance()->RevokeIsolatedFileSystem(id_);
+ IsolatedContext::GetInstance()->RevokeFileSystem(id_);
}
IsolatedContext* isolated_context() const {
@@ -55,7 +67,8 @@ class IsolatedContextTest : public testing::Test {
protected:
std::string id_;
- std::set<FilePath> fileset_;
+ std::multiset<FilePath> fileset_;
+ std::vector<std::string> names_;
private:
DISALLOW_COPY_AND_ASSIGN(IsolatedContextTest);
@@ -63,40 +76,41 @@ class IsolatedContextTest : public testing::Test {
TEST_F(IsolatedContextTest, RegisterAndRevokeTest) {
// See if the returned top-level entries match with what we registered.
- std::vector<FilePath> toplevels;
- ASSERT_TRUE(isolated_context()->GetTopLevelPaths(id_, &toplevels));
+ std::vector<FileInfo> toplevels;
+ ASSERT_TRUE(isolated_context()->GetRegisteredFileInfo(id_, &toplevels));
ASSERT_EQ(fileset_.size(), toplevels.size());
for (size_t i = 0; i < toplevels.size(); ++i) {
- ASSERT_TRUE(fileset_.find(toplevels[i]) != fileset_.end());
+ ASSERT_TRUE(fileset_.find(toplevels[i].path) != fileset_.end());
}
- // See if the basename of each registered kTestPaths (that is what we
- // register in SetUp() by RegisterIsolatedFileSystem) is properly cracked as
+ // See if the name of each registered kTestPaths (that is what we
+ // register in SetUp() by RegisterFileSystem) is properly cracked as
// a valid virtual path in the isolated filesystem.
for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
- FilePath virtual_path = isolated_context()->CreateVirtualPath(
- id_, kTestPaths[i].BaseName());
+ FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_)
+ .AppendASCII(names_[i]);
std::string cracked_id;
- FilePath root_path, cracked_path;
+ FileInfo root_info;
+ FilePath cracked_path;
ASSERT_TRUE(isolated_context()->CrackIsolatedPath(
- virtual_path, &cracked_id, &root_path, &cracked_path));
+ virtual_path, &cracked_id, &root_info, &cracked_path));
ASSERT_EQ(kTestPaths[i].NormalizePathSeparators().value(),
cracked_path.value());
- ASSERT_TRUE(fileset_.find(root_path.NormalizePathSeparators())
+ ASSERT_TRUE(fileset_.find(root_info.path.NormalizePathSeparators())
!= fileset_.end());
ASSERT_EQ(id_, cracked_id);
}
// Revoking the current one and registering a new (empty) one.
- isolated_context()->RevokeIsolatedFileSystem(id_);
- std::string id2 = isolated_context()->RegisterIsolatedFileSystem(
- std::set<FilePath>());
+ isolated_context()->RevokeFileSystem(id_);
+ std::string id2 = isolated_context()->RegisterFileSystem(
+ IsolatedContext::FileInfoSet());
- // Make sure the GetTopLevelPaths returns true only for the new one.
- ASSERT_TRUE(isolated_context()->GetTopLevelPaths(id2, &toplevels));
- ASSERT_FALSE(isolated_context()->GetTopLevelPaths(id_, &toplevels));
+ // Make sure the GetRegisteredFileInfo returns true only for the new one.
+ ASSERT_TRUE(isolated_context()->GetRegisteredFileInfo(id2, &toplevels));
+ ASSERT_FALSE(isolated_context()->GetRegisteredFileInfo(id_, &toplevels));
- isolated_context()->RevokeIsolatedFileSystem(id2);
+ isolated_context()->RevokeFileSystem(id2);
}
TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
@@ -122,18 +136,19 @@ TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) {
SCOPED_TRACE(testing::Message() << "Testing "
<< kTestPaths[i].value() << " " << relatives[j].path);
- FilePath virtual_path = isolated_context()->CreateVirtualPath(
- id_, kTestPaths[i].BaseName().Append(relatives[j].path));
+ FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_)
+ .AppendASCII(names_[i]).Append(relatives[j].path);
std::string cracked_id;
- FilePath root_path, cracked_path;
+ FileInfo root_info;
+ FilePath cracked_path;
if (!relatives[j].valid) {
ASSERT_FALSE(isolated_context()->CrackIsolatedPath(
- virtual_path, &cracked_id, &root_path, &cracked_path));
+ virtual_path, &cracked_id, &root_info, &cracked_path));
continue;
}
ASSERT_TRUE(isolated_context()->CrackIsolatedPath(
- virtual_path, &cracked_id, &root_path, &cracked_path));
- ASSERT_TRUE(fileset_.find(root_path.NormalizePathSeparators())
+ virtual_path, &cracked_id, &root_info, &cracked_path));
+ ASSERT_TRUE(fileset_.find(root_info.path.NormalizePathSeparators())
!= fileset_.end());
ASSERT_EQ(kTestPaths[i].Append(relatives[j].path)
.NormalizePathSeparators().value(),
@@ -145,24 +160,23 @@ TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
TEST_F(IsolatedContextTest, TestWithVirtualRoot) {
std::string cracked_id;
- FilePath root_path, cracked_path;
- const FilePath root(FPL("/"));
+ FilePath cracked_path;
// Trying to crack virtual root "/" returns true but with empty cracked path
// as "/" of the isolated filesystem is a pure virtual directory
// that has no corresponding platform directory.
- FilePath virtual_path = isolated_context()->CreateVirtualPath(id_, root);
+ FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_);
ASSERT_TRUE(isolated_context()->CrackIsolatedPath(
- virtual_path, &cracked_id, &root_path, &cracked_path));
+ virtual_path, &cracked_id, NULL, &cracked_path));
ASSERT_EQ(FPL(""), cracked_path.value());
ASSERT_EQ(id_, cracked_id);
// Trying to crack "/foo" should fail (because "foo" is not the one
// included in the kTestPaths).
- virtual_path = isolated_context()->CreateVirtualPath(
- id_, FilePath(FPL("foo")));
+ virtual_path = isolated_context()->CreateVirtualRootPath(
+ id_).AppendASCII("foo");
ASSERT_FALSE(isolated_context()->CrackIsolatedPath(
- virtual_path, &cracked_id, &root_path, &cracked_path));
+ virtual_path, &cracked_id, NULL, &cracked_path));
}
} // namespace fileapi
« no previous file with comments | « webkit/fileapi/isolated_context.cc ('k') | webkit/fileapi/isolated_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698