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

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

Issue 453673003: [SyncFS] Promote demoted changes in default remote side backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test expectation Created 6 years, 4 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 | « chrome/browser/sync_file_system/sync_file_system_service.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/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ACTION_P(MockStatusCallback, status) { 112 ACTION_P(MockStatusCallback, status) {
113 base::ThreadTaskRunnerHandle::Get()->PostTask( 113 base::ThreadTaskRunnerHandle::Get()->PostTask(
114 FROM_HERE, base::Bind(arg4, status)); 114 FROM_HERE, base::Bind(arg4, status));
115 } 115 }
116 116
117 ACTION_P2(MockSyncFileCallback, status, url) { 117 ACTION_P2(MockSyncFileCallback, status, url) {
118 base::ThreadTaskRunnerHandle::Get()->PostTask( 118 base::ThreadTaskRunnerHandle::Get()->PostTask(
119 FROM_HERE, base::Bind(arg0, status, url)); 119 FROM_HERE, base::Bind(arg0, status, url));
120 } 120 }
121 121
122 ACTION(InvokeCompletionClosure) {
123 base::ThreadTaskRunnerHandle::Get()->PostTask(
124 FROM_HERE, base::Bind(arg0));
125 }
126
122 class SyncFileSystemServiceTest : public testing::Test { 127 class SyncFileSystemServiceTest : public testing::Test {
123 protected: 128 protected:
124 SyncFileSystemServiceTest() 129 SyncFileSystemServiceTest()
125 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | 130 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD |
126 content::TestBrowserThreadBundle::REAL_IO_THREAD) {} 131 content::TestBrowserThreadBundle::REAL_IO_THREAD) {}
127 132
128 virtual void SetUp() OVERRIDE { 133 virtual void SetUp() OVERRIDE {
129 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); 134 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
130 file_system_.reset(new CannedSyncableFileSystem( 135 file_system_.reset(new CannedSyncableFileSystem(
131 GURL(kOrigin), 136 GURL(kOrigin),
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 347 }
343 348
344 // The local_change_processor's ApplyLocalChange should be called once 349 // The local_change_processor's ApplyLocalChange should be called once
345 // with ADD_OR_UPDATE change for TYPE_FILE. 350 // with ADD_OR_UPDATE change for TYPE_FILE.
346 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, 351 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
347 SYNC_FILE_TYPE_FILE); 352 SYNC_FILE_TYPE_FILE);
348 EXPECT_CALL(*mock_local_change_processor(), 353 EXPECT_CALL(*mock_local_change_processor(),
349 ApplyLocalChange(change, _, _, kFile, _)) 354 ApplyLocalChange(change, _, _, kFile, _))
350 .WillOnce(MockStatusCallback(SYNC_STATUS_OK)); 355 .WillOnce(MockStatusCallback(SYNC_STATUS_OK));
351 356
357 EXPECT_CALL(*mock_remote_service(), PromoteDemotedChanges(_))
358 .WillRepeatedly(InvokeCompletionClosure());
359
352 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile)); 360 EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile));
353 361
354 run_loop.Run(); 362 run_loop.Run();
355 363
356 file_system_->RemoveSyncStatusObserver(&status_observer); 364 file_system_->RemoveSyncStatusObserver(&status_observer);
357 } 365 }
358 366
359 TEST_F(SyncFileSystemServiceTest, SimpleRemoteSyncFlow) { 367 TEST_F(SyncFileSystemServiceTest, SimpleRemoteSyncFlow) {
360 InitializeApp(); 368 InitializeApp();
361 369
(...skipping 29 matching lines...) Expand all
391 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_)) 399 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_))
392 .WillOnce(MockSyncFileCallback(SYNC_STATUS_FILE_BUSY, 400 .WillOnce(MockSyncFileCallback(SYNC_STATUS_FILE_BUSY,
393 kFile)); 401 kFile));
394 402
395 // ProcessRemoteChange should be called again when the becomes 403 // ProcessRemoteChange should be called again when the becomes
396 // not busy. 404 // not busy.
397 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_)) 405 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_))
398 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 406 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
399 } 407 }
400 408
409 EXPECT_CALL(*mock_remote_service(), PromoteDemotedChanges(_))
410 .WillRepeatedly(InvokeCompletionClosure());
411
401 // We might also see an activity for local sync as we're going to make 412 // We might also see an activity for local sync as we're going to make
402 // a local write operation on kFile. 413 // a local write operation on kFile.
403 EXPECT_CALL(*mock_local_change_processor(), 414 EXPECT_CALL(*mock_local_change_processor(),
404 ApplyLocalChange(_, _, _, kFile, _)) 415 ApplyLocalChange(_, _, _, kFile, _))
405 .Times(AnyNumber()); 416 .Times(AnyNumber());
406 417
407 // This should trigger a remote sync. 418 // This should trigger a remote sync.
408 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); 419 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1);
409 420
410 // Start a local operation on the same file (to make it BUSY). 421 // Start a local operation on the same file (to make it BUSY).
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 base::Bind(&AssignValueAndQuit<SyncFileStatus>, 477 base::Bind(&AssignValueAndQuit<SyncFileStatus>,
467 &run_loop, &status, &sync_file_status)); 478 &run_loop, &status, &sync_file_status));
468 run_loop.Run(); 479 run_loop.Run();
469 480
470 EXPECT_EQ(SYNC_STATUS_OK, status); 481 EXPECT_EQ(SYNC_STATUS_OK, status);
471 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); 482 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status);
472 } 483 }
473 } 484 }
474 485
475 } // namespace sync_file_system 486 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698