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 <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" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "chrome/browser/sync_file_system/local_file_sync_service.h" | 12 #include "chrome/browser/sync_file_system/local_file_sync_service.h" |
13 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" | 13 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" |
14 #include "chrome/browser/sync_file_system/sync_event_observer.h" | 14 #include "chrome/browser/sync_file_system/sync_event_observer.h" |
15 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | 15 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
16 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 16 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "webkit/fileapi/file_system_context.h" | 19 #include "webkit/fileapi/file_system_context.h" |
20 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" | 20 #include "webkit/fileapi/syncable/canned_syncable_file_system.h" |
21 #include "webkit/fileapi/syncable/local_file_sync_context.h" | 21 #include "webkit/fileapi/syncable/local_file_sync_context.h" |
22 #include "webkit/fileapi/syncable/mock_sync_status_observer.h" | 22 #include "webkit/fileapi/syncable/mock_sync_status_observer.h" |
23 #include "webkit/fileapi/syncable/sync_callbacks.h" | 23 #include "webkit/fileapi/syncable/sync_callbacks.h" |
24 #include "webkit/fileapi/syncable/sync_file_metadata.h" | 24 #include "webkit/fileapi/syncable/sync_file_metadata.h" |
25 #include "webkit/fileapi/syncable/sync_status_code.h" | 25 #include "webkit/fileapi/syncable/sync_status_code.h" |
26 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 26 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
27 | 27 |
28 using fileapi::FileChange; | |
29 using fileapi::FileSystemURL; | 28 using fileapi::FileSystemURL; |
30 using fileapi::FileSystemURLSet; | 29 using fileapi::FileSystemURLSet; |
31 using fileapi::MockSyncStatusObserver; | 30 using fileapi::MockSyncStatusObserver; |
32 using fileapi::SyncFileMetadata; | 31 using fileapi::SyncFileMetadata; |
33 using fileapi::SyncStatusCode; | 32 using fileapi::SyncStatusCode; |
| 33 using sync_file_system::FileChange; |
34 using ::testing::AnyNumber; | 34 using ::testing::AnyNumber; |
35 using ::testing::AtLeast; | 35 using ::testing::AtLeast; |
36 using ::testing::InSequence; | 36 using ::testing::InSequence; |
37 using ::testing::InvokeWithoutArgs; | 37 using ::testing::InvokeWithoutArgs; |
38 using ::testing::Return; | 38 using ::testing::Return; |
39 using ::testing::StrictMock; | 39 using ::testing::StrictMock; |
40 using ::testing::_; | 40 using ::testing::_; |
41 | 41 |
42 namespace sync_file_system { | 42 namespace sync_file_system { |
43 | 43 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 // We expect a set of method calls for starting a local sync. | 321 // We expect a set of method calls for starting a local sync. |
322 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) | 322 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) |
323 .Times(AtLeast(2)) | 323 .Times(AtLeast(2)) |
324 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); | 324 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); |
325 EXPECT_CALL(*mock_remote_service(), GetLocalChangeProcessor()) | 325 EXPECT_CALL(*mock_remote_service(), GetLocalChangeProcessor()) |
326 .WillRepeatedly(Return(&local_change_processor)); | 326 .WillRepeatedly(Return(&local_change_processor)); |
327 | 327 |
328 // The local_change_processor's ApplyLocalChange should be called once | 328 // The local_change_processor's ApplyLocalChange should be called once |
329 // with ADD_OR_UPDATE change for TYPE_FILE. | 329 // with ADD_OR_UPDATE change for TYPE_FILE. |
330 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, | 330 const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE, |
331 fileapi::SYNC_FILE_TYPE_FILE); | 331 SYNC_FILE_TYPE_FILE); |
332 EXPECT_CALL(local_change_processor, ApplyLocalChange(change, _, kFile, _)) | 332 EXPECT_CALL(local_change_processor, ApplyLocalChange(change, _, kFile, _)) |
333 .WillOnce(MockStatusCallback(fileapi::SYNC_STATUS_OK)); | 333 .WillOnce(MockStatusCallback(fileapi::SYNC_STATUS_OK)); |
334 | 334 |
335 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile)); | 335 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->CreateFile(kFile)); |
336 | 336 |
337 run_loop.Run(); | 337 run_loop.Run(); |
338 } | 338 } |
339 | 339 |
340 TEST_F(SyncFileSystemServiceTest, SimpleRemoteSyncFlow) { | 340 TEST_F(SyncFileSystemServiceTest, SimpleRemoteSyncFlow) { |
341 InitializeApp(); | 341 InitializeApp(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 base::Bind(&AssignValueAndQuit<SyncFileStatus>, | 493 base::Bind(&AssignValueAndQuit<SyncFileStatus>, |
494 &run_loop, &status, &sync_file_status)); | 494 &run_loop, &status, &sync_file_status)); |
495 run_loop.Run(); | 495 run_loop.Run(); |
496 | 496 |
497 EXPECT_EQ(fileapi::SYNC_STATUS_OK, status); | 497 EXPECT_EQ(fileapi::SYNC_STATUS_OK, status); |
498 EXPECT_EQ(SYNC_FILE_STATUS_CONFLICTING, sync_file_status); | 498 EXPECT_EQ(SYNC_FILE_STATUS_CONFLICTING, sync_file_status); |
499 } | 499 } |
500 } | 500 } |
501 | 501 |
502 } // namespace sync_file_system | 502 } // namespace sync_file_system |
OLD | NEW |