Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: webkit/fileapi/syncable/syncable_file_system_unittest.cc

Issue 12315004: Migrated sync_file_type and file_change from namespace fileapi to sync_file_system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/syncable/sync_file_type.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/stl_util.h" 5 #include "base/stl_util.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "webkit/fileapi/file_system_context.h" 7 #include "webkit/fileapi/file_system_context.h"
8 #include "webkit/fileapi/file_system_task_runners.h" 8 #include "webkit/fileapi/file_system_task_runners.h"
9 #include "webkit/fileapi/file_system_types.h" 9 #include "webkit/fileapi/file_system_types.h"
10 #include "webkit/fileapi/isolated_context.h" 10 #include "webkit/fileapi/isolated_context.h"
11 #include "webkit/fileapi/local_file_system_operation.h" 11 #include "webkit/fileapi/local_file_system_operation.h"
12 #include "webkit/fileapi/local_file_system_test_helper.h" 12 #include "webkit/fileapi/local_file_system_test_helper.h"
13 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" 13 #include "webkit/fileapi/syncable/canned_syncable_file_system.h"
14 #include "webkit/fileapi/syncable/local_file_change_tracker.h" 14 #include "webkit/fileapi/syncable/local_file_change_tracker.h"
15 #include "webkit/fileapi/syncable/local_file_sync_context.h" 15 #include "webkit/fileapi/syncable/local_file_sync_context.h"
16 #include "webkit/fileapi/syncable/syncable_file_system_util.h" 16 #include "webkit/fileapi/syncable/syncable_file_system_util.h"
17 #include "webkit/quota/quota_manager.h" 17 #include "webkit/quota/quota_manager.h"
18 #include "webkit/quota/quota_types.h" 18 #include "webkit/quota/quota_types.h"
19 19
20 using base::PlatformFileError; 20 using base::PlatformFileError;
21 using quota::QuotaManager; 21 using quota::QuotaManager;
22 using quota::QuotaStatusCode; 22 using quota::QuotaStatusCode;
23 using sync_file_system::FileChange;
24 using sync_file_system::FileChangeList;
23 25
24 namespace fileapi { 26 namespace fileapi {
25 27
26 class SyncableFileSystemTest : public testing::Test { 28 class SyncableFileSystemTest : public testing::Test {
27 public: 29 public:
28 SyncableFileSystemTest() 30 SyncableFileSystemTest()
29 : file_system_(GURL("http://example.com/"), "test", 31 : file_system_(GURL("http://example.com/"), "test",
30 base::MessageLoopProxy::current(), 32 base::MessageLoopProxy::current(),
31 base::MessageLoopProxy::current()), 33 base::MessageLoopProxy::current()),
32 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} 34 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {}
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 FileSystemURLSet urls; 182 FileSystemURLSet urls;
181 file_system_.GetChangedURLsInTracker(&urls); 183 file_system_.GetChangedURLsInTracker(&urls);
182 184
183 EXPECT_EQ(3U, urls.size()); 185 EXPECT_EQ(3U, urls.size());
184 EXPECT_TRUE(ContainsKey(urls, URL(kPath0))); 186 EXPECT_TRUE(ContainsKey(urls, URL(kPath0)));
185 EXPECT_TRUE(ContainsKey(urls, URL(kPath1))); 187 EXPECT_TRUE(ContainsKey(urls, URL(kPath1)));
186 EXPECT_TRUE(ContainsKey(urls, URL(kPath2))); 188 EXPECT_TRUE(ContainsKey(urls, URL(kPath2)));
187 189
188 VerifyAndClearChange(URL(kPath0), 190 VerifyAndClearChange(URL(kPath0),
189 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 191 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
190 SYNC_FILE_TYPE_DIRECTORY)); 192 sync_file_system::SYNC_FILE_TYPE_DIRECTORY));
191 VerifyAndClearChange(URL(kPath1), 193 VerifyAndClearChange(URL(kPath1),
192 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 194 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
193 SYNC_FILE_TYPE_DIRECTORY)); 195 sync_file_system::SYNC_FILE_TYPE_DIRECTORY));
194 VerifyAndClearChange(URL(kPath2), 196 VerifyAndClearChange(URL(kPath2),
195 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 197 FileChange(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
196 SYNC_FILE_TYPE_FILE)); 198 sync_file_system::SYNC_FILE_TYPE_FILE));
197 199
198 // Creates and removes a same directory. 200 // Creates and removes a same directory.
199 EXPECT_EQ(base::PLATFORM_FILE_OK, 201 EXPECT_EQ(base::PLATFORM_FILE_OK,
200 file_system_.CreateDirectory(URL(kPath3))); 202 file_system_.CreateDirectory(URL(kPath3)));
201 EXPECT_EQ(base::PLATFORM_FILE_OK, 203 EXPECT_EQ(base::PLATFORM_FILE_OK,
202 file_system_.Remove(URL(kPath3), false /* recursive */)); 204 file_system_.Remove(URL(kPath3), false /* recursive */));
203 205
204 // The changes will be offset. 206 // The changes will be offset.
205 urls.clear(); 207 urls.clear();
206 file_system_.GetChangedURLsInTracker(&urls); 208 file_system_.GetChangedURLsInTracker(&urls);
207 EXPECT_TRUE(urls.empty()); 209 EXPECT_TRUE(urls.empty());
208 210
209 // Recursively removes the kPath0 directory. 211 // Recursively removes the kPath0 directory.
210 EXPECT_EQ(base::PLATFORM_FILE_OK, 212 EXPECT_EQ(base::PLATFORM_FILE_OK,
211 file_system_.Remove(URL(kPath0), true /* recursive */)); 213 file_system_.Remove(URL(kPath0), true /* recursive */));
212 214
213 urls.clear(); 215 urls.clear();
214 file_system_.GetChangedURLsInTracker(&urls); 216 file_system_.GetChangedURLsInTracker(&urls);
215 217
216 // kPath0 and its all chidren (kPath1 and kPath2) must have been deleted. 218 // kPath0 and its all chidren (kPath1 and kPath2) must have been deleted.
217 EXPECT_EQ(3U, urls.size()); 219 EXPECT_EQ(3U, urls.size());
218 EXPECT_TRUE(ContainsKey(urls, URL(kPath0))); 220 EXPECT_TRUE(ContainsKey(urls, URL(kPath0)));
219 EXPECT_TRUE(ContainsKey(urls, URL(kPath1))); 221 EXPECT_TRUE(ContainsKey(urls, URL(kPath1)));
220 EXPECT_TRUE(ContainsKey(urls, URL(kPath2))); 222 EXPECT_TRUE(ContainsKey(urls, URL(kPath2)));
221 223
222 VerifyAndClearChange(URL(kPath0), 224 VerifyAndClearChange(URL(kPath0),
223 FileChange(FileChange::FILE_CHANGE_DELETE, 225 FileChange(FileChange::FILE_CHANGE_DELETE,
224 SYNC_FILE_TYPE_DIRECTORY)); 226 sync_file_system::SYNC_FILE_TYPE_DIRECTORY));
225 VerifyAndClearChange(URL(kPath1), 227 VerifyAndClearChange(URL(kPath1),
226 FileChange(FileChange::FILE_CHANGE_DELETE, 228 FileChange(FileChange::FILE_CHANGE_DELETE,
227 SYNC_FILE_TYPE_DIRECTORY)); 229 sync_file_system::SYNC_FILE_TYPE_DIRECTORY));
228 VerifyAndClearChange(URL(kPath2), 230 VerifyAndClearChange(URL(kPath2),
229 FileChange(FileChange::FILE_CHANGE_DELETE, 231 FileChange(FileChange::FILE_CHANGE_DELETE,
230 SYNC_FILE_TYPE_FILE)); 232 sync_file_system::SYNC_FILE_TYPE_FILE));
231 } 233 }
232 234
233 // Make sure directory operation is disabled (when it's configured so). 235 // Make sure directory operation is disabled (when it's configured so).
234 TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) { 236 TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) {
235 file_system_.EnableDirectoryOperations(false); 237 file_system_.EnableDirectoryOperations(false);
236 EXPECT_EQ(base::PLATFORM_FILE_OK, 238 EXPECT_EQ(base::PLATFORM_FILE_OK,
237 file_system_.OpenFileSystem()); 239 file_system_.OpenFileSystem());
238 240
239 // Try some directory operations (which should fail). 241 // Try some directory operations (which should fail).
240 EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, 242 EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
(...skipping 27 matching lines...) Expand all
268 270
269 // Now try copying the directory into the syncable file system, which should 271 // Now try copying the directory into the syncable file system, which should
270 // fail if directory operation is disabled. (http://crbug.com/161442) 272 // fail if directory operation is disabled. (http://crbug.com/161442)
271 EXPECT_NE(base::PLATFORM_FILE_OK, 273 EXPECT_NE(base::PLATFORM_FILE_OK,
272 file_system_.Copy(kSrcDir, URL("dest"))); 274 file_system_.Copy(kSrcDir, URL("dest")));
273 275
274 other_file_system_.TearDown(); 276 other_file_system_.TearDown();
275 } 277 }
276 278
277 } // namespace fileapi 279 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/syncable/sync_file_type.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698