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 // Browser test for basic Chrome OS file manager functionality: | 5 // Browser test for basic Chrome OS file manager functionality: |
| 6 // - The file list is updated when a file is added externally to the Downloads | 6 // - The file list is updated when a file is added externally to the Downloads |
| 7 // folder. | 7 // folder. |
| 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. | 8 // - Selecting a file and copy-pasting it with the keyboard copies the file. |
| 9 // - Selecting a file and pressing delete deletes it. | 9 // - Selecting a file and pressing delete deletes it. |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 &AddEntriesMessage::entries); | 202 &AddEntriesMessage::entries); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Test volume. | 205 // Test volume. |
| 206 class TestVolume { | 206 class TestVolume { |
| 207 protected: | 207 protected: |
| 208 explicit TestVolume(const std::string& name) : name_(name) {} | 208 explicit TestVolume(const std::string& name) : name_(name) {} |
| 209 virtual ~TestVolume() {} | 209 virtual ~TestVolume() {} |
| 210 | 210 |
| 211 bool CreateRootDirectory(const Profile* profile) { | 211 bool CreateRootDirectory(const Profile* profile) { |
| 212 return root_.Set(profile->GetPath().Append(name_)); | 212 const base::FilePath path = profile->GetPath().Append(name_); |
| 213 return root_.path() == path || root_.Set(path); | |
| 213 } | 214 } |
| 214 | 215 |
| 215 const std::string& name() { return name_; } | 216 const std::string& name() { return name_; } |
| 216 const base::FilePath root_path() { return root_.path(); } | 217 const base::FilePath root_path() { return root_.path(); } |
| 217 | 218 |
| 218 private: | 219 private: |
| 219 std::string name_; | 220 std::string name_; |
| 220 base::ScopedTempDir root_; | 221 base::ScopedTempDir root_; |
| 221 }; | 222 }; |
| 222 | 223 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 DownloadsTestVolume() : LocalTestVolume("Downloads") {} | 285 DownloadsTestVolume() : LocalTestVolume("Downloads") {} |
| 285 virtual ~DownloadsTestVolume() {} | 286 virtual ~DownloadsTestVolume() {} |
| 286 | 287 |
| 287 virtual bool Mount(Profile* profile) OVERRIDE { | 288 virtual bool Mount(Profile* profile) OVERRIDE { |
| 288 return CreateRootDirectory(profile) && | 289 return CreateRootDirectory(profile) && |
| 289 VolumeManager::Get(profile) | 290 VolumeManager::Get(profile) |
| 290 ->RegisterDownloadsDirectoryForTesting(root_path()); | 291 ->RegisterDownloadsDirectoryForTesting(root_path()); |
| 291 } | 292 } |
| 292 }; | 293 }; |
| 293 | 294 |
| 294 class FakeUsbTestVolume : public LocalTestVolume { | 295 // Test volume for mimicing a specified type of volumes by a local folder. |
| 296 class FakeTestVolume : public LocalTestVolume { | |
| 295 public: | 297 public: |
| 296 FakeUsbTestVolume() : LocalTestVolume("fake-usb") {} | 298 FakeTestVolume(const std::string& name, |
| 297 virtual ~FakeUsbTestVolume() {} | 299 VolumeType volume_type, |
| 300 chromeos::DeviceType device_type) | |
| 301 : LocalTestVolume(name), | |
| 302 volume_type_(volume_type), | |
| 303 device_type_(device_type) {} | |
| 304 virtual ~FakeTestVolume() {} | |
| 305 | |
| 306 // Simple test entries used for testing, e.g., read-only volumes. | |
| 307 bool PrepareTestEntries(Profile* profile) { | |
| 308 if (!CreateRootDirectory(profile)) | |
| 309 return false; | |
| 310 // Must be in sync with BASIC_FAKE_ENTRY_SET in the JS test code. | |
| 311 CreateEntry( | |
| 312 TestEntryInfo(FILE, "text.txt", "hello.txt", "text/plain", NONE, | |
| 313 base::Time::Now())); | |
| 314 CreateEntry( | |
| 315 TestEntryInfo(DIRECTORY, std::string(), "A", std::string(), NONE, | |
| 316 base::Time::Now())); | |
| 317 return true; | |
| 318 } | |
| 298 | 319 |
| 299 virtual bool Mount(Profile* profile) OVERRIDE { | 320 virtual bool Mount(Profile* profile) OVERRIDE { |
| 300 if (!CreateRootDirectory(profile)) | 321 if (!CreateRootDirectory(profile)) |
| 301 return false; | 322 return false; |
| 302 fileapi::ExternalMountPoints* const mount_points = | 323 fileapi::ExternalMountPoints* const mount_points = |
| 303 fileapi::ExternalMountPoints::GetSystemInstance(); | 324 fileapi::ExternalMountPoints::GetSystemInstance(); |
| 304 | 325 |
| 305 // First revoke the existing mount point (if any). | 326 // First revoke the existing mount point (if any). |
| 306 mount_points->RevokeFileSystem(name()); | 327 mount_points->RevokeFileSystem(name()); |
| 307 const bool result = | 328 const bool result = |
| 308 mount_points->RegisterFileSystem(name(), | 329 mount_points->RegisterFileSystem(name(), |
| 309 fileapi::kFileSystemTypeNativeLocal, | 330 fileapi::kFileSystemTypeNativeLocal, |
| 310 fileapi::FileSystemMountOption(), | 331 fileapi::FileSystemMountOption(), |
| 311 root_path()); | 332 root_path()); |
| 312 if (!result) | 333 if (!result) |
| 313 return false; | 334 return false; |
| 314 | 335 |
| 315 VolumeManager::Get(profile) | 336 VolumeManager::Get(profile)->AddVolumeInfoForTesting( |
| 316 ->AddVolumeInfoForTesting(root_path(), | 337 root_path(), volume_type_, device_type_); |
| 317 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, | |
| 318 chromeos::DEVICE_TYPE_USB); | |
| 319 return true; | 338 return true; |
| 320 } | 339 } |
| 340 | |
| 341 private: | |
| 342 const VolumeType volume_type_; | |
| 343 const chromeos::DeviceType device_type_; | |
| 321 }; | 344 }; |
| 322 | 345 |
| 323 // The drive volume class for test. | 346 // The drive volume class for test. |
| 324 // This class provides the operations for a test volume that simulates Google | 347 // This class provides the operations for a test volume that simulates Google |
| 325 // drive. | 348 // drive. |
| 326 class DriveTestVolume : public TestVolume { | 349 class DriveTestVolume : public TestVolume { |
| 327 public: | 350 public: |
| 328 DriveTestVolume() : TestVolume("drive"), integration_service_(NULL) {} | 351 DriveTestVolume() : TestVolume("drive"), integration_service_(NULL) {} |
| 329 virtual ~DriveTestVolume() {} | 352 virtual ~DriveTestVolume() {} |
| 330 | 353 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 | 551 |
| 529 // Overriding point for test configurations. | 552 // Overriding point for test configurations. |
| 530 virtual GuestMode GetGuestModeParam() const = 0; | 553 virtual GuestMode GetGuestModeParam() const = 0; |
| 531 virtual const char* GetTestCaseNameParam() const = 0; | 554 virtual const char* GetTestCaseNameParam() const = 0; |
| 532 virtual std::string OnMessage(const std::string& name, | 555 virtual std::string OnMessage(const std::string& name, |
| 533 const base::Value* value); | 556 const base::Value* value); |
| 534 | 557 |
| 535 scoped_ptr<LocalTestVolume> local_volume_; | 558 scoped_ptr<LocalTestVolume> local_volume_; |
| 536 linked_ptr<DriveTestVolume> drive_volume_; | 559 linked_ptr<DriveTestVolume> drive_volume_; |
| 537 std::map<Profile*, linked_ptr<DriveTestVolume> > drive_volumes_; | 560 std::map<Profile*, linked_ptr<DriveTestVolume> > drive_volumes_; |
| 538 scoped_ptr<LocalTestVolume> usb_volume_; | 561 scoped_ptr<FakeTestVolume> usb_volume_; |
| 562 scoped_ptr<FakeTestVolume> mtp_volume_; | |
| 539 | 563 |
| 540 private: | 564 private: |
| 541 drive::DriveIntegrationService* CreateDriveIntegrationService( | 565 drive::DriveIntegrationService* CreateDriveIntegrationService( |
| 542 Profile* profile); | 566 Profile* profile); |
| 543 DriveIntegrationServiceFactory::FactoryCallback | 567 DriveIntegrationServiceFactory::FactoryCallback |
| 544 create_drive_integration_service_; | 568 create_drive_integration_service_; |
| 545 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> | 569 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> |
| 546 service_factory_for_test_; | 570 service_factory_for_test_; |
| 547 }; | 571 }; |
| 548 | 572 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 if (usb_volume_) | 698 if (usb_volume_) |
| 675 usb_volume_->CreateEntry(*message.entries[i]); | 699 usb_volume_->CreateEntry(*message.entries[i]); |
| 676 break; | 700 break; |
| 677 default: | 701 default: |
| 678 NOTREACHED(); | 702 NOTREACHED(); |
| 679 break; | 703 break; |
| 680 } | 704 } |
| 681 } | 705 } |
| 682 return "onEntryAdded"; | 706 return "onEntryAdded"; |
| 683 } else if (name == "mountFakeUsb") { | 707 } else if (name == "mountFakeUsb") { |
| 684 usb_volume_.reset(new FakeUsbTestVolume()); | 708 usb_volume_.reset(new FakeTestVolume("fake-usb", |
| 709 VOLUME_TYPE_REMOVABLE_DISK_PARTITION, | |
| 710 chromeos::DEVICE_TYPE_USB)); | |
| 685 usb_volume_->Mount(profile()); | 711 usb_volume_->Mount(profile()); |
| 686 return "true"; | 712 return "true"; |
| 713 } else if (name == "mountFakeMtp") { | |
| 714 mtp_volume_.reset(new FakeTestVolume("fake-mtp", | |
| 715 VOLUME_TYPE_MTP, | |
| 716 chromeos::DEVICE_TYPE_UNKNOWN)); | |
| 717 mtp_volume_->PrepareTestEntries(profile()); | |
|
hirono
2014/06/03 10:15:39
Should we check the result of PrepareTestEntries?
kinaba
2014/06/04 01:50:53
Obviously. Done.
| |
| 718 mtp_volume_->Mount(profile()); | |
| 719 return "true"; | |
| 687 } | 720 } |
| 688 return "unknownMessage"; | 721 return "unknownMessage"; |
| 689 } | 722 } |
| 690 | 723 |
| 691 drive::DriveIntegrationService* | 724 drive::DriveIntegrationService* |
| 692 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { | 725 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { |
| 693 drive_volumes_[profile].reset(new DriveTestVolume()); | 726 drive_volumes_[profile].reset(new DriveTestVolume()); |
| 694 return drive_volumes_[profile]->CreateDriveIntegrationService(profile); | 727 return drive_volumes_[profile]->CreateDriveIntegrationService(profile); |
| 695 } | 728 } |
| 696 | 729 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 712 | 745 |
| 713 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTest, Test) { | 746 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTest, Test) { |
| 714 StartTest(); | 747 StartTest(); |
| 715 } | 748 } |
| 716 | 749 |
| 717 INSTANTIATE_TEST_CASE_P( | 750 INSTANTIATE_TEST_CASE_P( |
| 718 FileDisplay, | 751 FileDisplay, |
| 719 FileManagerBrowserTest, | 752 FileManagerBrowserTest, |
| 720 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDownloads"), | 753 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDownloads"), |
| 721 TestParameter(IN_GUEST_MODE, "fileDisplayDownloads"), | 754 TestParameter(IN_GUEST_MODE, "fileDisplayDownloads"), |
| 722 TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDrive"))); | 755 TestParameter(NOT_IN_GUEST_MODE, "fileDisplayDrive"), |
| 756 TestParameter(NOT_IN_GUEST_MODE, "fileDisplayMtp"))); | |
| 723 | 757 |
| 724 INSTANTIATE_TEST_CASE_P( | 758 INSTANTIATE_TEST_CASE_P( |
| 725 OpenZipFiles, | 759 OpenZipFiles, |
| 726 FileManagerBrowserTest, | 760 FileManagerBrowserTest, |
| 727 ::testing::Values(TestParameter(IN_GUEST_MODE, "zipOpenDownloads"), | 761 ::testing::Values(TestParameter(IN_GUEST_MODE, "zipOpenDownloads"), |
| 728 TestParameter(NOT_IN_GUEST_MODE, "zipOpenDownloads"), | 762 TestParameter(NOT_IN_GUEST_MODE, "zipOpenDownloads"), |
| 729 TestParameter(NOT_IN_GUEST_MODE, "zipOpenDrive"))); | 763 TestParameter(NOT_IN_GUEST_MODE, "zipOpenDrive"))); |
| 730 | 764 |
| 731 INSTANTIATE_TEST_CASE_P( | 765 INSTANTIATE_TEST_CASE_P( |
| 732 OpenVideoFiles, | 766 OpenVideoFiles, |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 // (bob and charlie) are added in the test. Thus the existing test verifies | 1097 // (bob and charlie) are added in the test. Thus the existing test verifies |
| 1064 // that the feature is effectively working with lastly logged in users. | 1098 // that the feature is effectively working with lastly logged in users. |
| 1065 AddExtraUsersForStressTesting(); | 1099 AddExtraUsersForStressTesting(); |
| 1066 | 1100 |
| 1067 set_test_case_name("multiProfileVisitDesktopMenu"); | 1101 set_test_case_name("multiProfileVisitDesktopMenu"); |
| 1068 StartTest(); | 1102 StartTest(); |
| 1069 } | 1103 } |
| 1070 | 1104 |
| 1071 } // namespace | 1105 } // namespace |
| 1072 } // namespace file_manager | 1106 } // namespace file_manager |
| OLD | NEW |