| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "webkit/fileapi/external_mount_points.h" | 5 #include "webkit/fileapi/external_mount_points.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 mount_points->RegisterFileSystem("o", | 147 mount_points->RegisterFileSystem("o", |
| 148 fileapi::kFileSystemTypeNativeLocal, | 148 fileapi::kFileSystemTypeNativeLocal, |
| 149 base::FilePath(DRIVE FPL("/m/n/o"))); | 149 base::FilePath(DRIVE FPL("/m/n/o"))); |
| 150 // A mount point whose name does not match its path base name. | 150 // A mount point whose name does not match its path base name. |
| 151 mount_points->RegisterFileSystem("mount", | 151 mount_points->RegisterFileSystem("mount", |
| 152 fileapi::kFileSystemTypeNativeLocal, | 152 fileapi::kFileSystemTypeNativeLocal, |
| 153 base::FilePath(DRIVE FPL("/root/foo"))); | 153 base::FilePath(DRIVE FPL("/root/foo"))); |
| 154 // A mount point with an empty path. | 154 // A mount point with an empty path. |
| 155 mount_points->RegisterFileSystem("empty_path", | 155 mount_points->RegisterFileSystem("empty_path", |
| 156 fileapi::kFileSystemTypeNativeLocal, | 156 fileapi::kFileSystemTypeNativeLocal, |
| 157 base::FilePath(FPL(""))); | 157 base::FilePath()); |
| 158 | 158 |
| 159 struct TestCase { | 159 struct TestCase { |
| 160 const base::FilePath::CharType* const local_path; | 160 const base::FilePath::CharType* const local_path; |
| 161 bool success; | 161 bool success; |
| 162 const base::FilePath::CharType* const virtual_path; | 162 const base::FilePath::CharType* const virtual_path; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 const TestCase kTestCases[] = { | 165 const TestCase kTestCases[] = { |
| 166 // Empty path. | 166 // Empty path. |
| 167 { FPL(""), false, FPL("") }, | 167 { FPL(""), false, FPL("") }, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 const GURL kTestOrigin("http://chromium.org"); | 264 const GURL kTestOrigin("http://chromium.org"); |
| 265 | 265 |
| 266 mount_points->RegisterFileSystem("c", | 266 mount_points->RegisterFileSystem("c", |
| 267 fileapi::kFileSystemTypeNativeLocal, | 267 fileapi::kFileSystemTypeNativeLocal, |
| 268 base::FilePath(DRIVE FPL("/a/b/c"))); | 268 base::FilePath(DRIVE FPL("/a/b/c"))); |
| 269 mount_points->RegisterFileSystem("c(1)", | 269 mount_points->RegisterFileSystem("c(1)", |
| 270 fileapi::kFileSystemTypeDrive, | 270 fileapi::kFileSystemTypeDrive, |
| 271 base::FilePath(DRIVE FPL("/a/b/c(1)"))); | 271 base::FilePath(DRIVE FPL("/a/b/c(1)"))); |
| 272 mount_points->RegisterFileSystem("empty_path", | 272 mount_points->RegisterFileSystem("empty_path", |
| 273 fileapi::kFileSystemTypeSyncable, | 273 fileapi::kFileSystemTypeSyncable, |
| 274 base::FilePath(FPL(""))); | 274 base::FilePath()); |
| 275 mount_points->RegisterFileSystem("mount", | 275 mount_points->RegisterFileSystem("mount", |
| 276 fileapi::kFileSystemTypeDrive, | 276 fileapi::kFileSystemTypeDrive, |
| 277 base::FilePath(DRIVE FPL("/root"))); | 277 base::FilePath(DRIVE FPL("/root"))); |
| 278 | 278 |
| 279 // Try cracking invalid GURL. | 279 // Try cracking invalid GURL. |
| 280 FileSystemURL invalid = mount_points->CrackURL(GURL("http://chromium.og")); | 280 FileSystemURL invalid = mount_points->CrackURL(GURL("http://chromium.og")); |
| 281 EXPECT_FALSE(invalid.is_valid()); | 281 EXPECT_FALSE(invalid.is_valid()); |
| 282 | 282 |
| 283 // Try cracking isolated path. | 283 // Try cracking isolated path. |
| 284 FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL( | 284 FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL( |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 const GURL kTestOrigin("http://chromium.org"); | 375 const GURL kTestOrigin("http://chromium.org"); |
| 376 | 376 |
| 377 mount_points->RegisterFileSystem("c", | 377 mount_points->RegisterFileSystem("c", |
| 378 fileapi::kFileSystemTypeNativeLocal, | 378 fileapi::kFileSystemTypeNativeLocal, |
| 379 base::FilePath(DRIVE FPL("/a/b/c"))); | 379 base::FilePath(DRIVE FPL("/a/b/c"))); |
| 380 mount_points->RegisterFileSystem("c(1)", | 380 mount_points->RegisterFileSystem("c(1)", |
| 381 fileapi::kFileSystemTypeDrive, | 381 fileapi::kFileSystemTypeDrive, |
| 382 base::FilePath(DRIVE FPL("/a/b/c(1)"))); | 382 base::FilePath(DRIVE FPL("/a/b/c(1)"))); |
| 383 mount_points->RegisterFileSystem("empty_path", | 383 mount_points->RegisterFileSystem("empty_path", |
| 384 fileapi::kFileSystemTypeSyncable, | 384 fileapi::kFileSystemTypeSyncable, |
| 385 base::FilePath(FPL(""))); | 385 base::FilePath()); |
| 386 mount_points->RegisterFileSystem("mount", | 386 mount_points->RegisterFileSystem("mount", |
| 387 fileapi::kFileSystemTypeDrive, | 387 fileapi::kFileSystemTypeDrive, |
| 388 base::FilePath(DRIVE FPL("/root"))); | 388 base::FilePath(DRIVE FPL("/root"))); |
| 389 | 389 |
| 390 struct TestCase { | 390 struct TestCase { |
| 391 const base::FilePath::CharType* const path; | 391 const base::FilePath::CharType* const path; |
| 392 bool expect_valid; | 392 bool expect_valid; |
| 393 fileapi::FileSystemType expect_type; | 393 fileapi::FileSystemType expect_type; |
| 394 const base::FilePath::CharType* const expect_path; | 394 const base::FilePath::CharType* const expect_path; |
| 395 const char* const expect_name; | 395 const char* const expect_name; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 EXPECT_EQ(base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(
), | 453 EXPECT_EQ(base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(
), |
| 454 cracked_path) | 454 cracked_path) |
| 455 << "Test case index: " << i; | 455 << "Test case index: " << i; |
| 456 EXPECT_EQ(kTestCases[i].expect_name, cracked_name) | 456 EXPECT_EQ(kTestCases[i].expect_name, cracked_name) |
| 457 << "Test case index: " << i; | 457 << "Test case index: " << i; |
| 458 } | 458 } |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace | 461 } // namespace |
| 462 | 462 |
| OLD | NEW |