OLD | NEW |
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 "chrome/browser/sync_file_system/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 SyncFileStatus status, | 97 SyncFileStatus status, |
98 SyncAction action, | 98 SyncAction action, |
99 SyncDirection direction)); | 99 SyncDirection direction)); |
100 }; | 100 }; |
101 | 101 |
102 ACTION_P3(NotifyStateAndCallback, | 102 ACTION_P3(NotifyStateAndCallback, |
103 mock_remote_service, service_state, operation_status) { | 103 mock_remote_service, service_state, operation_status) { |
104 mock_remote_service->NotifyRemoteServiceStateUpdated( | 104 mock_remote_service->NotifyRemoteServiceStateUpdated( |
105 service_state, "Test event."); | 105 service_state, "Test event."); |
106 base::ThreadTaskRunnerHandle::Get()->PostTask( | 106 base::ThreadTaskRunnerHandle::Get()->PostTask( |
107 FROM_HERE, base::Bind(arg1, operation_status)); | 107 FROM_HERE, base::BindOnce(arg1, operation_status)); |
108 } | 108 } |
109 | 109 |
110 ACTION_P(RecordState, states) { | 110 ACTION_P(RecordState, states) { |
111 states->push_back(arg1); | 111 states->push_back(arg1); |
112 } | 112 } |
113 | 113 |
114 ACTION_P(MockStatusCallback, status) { | 114 ACTION_P(MockStatusCallback, status) { |
115 base::ThreadTaskRunnerHandle::Get()->PostTask( | 115 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
116 FROM_HERE, base::Bind(arg4, status)); | 116 base::BindOnce(arg4, status)); |
117 } | 117 } |
118 | 118 |
119 ACTION_P2(MockSyncFileCallback, status, url) { | 119 ACTION_P2(MockSyncFileCallback, status, url) { |
120 base::ThreadTaskRunnerHandle::Get()->PostTask( | 120 base::ThreadTaskRunnerHandle::Get()->PostTask( |
121 FROM_HERE, base::Bind(arg0, status, url)); | 121 FROM_HERE, base::BindOnce(arg0, status, url)); |
122 } | 122 } |
123 | 123 |
124 ACTION(InvokeCompletionClosure) { | 124 ACTION(InvokeCompletionClosure) { |
125 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, arg0); | 125 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, arg0); |
126 } | 126 } |
127 | 127 |
128 class SyncFileSystemServiceTest : public testing::Test { | 128 class SyncFileSystemServiceTest : public testing::Test { |
129 protected: | 129 protected: |
130 SyncFileSystemServiceTest() | 130 SyncFileSystemServiceTest() |
131 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 131 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 EXPECT_CALL(*mock_local_change_processor(), | 417 EXPECT_CALL(*mock_local_change_processor(), |
418 ApplyLocalChange(_, _, _, kFile, _)) | 418 ApplyLocalChange(_, _, _, kFile, _)) |
419 .Times(AnyNumber()); | 419 .Times(AnyNumber()); |
420 | 420 |
421 // This should trigger a remote sync. | 421 // This should trigger a remote sync. |
422 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); | 422 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); |
423 | 423 |
424 // Start a local operation on the same file (to make it BUSY). | 424 // Start a local operation on the same file (to make it BUSY). |
425 base::RunLoop verify_file_error_run_loop; | 425 base::RunLoop verify_file_error_run_loop; |
426 BrowserThread::PostTask( | 426 BrowserThread::PostTask( |
427 BrowserThread::IO, | 427 BrowserThread::IO, FROM_HERE, |
428 FROM_HERE, | 428 base::BindOnce(&CannedSyncableFileSystem::DoCreateFile, |
429 base::Bind(&CannedSyncableFileSystem::DoCreateFile, | 429 base::Unretained(file_system_.get()), kFile, |
430 base::Unretained(file_system_.get()), | 430 base::Bind(&VerifyFileError, |
431 kFile, base::Bind(&VerifyFileError, | 431 verify_file_error_run_loop.QuitClosure()))); |
432 verify_file_error_run_loop.QuitClosure()))); | |
433 | 432 |
434 run_loop.Run(); | 433 run_loop.Run(); |
435 | 434 |
436 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); | 435 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); |
437 | 436 |
438 verify_file_error_run_loop.Run(); | 437 verify_file_error_run_loop.Run(); |
439 } | 438 } |
440 | 439 |
441 #if defined(THREAD_SANITIZER) | 440 #if defined(THREAD_SANITIZER) |
442 // SyncFileSystemServiceTest.GetFileSyncStatus fails under ThreadSanitizer, | 441 // SyncFileSystemServiceTest.GetFileSyncStatus fails under ThreadSanitizer, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 base::Bind(&AssignValueAndQuit<SyncFileStatus>, | 479 base::Bind(&AssignValueAndQuit<SyncFileStatus>, |
481 &run_loop, &status, &sync_file_status)); | 480 &run_loop, &status, &sync_file_status)); |
482 run_loop.Run(); | 481 run_loop.Run(); |
483 | 482 |
484 EXPECT_EQ(SYNC_STATUS_OK, status); | 483 EXPECT_EQ(SYNC_STATUS_OK, status); |
485 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); | 484 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); |
486 } | 485 } |
487 } | 486 } |
488 | 487 |
489 } // namespace sync_file_system | 488 } // namespace sync_file_system |
OLD | NEW |