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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service_unittest.cc

Issue 11602004: Cleanup: Remote metadata parameter from ApplyLocalChange (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | « chrome/browser/sync_file_system/mock_local_change_processor.cc ('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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::MessageLoopProxy::current()->PostTask( 98 base::MessageLoopProxy::current()->PostTask(
99 FROM_HERE, base::Bind(arg1, operation_status)); 99 FROM_HERE, base::Bind(arg1, operation_status));
100 } 100 }
101 101
102 ACTION_P(RecordState, states) { 102 ACTION_P(RecordState, states) {
103 states->push_back(arg1); 103 states->push_back(arg1);
104 } 104 }
105 105
106 ACTION_P(MockStatusCallback, status) { 106 ACTION_P(MockStatusCallback, status) {
107 base::MessageLoopProxy::current()->PostTask( 107 base::MessageLoopProxy::current()->PostTask(
108 FROM_HERE, base::Bind(arg4, status)); 108 FROM_HERE, base::Bind(arg3, status));
109 } 109 }
110 110
111 ACTION_P3(MockSyncOperationCallback, status, url, operation_type) { 111 ACTION_P3(MockSyncOperationCallback, status, url, operation_type) {
112 base::MessageLoopProxy::current()->PostTask( 112 base::MessageLoopProxy::current()->PostTask(
113 FROM_HERE, base::Bind(arg1, status, url, operation_type)); 113 FROM_HERE, base::Bind(arg1, status, url, operation_type));
114 } 114 }
115 115
116 class SyncFileSystemServiceTest : public testing::Test { 116 class SyncFileSystemServiceTest : public testing::Test {
117 protected: 117 protected:
118 SyncFileSystemServiceTest() {} 118 SyncFileSystemServiceTest() {}
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) 456 EXPECT_CALL(*mock_remote_service(), GetCurrentState())
457 .Times(AtLeast(2)) 457 .Times(AtLeast(2))
458 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); 458 .WillRepeatedly(Return(REMOTE_SERVICE_OK));
459 EXPECT_CALL(*mock_remote_service(), GetLocalChangeProcessor()) 459 EXPECT_CALL(*mock_remote_service(), GetLocalChangeProcessor())
460 .WillRepeatedly(Return(&local_change_processor)); 460 .WillRepeatedly(Return(&local_change_processor));
461 461
462 // The local_change_processor's ApplyLocalChange should be called once 462 // The local_change_processor's ApplyLocalChange should be called once
463 // with ADD_OR_UPDATE change for TYPE_FILE. 463 // with ADD_OR_UPDATE change for TYPE_FILE.
464 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 464 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
465 fileapi::SYNC_FILE_TYPE_FILE); 465 fileapi::SYNC_FILE_TYPE_FILE);
466 EXPECT_CALL(local_change_processor, ApplyLocalChange(change, _, _, kFile, _)) 466 EXPECT_CALL(local_change_processor, ApplyLocalChange(change, _, kFile, _))
467 .WillOnce(MockStatusCallback(fileapi::SYNC_STATUS_OK)); 467 .WillOnce(MockStatusCallback(fileapi::SYNC_STATUS_OK));
468 468
469 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile)); 469 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile));
470 470
471 run_loop.Run(); 471 run_loop.Run();
472 } 472 }
473 473
474 TEST_F(SyncFileSystemServiceTest, SimpleRemoteSyncFlow) { 474 TEST_F(SyncFileSystemServiceTest, SimpleRemoteSyncFlow) {
475 InitializeApp(); 475 InitializeApp();
476 476
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 fileapi::SYNC_OPERATION_NONE)); 521 fileapi::SYNC_OPERATION_NONE));
522 522
523 // ProcessRemoteChange should be called again when the becomes 523 // ProcessRemoteChange should be called again when the becomes
524 // not busy. 524 // not busy.
525 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) 525 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _))
526 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 526 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
527 } 527 }
528 528
529 // We might also see an activity for local sync as we're going to make 529 // We might also see an activity for local sync as we're going to make
530 // a local write operation on kFile. 530 // a local write operation on kFile.
531 EXPECT_CALL(local_change_processor, ApplyLocalChange(_, _, _, kFile, _)) 531 EXPECT_CALL(local_change_processor, ApplyLocalChange(_, _, kFile, _))
532 .Times(AnyNumber()); 532 .Times(AnyNumber());
533 533
534 // This should trigger a remote sync. 534 // This should trigger a remote sync.
535 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); 535 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1);
536 536
537 // Start a local operation on the same file (to make it BUSY). 537 // Start a local operation on the same file (to make it BUSY).
538 base::WaitableEvent event(false, false); 538 base::WaitableEvent event(false, false);
539 thread_helper_.io_task_runner()->PostTask( 539 thread_helper_.io_task_runner()->PostTask(
540 FROM_HERE, base::Bind(&fileapi::CannedSyncableFileSystem::DoCreateFile, 540 FROM_HERE, base::Bind(&fileapi::CannedSyncableFileSystem::DoCreateFile,
541 base::Unretained(file_system_.get()), 541 base::Unretained(file_system_.get()),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 base::Bind(&AssignValueAndQuit<fileapi::SyncFileStatus>, 628 base::Bind(&AssignValueAndQuit<fileapi::SyncFileStatus>,
629 &run_loop, &status, &sync_file_status)); 629 &run_loop, &status, &sync_file_status));
630 run_loop.Run(); 630 run_loop.Run();
631 631
632 EXPECT_EQ(fileapi::SYNC_STATUS_OK, status); 632 EXPECT_EQ(fileapi::SYNC_STATUS_OK, status);
633 EXPECT_EQ(fileapi::SYNC_FILE_STATUS_CONFLICTING, sync_file_status); 633 EXPECT_EQ(fileapi::SYNC_FILE_STATUS_CONFLICTING, sync_file_status);
634 } 634 }
635 } 635 }
636 636
637 } // namespace sync_file_system 637 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/mock_local_change_processor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698