OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
6 #include <stack> | 6 #include <stack> |
7 | 7 |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 fake_drive_service_helper_.reset(new FakeDriveServiceHelper( | 113 fake_drive_service_helper_.reset(new FakeDriveServiceHelper( |
114 drive_service.get(), uploader.get(), | 114 drive_service.get(), uploader.get(), |
115 kSyncRootFolderTitle)); | 115 kSyncRootFolderTitle)); |
116 | 116 |
117 remote_sync_service_.reset( | 117 remote_sync_service_.reset( |
118 new SyncEngine(base::ThreadTaskRunnerHandle::Get(), // ui_task_runner | 118 new SyncEngine(base::ThreadTaskRunnerHandle::Get(), // ui_task_runner |
119 worker_task_runner_.get(), | 119 worker_task_runner_.get(), |
120 drive_task_runner.get(), | 120 drive_task_runner.get(), |
121 base_dir_.path(), | 121 base_dir_.path(), |
122 NULL, // task_logger | 122 nullptr, // task_logger |
123 NULL, // notification_manager | 123 nullptr, // notification_manager |
124 NULL, // extension_service | 124 nullptr, // extension_service |
125 NULL, // signin_manager | 125 nullptr, // signin_manager |
126 NULL, // token_service | 126 nullptr, // token_service |
127 NULL, // request_context | 127 nullptr, // request_context |
128 scoped_ptr<SyncEngine::DriveServiceFactory>(), | 128 scoped_ptr<SyncEngine::DriveServiceFactory>(), |
129 in_memory_env_.get())); | 129 in_memory_env_.get())); |
130 remote_sync_service_->AddServiceObserver(this); | 130 remote_sync_service_->AddServiceObserver(this); |
131 remote_sync_service_->InitializeForTesting( | 131 remote_sync_service_->InitializeForTesting( |
132 drive_service.PassAs<drive::DriveServiceInterface>(), | 132 drive_service.PassAs<drive::DriveServiceInterface>(), |
133 uploader.Pass(), | 133 uploader.Pass(), |
134 scoped_ptr<SyncWorkerInterface>()); | 134 scoped_ptr<SyncWorkerInterface>()); |
135 remote_sync_service_->SetSyncEnabled(true); | 135 remote_sync_service_->SetSyncEnabled(true); |
136 | 136 |
137 local_sync_service_->SetLocalChangeProcessor(remote_sync_service_.get()); | 137 local_sync_service_->SetLocalChangeProcessor(remote_sync_service_.get()); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 EXPECT_EQ(google_apis::HTTP_CREATED, | 1210 EXPECT_EQ(google_apis::HTTP_CREATED, |
1211 fake_drive_service_helper()->AddFolder( | 1211 fake_drive_service_helper()->AddFolder( |
1212 app_root_folder_id, | 1212 app_root_folder_id, |
1213 "conflict_to_pending_remote", &file_id)); | 1213 "conflict_to_pending_remote", &file_id)); |
1214 | 1214 |
1215 FetchRemoteChanges(); | 1215 FetchRemoteChanges(); |
1216 | 1216 |
1217 EXPECT_EQ(google_apis::HTTP_CREATED, | 1217 EXPECT_EQ(google_apis::HTTP_CREATED, |
1218 fake_drive_service_helper()->AddFolder( | 1218 fake_drive_service_helper()->AddFolder( |
1219 app_root_folder_id, | 1219 app_root_folder_id, |
1220 "conflict_to_existing_remote", NULL)); | 1220 "conflict_to_existing_remote", nullptr)); |
1221 | 1221 |
1222 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 1222 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
1223 VerifyConsistency(); | 1223 VerifyConsistency(); |
1224 | 1224 |
1225 EXPECT_EQ(1u, CountApp()); | 1225 EXPECT_EQ(1u, CountApp()); |
1226 EXPECT_EQ(3u, CountLocalFile(app_id)); | 1226 EXPECT_EQ(3u, CountLocalFile(app_id)); |
1227 VerifyLocalFolder(app_id, FPL("conflict_to_pending_remote")); | 1227 VerifyLocalFolder(app_id, FPL("conflict_to_pending_remote")); |
1228 VerifyLocalFolder(app_id, FPL("conflict_to_existing_remote")); | 1228 VerifyLocalFolder(app_id, FPL("conflict_to_existing_remote")); |
1229 | 1229 |
1230 EXPECT_EQ(4u, CountMetadata()); | 1230 EXPECT_EQ(4u, CountMetadata()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 RegisterApp(app_id); | 1273 RegisterApp(app_id); |
1274 std::string app_root_folder_id = GetFileIDByPath(app_id, FPL("")); | 1274 std::string app_root_folder_id = GetFileIDByPath(app_id, FPL("")); |
1275 | 1275 |
1276 AddLocalFolder(app_id, FPL("conflict_to_pending_remote")); | 1276 AddLocalFolder(app_id, FPL("conflict_to_pending_remote")); |
1277 AddLocalFolder(app_id, FPL("conflict_to_existing_remote")); | 1277 AddLocalFolder(app_id, FPL("conflict_to_existing_remote")); |
1278 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); | 1278 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); |
1279 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); | 1279 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); |
1280 | 1280 |
1281 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 1281 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
1282 fake_drive_service_helper()->AddFile( | 1282 fake_drive_service_helper()->AddFile( |
1283 app_root_folder_id, "conflict_to_pending_remote", "foo", NULL)); | 1283 app_root_folder_id, "conflict_to_pending_remote", "foo", |
| 1284 nullptr)); |
1284 | 1285 |
1285 FetchRemoteChanges(); | 1286 FetchRemoteChanges(); |
1286 | 1287 |
1287 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 1288 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
1288 fake_drive_service_helper()->AddFile( | 1289 fake_drive_service_helper()->AddFile( |
1289 app_root_folder_id, "conflict_to_existing_remote", "bar", | 1290 app_root_folder_id, "conflict_to_existing_remote", "bar", |
1290 NULL)); | 1291 nullptr)); |
1291 | 1292 |
1292 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 1293 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
1293 VerifyConsistency(); | 1294 VerifyConsistency(); |
1294 | 1295 |
1295 EXPECT_EQ(1u, CountApp()); | 1296 EXPECT_EQ(1u, CountApp()); |
1296 EXPECT_EQ(3u, CountLocalFile(app_id)); | 1297 EXPECT_EQ(3u, CountLocalFile(app_id)); |
1297 VerifyLocalFile(app_id, FPL("conflict_to_pending_remote"), "foo"); | 1298 VerifyLocalFile(app_id, FPL("conflict_to_pending_remote"), "foo"); |
1298 VerifyLocalFile(app_id, FPL("conflict_to_existing_remote"), "bar"); | 1299 VerifyLocalFile(app_id, FPL("conflict_to_existing_remote"), "bar"); |
1299 | 1300 |
1300 EXPECT_EQ(4u, CountMetadata()); | 1301 EXPECT_EQ(4u, CountMetadata()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 | 1548 |
1548 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 1549 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
1549 VerifyConsistency(); | 1550 VerifyConsistency(); |
1550 | 1551 |
1551 // Test body starts from here. | 1552 // Test body starts from here. |
1552 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); | 1553 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); |
1553 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); | 1554 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); |
1554 | 1555 |
1555 EXPECT_EQ(google_apis::HTTP_CREATED, | 1556 EXPECT_EQ(google_apis::HTTP_CREATED, |
1556 fake_drive_service_helper()->AddFolder( | 1557 fake_drive_service_helper()->AddFolder( |
1557 app_root_folder_id, "conflict_to_pending_remote", NULL)); | 1558 app_root_folder_id, "conflict_to_pending_remote", nullptr)); |
1558 | 1559 |
1559 FetchRemoteChanges(); | 1560 FetchRemoteChanges(); |
1560 | 1561 |
1561 EXPECT_EQ(google_apis::HTTP_CREATED, | 1562 EXPECT_EQ(google_apis::HTTP_CREATED, |
1562 fake_drive_service_helper()->AddFolder( | 1563 fake_drive_service_helper()->AddFolder( |
1563 app_root_folder_id, "conflict_to_existing_remote", NULL)); | 1564 app_root_folder_id, "conflict_to_existing_remote", nullptr)); |
1564 | 1565 |
1565 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 1566 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
1566 VerifyConsistency(); | 1567 VerifyConsistency(); |
1567 | 1568 |
1568 EXPECT_EQ(1u, CountApp()); | 1569 EXPECT_EQ(1u, CountApp()); |
1569 EXPECT_EQ(3u, CountLocalFile(app_id)); | 1570 EXPECT_EQ(3u, CountLocalFile(app_id)); |
1570 VerifyLocalFolder(app_id, FPL("conflict_to_pending_remote")); | 1571 VerifyLocalFolder(app_id, FPL("conflict_to_pending_remote")); |
1571 VerifyLocalFolder(app_id, FPL("conflict_to_existing_remote")); | 1572 VerifyLocalFolder(app_id, FPL("conflict_to_existing_remote")); |
1572 | 1573 |
1573 EXPECT_EQ(4u, CountMetadata()); | 1574 EXPECT_EQ(4u, CountMetadata()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 | 1623 |
1623 std::string app_root_folder_id = GetFileIDByPath(app_id, FPL("")); | 1624 std::string app_root_folder_id = GetFileIDByPath(app_id, FPL("")); |
1624 AddOrUpdateLocalFile(app_id, FPL("conflict_to_pending_remote"), "foo"); | 1625 AddOrUpdateLocalFile(app_id, FPL("conflict_to_pending_remote"), "foo"); |
1625 AddOrUpdateLocalFile(app_id, FPL("conflict_to_existing_remote"), "bar"); | 1626 AddOrUpdateLocalFile(app_id, FPL("conflict_to_existing_remote"), "bar"); |
1626 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); | 1627 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); |
1627 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); | 1628 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); |
1628 | 1629 |
1629 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 1630 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
1630 fake_drive_service_helper()->AddFile( | 1631 fake_drive_service_helper()->AddFile( |
1631 app_root_folder_id, "conflict_to_pending_remote", "hoge", | 1632 app_root_folder_id, "conflict_to_pending_remote", "hoge", |
1632 NULL)); | 1633 nullptr)); |
1633 | 1634 |
1634 FetchRemoteChanges(); | 1635 FetchRemoteChanges(); |
1635 | 1636 |
1636 EXPECT_EQ(google_apis::HTTP_SUCCESS, | 1637 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
1637 fake_drive_service_helper()->AddFile( | 1638 fake_drive_service_helper()->AddFile( |
1638 app_root_folder_id, "conflict_to_existing_remote", "fuga", | 1639 app_root_folder_id, "conflict_to_existing_remote", "fuga", |
1639 NULL)); | 1640 nullptr)); |
1640 | 1641 |
1641 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); | 1642 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
1642 VerifyConsistency(); | 1643 VerifyConsistency(); |
1643 | 1644 |
1644 EXPECT_EQ(1u, CountApp()); | 1645 EXPECT_EQ(1u, CountApp()); |
1645 EXPECT_EQ(3u, CountLocalFile(app_id)); | 1646 EXPECT_EQ(3u, CountLocalFile(app_id)); |
1646 VerifyLocalFile(app_id, FPL("conflict_to_pending_remote"), "hoge"); | 1647 VerifyLocalFile(app_id, FPL("conflict_to_pending_remote"), "hoge"); |
1647 VerifyLocalFile(app_id, FPL("conflict_to_existing_remote"), "fuga"); | 1648 VerifyLocalFile(app_id, FPL("conflict_to_existing_remote"), "fuga"); |
1648 | 1649 |
1649 EXPECT_EQ(4u, CountMetadata()); | 1650 EXPECT_EQ(4u, CountMetadata()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 | 1722 |
1722 EXPECT_EQ(1u, CountApp()); | 1723 EXPECT_EQ(1u, CountApp()); |
1723 EXPECT_EQ(1u, CountLocalFile(app_id)); | 1724 EXPECT_EQ(1u, CountLocalFile(app_id)); |
1724 | 1725 |
1725 EXPECT_EQ(2u, CountMetadata()); | 1726 EXPECT_EQ(2u, CountMetadata()); |
1726 EXPECT_EQ(2u, CountTracker()); | 1727 EXPECT_EQ(2u, CountTracker()); |
1727 } | 1728 } |
1728 | 1729 |
1729 } // namespace drive_backend | 1730 } // namespace drive_backend |
1730 } // namespace sync_file_system | 1731 } // namespace sync_file_system |
OLD | NEW |