Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service_sync_unittest.cc

Issue 15808002: SyncFS: Convert WAPI ResourceID to DriveAPI FileID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/fileapi/syncable/syncable_file_system_util.h" 21 #include "webkit/browser/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
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_UNKNOWN:
203 NOTREACHED();
204 break;
205 case SYNC_FILE_TYPE_FILE:
206 inserted.first->second =
207 base::StringPrintf("file:%" PRId64, ++resource_count_);
208 break;
209 case SYNC_FILE_TYPE_DIRECTORY:
210 inserted.first->second =
211 base::StringPrintf("folder:%" PRId64, ++resource_count_);
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698