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

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

Issue 24030002: Adds callbacks to notify progress into Copy's API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_.CreateFile(URL(kChild))); 233 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_.CreateFile(URL(kChild)));
234 234
235 // Start syncing the kParent directory. 235 // Start syncing the kParent directory.
236 sync_status()->StartSyncing(URL(kParent)); 236 sync_status()->StartSyncing(URL(kParent));
237 237
238 // Copying kDir to other directory should succeed, while moving would fail 238 // Copying kDir to other directory should succeed, while moving would fail
239 // (since the source directory is in syncing). 239 // (since the source directory is in syncing).
240 ResetCallbackStatus(); 240 ResetCallbackStatus();
241 file_system_.operation_runner()->Copy( 241 file_system_.operation_runner()->Copy(
242 URL(kDir), URL("dest-copy"), 242 URL(kDir), URL("dest-copy"),
243 fileapi::FileSystemOperationRunner::CopyProgressCallback(),
243 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); 244 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
244 file_system_.operation_runner()->Move( 245 file_system_.operation_runner()->Move(
245 URL(kDir), URL("dest-move"), 246 URL(kDir), URL("dest-move"),
246 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); 247 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
247 base::MessageLoop::current()->RunUntilIdle(); 248 base::MessageLoop::current()->RunUntilIdle();
248 EXPECT_EQ(1, callback_count_); 249 EXPECT_EQ(1, callback_count_);
249 250
250 // Only "dest-copy1" should exist. 251 // Only "dest-copy1" should exist.
251 EXPECT_EQ(base::PLATFORM_FILE_OK, 252 EXPECT_EQ(base::PLATFORM_FILE_OK,
252 file_system_.DirectoryExists(URL("dest-copy"))); 253 file_system_.DirectoryExists(URL("dest-copy")));
253 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 254 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
254 file_system_.DirectoryExists(URL("dest-move"))); 255 file_system_.DirectoryExists(URL("dest-move")));
255 256
256 // Start syncing the "dest-copy2" directory. 257 // Start syncing the "dest-copy2" directory.
257 sync_status()->StartSyncing(URL("dest-copy2")); 258 sync_status()->StartSyncing(URL("dest-copy2"));
258 259
259 // Now the destination is also locked copying kDir should be queued. 260 // Now the destination is also locked copying kDir should be queued.
260 ResetCallbackStatus(); 261 ResetCallbackStatus();
261 file_system_.operation_runner()->Copy( 262 file_system_.operation_runner()->Copy(
262 URL(kDir), URL("dest-copy2"), 263 URL(kDir), URL("dest-copy2"),
264 fileapi::FileSystemOperationRunner::CopyProgressCallback(),
263 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); 265 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
264 base::MessageLoop::current()->RunUntilIdle(); 266 base::MessageLoop::current()->RunUntilIdle();
265 EXPECT_EQ(0, callback_count_); 267 EXPECT_EQ(0, callback_count_);
266 268
267 // Finish syncing the "dest-copy2" directory to unlock Copy. 269 // Finish syncing the "dest-copy2" directory to unlock Copy.
268 sync_status()->EndSyncing(URL("dest-copy2")); 270 sync_status()->EndSyncing(URL("dest-copy2"));
269 ResetCallbackStatus(); 271 ResetCallbackStatus();
270 base::MessageLoop::current()->RunUntilIdle(); 272 base::MessageLoop::current()->RunUntilIdle();
271 EXPECT_EQ(1, callback_count_); 273 EXPECT_EQ(1, callback_count_);
272 274
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 file_system_.operation_runner()->Truncate( 387 file_system_.operation_runner()->Truncate(
386 URL(kFile), 10, 388 URL(kFile), 10,
387 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); 389 ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK));
388 file_system_.operation_runner()->Cancel( 390 file_system_.operation_runner()->Cancel(
389 id, ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_INVALID_OPERATION)); 391 id, ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_INVALID_OPERATION));
390 base::MessageLoop::current()->RunUntilIdle(); 392 base::MessageLoop::current()->RunUntilIdle();
391 EXPECT_EQ(2, callback_count_); 393 EXPECT_EQ(2, callback_count_);
392 } 394 }
393 395
394 } // namespace sync_file_system 396 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698