OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 map["filesystem_resource"] = buffer; | 142 map["filesystem_resource"] = buffer; |
143 ScopedRef<Html5FsForTesting> fs( | 143 ScopedRef<Html5FsForTesting> fs( |
144 new Html5FsForTesting(map, &ppapi_)); | 144 new Html5FsForTesting(map, &ppapi_)); |
145 | 145 |
146 ASSERT_EQ(0, fs->Access(Path("/foo"), R_OK | W_OK | X_OK)); | 146 ASSERT_EQ(0, fs->Access(Path("/foo"), R_OK | W_OK | X_OK)); |
147 | 147 |
148 ppapi_html5_.GetCoreInterface()->ReleaseResource(filesystem); | 148 ppapi_html5_.GetCoreInterface()->ReleaseResource(filesystem); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
| 152 TEST_F(Html5FsTest, MountSubtree) { |
| 153 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo/bar", |
| 154 NULL)); |
| 155 StringMap_t map; |
| 156 map["SOURCE"] = "/foo"; |
| 157 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
| 158 |
| 159 ASSERT_EQ(0, fs->Access(Path("/bar"), R_OK | W_OK | X_OK)); |
| 160 ASSERT_EQ(ENOENT, fs->Access(Path("/foo/bar"), F_OK)); |
| 161 } |
| 162 |
152 TEST_F(Html5FsTest, Access) { | 163 TEST_F(Html5FsTest, Access) { |
153 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo", NULL)); | 164 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/foo", NULL)); |
154 | 165 |
155 StringMap_t map; | 166 StringMap_t map; |
156 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 167 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
157 | 168 |
158 ASSERT_EQ(0, fs->Access(Path("/foo"), R_OK | W_OK | X_OK)); | 169 ASSERT_EQ(0, fs->Access(Path("/foo"), R_OK | W_OK | X_OK)); |
159 ASSERT_EQ(ENOENT, fs->Access(Path("/bar"), F_OK)); | 170 ASSERT_EQ(ENOENT, fs->Access(Path("/bar"), F_OK)); |
160 } | 171 } |
161 | 172 |
(...skipping 20 matching lines...) Expand all Loading... |
182 | 193 |
183 StringMap_t map; | 194 StringMap_t map; |
184 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 195 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
185 | 196 |
186 Path path("/foo"); | 197 Path path("/foo"); |
187 ASSERT_EQ(0, fs->Access(path, F_OK)); | 198 ASSERT_EQ(0, fs->Access(path, F_OK)); |
188 ASSERT_EQ(0, fs->Remove(path)); | 199 ASSERT_EQ(0, fs->Remove(path)); |
189 EXPECT_EQ(ENOENT, fs->Access(path, F_OK)); | 200 EXPECT_EQ(ENOENT, fs->Access(path, F_OK)); |
190 } | 201 } |
191 | 202 |
192 // Unlink + Rmdir forward to Remove unconditionally, which will not fail if the | 203 TEST_F(Html5FsTest, Unlink) { |
193 // file type is wrong. | |
194 TEST_F(Html5FsTest, DISABLED_Unlink) { | |
195 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL)); | 204 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL)); |
196 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL)); | 205 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL)); |
197 | 206 |
198 StringMap_t map; | 207 StringMap_t map; |
199 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 208 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
200 | 209 |
201 ASSERT_EQ(EISDIR, fs->Unlink(Path("/dir"))); | 210 ASSERT_EQ(EISDIR, fs->Unlink(Path("/dir"))); |
202 EXPECT_EQ(0, fs->Unlink(Path("/file"))); | 211 EXPECT_EQ(0, fs->Unlink(Path("/file"))); |
203 EXPECT_EQ(ENOENT, fs->Access(Path("/file"), F_OK)); | 212 EXPECT_EQ(ENOENT, fs->Access(Path("/file"), F_OK)); |
204 EXPECT_EQ(0, fs->Access(Path("/dir"), F_OK)); | 213 EXPECT_EQ(0, fs->Access(Path("/dir"), F_OK)); |
205 } | 214 } |
206 | 215 |
207 // Unlink + Rmdir forward to Remove unconditionally, which will not fail if the | 216 TEST_F(Html5FsTest, Rmdir) { |
208 // file type is wrong. | |
209 TEST_F(Html5FsTest, DISABLED_Rmdir) { | |
210 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL)); | 217 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddEmptyFile("/file", NULL)); |
211 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL)); | 218 EXPECT_TRUE(ppapi_html5_.filesystem_template()->AddDirectory("/dir", NULL)); |
212 | 219 |
213 StringMap_t map; | 220 StringMap_t map; |
214 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); | 221 ScopedRef<Html5FsForTesting> fs(new Html5FsForTesting(map, &ppapi_)); |
215 | 222 |
216 ASSERT_EQ(ENOTDIR, fs->Rmdir(Path("/file"))); | 223 ASSERT_EQ(ENOTDIR, fs->Rmdir(Path("/file"))); |
217 EXPECT_EQ(0, fs->Rmdir(Path("/dir"))); | 224 EXPECT_EQ(0, fs->Rmdir(Path("/dir"))); |
218 EXPECT_EQ(ENOENT, fs->Access(Path("/dir"), F_OK)); | 225 EXPECT_EQ(ENOENT, fs->Access(Path("/dir"), F_OK)); |
219 EXPECT_EQ(0, fs->Access(Path("/file"), F_OK)); | 226 EXPECT_EQ(0, fs->Access(Path("/file"), F_OK)); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen); | 524 EXPECT_EQ(sizeof(dirent), dirents[i].d_reclen); |
518 dirnames.insert(dirents[i].d_name); | 525 dirnames.insert(dirents[i].d_name); |
519 } | 526 } |
520 | 527 |
521 EXPECT_EQ(1, dirnames.count("file")); | 528 EXPECT_EQ(1, dirnames.count("file")); |
522 EXPECT_EQ(1, dirnames.count("file2")); | 529 EXPECT_EQ(1, dirnames.count("file2")); |
523 EXPECT_EQ(1, dirnames.count(".")); | 530 EXPECT_EQ(1, dirnames.count(".")); |
524 EXPECT_EQ(1, dirnames.count("..")); | 531 EXPECT_EQ(1, dirnames.count("..")); |
525 } | 532 } |
526 } | 533 } |
OLD | NEW |