| 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/file_util.h" | 8 #include "base/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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 VerifyConsistency(); | 965 VerifyConsistency(); |
| 966 | 966 |
| 967 EXPECT_EQ(1u, CountApp()); | 967 EXPECT_EQ(1u, CountApp()); |
| 968 EXPECT_EQ(2u, CountLocalFile(app_id)); | 968 EXPECT_EQ(2u, CountLocalFile(app_id)); |
| 969 VerifyLocalFolder(app_id, base::FilePath(FPL("conflict_to_pending_remote"))); | 969 VerifyLocalFolder(app_id, base::FilePath(FPL("conflict_to_pending_remote"))); |
| 970 | 970 |
| 971 EXPECT_EQ(3u, CountMetadata()); | 971 EXPECT_EQ(3u, CountMetadata()); |
| 972 EXPECT_EQ(3u, CountTracker()); | 972 EXPECT_EQ(3u, CountTracker()); |
| 973 } | 973 } |
| 974 | 974 |
| 975 TEST_F(DriveBackendSyncTest, ConflictTest_AddFolder_AddFile) { |
| 976 std::string app_id = "example"; |
| 977 |
| 978 RegisterApp(app_id); |
| 979 std::string app_root_folder_id = GetFileIDByPath(app_id, FPL("")); |
| 980 |
| 981 AddLocalFolder(app_id, FPL("conflict_to_pending_remote")); |
| 982 AddLocalFolder(app_id, FPL("conflict_to_existing_remote")); |
| 983 |
| 984 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
| 985 fake_drive_service_helper()->AddFile( |
| 986 app_root_folder_id, "conflict_to_pending_remote", "foo", NULL)); |
| 987 |
| 988 FetchRemoteChanges(); |
| 989 |
| 990 EXPECT_EQ(google_apis::HTTP_SUCCESS, |
| 991 fake_drive_service_helper()->AddFile( |
| 992 app_root_folder_id, "conflict_to_existing_remote", "foo", |
| 993 NULL)); |
| 994 |
| 995 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
| 996 VerifyConsistency(); |
| 997 |
| 998 EXPECT_EQ(1u, CountApp()); |
| 999 EXPECT_EQ(3u, CountLocalFile(app_id)); |
| 1000 VerifyLocalFolder(app_id, base::FilePath(FPL("conflict_to_pending_remote"))); |
| 1001 VerifyLocalFolder(app_id, base::FilePath(FPL("conflict_to_existing_remote"))); |
| 1002 |
| 1003 EXPECT_EQ(4u, CountMetadata()); |
| 1004 EXPECT_EQ(4u, CountTracker()); |
| 1005 } |
| 1006 |
| 1007 TEST_F(DriveBackendSyncTest, ConflictTest_AddFolder_DeleteFile) { |
| 1008 std::string app_id = "example"; |
| 1009 |
| 1010 RegisterApp(app_id); |
| 1011 std::string app_root_folder_id = GetFileIDByPath(app_id, FPL("")); |
| 1012 |
| 1013 AddOrUpdateLocalFile(app_id, FPL("conflict_to_pending_remote"), "foo"); |
| 1014 AddOrUpdateLocalFile(app_id, FPL("conflict_to_existing_remote"), "bar"); |
| 1015 |
| 1016 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
| 1017 VerifyConsistency(); |
| 1018 |
| 1019 RemoveLocal(app_id, FPL("conflict_to_pending_remote")); |
| 1020 AddLocalFolder(app_id, FPL("conflict_to_pending_remote")); |
| 1021 |
| 1022 RemoveLocal(app_id, FPL("conflict_to_existing_remote")); |
| 1023 AddLocalFolder(app_id, FPL("conflict_to_existing_remote")); |
| 1024 |
| 1025 EXPECT_EQ(google_apis::HTTP_NO_CONTENT, |
| 1026 fake_drive_service_helper()->DeleteResource( |
| 1027 GetFileIDByPath(app_id, FPL("conflict_to_pending_remote")))); |
| 1028 |
| 1029 FetchRemoteChanges(); |
| 1030 |
| 1031 EXPECT_EQ(google_apis::HTTP_NO_CONTENT, |
| 1032 fake_drive_service_helper()->DeleteResource( |
| 1033 GetFileIDByPath(app_id, FPL("conflict_to_existing_remote")))); |
| 1034 |
| 1035 EXPECT_EQ(SYNC_STATUS_OK, ProcessChangesUntilDone()); |
| 1036 VerifyConsistency(); |
| 1037 |
| 1038 EXPECT_EQ(1u, CountApp()); |
| 1039 EXPECT_EQ(3u, CountLocalFile(app_id)); |
| 1040 VerifyLocalFolder(app_id, base::FilePath(FPL("conflict_to_pending_remote"))); |
| 1041 VerifyLocalFolder(app_id, base::FilePath(FPL("conflict_to_existing_remote"))); |
| 1042 |
| 1043 EXPECT_EQ(4u, CountMetadata()); |
| 1044 EXPECT_EQ(4u, CountTracker()); |
| 1045 } |
| 1046 |
| 975 } // namespace drive_backend | 1047 } // namespace drive_backend |
| 976 } // namespace sync_file_system | 1048 } // namespace sync_file_system |
| OLD | NEW |