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

Side by Side Diff: chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent)) 156 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
157 return false; 157 return false;
158 158
159 test_file = test_dir.AppendASCII("empty_test_file.foo"); 159 test_file = test_dir.AppendASCII("empty_test_file.foo");
160 if (!google_apis::test_util::WriteStringToFile(test_file, "")) 160 if (!google_apis::test_util::WriteStringToFile(test_file, ""))
161 return false; 161 return false;
162 162
163 return true; 163 return true;
164 } 164 }
165 165
166 scoped_ptr<google_apis::FileResource> UpdateDriveEntryTime( 166 std::unique_ptr<google_apis::FileResource> UpdateDriveEntryTime(
167 drive::FakeDriveService* fake_drive_service, 167 drive::FakeDriveService* fake_drive_service,
168 const std::string& resource_id, 168 const std::string& resource_id,
169 const std::string& last_modified, 169 const std::string& last_modified,
170 const std::string& last_viewed_by_me) { 170 const std::string& last_viewed_by_me) {
171 base::Time last_modified_time, last_viewed_by_me_time; 171 base::Time last_modified_time, last_viewed_by_me_time;
172 if (!google_apis::util::GetTimeFromString(last_modified, 172 if (!google_apis::util::GetTimeFromString(last_modified,
173 &last_modified_time) || 173 &last_modified_time) ||
174 !google_apis::util::GetTimeFromString(last_viewed_by_me, 174 !google_apis::util::GetTimeFromString(last_viewed_by_me,
175 &last_viewed_by_me_time)) 175 &last_viewed_by_me_time))
176 return scoped_ptr<google_apis::FileResource>(); 176 return std::unique_ptr<google_apis::FileResource>();
177 177
178 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 178 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
179 scoped_ptr<google_apis::FileResource> entry; 179 std::unique_ptr<google_apis::FileResource> entry;
180 fake_drive_service->UpdateResource( 180 fake_drive_service->UpdateResource(
181 resource_id, 181 resource_id,
182 std::string(), // parent_resource_id 182 std::string(), // parent_resource_id
183 std::string(), // title 183 std::string(), // title
184 last_modified_time, last_viewed_by_me_time, 184 last_modified_time, last_viewed_by_me_time,
185 google_apis::drive::Properties(), 185 google_apis::drive::Properties(),
186 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 186 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
187 base::RunLoop().RunUntilIdle(); 187 base::RunLoop().RunUntilIdle();
188 if (error != google_apis::HTTP_SUCCESS) 188 if (error != google_apis::HTTP_SUCCESS)
189 return scoped_ptr<google_apis::FileResource>(); 189 return std::unique_ptr<google_apis::FileResource>();
190 190
191 return entry; 191 return entry;
192 } 192 }
193 193
194 scoped_ptr<google_apis::FileResource> AddFileToDriveService( 194 std::unique_ptr<google_apis::FileResource> AddFileToDriveService(
195 drive::FakeDriveService* fake_drive_service, 195 drive::FakeDriveService* fake_drive_service,
196 const std::string& mime_type, 196 const std::string& mime_type,
197 const std::string& content, 197 const std::string& content,
198 const std::string& parent_resource_id, 198 const std::string& parent_resource_id,
199 const std::string& title, 199 const std::string& title,
200 const std::string& last_modified, 200 const std::string& last_modified,
201 const std::string& last_viewed_by_me) { 201 const std::string& last_viewed_by_me) {
202 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 202 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
203 scoped_ptr<google_apis::FileResource> entry; 203 std::unique_ptr<google_apis::FileResource> entry;
204 fake_drive_service->AddNewFile( 204 fake_drive_service->AddNewFile(
205 mime_type, 205 mime_type,
206 content, 206 content,
207 parent_resource_id, 207 parent_resource_id,
208 title, 208 title,
209 false, // shared_with_me 209 false, // shared_with_me
210 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 210 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
211 base::RunLoop().RunUntilIdle(); 211 base::RunLoop().RunUntilIdle();
212 if (error != google_apis::HTTP_CREATED) 212 if (error != google_apis::HTTP_CREATED)
213 return scoped_ptr<google_apis::FileResource>(); 213 return std::unique_ptr<google_apis::FileResource>();
214 214
215 return UpdateDriveEntryTime(fake_drive_service, entry->file_id(), 215 return UpdateDriveEntryTime(fake_drive_service, entry->file_id(),
216 last_modified, last_viewed_by_me); 216 last_modified, last_viewed_by_me);
217 } 217 }
218 218
219 scoped_ptr<google_apis::FileResource> AddDirectoryToDriveService( 219 std::unique_ptr<google_apis::FileResource> AddDirectoryToDriveService(
220 drive::FakeDriveService* fake_drive_service, 220 drive::FakeDriveService* fake_drive_service,
221 const std::string& parent_resource_id, 221 const std::string& parent_resource_id,
222 const std::string& title, 222 const std::string& title,
223 const std::string& last_modified, 223 const std::string& last_modified,
224 const std::string& last_viewed_by_me) { 224 const std::string& last_viewed_by_me) {
225 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 225 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
226 scoped_ptr<google_apis::FileResource> entry; 226 std::unique_ptr<google_apis::FileResource> entry;
227 fake_drive_service->AddNewDirectory( 227 fake_drive_service->AddNewDirectory(
228 parent_resource_id, title, drive::AddNewDirectoryOptions(), 228 parent_resource_id, title, drive::AddNewDirectoryOptions(),
229 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 229 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
230 base::RunLoop().RunUntilIdle(); 230 base::RunLoop().RunUntilIdle();
231 if (error != google_apis::HTTP_CREATED) 231 if (error != google_apis::HTTP_CREATED)
232 return scoped_ptr<google_apis::FileResource>(); 232 return std::unique_ptr<google_apis::FileResource>();
233 233
234 return UpdateDriveEntryTime(fake_drive_service, entry->file_id(), 234 return UpdateDriveEntryTime(fake_drive_service, entry->file_id(),
235 last_modified, last_viewed_by_me); 235 last_modified, last_viewed_by_me);
236 } 236 }
237 237
238 // Sets up the drive service state. 238 // Sets up the drive service state.
239 // The hierarchy is the same as for the local file system. 239 // The hierarchy is the same as for the local file system.
240 bool InitializeDriveService( 240 bool InitializeDriveService(
241 drive::FakeDriveService* fake_drive_service, 241 drive::FakeDriveService* fake_drive_service,
242 std::map<std::string, std::string>* out_resource_ids) { 242 std::map<std::string, std::string>* out_resource_ids) {
243 scoped_ptr<google_apis::FileResource> entry; 243 std::unique_ptr<google_apis::FileResource> entry;
244 244
245 entry = AddDirectoryToDriveService(fake_drive_service, 245 entry = AddDirectoryToDriveService(fake_drive_service,
246 fake_drive_service->GetRootResourceId(), 246 fake_drive_service->GetRootResourceId(),
247 "test_dir", 247 "test_dir",
248 "2012-01-02T00:00:00.000Z", 248 "2012-01-02T00:00:00.000Z",
249 "2012-01-02T00:00:01.000Z"); 249 "2012-01-02T00:00:01.000Z");
250 if (!entry) 250 if (!entry)
251 return false; 251 return false;
252 (*out_resource_ids)[entry->title()] = entry->file_id(); 252 (*out_resource_ids)[entry->title()] = entry->file_id();
253 253
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids)); 546 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids));
547 547
548 return new drive::DriveIntegrationService( 548 return new drive::DriveIntegrationService(
549 profile, NULL, fake_drive_service_, "", test_cache_root_.path(), NULL); 549 profile, NULL, fake_drive_service_, "", test_cache_root_.path(), NULL);
550 } 550 }
551 551
552 base::ScopedTempDir test_cache_root_; 552 base::ScopedTempDir test_cache_root_;
553 drive::FakeDriveService* fake_drive_service_; 553 drive::FakeDriveService* fake_drive_service_;
554 DriveIntegrationServiceFactory::FactoryCallback 554 DriveIntegrationServiceFactory::FactoryCallback
555 create_drive_integration_service_; 555 create_drive_integration_service_;
556 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> 556 std::unique_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
557 service_factory_for_test_; 557 service_factory_for_test_;
558 }; 558 };
559 559
560 // Tests for Drive file systems in multi-profile setting. 560 // Tests for Drive file systems in multi-profile setting.
561 class MultiProfileDriveFileSystemExtensionApiTest : 561 class MultiProfileDriveFileSystemExtensionApiTest :
562 public FileSystemExtensionApiTestBase { 562 public FileSystemExtensionApiTestBase {
563 public: 563 public:
564 MultiProfileDriveFileSystemExtensionApiTest() : second_profile_(NULL) {} 564 MultiProfileDriveFileSystemExtensionApiTest() : second_profile_(NULL) {}
565 565
566 void SetUpOnMainThread() override { 566 void SetUpOnMainThread() override {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 bool AddTestHostedDocuments() { 618 bool AddTestHostedDocuments() {
619 const char kResourceId[] = "unique-id-for-multiprofile-copy-test"; 619 const char kResourceId[] = "unique-id-for-multiprofile-copy-test";
620 drive::FakeDriveService* const main_service = 620 drive::FakeDriveService* const main_service =
621 static_cast<drive::FakeDriveService*>( 621 static_cast<drive::FakeDriveService*>(
622 drive::util::GetDriveServiceByProfile(browser()->profile())); 622 drive::util::GetDriveServiceByProfile(browser()->profile()));
623 drive::FakeDriveService* const sub_service = 623 drive::FakeDriveService* const sub_service =
624 static_cast<drive::FakeDriveService*>( 624 static_cast<drive::FakeDriveService*>(
625 drive::util::GetDriveServiceByProfile(second_profile_)); 625 drive::util::GetDriveServiceByProfile(second_profile_));
626 626
627 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; 627 google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
628 scoped_ptr<google_apis::FileResource> entry; 628 std::unique_ptr<google_apis::FileResource> entry;
629 629
630 // Place a hosted document under root/test_dir of the sub profile. 630 // Place a hosted document under root/test_dir of the sub profile.
631 sub_service->AddNewFileWithResourceId( 631 sub_service->AddNewFileWithResourceId(
632 kResourceId, 632 kResourceId,
633 "application/vnd.google-apps.document", "", 633 "application/vnd.google-apps.document", "",
634 resource_ids_["test_dir"], "hosted_doc", true, 634 resource_ids_["test_dir"], "hosted_doc", true,
635 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 635 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
636 content::RunAllBlockingPoolTasksUntilIdle(); 636 content::RunAllBlockingPoolTasksUntilIdle();
637 if (error != google_apis::HTTP_CREATED) 637 if (error != google_apis::HTTP_CREATED)
638 return false; 638 return false;
639 639
640 // Place the hosted document with no parent in the main profile, for 640 // Place the hosted document with no parent in the main profile, for
641 // simulating the situation that the document is shared to the main profile. 641 // simulating the situation that the document is shared to the main profile.
642 error = google_apis::DRIVE_OTHER_ERROR; 642 error = google_apis::DRIVE_OTHER_ERROR;
643 main_service->AddNewFileWithResourceId( 643 main_service->AddNewFileWithResourceId(
644 kResourceId, 644 kResourceId,
645 "application/vnd.google-apps.document", "", "", "hosted_doc", true, 645 "application/vnd.google-apps.document", "", "", "hosted_doc", true,
646 google_apis::test_util::CreateCopyResultCallback(&error, &entry)); 646 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
647 content::RunAllBlockingPoolTasksUntilIdle(); 647 content::RunAllBlockingPoolTasksUntilIdle();
648 return (error == google_apis::HTTP_CREATED); 648 return (error == google_apis::HTTP_CREATED);
649 } 649 }
650 650
651 base::ScopedTempDir tmp_dir_; 651 base::ScopedTempDir tmp_dir_;
652 DriveIntegrationServiceFactory::FactoryCallback 652 DriveIntegrationServiceFactory::FactoryCallback
653 create_drive_integration_service_; 653 create_drive_integration_service_;
654 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> 654 std::unique_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
655 service_factory_for_test_; 655 service_factory_for_test_;
656 Profile* second_profile_; 656 Profile* second_profile_;
657 std::map<std::string, std::string> resource_ids_; 657 std::map<std::string, std::string> resource_ids_;
658 }; 658 };
659 659
660 class LocalAndDriveFileSystemExtensionApiTest 660 class LocalAndDriveFileSystemExtensionApiTest
661 : public FileSystemExtensionApiTestBase { 661 : public FileSystemExtensionApiTestBase {
662 public: 662 public:
663 LocalAndDriveFileSystemExtensionApiTest() {} 663 LocalAndDriveFileSystemExtensionApiTest() {}
664 ~LocalAndDriveFileSystemExtensionApiTest() override {} 664 ~LocalAndDriveFileSystemExtensionApiTest() override {}
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 private: 718 private:
719 // For local volume. 719 // For local volume.
720 base::ScopedTempDir local_tmp_dir_; 720 base::ScopedTempDir local_tmp_dir_;
721 base::FilePath local_mount_point_dir_; 721 base::FilePath local_mount_point_dir_;
722 722
723 // For drive volume. 723 // For drive volume.
724 base::ScopedTempDir test_cache_root_; 724 base::ScopedTempDir test_cache_root_;
725 drive::FakeDriveService* fake_drive_service_; 725 drive::FakeDriveService* fake_drive_service_;
726 DriveIntegrationServiceFactory::FactoryCallback 726 DriveIntegrationServiceFactory::FactoryCallback
727 create_drive_integration_service_; 727 create_drive_integration_service_;
728 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> 728 std::unique_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
729 service_factory_for_test_; 729 service_factory_for_test_;
730 }; 730 };
731 731
732 // 732 //
733 // LocalFileSystemExtensionApiTests. 733 // LocalFileSystemExtensionApiTests.
734 // 734 //
735 735
736 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) { 736 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) {
737 EXPECT_TRUE(RunFileSystemExtensionApiTest( 737 EXPECT_TRUE(RunFileSystemExtensionApiTest(
738 "file_browser/filesystem_operations_test", 738 "file_browser/filesystem_operations_test",
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 AppFileHandlerMulti) { 858 AppFileHandlerMulti) {
859 EXPECT_TRUE( 859 EXPECT_TRUE(
860 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", 860 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi",
861 FILE_PATH_LITERAL("manifest.json"), 861 FILE_PATH_LITERAL("manifest.json"),
862 "", 862 "",
863 FLAGS_NONE)) 863 FLAGS_NONE))
864 << message_; 864 << message_;
865 } 865 }
866 } // namespace 866 } // namespace
867 } // namespace file_manager 867 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/feedback_util.cc ('k') | chrome/browser/chromeos/file_manager/file_browser_handlers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698