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

Side by Side Diff: chrome/browser/sync_file_system/local/syncable_file_operation_runner_unittest.cc

Issue 1194783002: Add fileManagerPrivate.onCopyError event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove const and rename enum. Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 EXPECT_EQ(File::FILE_OK, file_system_.CreateDirectory(URL(kDir))); 244 EXPECT_EQ(File::FILE_OK, file_system_.CreateDirectory(URL(kDir)));
245 EXPECT_EQ(File::FILE_OK, file_system_.CreateFile(URL(kChild))); 245 EXPECT_EQ(File::FILE_OK, file_system_.CreateFile(URL(kChild)));
246 246
247 // Start syncing the kParent directory. 247 // Start syncing the kParent directory.
248 sync_status()->StartSyncing(URL(kParent)); 248 sync_status()->StartSyncing(URL(kParent));
249 249
250 // Copying kDir to other directory should succeed, while moving would fail 250 // Copying kDir to other directory should succeed, while moving would fail
251 // (since the source directory is in syncing). 251 // (since the source directory is in syncing).
252 ResetCallbackStatus(); 252 ResetCallbackStatus();
253 file_system_.operation_runner()->Copy( 253 file_system_.operation_runner()->Copy(
254 URL(kDir), 254 URL(kDir), URL("dest-copy"), storage::FileSystemOperation::OPTION_NONE,
255 URL("dest-copy"), 255 storage::FileSystemOperation::ERROR_BEHAVIOR_ABORT,
256 storage::FileSystemOperation::OPTION_NONE,
257 storage::FileSystemOperationRunner::CopyProgressCallback(), 256 storage::FileSystemOperationRunner::CopyProgressCallback(),
258 ExpectStatus(FROM_HERE, File::FILE_OK)); 257 ExpectStatus(FROM_HERE, File::FILE_OK));
259 file_system_.operation_runner()->Move( 258 file_system_.operation_runner()->Move(
260 URL(kDir), 259 URL(kDir),
261 URL("dest-move"), 260 URL("dest-move"),
262 storage::FileSystemOperation::OPTION_NONE, 261 storage::FileSystemOperation::OPTION_NONE,
263 ExpectStatus(FROM_HERE, File::FILE_OK)); 262 ExpectStatus(FROM_HERE, File::FILE_OK));
264 base::RunLoop().Run(); 263 base::RunLoop().Run();
265 EXPECT_EQ(1, callback_count_); 264 EXPECT_EQ(1, callback_count_);
266 265
267 // Only "dest-copy1" should exist. 266 // Only "dest-copy1" should exist.
268 EXPECT_EQ(File::FILE_OK, 267 EXPECT_EQ(File::FILE_OK,
269 file_system_.DirectoryExists(URL("dest-copy"))); 268 file_system_.DirectoryExists(URL("dest-copy")));
270 EXPECT_EQ(File::FILE_ERROR_NOT_FOUND, 269 EXPECT_EQ(File::FILE_ERROR_NOT_FOUND,
271 file_system_.DirectoryExists(URL("dest-move"))); 270 file_system_.DirectoryExists(URL("dest-move")));
272 271
273 // Start syncing the "dest-copy2" directory. 272 // Start syncing the "dest-copy2" directory.
274 sync_status()->StartSyncing(URL("dest-copy2")); 273 sync_status()->StartSyncing(URL("dest-copy2"));
275 274
276 // Now the destination is also locked copying kDir should be queued. 275 // Now the destination is also locked copying kDir should be queued.
277 ResetCallbackStatus(); 276 ResetCallbackStatus();
278 file_system_.operation_runner()->Copy( 277 file_system_.operation_runner()->Copy(
279 URL(kDir), 278 URL(kDir), URL("dest-copy2"), storage::FileSystemOperation::OPTION_NONE,
280 URL("dest-copy2"), 279 storage::FileSystemOperation::ERROR_BEHAVIOR_ABORT,
281 storage::FileSystemOperation::OPTION_NONE,
282 storage::FileSystemOperationRunner::CopyProgressCallback(), 280 storage::FileSystemOperationRunner::CopyProgressCallback(),
283 ExpectStatus(FROM_HERE, File::FILE_OK)); 281 ExpectStatus(FROM_HERE, File::FILE_OK));
284 base::RunLoop().RunUntilIdle(); 282 base::RunLoop().RunUntilIdle();
285 EXPECT_EQ(0, callback_count_); 283 EXPECT_EQ(0, callback_count_);
286 284
287 // Finish syncing the "dest-copy2" directory to unlock Copy. 285 // Finish syncing the "dest-copy2" directory to unlock Copy.
288 sync_status()->EndSyncing(URL("dest-copy2")); 286 sync_status()->EndSyncing(URL("dest-copy2"));
289 ResetCallbackStatus(); 287 ResetCallbackStatus();
290 base::RunLoop().Run(); 288 base::RunLoop().Run();
291 EXPECT_EQ(1, callback_count_); 289 EXPECT_EQ(1, callback_count_);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 storage::FileSystemOperationRunner::OperationID id = 402 storage::FileSystemOperationRunner::OperationID id =
405 file_system_.operation_runner()->Truncate( 403 file_system_.operation_runner()->Truncate(
406 URL(kFile), 10, ExpectStatus(FROM_HERE, File::FILE_OK)); 404 URL(kFile), 10, ExpectStatus(FROM_HERE, File::FILE_OK));
407 file_system_.operation_runner()->Cancel( 405 file_system_.operation_runner()->Cancel(
408 id, ExpectStatus(FROM_HERE, File::FILE_ERROR_INVALID_OPERATION)); 406 id, ExpectStatus(FROM_HERE, File::FILE_ERROR_INVALID_OPERATION));
409 base::RunLoop().Run(); 407 base::RunLoop().Run();
410 EXPECT_EQ(2, callback_count_); 408 EXPECT_EQ(2, callback_count_);
411 } 409 }
412 410
413 } // namespace sync_file_system 411 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698