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

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

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_backend_v1/drive_file_sync_servi ce.h" 5 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi ce.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 file_system->SetUp(); 128 file_system->SetUp();
129 local_sync_service_->MaybeInitializeFileSystemContext( 129 local_sync_service_->MaybeInitializeFileSystemContext(
130 origin, file_system->file_system_context(), 130 origin, file_system->file_system_context(),
131 CreateResultReceiver(&status)); 131 CreateResultReceiver(&status));
132 FlushMessageLoop(); 132 FlushMessageLoop();
133 EXPECT_EQ(SYNC_STATUS_OK, status); 133 EXPECT_EQ(SYNC_STATUS_OK, status);
134 134
135 file_system->backend()->sync_context()-> 135 file_system->backend()->sync_context()->
136 set_mock_notify_changes_duration_in_sec(0); 136 set_mock_notify_changes_duration_in_sec(0);
137 137
138 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system->OpenFileSystem()); 138 EXPECT_EQ(base::File::FILE_OK, file_system->OpenFileSystem());
139 file_systems_[origin] = file_system; 139 file_systems_[origin] = file_system;
140 } 140 }
141 141
142 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 142 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
143 remote_sync_service_->RegisterOrigin( 143 remote_sync_service_->RegisterOrigin(
144 origin, CreateResultReceiver(&status)); 144 origin, CreateResultReceiver(&status));
145 FlushMessageLoop(); 145 FlushMessageLoop();
146 EXPECT_EQ(SYNC_STATUS_OK, status); 146 EXPECT_EQ(SYNC_STATUS_OK, status);
147 } 147 }
148 148
149 void AddOrUpdateLocalFile(const GURL& origin, 149 void AddOrUpdateLocalFile(const GURL& origin,
150 const base::FilePath& path, 150 const base::FilePath& path,
151 const std::string& content) { 151 const std::string& content) {
152 fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path)); 152 fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path));
153 ASSERT_TRUE(ContainsKey(file_systems_, origin)); 153 ASSERT_TRUE(ContainsKey(file_systems_, origin));
154 EXPECT_EQ(base::PLATFORM_FILE_OK, file_systems_[origin]->CreateFile(url)); 154 EXPECT_EQ(base::File::FILE_OK, file_systems_[origin]->CreateFile(url));
155 int64 bytes_written = file_systems_[origin]->WriteString(url, content); 155 int64 bytes_written = file_systems_[origin]->WriteString(url, content);
156 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); 156 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written);
157 FlushMessageLoop(); 157 FlushMessageLoop();
158 } 158 }
159 159
160 void UpdateLocalFile(const GURL& origin, 160 void UpdateLocalFile(const GURL& origin,
161 const base::FilePath& path, 161 const base::FilePath& path,
162 const std::string& content) { 162 const std::string& content) {
163 ASSERT_TRUE(ContainsKey(file_systems_, origin)); 163 ASSERT_TRUE(ContainsKey(file_systems_, origin));
164 int64 bytes_written = file_systems_[origin]->WriteString( 164 int64 bytes_written = file_systems_[origin]->WriteString(
165 CreateSyncableFileSystemURL(origin, path), content); 165 CreateSyncableFileSystemURL(origin, path), content);
166 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); 166 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written);
167 FlushMessageLoop(); 167 FlushMessageLoop();
168 } 168 }
169 169
170 void RemoveLocal(const GURL& origin, const base::FilePath& path) { 170 void RemoveLocal(const GURL& origin, const base::FilePath& path) {
171 ASSERT_TRUE(ContainsKey(file_systems_, origin)); 171 ASSERT_TRUE(ContainsKey(file_systems_, origin));
172 EXPECT_EQ(base::PLATFORM_FILE_OK, 172 EXPECT_EQ(base::File::FILE_OK,
173 file_systems_[origin]->Remove( 173 file_systems_[origin]->Remove(
174 CreateSyncableFileSystemURL(origin, path), 174 CreateSyncableFileSystemURL(origin, path),
175 true /* recursive */)); 175 true /* recursive */));
176 FlushMessageLoop(); 176 FlushMessageLoop();
177 } 177 }
178 178
179 SyncStatusCode ProcessLocalChange() { 179 SyncStatusCode ProcessLocalChange() {
180 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 180 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
181 fileapi::FileSystemURL url; 181 fileapi::FileSystemURL url;
182 local_sync_service_->ProcessLocalChange( 182 local_sync_service_->ProcessLocalChange(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 for (ScopedVector<ResourceEntry>::iterator itr = remote_entries.begin(); 293 for (ScopedVector<ResourceEntry>::iterator itr = remote_entries.begin();
294 itr != remote_entries.end(); 294 itr != remote_entries.end();
295 ++itr) { 295 ++itr) {
296 const ResourceEntry& remote_entry = **itr; 296 const ResourceEntry& remote_entry = **itr;
297 EXPECT_FALSE(ContainsKey(remote_entry_by_title, remote_entry.title())); 297 EXPECT_FALSE(ContainsKey(remote_entry_by_title, remote_entry.title()));
298 remote_entry_by_title[remote_entry.title()] = *itr; 298 remote_entry_by_title[remote_entry.title()] = *itr;
299 } 299 }
300 300
301 fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path)); 301 fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path));
302 CannedSyncableFileSystem::FileEntryList local_entries; 302 CannedSyncableFileSystem::FileEntryList local_entries;
303 EXPECT_EQ(base::PLATFORM_FILE_OK, 303 EXPECT_EQ(base::File::FILE_OK,
304 file_system->ReadDirectory(url, &local_entries)); 304 file_system->ReadDirectory(url, &local_entries));
305 for (CannedSyncableFileSystem::FileEntryList::iterator itr = 305 for (CannedSyncableFileSystem::FileEntryList::iterator itr =
306 local_entries.begin(); 306 local_entries.begin();
307 itr != local_entries.end(); 307 itr != local_entries.end();
308 ++itr) { 308 ++itr) {
309 const fileapi::DirectoryEntry& local_entry = *itr; 309 const fileapi::DirectoryEntry& local_entry = *itr;
310 fileapi::FileSystemURL entry_url( 310 fileapi::FileSystemURL entry_url(
311 CreateSyncableFileSystemURL(origin, path.Append(local_entry.name))); 311 CreateSyncableFileSystemURL(origin, path.Append(local_entry.name)));
312 std::string title = DriveFileSyncService::PathToTitle(entry_url.path()); 312 std::string title = DriveFileSyncService::PathToTitle(entry_url.path());
313 ASSERT_TRUE(ContainsKey(remote_entry_by_title, title)); 313 ASSERT_TRUE(ContainsKey(remote_entry_by_title, title));
(...skipping 16 matching lines...) Expand all
330 } 330 }
331 331
332 void VerifyConsistencyForFile(const GURL& origin, 332 void VerifyConsistencyForFile(const GURL& origin,
333 const base::FilePath& path, 333 const base::FilePath& path,
334 const std::string& file_id, 334 const std::string& file_id,
335 CannedSyncableFileSystem* file_system) { 335 CannedSyncableFileSystem* file_system) {
336 fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path)); 336 fileapi::FileSystemURL url(CreateSyncableFileSystemURL(origin, path));
337 std::string file_content; 337 std::string file_content;
338 EXPECT_EQ(google_apis::HTTP_SUCCESS, 338 EXPECT_EQ(google_apis::HTTP_SUCCESS,
339 fake_drive_helper_->ReadFile(file_id, &file_content)); 339 fake_drive_helper_->ReadFile(file_id, &file_content));
340 EXPECT_EQ(base::PLATFORM_FILE_OK, 340 EXPECT_EQ(base::File::FILE_OK,
341 file_system->VerifyFile(url, file_content)); 341 file_system->VerifyFile(url, file_content));
342 } 342 }
343 343
344 void FlushMessageLoop() { 344 void FlushMessageLoop() {
345 base::MessageLoop::current()->RunUntilIdle(); 345 base::MessageLoop::current()->RunUntilIdle();
346 BrowserThread::GetBlockingPool()->FlushForTesting(); 346 BrowserThread::GetBlockingPool()->FlushForTesting();
347 base::MessageLoop::current()->RunUntilIdle(); 347 base::MessageLoop::current()->RunUntilIdle();
348 } 348 }
349 349
350 void TestInitialization(); 350 void TestInitialization();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 ASSERT_FALSE(IsDriveAPIDisabled()); 571 ASSERT_FALSE(IsDriveAPIDisabled());
572 TestRemoteFileDeletion(); 572 TestRemoteFileDeletion();
573 } 573 }
574 574
575 TEST_F(DriveFileSyncServiceSyncTest, RemoteFileDeletionTest_WAPI) { 575 TEST_F(DriveFileSyncServiceSyncTest, RemoteFileDeletionTest_WAPI) {
576 ScopedDisableDriveAPI disable_drive_api; 576 ScopedDisableDriveAPI disable_drive_api;
577 TestRemoteFileDeletion(); 577 TestRemoteFileDeletion();
578 } 578 }
579 579
580 } // namespace sync_file_system 580 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698