Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/drive_file_sync_service.h" | 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/sync_file_system/drive/fake_api_util.h" | 14 #include "chrome/browser/sync_file_system/drive/fake_api_util.h" |
| 15 #include "chrome/browser/sync_file_system/drive_metadata_store.h" | 15 #include "chrome/browser/sync_file_system/drive_metadata_store.h" |
| 16 #include "chrome/browser/sync_file_system/fake_remote_change_processor.h" | 16 #include "chrome/browser/sync_file_system/fake_remote_change_processor.h" |
| 17 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" | 17 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 21 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
| 22 | 22 |
| 23 namespace sync_file_system { | 23 namespace sync_file_system { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const char kSyncRootResourceId[] = "sync_root_resource_id"; | 27 const char kSyncRootResourceId[] = "folder:sync_root_resource_id"; |
| 28 const char kParentResourceId[] = "parent_resource_id"; | 28 const char kParentResourceId[] = "folder:parent_resource_id"; |
| 29 const char kAppId[] = "app-id"; | 29 const char kAppId[] = "app-id"; |
| 30 const char kAppOrigin[] = "chrome-extension://app-id"; | 30 const char kAppOrigin[] = "chrome-extension://app-id"; |
| 31 | 31 |
| 32 void DidInitialize(bool* done, SyncStatusCode status, bool created) { | 32 void DidInitialize(bool* done, SyncStatusCode status, bool created) { |
| 33 EXPECT_EQ(SYNC_STATUS_OK, status); | 33 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 34 *done = true; | 34 *done = true; |
| 35 } | 35 } |
| 36 | 36 |
| 37 void DidProcessRemoteChange(bool* done, | 37 void DidProcessRemoteChange(bool* done, |
| 38 SyncStatusCode* status_out, | 38 SyncStatusCode* status_out, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 fake_remote_processor_.reset(); | 191 fake_remote_processor_.reset(); |
| 192 message_loop_.RunUntilIdle(); | 192 message_loop_.RunUntilIdle(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void AddOrUpdateResource(const std::string& title, | 195 void AddOrUpdateResource(const std::string& title, |
| 196 SyncFileType type) { | 196 SyncFileType type) { |
| 197 typedef ResourceIdByTitle::iterator iterator; | 197 typedef ResourceIdByTitle::iterator iterator; |
| 198 std::pair<iterator, bool> inserted = | 198 std::pair<iterator, bool> inserted = |
| 199 resources_.insert(std::make_pair(title, std::string())); | 199 resources_.insert(std::make_pair(title, std::string())); |
| 200 if (inserted.second) { | 200 if (inserted.second) { |
| 201 inserted.first->second = | 201 switch (type) { |
| 202 base::StringPrintf("%" PRId64, ++resource_count_); | 202 case SYNC_FILE_TYPE_FILE: |
| 203 inserted.first->second = | |
| 204 base::StringPrintf("file:%" PRId64, ++resource_count_); | |
| 205 break; | |
| 206 case SYNC_FILE_TYPE_DIRECTORY: | |
| 207 inserted.first->second = | |
| 208 base::StringPrintf("folder:%" PRId64, ++resource_count_); | |
| 209 break; | |
| 210 default: | |
|
tzik
2013/05/29 04:30:24
ditto
nhiroki
2013/05/29 06:31:03
Done.
| |
| 211 NOTREACHED(); | |
| 212 break; | |
| 213 } | |
| 203 } | 214 } |
| 204 std::string resource_id = inserted.first->second; | 215 std::string resource_id = inserted.first->second; |
| 205 std::string md5_checksum; | 216 std::string md5_checksum; |
| 206 if (type == SYNC_FILE_TYPE_FILE) | 217 if (type == SYNC_FILE_TYPE_FILE) |
| 207 md5_checksum = base::StringPrintf("%" PRIx64, base::RandUint64()); | 218 md5_checksum = base::StringPrintf("%" PRIx64, base::RandUint64()); |
| 208 | 219 |
| 209 fake_api_util_->PushRemoteChange(kParentResourceId, | 220 fake_api_util_->PushRemoteChange(kParentResourceId, |
| 210 kAppId, | 221 kAppId, |
| 211 title, | 222 title, |
| 212 resource_id, | 223 resource_id, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 TEST_F(DriveFileSyncServiceSyncTest, DeleteDirectoryTest) { | 436 TEST_F(DriveFileSyncServiceSyncTest, DeleteDirectoryTest) { |
| 426 std::string kDir = "dir title"; | 437 std::string kDir = "dir title"; |
| 427 SyncEvent sync_event[] = { | 438 SyncEvent sync_event[] = { |
| 428 CreateRemoteDirectoryAddEvent(kDir), | 439 CreateRemoteDirectoryAddEvent(kDir), |
| 429 CreateRemoteFileDeleteEvent(kDir), | 440 CreateRemoteFileDeleteEvent(kDir), |
| 430 }; | 441 }; |
| 431 RunTest(CreateTestCase(sync_event)); | 442 RunTest(CreateTestCase(sync_event)); |
| 432 } | 443 } |
| 433 | 444 |
| 434 } // namespace sync_file_system | 445 } // namespace sync_file_system |
| OLD | NEW |