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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 SyncStatusCode status, | 66 SyncStatusCode status, |
67 typename AssignTrait<R>::ArgumentType value) { | 67 typename AssignTrait<R>::ArgumentType value) { |
68 DCHECK(status_out); | 68 DCHECK(status_out); |
69 DCHECK(value_out); | 69 DCHECK(value_out); |
70 DCHECK(run_loop); | 70 DCHECK(run_loop); |
71 *status_out = status; | 71 *status_out = status; |
72 *value_out = value; | 72 *value_out = value; |
73 run_loop->Quit(); | 73 run_loop->Quit(); |
74 } | 74 } |
75 | 75 |
76 // This is called on IO thread. | 76 // This is called on IO thread. Posts |callback| to be called on UI thread. |
77 void VerifyFileError(base::RunLoop* run_loop, | 77 void VerifyFileError(base::Closure callback, |
78 base::File::Error error) { | 78 base::File::Error error) { |
79 DCHECK(run_loop); | |
80 EXPECT_EQ(base::File::FILE_OK, error); | 79 EXPECT_EQ(base::File::FILE_OK, error); |
81 run_loop->Quit(); | 80 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
82 } | 81 } |
83 | 82 |
84 } // namespace | 83 } // namespace |
85 | 84 |
86 class MockSyncEventObserver : public SyncEventObserver { | 85 class MockSyncEventObserver : public SyncEventObserver { |
87 public: | 86 public: |
88 MockSyncEventObserver() {} | 87 MockSyncEventObserver() {} |
89 virtual ~MockSyncEventObserver() {} | 88 virtual ~MockSyncEventObserver() {} |
90 | 89 |
91 MOCK_METHOD3(OnSyncStateUpdated, | 90 MOCK_METHOD3(OnSyncStateUpdated, |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); | 422 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); |
424 | 423 |
425 // 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). |
426 base::RunLoop verify_file_error_run_loop; | 425 base::RunLoop verify_file_error_run_loop; |
427 BrowserThread::PostTask( | 426 BrowserThread::PostTask( |
428 BrowserThread::IO, | 427 BrowserThread::IO, |
429 FROM_HERE, | 428 FROM_HERE, |
430 base::Bind(&CannedSyncableFileSystem::DoCreateFile, | 429 base::Bind(&CannedSyncableFileSystem::DoCreateFile, |
431 base::Unretained(file_system_.get()), | 430 base::Unretained(file_system_.get()), |
432 kFile, base::Bind(&VerifyFileError, | 431 kFile, base::Bind(&VerifyFileError, |
433 &verify_file_error_run_loop))); | 432 verify_file_error_run_loop.QuitClosure()))); |
434 | 433 |
435 run_loop.Run(); | 434 run_loop.Run(); |
436 | 435 |
437 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); | 436 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); |
438 | 437 |
439 verify_file_error_run_loop.Run(); | 438 verify_file_error_run_loop.Run(); |
440 } | 439 } |
441 | 440 |
442 #if defined(THREAD_SANITIZER) | 441 #if defined(THREAD_SANITIZER) |
443 // SyncFileSystemServiceTest.GetFileSyncStatus fails under ThreadSanitizer, | 442 // SyncFileSystemServiceTest.GetFileSyncStatus fails under ThreadSanitizer, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 base::Bind(&AssignValueAndQuit<SyncFileStatus>, | 480 base::Bind(&AssignValueAndQuit<SyncFileStatus>, |
482 &run_loop, &status, &sync_file_status)); | 481 &run_loop, &status, &sync_file_status)); |
483 run_loop.Run(); | 482 run_loop.Run(); |
484 | 483 |
485 EXPECT_EQ(SYNC_STATUS_OK, status); | 484 EXPECT_EQ(SYNC_STATUS_OK, status); |
486 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); | 485 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); |
487 } | 486 } |
488 } | 487 } |
489 | 488 |
490 } // namespace sync_file_system | 489 } // namespace sync_file_system |
OLD | NEW |