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

Side by Side Diff: webkit/fileapi/isolated_context_unittest.cc

Issue 10810053: Enables internal filesystem types via Isolated filesystems (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: layout test crash fix 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/isolated_context.cc ('k') | webkit/fileapi/isolated_file_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/fileapi/isolated_context.h" 5 #include "webkit/fileapi/isolated_context.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ASSERT_TRUE(fileset_.find(toplevels[i].path) != fileset_.end()); 87 ASSERT_TRUE(fileset_.find(toplevels[i].path) != fileset_.end());
88 } 88 }
89 89
90 // See if the name of each registered kTestPaths (that is what we 90 // See if the name of each registered kTestPaths (that is what we
91 // register in SetUp() by RegisterDraggedFileSystem) is properly cracked as 91 // register in SetUp() by RegisterDraggedFileSystem) is properly cracked as
92 // a valid virtual path in the isolated filesystem. 92 // a valid virtual path in the isolated filesystem.
93 for (size_t i = 0; i < arraysize(kTestPaths); ++i) { 93 for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
94 FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_) 94 FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_)
95 .AppendASCII(names_[i]); 95 .AppendASCII(names_[i]);
96 std::string cracked_id; 96 std::string cracked_id;
97 FileInfo root_info;
98 FilePath cracked_path; 97 FilePath cracked_path;
98 FileSystemType cracked_type;
99 ASSERT_TRUE(isolated_context()->CrackIsolatedPath( 99 ASSERT_TRUE(isolated_context()->CrackIsolatedPath(
100 virtual_path, &cracked_id, &root_info, &cracked_path)); 100 virtual_path, &cracked_id, &cracked_type, &cracked_path));
101 ASSERT_EQ(kTestPaths[i].NormalizePathSeparators().value(), 101 ASSERT_EQ(kTestPaths[i].NormalizePathSeparators().value(),
102 cracked_path.value()); 102 cracked_path.value());
103 ASSERT_TRUE(fileset_.find(root_info.path.NormalizePathSeparators())
104 != fileset_.end());
105 ASSERT_EQ(id_, cracked_id); 103 ASSERT_EQ(id_, cracked_id);
104 ASSERT_EQ(kFileSystemTypeDragged, cracked_type);
106 } 105 }
107 106
108 // Make sure GetRegisteredPath returns false for id_ since it is 107 // Make sure GetRegisteredPath returns false for id_ since it is
109 // registered for dragged files. 108 // registered for dragged files.
110 FilePath path; 109 FilePath path;
111 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path)); 110 ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path));
112 111
113 // Revoking the current one and registering a new one. 112 // Revoking the current one and registering a new one.
114 isolated_context()->RevokeFileSystem(id_); 113 isolated_context()->RevokeFileSystem(id_);
115 std::string id2 = isolated_context()->RegisterFileSystemForPath( 114 std::string id2 = isolated_context()->RegisterFileSystemForPath(
(...skipping 29 matching lines...) Expand all
145 { FPL("foo/..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS }, 144 { FPL("foo/..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
146 }; 145 };
147 146
148 for (size_t i = 0; i < arraysize(kTestPaths); ++i) { 147 for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
149 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) { 148 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) {
150 SCOPED_TRACE(testing::Message() << "Testing " 149 SCOPED_TRACE(testing::Message() << "Testing "
151 << kTestPaths[i].value() << " " << relatives[j].path); 150 << kTestPaths[i].value() << " " << relatives[j].path);
152 FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_) 151 FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_)
153 .AppendASCII(names_[i]).Append(relatives[j].path); 152 .AppendASCII(names_[i]).Append(relatives[j].path);
154 std::string cracked_id; 153 std::string cracked_id;
155 FileInfo root_info;
156 FilePath cracked_path; 154 FilePath cracked_path;
155 FileSystemType cracked_type;
157 if (!relatives[j].valid) { 156 if (!relatives[j].valid) {
158 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( 157 ASSERT_FALSE(isolated_context()->CrackIsolatedPath(
159 virtual_path, &cracked_id, &root_info, &cracked_path)); 158 virtual_path, &cracked_id, &cracked_type, &cracked_path));
160 continue; 159 continue;
161 } 160 }
162 ASSERT_TRUE(isolated_context()->CrackIsolatedPath( 161 ASSERT_TRUE(isolated_context()->CrackIsolatedPath(
163 virtual_path, &cracked_id, &root_info, &cracked_path)); 162 virtual_path, &cracked_id, &cracked_type, &cracked_path));
164 ASSERT_TRUE(fileset_.find(root_info.path.NormalizePathSeparators())
165 != fileset_.end());
166 ASSERT_EQ(kTestPaths[i].Append(relatives[j].path) 163 ASSERT_EQ(kTestPaths[i].Append(relatives[j].path)
167 .NormalizePathSeparators().value(), 164 .NormalizePathSeparators().value(),
168 cracked_path.value()); 165 cracked_path.value());
169 ASSERT_EQ(id_, cracked_id); 166 ASSERT_EQ(id_, cracked_id);
167 ASSERT_EQ(kFileSystemTypeDragged, cracked_type);
170 } 168 }
171 } 169 }
172 } 170 }
173 171
174 TEST_F(IsolatedContextTest, TestWithVirtualRoot) { 172 TEST_F(IsolatedContextTest, TestWithVirtualRoot) {
175 std::string cracked_id; 173 std::string cracked_id;
176 FilePath cracked_path; 174 FilePath cracked_path;
177 175
178 // Trying to crack virtual root "/" returns true but with empty cracked path 176 // Trying to crack virtual root "/" returns true but with empty cracked path
179 // as "/" of the isolated filesystem is a pure virtual directory 177 // as "/" of the isolated filesystem is a pure virtual directory
180 // that has no corresponding platform directory. 178 // that has no corresponding platform directory.
181 FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_); 179 FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_);
182 ASSERT_TRUE(isolated_context()->CrackIsolatedPath( 180 ASSERT_TRUE(isolated_context()->CrackIsolatedPath(
183 virtual_path, &cracked_id, NULL, &cracked_path)); 181 virtual_path, &cracked_id, NULL, &cracked_path));
184 ASSERT_EQ(FPL(""), cracked_path.value()); 182 ASSERT_EQ(FPL(""), cracked_path.value());
185 ASSERT_EQ(id_, cracked_id); 183 ASSERT_EQ(id_, cracked_id);
186 184
187 // Trying to crack "/foo" should fail (because "foo" is not the one 185 // Trying to crack "/foo" should fail (because "foo" is not the one
188 // included in the kTestPaths). 186 // included in the kTestPaths).
189 virtual_path = isolated_context()->CreateVirtualRootPath( 187 virtual_path = isolated_context()->CreateVirtualRootPath(
190 id_).AppendASCII("foo"); 188 id_).AppendASCII("foo");
191 ASSERT_FALSE(isolated_context()->CrackIsolatedPath( 189 ASSERT_FALSE(isolated_context()->CrackIsolatedPath(
192 virtual_path, &cracked_id, NULL, &cracked_path)); 190 virtual_path, &cracked_id, NULL, &cracked_path));
193 } 191 }
194 192
195 } // namespace fileapi 193 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/isolated_context.cc ('k') | webkit/fileapi/isolated_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698