OLD | NEW |
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/syncable/syncable_file_system_util.h" | 5 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "webkit/browser/fileapi/external_mount_points.h" | 11 #include "webkit/browser/fileapi/external_mount_points.h" |
| 12 #include "webkit/fileapi/file_system_types.h" |
12 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" | 13 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" |
13 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 14 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
14 | 15 |
15 using fileapi::ExternalMountPoints; | 16 using fileapi::ExternalMountPoints; |
16 using fileapi::FileSystemURL; | 17 using fileapi::FileSystemURL; |
17 using fileapi::ScopedExternalFileSystem; | 18 using fileapi::ScopedExternalFileSystem; |
18 | 19 |
19 namespace sync_file_system { | 20 namespace sync_file_system { |
20 | 21 |
21 namespace { | 22 namespace { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 EXPECT_TRUE(deserialized.is_valid()); | 140 EXPECT_TRUE(deserialized.is_valid()); |
140 | 141 |
141 // Shutting down. | 142 // Shutting down. |
142 file_system.TearDown(); | 143 file_system.TearDown(); |
143 RevokeSyncableFileSystem(kServiceName); | 144 RevokeSyncableFileSystem(kServiceName); |
144 sync_context->ShutdownOnUIThread(); | 145 sync_context->ShutdownOnUIThread(); |
145 sync_context = NULL; | 146 sync_context = NULL; |
146 base::MessageLoop::current()->RunUntilIdle(); | 147 base::MessageLoop::current()->RunUntilIdle(); |
147 } | 148 } |
148 | 149 |
| 150 TEST(SyncableFileSystemUtilTest, SyncableFileSystemURL_IsParent) { |
| 151 ScopedExternalFileSystem scoped1("foo", fileapi::kFileSystemTypeSyncable, |
| 152 base::FilePath()); |
| 153 ScopedExternalFileSystem scoped2("bar", fileapi::kFileSystemTypeSyncable, |
| 154 base::FilePath()); |
| 155 |
| 156 const std::string root1 = sync_file_system::GetSyncableFileSystemRootURI( |
| 157 GURL("http://example.com"), "foo").spec(); |
| 158 const std::string root2 = sync_file_system::GetSyncableFileSystemRootURI( |
| 159 GURL("http://example.com"), "bar").spec(); |
| 160 |
| 161 const std::string parent("dir"); |
| 162 const std::string child("dir/child"); |
| 163 |
| 164 // True case. |
| 165 EXPECT_TRUE(CreateFileSystemURL(root1 + parent).IsParent( |
| 166 CreateFileSystemURL(root1 + child))); |
| 167 EXPECT_TRUE(CreateFileSystemURL(root2 + parent).IsParent( |
| 168 CreateFileSystemURL(root2 + child))); |
| 169 |
| 170 // False case: different filesystem ID. |
| 171 EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent( |
| 172 CreateFileSystemURL(root2 + child))); |
| 173 EXPECT_FALSE(CreateFileSystemURL(root2 + parent).IsParent( |
| 174 CreateFileSystemURL(root1 + child))); |
| 175 } |
| 176 |
149 } // namespace sync_file_system | 177 } // namespace sync_file_system |
OLD | NEW |