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/browser/fileapi/file_system_context.h" | 19 #include "webkit/browser/fileapi/file_system_context.h" |
20 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h" | 20 #include "webkit/browser/fileapi/syncable/canned_syncable_file_system.h" |
21 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" | 21 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" |
22 #include "webkit/browser/fileapi/syncable/mock_sync_status_observer.h" | 22 #include "webkit/browser/fileapi/syncable/mock_sync_status_observer.h" |
23 #include "webkit/browser/fileapi/syncable/sync_callbacks.h" | 23 #include "webkit/browser/fileapi/syncable/sync_callbacks.h" |
24 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h" | 24 #include "webkit/browser/fileapi/syncable/sync_file_metadata.h" |
| 25 #include "webkit/browser/fileapi/syncable/sync_file_system_backend.h" |
25 #include "webkit/browser/fileapi/syncable/sync_status_code.h" | 26 #include "webkit/browser/fileapi/syncable/sync_status_code.h" |
26 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" | 27 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" |
27 | 28 |
28 using fileapi::FileSystemURL; | 29 using fileapi::FileSystemURL; |
29 using fileapi::FileSystemURLSet; | 30 using fileapi::FileSystemURLSet; |
30 using ::testing::AnyNumber; | 31 using ::testing::AnyNumber; |
31 using ::testing::AtLeast; | 32 using ::testing::AtLeast; |
32 using ::testing::InSequence; | 33 using ::testing::InSequence; |
33 using ::testing::InvokeWithoutArgs; | 34 using ::testing::InvokeWithoutArgs; |
34 using ::testing::Return; | 35 using ::testing::Return; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 SYNC_STATUS_FAILED); | 292 SYNC_STATUS_FAILED); |
292 } | 293 } |
293 | 294 |
294 // Flaky. http://crbug.com/237710 | 295 // Flaky. http://crbug.com/237710 |
295 TEST_F(SyncFileSystemServiceTest, DISABLED_SimpleLocalSyncFlow) { | 296 TEST_F(SyncFileSystemServiceTest, DISABLED_SimpleLocalSyncFlow) { |
296 InitializeApp(); | 297 InitializeApp(); |
297 | 298 |
298 StrictMock<MockSyncStatusObserver> status_observer; | 299 StrictMock<MockSyncStatusObserver> status_observer; |
299 | 300 |
300 EnableSync(); | 301 EnableSync(); |
301 file_system_->file_system_context()->sync_context()-> | 302 file_system_->backend()->sync_context()-> |
302 set_mock_notify_changes_duration_in_sec(0); | 303 set_mock_notify_changes_duration_in_sec(0); |
303 file_system_->AddSyncStatusObserver(&status_observer); | 304 file_system_->AddSyncStatusObserver(&status_observer); |
304 | 305 |
305 // We'll test one local sync for this file. | 306 // We'll test one local sync for this file. |
306 const FileSystemURL kFile(file_system_->URL("foo")); | 307 const FileSystemURL kFile(file_system_->URL("foo")); |
307 | 308 |
308 base::RunLoop run_loop; | 309 base::RunLoop run_loop; |
309 | 310 |
310 // We should get called OnSyncEnabled and OnWriteEnabled on kFile. | 311 // We should get called OnSyncEnabled and OnWriteEnabled on kFile. |
311 // (We quit the run loop when OnWriteEnabled is called on kFile) | 312 // (We quit the run loop when OnWriteEnabled is called on kFile) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // This should trigger a remote sync. | 350 // This should trigger a remote sync. |
350 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); | 351 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); |
351 | 352 |
352 run_loop.Run(); | 353 run_loop.Run(); |
353 } | 354 } |
354 | 355 |
355 TEST_F(SyncFileSystemServiceTest, SimpleSyncFlowWithFileBusy) { | 356 TEST_F(SyncFileSystemServiceTest, SimpleSyncFlowWithFileBusy) { |
356 InitializeApp(); | 357 InitializeApp(); |
357 | 358 |
358 EnableSync(); | 359 EnableSync(); |
359 file_system_->file_system_context()->sync_context()-> | 360 file_system_->backend()->sync_context()-> |
360 set_mock_notify_changes_duration_in_sec(0); | 361 set_mock_notify_changes_duration_in_sec(0); |
361 | 362 |
362 const FileSystemURL kFile(file_system_->URL("foo")); | 363 const FileSystemURL kFile(file_system_->URL("foo")); |
363 | 364 |
364 base::RunLoop run_loop; | 365 base::RunLoop run_loop; |
365 | 366 |
366 // We expect a set of method calls for starting a remote sync. | 367 // We expect a set of method calls for starting a remote sync. |
367 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) | 368 EXPECT_CALL(*mock_remote_service(), GetCurrentState()) |
368 .Times(AtLeast(3)) | 369 .Times(AtLeast(3)) |
369 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); | 370 .WillRepeatedly(Return(REMOTE_SERVICE_OK)); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 base::Bind(&AssignValueAndQuit<SyncFileStatus>, | 486 base::Bind(&AssignValueAndQuit<SyncFileStatus>, |
486 &run_loop, &status, &sync_file_status)); | 487 &run_loop, &status, &sync_file_status)); |
487 run_loop.Run(); | 488 run_loop.Run(); |
488 | 489 |
489 EXPECT_EQ(SYNC_STATUS_OK, status); | 490 EXPECT_EQ(SYNC_STATUS_OK, status); |
490 EXPECT_EQ(SYNC_FILE_STATUS_CONFLICTING, sync_file_status); | 491 EXPECT_EQ(SYNC_FILE_STATUS_CONFLICTING, sync_file_status); |
491 } | 492 } |
492 } | 493 } |
493 | 494 |
494 } // namespace sync_file_system | 495 } // namespace sync_file_system |
OLD | NEW |