external_mount_points_unittest.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "storage/browser/file_system/external_mount_points.h"
  5. #include <stddef.h>
  6. #include <string>
  7. #include "base/files/file_path.h"
  8. #include "storage/browser/file_system/file_system_url.h"
  9. #include "storage/common/file_system/file_system_mount_option.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. #include "third_party/blink/public/common/storage_key/storage_key.h"
  12. #include "url/gurl.h"
  13. #define FPL FILE_PATH_LITERAL
  14. #if defined(FILE_PATH_USES_DRIVE_LETTERS)
  15. #define DRIVE FPL("C:")
  16. #else
  17. #define DRIVE
  18. #endif
  19. class GURL;
  20. namespace storage {
  21. TEST(ExternalMountPointsTest, AddMountPoint) {
  22. scoped_refptr<ExternalMountPoints> mount_points =
  23. ExternalMountPoints::CreateRefCounted();
  24. struct TestCase {
  25. // The mount point's name.
  26. const char* const name;
  27. // The mount point's path.
  28. const base::FilePath::CharType* const path;
  29. // Whether the mount point registration should succeed.
  30. bool success;
  31. // Path returned by GetRegisteredPath. nullptr if the method is expected to
  32. // fail.
  33. const base::FilePath::CharType* const registered_path;
  34. };
  35. const TestCase kTestCases[] = {
  36. // Valid mount point.
  37. {"test", DRIVE FPL("/foo/test"), true, DRIVE FPL("/foo/test")},
  38. // Valid mount point with only one path component.
  39. {"bbb", DRIVE FPL("/bbb"), true, DRIVE FPL("/bbb")},
  40. // Existing mount point path is substring of the mount points path.
  41. {"test11", DRIVE FPL("/foo/test11"), true, DRIVE FPL("/foo/test11")},
  42. // Path substring of an existing path.
  43. {"test1", DRIVE FPL("/foo/test1"), true, DRIVE FPL("/foo/test1")},
  44. // Empty mount point name and path.
  45. {"", DRIVE FPL(""), false, nullptr},
  46. // Empty mount point name.
  47. {"", DRIVE FPL("/ddd"), false, nullptr},
  48. // Empty mount point path.
  49. {"empty_path", FPL(""), true, FPL("")},
  50. // Name different from path's base name.
  51. {"not_base_name", DRIVE FPL("/x/y/z"), true, DRIVE FPL("/x/y/z")},
  52. // References parent.
  53. {"invalid", DRIVE FPL("../foo/invalid"), false, nullptr},
  54. // Relative path.
  55. {"relative", DRIVE FPL("foo/relative"), false, nullptr},
  56. // Existing mount point path.
  57. {"path_exists", DRIVE FPL("/foo/test"), false, nullptr},
  58. // Mount point with the same name exists.
  59. {"test", DRIVE FPL("/foo/a/test_name_exists"), false,
  60. DRIVE FPL("/foo/test")},
  61. // Child of an existing mount point.
  62. {"a1", DRIVE FPL("/foo/test/a"), false, nullptr},
  63. // Parent of an existing mount point.
  64. {"foo1", DRIVE FPL("/foo"), false, nullptr},
  65. // Bit bigger depth.
  66. {"g", DRIVE FPL("/foo/a/b/c/d/e/f/g"), true,
  67. DRIVE FPL("/foo/a/b/c/d/e/f/g")},
  68. // Sibling mount point (with similar name) exists.
  69. {"ff", DRIVE FPL("/foo/a/b/c/d/e/ff"), true,
  70. DRIVE FPL("/foo/a/b/c/d/e/ff")},
  71. // Lexicographically last among existing mount points.
  72. {"yyy", DRIVE FPL("/zzz/yyy"), true, DRIVE FPL("/zzz/yyy")},
  73. // Parent of the lexicographically last mount point.
  74. {"zzz1", DRIVE FPL("/zzz"), false, nullptr},
  75. // Child of the lexicographically last mount point.
  76. {"xxx1", DRIVE FPL("/zzz/yyy/xxx"), false, nullptr},
  77. // Lexicographically first among existing mount points.
  78. {"b", DRIVE FPL("/a/b"), true, DRIVE FPL("/a/b")},
  79. // Parent of lexicographically first mount point.
  80. {"a2", DRIVE FPL("/a"), false, nullptr},
  81. // Child of lexicographically last mount point.
  82. {"c1", DRIVE FPL("/a/b/c"), false, nullptr},
  83. // Parent to all of the mount points.
  84. {"root", DRIVE FPL("/"), false, nullptr},
  85. // Path contains .. component.
  86. {"funky", DRIVE FPL("/tt/fun/../funky"), false, nullptr},
  87. // Windows separators.
  88. #if defined(FILE_PATH_USES_WIN_SEPARATORS)
  89. {"win", DRIVE FPL("\\try\\separators\\win"), true,
  90. DRIVE FPL("\\try\\separators\\win")},
  91. {"win1", DRIVE FPL("\\try/separators\\win1"), true,
  92. DRIVE FPL("\\try/separators\\win1")},
  93. {"win2", DRIVE FPL("\\try/separators\\win"), false, nullptr},
  94. #else
  95. {"win", DRIVE FPL("\\separators\\win"), false, nullptr},
  96. {"win1", DRIVE FPL("\\try/separators\\win1"), false, nullptr},
  97. #endif
  98. // Win separators, but relative path.
  99. {"win2", DRIVE FPL("try\\separators\\win2"), false, nullptr},
  100. };
  101. // Test adding mount points.
  102. for (const auto& test : kTestCases) {
  103. EXPECT_EQ(test.success,
  104. mount_points->RegisterFileSystem(test.name, kFileSystemTypeLocal,
  105. FileSystemMountOption(),
  106. base::FilePath(test.path)))
  107. << "Adding mount point: " << test.name << " with path " << test.path;
  108. }
  109. // Test that final mount point presence state is as expected.
  110. for (size_t i = 0; i < std::size(kTestCases); ++i) {
  111. base::FilePath found_path;
  112. EXPECT_EQ(kTestCases[i].registered_path != nullptr,
  113. mount_points->GetRegisteredPath(kTestCases[i].name, &found_path))
  114. << "Test case: " << i;
  115. if (kTestCases[i].registered_path) {
  116. base::FilePath expected_path(kTestCases[i].registered_path);
  117. EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path);
  118. }
  119. }
  120. }
  121. TEST(ExternalMountPointsTest, GetVirtualPath) {
  122. scoped_refptr<ExternalMountPoints> mount_points =
  123. ExternalMountPoints::CreateRefCounted();
  124. mount_points->RegisterFileSystem("c", kFileSystemTypeLocal,
  125. FileSystemMountOption(),
  126. base::FilePath(DRIVE FPL("/a/b/c")));
  127. // Note that "/a/b/c" < "/a/b/c(1)" < "/a/b/c/".
  128. mount_points->RegisterFileSystem("c(1)", kFileSystemTypeLocal,
  129. FileSystemMountOption(),
  130. base::FilePath(DRIVE FPL("/a/b/c(1)")));
  131. mount_points->RegisterFileSystem("x", kFileSystemTypeLocal,
  132. FileSystemMountOption(),
  133. base::FilePath(DRIVE FPL("/z/y/x")));
  134. mount_points->RegisterFileSystem("o", kFileSystemTypeLocal,
  135. FileSystemMountOption(),
  136. base::FilePath(DRIVE FPL("/m/n/o")));
  137. // A mount point whose name does not match its path base name.
  138. mount_points->RegisterFileSystem("mount", kFileSystemTypeLocal,
  139. FileSystemMountOption(),
  140. base::FilePath(DRIVE FPL("/root/foo")));
  141. // A mount point with an empty path.
  142. mount_points->RegisterFileSystem("empty_path", kFileSystemTypeLocal,
  143. FileSystemMountOption(), base::FilePath());
  144. struct TestCase {
  145. const base::FilePath::CharType* const local_path;
  146. bool success;
  147. const base::FilePath::CharType* const virtual_path;
  148. };
  149. const TestCase kTestCases[] = {
  150. // Empty path.
  151. {FPL(""), false, FPL("")},
  152. // No registered mount point (but is parent to a mount point).
  153. {DRIVE FPL("/a/b"), false, FPL("")},
  154. // No registered mount point (but is parent to a mount point).
  155. {DRIVE FPL("/z/y"), false, FPL("")},
  156. // No registered mount point (but is parent to a mount point).
  157. {DRIVE FPL("/m/n"), false, FPL("")},
  158. // No registered mount point.
  159. {DRIVE FPL("/foo/mount"), false, FPL("")},
  160. // An existing mount point path is substring.
  161. {DRIVE FPL("/a/b/c1"), false, FPL("")},
  162. // No leading /.
  163. {DRIVE FPL("a/b/c"), false, FPL("")},
  164. // Sibling to a root path.
  165. {DRIVE FPL("/a/b/d/e"), false, FPL("")},
  166. // Sibling to a root path.
  167. {DRIVE FPL("/z/y/v/u"), false, FPL("")},
  168. // Sibling to a root path.
  169. {DRIVE FPL("/m/n/p/q"), false, FPL("")},
  170. // Mount point root path.
  171. {DRIVE FPL("/a/b/c"), true, FPL("c")},
  172. // Mount point root path.
  173. {DRIVE FPL("/z/y/x"), true, FPL("x")},
  174. // Mount point root path.
  175. {DRIVE FPL("/m/n/o"), true, FPL("o")},
  176. // Mount point child path.
  177. {DRIVE FPL("/a/b/c/d/e"), true, FPL("c/d/e")},
  178. // Mount point child path.
  179. {DRIVE FPL("/z/y/x/v/u"), true, FPL("x/v/u")},
  180. // Mount point child path.
  181. {DRIVE FPL("/m/n/o/p/q"), true, FPL("o/p/q")},
  182. // Name doesn't match mount point path base name.
  183. {DRIVE FPL("/root/foo/a/b/c"), true, FPL("mount/a/b/c")},
  184. {DRIVE FPL("/root/foo"), true, FPL("mount")},
  185. // Mount point contains character whose ASCII code is smaller than file path
  186. // separator's.
  187. {DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e")},
  188. #if defined(FILE_PATH_USES_WIN_SEPARATORS)
  189. // Path with win separators mixed in.
  190. {DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d")},
  191. #endif
  192. };
  193. for (const auto& test_case : kTestCases) {
  194. // Initialize virtual path with a value.
  195. base::FilePath virtual_path(DRIVE FPL("/mount"));
  196. base::FilePath local_path(test_case.local_path);
  197. EXPECT_EQ(test_case.success,
  198. mount_points->GetVirtualPath(local_path, &virtual_path))
  199. << "Resolving " << test_case.local_path;
  200. // There are no guarantees for |virtual_path| value if |GetVirtualPath|
  201. // fails.
  202. if (!test_case.success)
  203. continue;
  204. base::FilePath expected_virtual_path(test_case.virtual_path);
  205. EXPECT_EQ(expected_virtual_path.NormalizePathSeparators(), virtual_path)
  206. << "Resolving " << test_case.local_path;
  207. }
  208. }
  209. TEST(ExternalMountPointsTest, HandlesFileSystemMountType) {
  210. scoped_refptr<ExternalMountPoints> mount_points =
  211. ExternalMountPoints::CreateRefCounted();
  212. const GURL test_origin("http://chromium.org");
  213. const base::FilePath test_path(FPL("/mount"));
  214. // Should handle External File System.
  215. EXPECT_TRUE(
  216. mount_points->HandlesFileSystemMountType(kFileSystemTypeExternal));
  217. // Shouldn't handle the rest.
  218. EXPECT_FALSE(
  219. mount_points->HandlesFileSystemMountType(kFileSystemTypeIsolated));
  220. EXPECT_FALSE(
  221. mount_points->HandlesFileSystemMountType(kFileSystemTypeTemporary));
  222. EXPECT_FALSE(
  223. mount_points->HandlesFileSystemMountType(kFileSystemTypePersistent));
  224. EXPECT_FALSE(mount_points->HandlesFileSystemMountType(kFileSystemTypeTest));
  225. // Not even if it's external subtype.
  226. EXPECT_FALSE(mount_points->HandlesFileSystemMountType(kFileSystemTypeLocal));
  227. EXPECT_FALSE(
  228. mount_points->HandlesFileSystemMountType(kFileSystemTypeRestrictedLocal));
  229. EXPECT_FALSE(
  230. mount_points->HandlesFileSystemMountType(kFileSystemTypeDriveFs));
  231. EXPECT_FALSE(
  232. mount_points->HandlesFileSystemMountType(kFileSystemTypeSyncable));
  233. }
  234. TEST(ExternalMountPointsTest, CreateCrackedFileSystemURL) {
  235. scoped_refptr<ExternalMountPoints> mount_points =
  236. ExternalMountPoints::CreateRefCounted();
  237. const blink::StorageKey kTestStorageKey =
  238. blink::StorageKey::CreateFromStringForTesting("http://chromium.org");
  239. mount_points->RegisterFileSystem("c", kFileSystemTypeLocal,
  240. FileSystemMountOption(),
  241. base::FilePath(DRIVE FPL("/a/b/c")));
  242. mount_points->RegisterFileSystem("c(1)", kFileSystemTypeDriveFs,
  243. FileSystemMountOption(),
  244. base::FilePath(DRIVE FPL("/a/b/c(1)")));
  245. mount_points->RegisterFileSystem("empty_path", kFileSystemTypeSyncable,
  246. FileSystemMountOption(), base::FilePath());
  247. mount_points->RegisterFileSystem("mount", kFileSystemTypeDriveFs,
  248. FileSystemMountOption(),
  249. base::FilePath(DRIVE FPL("/root")));
  250. // Try cracking invalid GURL.
  251. FileSystemURL invalid = mount_points->CrackURL(
  252. GURL("http://chromium.og"),
  253. blink::StorageKey::CreateFromStringForTesting("http://chromium.og"));
  254. EXPECT_FALSE(invalid.is_valid());
  255. // Try cracking isolated path.
  256. FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL(
  257. kTestStorageKey, kFileSystemTypeIsolated, base::FilePath(FPL("c")));
  258. EXPECT_FALSE(isolated.is_valid());
  259. // Try native local which is not cracked.
  260. FileSystemURL native_local = mount_points->CreateCrackedFileSystemURL(
  261. kTestStorageKey, kFileSystemTypeLocal, base::FilePath(FPL("c")));
  262. EXPECT_FALSE(native_local.is_valid());
  263. struct TestCase {
  264. const base::FilePath::CharType* const path;
  265. bool expect_valid;
  266. FileSystemType expect_type;
  267. const base::FilePath::CharType* const expect_path;
  268. const char* const expect_fs_id;
  269. };
  270. const TestCase kTestCases[] = {
  271. {FPL("c/d/e"), true, kFileSystemTypeLocal, DRIVE FPL("/a/b/c/d/e"), "c"},
  272. {FPL("c(1)/d/e"), true, kFileSystemTypeDriveFs, DRIVE FPL("/a/b/c(1)/d/e"),
  273. "c(1)"},
  274. {FPL("c(1)"), true, kFileSystemTypeDriveFs, DRIVE FPL("/a/b/c(1)"), "c(1)"},
  275. {FPL("empty_path/a"), true, kFileSystemTypeSyncable, FPL("a"),
  276. "empty_path"},
  277. {FPL("empty_path"), true, kFileSystemTypeSyncable, FPL(""), "empty_path"},
  278. {FPL("mount/a/b"), true, kFileSystemTypeDriveFs, DRIVE FPL("/root/a/b"),
  279. "mount"},
  280. {FPL("mount"), true, kFileSystemTypeDriveFs, DRIVE FPL("/root"), "mount"},
  281. {FPL("cc"), false, kFileSystemTypeUnknown, FPL(""), ""},
  282. {FPL(""), false, kFileSystemTypeUnknown, FPL(""), ""},
  283. {FPL(".."), false, kFileSystemTypeUnknown, FPL(""), ""},
  284. // Absolute paths.
  285. {FPL("/c/d/e"), false, kFileSystemTypeUnknown, FPL(""), ""},
  286. {FPL("/c(1)/d/e"), false, kFileSystemTypeUnknown, FPL(""), ""},
  287. {FPL("/empty_path"), false, kFileSystemTypeUnknown, FPL(""), ""},
  288. // PAth references parent.
  289. {FPL("c/d/../e"), false, kFileSystemTypeUnknown, FPL(""), ""},
  290. {FPL("/empty_path/a/../b"), false, kFileSystemTypeUnknown, FPL(""), ""},
  291. #if defined(FILE_PATH_USES_WIN_SEPARATORS)
  292. {FPL("c/d\\e"), true, kFileSystemTypeLocal, DRIVE FPL("/a/b/c/d/e"), "c"},
  293. {FPL("mount\\a\\b"), true, kFileSystemTypeDriveFs, DRIVE FPL("/root/a/b"),
  294. "mount"},
  295. #endif
  296. };
  297. for (size_t i = 0; i < std::size(kTestCases); ++i) {
  298. FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL(
  299. kTestStorageKey, kFileSystemTypeExternal,
  300. base::FilePath(kTestCases[i].path));
  301. EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid())
  302. << "Test case index: " << i;
  303. if (!kTestCases[i].expect_valid)
  304. continue;
  305. EXPECT_EQ(kTestStorageKey.origin(), cracked.origin())
  306. << "Test case index: " << i;
  307. EXPECT_EQ(kTestCases[i].expect_type, cracked.type())
  308. << "Test case index: " << i;
  309. EXPECT_EQ(
  310. base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(),
  311. cracked.path())
  312. << "Test case index: " << i;
  313. EXPECT_EQ(base::FilePath(kTestCases[i].path).NormalizePathSeparators(),
  314. cracked.virtual_path())
  315. << "Test case index: " << i;
  316. EXPECT_EQ(kTestCases[i].expect_fs_id, cracked.filesystem_id())
  317. << "Test case index: " << i;
  318. EXPECT_EQ(kFileSystemTypeExternal, cracked.mount_type())
  319. << "Test case index: " << i;
  320. }
  321. }
  322. TEST(ExternalMountPointsTest, CrackVirtualPath) {
  323. scoped_refptr<ExternalMountPoints> mount_points =
  324. ExternalMountPoints::CreateRefCounted();
  325. const GURL kTestOrigin("http://chromium.org");
  326. mount_points->RegisterFileSystem("c", kFileSystemTypeLocal,
  327. FileSystemMountOption(),
  328. base::FilePath(DRIVE FPL("/a/b/c")));
  329. mount_points->RegisterFileSystem("c(1)", kFileSystemTypeDriveFs,
  330. FileSystemMountOption(),
  331. base::FilePath(DRIVE FPL("/a/b/c(1)")));
  332. mount_points->RegisterFileSystem("empty_path", kFileSystemTypeSyncable,
  333. FileSystemMountOption(), base::FilePath());
  334. mount_points->RegisterFileSystem("mount", kFileSystemTypeDriveFs,
  335. FileSystemMountOption(),
  336. base::FilePath(DRIVE FPL("/root")));
  337. struct TestCase {
  338. const base::FilePath::CharType* const path;
  339. bool expect_valid;
  340. FileSystemType expect_type;
  341. const base::FilePath::CharType* const expect_path;
  342. const char* const expect_name;
  343. };
  344. const TestCase kTestCases[] = {
  345. {FPL("c/d/e"), true, kFileSystemTypeLocal, DRIVE FPL("/a/b/c/d/e"), "c"},
  346. {FPL("c(1)/d/e"), true, kFileSystemTypeDriveFs, DRIVE FPL("/a/b/c(1)/d/e"),
  347. "c(1)"},
  348. {FPL("c(1)"), true, kFileSystemTypeDriveFs, DRIVE FPL("/a/b/c(1)"), "c(1)"},
  349. {FPL("empty_path/a"), true, kFileSystemTypeSyncable, FPL("a"),
  350. "empty_path"},
  351. {FPL("empty_path"), true, kFileSystemTypeSyncable, FPL(""), "empty_path"},
  352. {FPL("mount/a/b"), true, kFileSystemTypeDriveFs, DRIVE FPL("/root/a/b"),
  353. "mount"},
  354. {FPL("mount"), true, kFileSystemTypeDriveFs, DRIVE FPL("/root"), "mount"},
  355. {FPL("cc"), false, kFileSystemTypeUnknown, FPL(""), ""},
  356. {FPL(""), false, kFileSystemTypeUnknown, FPL(""), ""},
  357. {FPL(".."), false, kFileSystemTypeUnknown, FPL(""), ""},
  358. // Absolute paths.
  359. {FPL("/c/d/e"), false, kFileSystemTypeUnknown, FPL(""), ""},
  360. {FPL("/c(1)/d/e"), false, kFileSystemTypeUnknown, FPL(""), ""},
  361. {FPL("/empty_path"), false, kFileSystemTypeUnknown, FPL(""), ""},
  362. // PAth references parent.
  363. {FPL("c/d/../e"), false, kFileSystemTypeUnknown, FPL(""), ""},
  364. {FPL("/empty_path/a/../b"), false, kFileSystemTypeUnknown, FPL(""), ""},
  365. #if defined(FILE_PATH_USES_WIN_SEPARATORS)
  366. {FPL("c/d\\e"), true, kFileSystemTypeLocal, DRIVE FPL("/a/b/c/d/e"), "c"},
  367. {FPL("mount\\a\\b"), true, kFileSystemTypeDriveFs, DRIVE FPL("/root/a/b"),
  368. "mount"},
  369. #endif
  370. };
  371. for (size_t i = 0; i < std::size(kTestCases); ++i) {
  372. std::string cracked_name;
  373. FileSystemType cracked_type;
  374. std::string cracked_id;
  375. base::FilePath cracked_path;
  376. FileSystemMountOption cracked_option;
  377. EXPECT_EQ(kTestCases[i].expect_valid,
  378. mount_points->CrackVirtualPath(
  379. base::FilePath(kTestCases[i].path), &cracked_name,
  380. &cracked_type, &cracked_id, &cracked_path, &cracked_option))
  381. << "Test case index: " << i;
  382. if (!kTestCases[i].expect_valid)
  383. continue;
  384. EXPECT_EQ(kTestCases[i].expect_type, cracked_type)
  385. << "Test case index: " << i;
  386. EXPECT_EQ(
  387. base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(),
  388. cracked_path)
  389. << "Test case index: " << i;
  390. EXPECT_EQ(kTestCases[i].expect_name, cracked_name)
  391. << "Test case index: " << i;
  392. // As of now we don't mount other filesystems with non-empty filesystem_id
  393. // onto external mount points.
  394. EXPECT_TRUE(cracked_id.empty()) << "Test case index: " << i;
  395. }
  396. }
  397. TEST(ExternalMountPointsTest, MountOption) {
  398. scoped_refptr<ExternalMountPoints> mount_points =
  399. ExternalMountPoints::CreateRefCounted();
  400. mount_points->RegisterFileSystem(
  401. "nosync", kFileSystemTypeLocal,
  402. FileSystemMountOption(FlushPolicy::NO_FLUSH_ON_COMPLETION),
  403. base::FilePath(DRIVE FPL("/nosync")));
  404. mount_points->RegisterFileSystem(
  405. "sync", kFileSystemTypeLocal,
  406. FileSystemMountOption(FlushPolicy::FLUSH_ON_COMPLETION),
  407. base::FilePath(DRIVE FPL("/sync")));
  408. std::string name;
  409. FileSystemType type;
  410. std::string cracked_id;
  411. FileSystemMountOption option;
  412. base::FilePath path;
  413. EXPECT_TRUE(mount_points->CrackVirtualPath(base::FilePath(FPL("nosync/file")),
  414. &name, &type, &cracked_id, &path,
  415. &option));
  416. EXPECT_EQ(FlushPolicy::NO_FLUSH_ON_COMPLETION, option.flush_policy());
  417. EXPECT_TRUE(mount_points->CrackVirtualPath(base::FilePath(FPL("sync/file")),
  418. &name, &type, &cracked_id, &path,
  419. &option));
  420. EXPECT_EQ(FlushPolicy::FLUSH_ON_COMPLETION, option.flush_policy());
  421. }
  422. } // namespace storage