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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 std::string sync_root_folder_id; 405 std::string sync_root_folder_id;
406 google_apis::DriveApiErrorCode error = 406 google_apis::DriveApiErrorCode error =
407 fake_drive_service_helper_->GetSyncRootFolderID(&sync_root_folder_id); 407 fake_drive_service_helper_->GetSyncRootFolderID(&sync_root_folder_id);
408 if (sync_root_folder_id.empty()) { 408 if (sync_root_folder_id.empty()) {
409 EXPECT_EQ(google_apis::HTTP_NOT_FOUND, error); 409 EXPECT_EQ(google_apis::HTTP_NOT_FOUND, error);
410 EXPECT_TRUE(file_systems_.empty()); 410 EXPECT_TRUE(file_systems_.empty());
411 return; 411 return;
412 } 412 }
413 EXPECT_EQ(google_apis::HTTP_SUCCESS, error); 413 EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
414 414
415 ScopedVector<google_apis::FileResource> remote_entries; 415 std::vector<std::unique_ptr<google_apis::FileResource>> remote_entries;
416 EXPECT_EQ(google_apis::HTTP_SUCCESS, 416 EXPECT_EQ(google_apis::HTTP_SUCCESS,
417 fake_drive_service_helper_->ListFilesInFolder( 417 fake_drive_service_helper_->ListFilesInFolder(
418 sync_root_folder_id, &remote_entries)); 418 sync_root_folder_id, &remote_entries));
419 std::map<std::string, const google_apis::FileResource*> app_root_by_title; 419 std::map<std::string, const google_apis::FileResource*> app_root_by_title;
420 for (ScopedVector<google_apis::FileResource>::iterator itr = 420 for (const auto& remote_entry : remote_entries) {
421 remote_entries.begin(); 421 EXPECT_FALSE(base::ContainsKey(app_root_by_title, remote_entry->title()));
Avi (use Gerrit) 2017/01/09 17:18:29 ContainsKey requires #include "base/stl_util.h"
leonhsl(Using Gerrit) 2017/01/10 04:39:36 Done.
422 itr != remote_entries.end(); 422 app_root_by_title[remote_entry->title()] = remote_entry.get();
423 ++itr) {
424 const google_apis::FileResource& remote_entry = **itr;
425 EXPECT_FALSE(base::ContainsKey(app_root_by_title, remote_entry.title()));
426 app_root_by_title[remote_entry.title()] = *itr;
427 } 423 }
428 424
429 for (std::map<std::string, CannedSyncableFileSystem*>::const_iterator itr = 425 for (std::map<std::string, CannedSyncableFileSystem*>::const_iterator itr =
430 file_systems_.begin(); 426 file_systems_.begin();
431 itr != file_systems_.end(); ++itr) { 427 itr != file_systems_.end(); ++itr) {
432 const std::string& app_id = itr->first; 428 const std::string& app_id = itr->first;
433 SCOPED_TRACE(testing::Message() << "Verifying app: " << app_id); 429 SCOPED_TRACE(testing::Message() << "Verifying app: " << app_id);
434 CannedSyncableFileSystem* file_system = itr->second; 430 CannedSyncableFileSystem* file_system = itr->second;
435 ASSERT_TRUE(base::ContainsKey(app_root_by_title, app_id)); 431 ASSERT_TRUE(base::ContainsKey(app_root_by_title, app_id));
436 VerifyConsistencyForFolder( 432 VerifyConsistencyForFolder(
437 app_id, base::FilePath(), 433 app_id, base::FilePath(),
438 app_root_by_title[app_id]->file_id(), 434 app_root_by_title[app_id]->file_id(),
439 file_system); 435 file_system);
440 } 436 }
441 } 437 }
442 438
443 void VerifyConsistencyForFolder(const std::string& app_id, 439 void VerifyConsistencyForFolder(const std::string& app_id,
444 const base::FilePath& path, 440 const base::FilePath& path,
445 const std::string& folder_id, 441 const std::string& folder_id,
446 CannedSyncableFileSystem* file_system) { 442 CannedSyncableFileSystem* file_system) {
447 SCOPED_TRACE(testing::Message() << "Verifying folder: " << path.value()); 443 SCOPED_TRACE(testing::Message() << "Verifying folder: " << path.value());
448 444
449 ScopedVector<google_apis::FileResource> remote_entries; 445 std::vector<std::unique_ptr<google_apis::FileResource>> remote_entries;
450 EXPECT_EQ(google_apis::HTTP_SUCCESS, 446 EXPECT_EQ(google_apis::HTTP_SUCCESS,
451 fake_drive_service_helper_->ListFilesInFolder( 447 fake_drive_service_helper_->ListFilesInFolder(
452 folder_id, &remote_entries)); 448 folder_id, &remote_entries));
453 std::map<std::string, const google_apis::FileResource*> 449 std::map<std::string, const google_apis::FileResource*>
454 remote_entry_by_title; 450 remote_entry_by_title;
455 for (size_t i = 0; i < remote_entries.size(); ++i) { 451 for (size_t i = 0; i < remote_entries.size(); ++i) {
456 google_apis::FileResource* remote_entry = remote_entries[i]; 452 google_apis::FileResource* remote_entry = remote_entries[i].get();
457 EXPECT_FALSE( 453 EXPECT_FALSE(
458 base::ContainsKey(remote_entry_by_title, remote_entry->title())) 454 base::ContainsKey(remote_entry_by_title, remote_entry->title()))
459 << "title: " << remote_entry->title(); 455 << "title: " << remote_entry->title();
460 remote_entry_by_title[remote_entry->title()] = remote_entry; 456 remote_entry_by_title[remote_entry->title()] = remote_entry;
461 } 457 }
462 458
463 storage::FileSystemURL url(CreateURL(app_id, path)); 459 storage::FileSystemURL url(CreateURL(app_id, path));
464 FileEntryList local_entries; 460 FileEntryList local_entries;
465 EXPECT_EQ(base::File::FILE_OK, 461 EXPECT_EQ(base::File::FILE_OK,
466 file_system->ReadDirectory(url, &local_entries)); 462 file_system->ReadDirectory(url, &local_entries));
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 1718
1723 EXPECT_EQ(1u, CountApp()); 1719 EXPECT_EQ(1u, CountApp());
1724 EXPECT_EQ(1u, CountLocalFile(app_id)); 1720 EXPECT_EQ(1u, CountLocalFile(app_id));
1725 1721
1726 EXPECT_EQ(2u, CountMetadata()); 1722 EXPECT_EQ(2u, CountMetadata());
1727 EXPECT_EQ(2u, CountTracker()); 1723 EXPECT_EQ(2u, CountTracker());
1728 } 1724 }
1729 1725
1730 } // namespace drive_backend 1726 } // namespace drive_backend
1731 } // namespace sync_file_system 1727 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698