| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_system_path_manager.h" | |
| 6 | |
| 7 #include <set> | 5 #include <set> |
| 8 #include <string> | 6 #include <string> |
| 9 | 7 |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 11 #include "base/bind.h" | 9 #include "base/bind.h" |
| 12 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 13 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 17 #include "base/message_loop_proxy.h" | 15 #include "base/message_loop_proxy.h" |
| 18 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
| 19 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
| 20 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 21 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "webkit/fileapi/file_system_context.h" |
| 23 #include "webkit/fileapi/file_system_util.h" | 22 #include "webkit/fileapi/file_system_util.h" |
| 23 #include "webkit/fileapi/mock_file_system_options.h" |
| 24 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 24 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 25 #include "webkit/quota/mock_special_storage_policy.h" | 25 #include "webkit/quota/mock_special_storage_policy.h" |
| 26 | 26 |
| 27 #if defined(OS_CHROMEOS) |
| 28 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
| 29 #endif |
| 30 |
| 27 namespace fileapi { | 31 namespace fileapi { |
| 32 |
| 28 namespace { | 33 namespace { |
| 29 | 34 |
| 30 // PS stands for path separator. | 35 // PS stands for path separator. |
| 31 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 36 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| 32 #define PS "\\" | 37 #define PS "\\" |
| 33 #else | 38 #else |
| 34 #define PS "/" | 39 #define PS "/" |
| 35 #endif | 40 #endif |
| 36 | 41 |
| 37 struct RootPathTestCase { | 42 struct RootPathTestCase { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 { FILE_PATH_LITERAL(" ."), false, }, | 194 { FILE_PATH_LITERAL(" ."), false, }, |
| 190 { FILE_PATH_LITERAL(". "), false, }, | 195 { FILE_PATH_LITERAL(". "), false, }, |
| 191 { FILE_PATH_LITERAL(" . "), false, }, | 196 { FILE_PATH_LITERAL(" . "), false, }, |
| 192 { FILE_PATH_LITERAL(" .."), false, }, | 197 { FILE_PATH_LITERAL(" .."), false, }, |
| 193 { FILE_PATH_LITERAL(".. "), false, }, | 198 { FILE_PATH_LITERAL(".. "), false, }, |
| 194 { FILE_PATH_LITERAL(" .. "), false, }, | 199 { FILE_PATH_LITERAL(" .. "), false, }, |
| 195 { FILE_PATH_LITERAL("b."), false, }, | 200 { FILE_PATH_LITERAL("b."), false, }, |
| 196 { FILE_PATH_LITERAL(".b"), false, }, | 201 { FILE_PATH_LITERAL(".b"), false, }, |
| 197 }; | 202 }; |
| 198 | 203 |
| 199 FilePath UTF8ToFilePath(const std::string& str) { | 204 FileSystemOptions CreateRootPathTestOptions() { |
| 200 FilePath::StringType result; | 205 std::vector<std::string> additional_allowed_schemes; |
| 201 #if defined(OS_POSIX) | 206 additional_allowed_schemes.push_back("file"); |
| 202 result = base::SysWideToNativeMB(UTF8ToWide(str)); | 207 #if defined(OS_CHROMEOS) |
| 203 #elif defined(OS_WIN) | 208 additional_allowed_schemes.push_back("chrome-extension"); |
| 204 result = UTF8ToUTF16(str); | |
| 205 #endif | 209 #endif |
| 206 return FilePath(result); | 210 return FileSystemOptions(FileSystemOptions::PROFILE_MODE_NORMAL, |
| 211 additional_allowed_schemes); |
| 207 } | 212 } |
| 208 | 213 |
| 209 } // namespace | 214 } // namespace |
| 210 | 215 |
| 211 class FileSystemPathManagerTest : public testing::Test { | 216 class FileSystemMountPointProviderTest : public testing::Test { |
| 212 public: | 217 public: |
| 213 FileSystemPathManagerTest() | 218 FileSystemMountPointProviderTest() |
| 214 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 219 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 215 } | 220 } |
| 216 | 221 |
| 217 void SetUp() { | 222 void SetUp() { |
| 218 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 223 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
| 219 root_path_callback_status_ = false; | 224 root_path_callback_status_ = false; |
| 220 root_path_.clear(); | 225 root_path_.clear(); |
| 221 file_system_name_.clear(); | 226 file_system_name_.clear(); |
| 227 special_storage_policy_ = new quota::MockSpecialStoragePolicy; |
| 222 } | 228 } |
| 223 | 229 |
| 224 protected: | 230 protected: |
| 225 FileSystemPathManager* NewPathManager( | 231 void SetupNewContext(const FileSystemOptions& options) { |
| 226 bool incognito, | 232 file_system_context_ = new FileSystemContext( |
| 227 bool allow_file_access) { | |
| 228 FileSystemPathManager* manager = new FileSystemPathManager( | |
| 229 base::MessageLoopProxy::current(), | 233 base::MessageLoopProxy::current(), |
| 234 base::MessageLoopProxy::current(), |
| 235 special_storage_policy_, |
| 236 NULL, |
| 230 data_dir_.path(), | 237 data_dir_.path(), |
| 231 scoped_refptr<quota::SpecialStoragePolicy>( | 238 options); |
| 232 new quota::MockSpecialStoragePolicy), | |
| 233 incognito, | |
| 234 allow_file_access); | |
| 235 #if defined(OS_CHROMEOS) | 239 #if defined(OS_CHROMEOS) |
| 236 fileapi::ExternalFileSystemMountPointProvider* ext_provider = | 240 fileapi::ExternalFileSystemMountPointProvider* ext_provider = |
| 237 manager->external_provider(); | 241 file_system_context_->external_provider(); |
| 238 ext_provider->AddMountPoint(FilePath("/tmp/testing")); | 242 ext_provider->AddMountPoint(FilePath("/tmp/testing")); |
| 239 #endif | 243 #endif |
| 240 return manager; | 244 } |
| 245 |
| 246 FileSystemMountPointProvider* provider(FileSystemType type) { |
| 247 DCHECK(file_system_context_); |
| 248 return file_system_context_->GetMountPointProvider(type); |
| 241 } | 249 } |
| 242 | 250 |
| 243 void OnGetRootPath(bool success, | 251 void OnGetRootPath(bool success, |
| 244 const FilePath& root_path, | 252 const FilePath& root_path, |
| 245 const std::string& name) { | 253 const std::string& name) { |
| 246 root_path_callback_status_ = success; | 254 root_path_callback_status_ = success; |
| 247 root_path_ = root_path; | 255 root_path_ = root_path; |
| 248 file_system_name_ = name; | 256 file_system_name_ = name; |
| 249 } | 257 } |
| 250 | 258 |
| 251 bool GetRootPath(FileSystemPathManager* manager, | 259 bool GetRootPath(const GURL& origin_url, |
| 252 const GURL& origin_url, | |
| 253 fileapi::FileSystemType type, | 260 fileapi::FileSystemType type, |
| 254 bool create, | 261 bool create, |
| 255 FilePath* root_path) { | 262 FilePath* root_path) { |
| 256 manager->ValidateFileSystemRootAndGetURL( | 263 provider(type)->ValidateFileSystemRootAndGetURL( |
| 257 origin_url, type, create, | 264 origin_url, type, create, |
| 258 base::Bind(&FileSystemPathManagerTest::OnGetRootPath, | 265 base::Bind(&FileSystemMountPointProviderTest::OnGetRootPath, |
| 259 weak_factory_.GetWeakPtr())); | 266 weak_factory_.GetWeakPtr())); |
| 260 MessageLoop::current()->RunAllPending(); | 267 MessageLoop::current()->RunAllPending(); |
| 261 if (root_path) | 268 if (root_path) |
| 262 *root_path = root_path_; | 269 *root_path = root_path_; |
| 263 return root_path_callback_status_; | 270 return root_path_callback_status_; |
| 264 } | 271 } |
| 265 | 272 |
| 266 FilePath data_path() { return data_dir_.path(); } | 273 FilePath data_path() { return data_dir_.path(); } |
| 267 FilePath file_system_path() { | 274 FilePath file_system_path() { |
| 268 return data_dir_.path().Append( | 275 return data_dir_.path().Append( |
| 269 SandboxMountPointProvider::kNewFileSystemDirectory); | 276 SandboxMountPointProvider::kNewFileSystemDirectory); |
| 270 } | 277 } |
| 271 FilePath external_file_system_path() { | 278 FilePath external_file_system_path() { |
| 272 return UTF8ToFilePath(std::string(fileapi::kExternalDir)); | 279 return FilePath::FromUTF8Unsafe(fileapi::kExternalDir); |
| 273 } | 280 } |
| 274 FilePath external_file_path_root() { | 281 FilePath external_file_path_root() { |
| 275 return UTF8ToFilePath(std::string("/tmp")); | 282 return FilePath::FromUTF8Unsafe("/tmp"); |
| 276 } | 283 } |
| 277 | 284 |
| 278 private: | 285 private: |
| 279 ScopedTempDir data_dir_; | 286 ScopedTempDir data_dir_; |
| 280 base::WeakPtrFactory<FileSystemPathManagerTest> weak_factory_; | 287 base::WeakPtrFactory<FileSystemMountPointProviderTest> weak_factory_; |
| 281 | 288 |
| 282 bool root_path_callback_status_; | 289 bool root_path_callback_status_; |
| 283 FilePath root_path_; | 290 FilePath root_path_; |
| 284 std::string file_system_name_; | 291 std::string file_system_name_; |
| 285 | 292 |
| 286 DISALLOW_COPY_AND_ASSIGN(FileSystemPathManagerTest); | 293 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
| 294 scoped_refptr<FileSystemContext> file_system_context_; |
| 295 |
| 296 DISALLOW_COPY_AND_ASSIGN(FileSystemMountPointProviderTest); |
| 287 }; | 297 }; |
| 288 | 298 |
| 289 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { | 299 TEST_F(FileSystemMountPointProviderTest, GetRootPathCreateAndExamine) { |
| 290 std::vector<FilePath> returned_root_path( | 300 std::vector<FilePath> returned_root_path( |
| 291 ARRAYSIZE_UNSAFE(kRootPathTestCases)); | 301 ARRAYSIZE_UNSAFE(kRootPathTestCases)); |
| 292 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 302 SetupNewContext(CreateRootPathTestOptions()); |
| 293 | 303 |
| 294 // Create a new root directory. | 304 // Create a new root directory. |
| 295 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 305 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
| 296 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " " | 306 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " " |
| 297 << kRootPathTestCases[i].expected_path); | 307 << kRootPathTestCases[i].expected_path); |
| 298 | 308 |
| 299 FilePath root_path; | 309 FilePath root_path; |
| 300 EXPECT_TRUE(GetRootPath(manager.get(), | 310 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
| 301 GURL(kRootPathTestCases[i].origin_url), | |
| 302 kRootPathTestCases[i].type, | 311 kRootPathTestCases[i].type, |
| 303 true /* create */, &root_path)); | 312 true /* create */, &root_path)); |
| 304 | 313 |
| 305 if (kRootPathTestCases[i].type != fileapi::kFileSystemTypeExternal) { | 314 if (kRootPathTestCases[i].type != fileapi::kFileSystemTypeExternal) { |
| 306 FilePath expected = file_system_path().AppendASCII( | 315 FilePath expected = file_system_path().AppendASCII( |
| 307 kRootPathTestCases[i].expected_path); | 316 kRootPathTestCases[i].expected_path); |
| 308 EXPECT_EQ(expected.value(), root_path.value()); | 317 EXPECT_EQ(expected.value(), root_path.value()); |
| 309 EXPECT_TRUE(file_util::DirectoryExists(root_path)); | 318 EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
| 310 } else { | 319 } else { |
| 311 // External file system root path is virtual one and does not match | 320 // External file system root path is virtual one and does not match |
| 312 // anything from the actual file system. | 321 // anything from the actual file system. |
| 313 EXPECT_EQ(external_file_system_path().value(), | 322 EXPECT_EQ(external_file_system_path().value(), |
| 314 root_path.value()); | 323 root_path.value()); |
| 315 } | 324 } |
| 316 ASSERT_TRUE(returned_root_path.size() > i); | 325 ASSERT_TRUE(returned_root_path.size() > i); |
| 317 returned_root_path[i] = root_path; | 326 returned_root_path[i] = root_path; |
| 318 } | 327 } |
| 319 | 328 |
| 320 // Get the root directory with create=false and see if we get the | 329 // Get the root directory with create=false and see if we get the |
| 321 // same directory. | 330 // same directory. |
| 322 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 331 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
| 323 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " " | 332 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " " |
| 324 << kRootPathTestCases[i].expected_path); | 333 << kRootPathTestCases[i].expected_path); |
| 325 | 334 |
| 326 FilePath root_path; | 335 FilePath root_path; |
| 327 EXPECT_TRUE(GetRootPath(manager.get(), | 336 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
| 328 GURL(kRootPathTestCases[i].origin_url), | |
| 329 kRootPathTestCases[i].type, | 337 kRootPathTestCases[i].type, |
| 330 false /* create */, &root_path)); | 338 false /* create */, &root_path)); |
| 331 ASSERT_TRUE(returned_root_path.size() > i); | 339 ASSERT_TRUE(returned_root_path.size() > i); |
| 332 EXPECT_EQ(returned_root_path[i].value(), root_path.value()); | 340 EXPECT_EQ(returned_root_path[i].value(), root_path.value()); |
| 333 } | 341 } |
| 334 } | 342 } |
| 335 | 343 |
| 336 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamineWithNewManager) { | 344 TEST_F(FileSystemMountPointProviderTest, |
| 345 GetRootPathCreateAndExamineWithNewProvider) { |
| 337 std::vector<FilePath> returned_root_path( | 346 std::vector<FilePath> returned_root_path( |
| 338 ARRAYSIZE_UNSAFE(kRootPathTestCases)); | 347 ARRAYSIZE_UNSAFE(kRootPathTestCases)); |
| 339 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 348 SetupNewContext(CreateAllowFileAccessOptions()); |
| 340 | 349 |
| 341 GURL origin_url("http://foo.com:1/"); | 350 GURL origin_url("http://foo.com:1/"); |
| 342 | 351 |
| 343 FilePath root_path1; | 352 FilePath root_path1; |
| 344 EXPECT_TRUE(GetRootPath(manager.get(), origin_url, | 353 EXPECT_TRUE(GetRootPath(origin_url, |
| 345 kFileSystemTypeTemporary, true, &root_path1)); | 354 kFileSystemTypeTemporary, true, &root_path1)); |
| 346 | 355 |
| 347 manager.reset(NewPathManager(false, false)); | 356 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 348 FilePath root_path2; | 357 FilePath root_path2; |
| 349 EXPECT_TRUE(GetRootPath(manager.get(), origin_url, | 358 EXPECT_TRUE(GetRootPath(origin_url, |
| 350 kFileSystemTypeTemporary, false, &root_path2)); | 359 kFileSystemTypeTemporary, false, &root_path2)); |
| 351 | 360 |
| 352 EXPECT_EQ(root_path1.value(), root_path2.value()); | 361 EXPECT_EQ(root_path1.value(), root_path2.value()); |
| 353 } | 362 } |
| 354 | 363 |
| 355 TEST_F(FileSystemPathManagerTest, GetRootPathGetWithoutCreate) { | 364 TEST_F(FileSystemMountPointProviderTest, GetRootPathGetWithoutCreate) { |
| 356 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 365 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 357 | 366 |
| 358 // Try to get a root directory without creating. | 367 // Try to get a root directory without creating. |
| 359 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 368 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
| 360 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " | 369 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " |
| 361 << kRootPathTestCases[i].expected_path); | 370 << kRootPathTestCases[i].expected_path); |
| 362 EXPECT_FALSE(GetRootPath(manager.get(), | 371 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
| 363 GURL(kRootPathTestCases[i].origin_url), | |
| 364 kRootPathTestCases[i].type, | 372 kRootPathTestCases[i].type, |
| 365 false /* create */, NULL)); | 373 false /* create */, NULL)); |
| 366 } | 374 } |
| 367 } | 375 } |
| 368 | 376 |
| 369 TEST_F(FileSystemPathManagerTest, GetRootPathInIncognito) { | 377 TEST_F(FileSystemMountPointProviderTest, GetRootPathInIncognito) { |
| 370 scoped_ptr<FileSystemPathManager> manager(NewPathManager( | 378 SetupNewContext(CreateIncognitoFileSystemOptions()); |
| 371 true /* incognito */, false)); | |
| 372 | 379 |
| 373 // Try to get a root directory. | 380 // Try to get a root directory. |
| 374 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 381 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
| 375 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " | 382 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " |
| 376 << kRootPathTestCases[i].expected_path); | 383 << kRootPathTestCases[i].expected_path); |
| 377 EXPECT_FALSE(GetRootPath(manager.get(), | 384 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
| 378 GURL(kRootPathTestCases[i].origin_url), | |
| 379 kRootPathTestCases[i].type, | 385 kRootPathTestCases[i].type, |
| 380 true /* create */, NULL)); | 386 true /* create */, NULL)); |
| 381 } | 387 } |
| 382 } | 388 } |
| 383 | 389 |
| 384 TEST_F(FileSystemPathManagerTest, GetRootPathFileURI) { | 390 TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURI) { |
| 385 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 391 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 386 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { | 392 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { |
| 387 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" | 393 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" |
| 388 << i << " " << kRootPathFileURITestCases[i].expected_path); | 394 << i << " " << kRootPathFileURITestCases[i].expected_path); |
| 389 EXPECT_FALSE(GetRootPath(manager.get(), | 395 EXPECT_FALSE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), |
| 390 GURL(kRootPathFileURITestCases[i].origin_url), | |
| 391 kRootPathFileURITestCases[i].type, | 396 kRootPathFileURITestCases[i].type, |
| 392 true /* create */, NULL)); | 397 true /* create */, NULL)); |
| 393 } | 398 } |
| 394 } | 399 } |
| 395 | 400 |
| 396 TEST_F(FileSystemPathManagerTest, GetRootPathFileURIWithAllowFlag) { | 401 TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURIWithAllowFlag) { |
| 397 scoped_ptr<FileSystemPathManager> manager(NewPathManager( | 402 SetupNewContext(CreateRootPathTestOptions()); |
| 398 false, true /* allow_file_access_from_files */)); | |
| 399 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { | 403 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { |
| 400 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" | 404 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" |
| 401 << i << " " << kRootPathFileURITestCases[i].expected_path); | 405 << i << " " << kRootPathFileURITestCases[i].expected_path); |
| 402 FilePath root_path; | 406 FilePath root_path; |
| 403 EXPECT_TRUE(GetRootPath(manager.get(), | 407 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), |
| 404 GURL(kRootPathFileURITestCases[i].origin_url), | |
| 405 kRootPathFileURITestCases[i].type, | 408 kRootPathFileURITestCases[i].type, |
| 406 true /* create */, &root_path)); | 409 true /* create */, &root_path)); |
| 407 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { | 410 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { |
| 408 FilePath expected = file_system_path().AppendASCII( | 411 FilePath expected = file_system_path().AppendASCII( |
| 409 kRootPathFileURITestCases[i].expected_path); | 412 kRootPathFileURITestCases[i].expected_path); |
| 410 EXPECT_EQ(expected.value(), root_path.value()); | 413 EXPECT_EQ(expected.value(), root_path.value()); |
| 411 EXPECT_TRUE(file_util::DirectoryExists(root_path)); | 414 EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
| 412 } else { | 415 } else { |
| 413 EXPECT_EQ(external_file_path_root().value(), root_path.value()); | 416 EXPECT_EQ(external_file_path_root().value(), root_path.value()); |
| 414 } | 417 } |
| 415 } | 418 } |
| 416 } | 419 } |
| 417 | 420 |
| 418 TEST_F(FileSystemPathManagerTest, IsRestrictedName) { | 421 TEST_F(FileSystemMountPointProviderTest, IsRestrictedName) { |
| 419 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 422 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 420 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { | 423 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { |
| 421 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " | 424 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " |
| 422 << kIsRestrictedNameTestCases[i].name); | 425 << kIsRestrictedNameTestCases[i].name); |
| 423 FilePath name(kIsRestrictedNameTestCases[i].name); | 426 FilePath name(kIsRestrictedNameTestCases[i].name); |
| 424 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, | 427 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, |
| 425 manager->IsRestrictedFileName(kFileSystemTypeTemporary, name)); | 428 provider(kFileSystemTypeTemporary)->IsRestrictedFileName(name)); |
| 426 } | 429 } |
| 427 } | 430 } |
| 428 | 431 |
| 429 } // namespace fileapi | 432 } // namespace fileapi |
| OLD | NEW |