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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 enum TargetVolume { LOCAL_VOLUME, DRIVE_VOLUME, USB_VOLUME, }; | 65 enum TargetVolume { LOCAL_VOLUME, DRIVE_VOLUME, USB_VOLUME, }; |
66 | 66 |
67 enum SharedOption { | 67 enum SharedOption { |
68 NONE, | 68 NONE, |
69 SHARED, | 69 SHARED, |
70 }; | 70 }; |
71 | 71 |
72 enum GuestMode { | 72 enum GuestMode { |
73 NOT_IN_GUEST_MODE, | 73 NOT_IN_GUEST_MODE, |
74 IN_GUEST_MODE, | 74 IN_GUEST_MODE, |
| 75 IN_INCOGNITO |
75 }; | 76 }; |
76 | 77 |
77 // This global operator is used from Google Test to format error messages. | 78 // This global operator is used from Google Test to format error messages. |
78 std::ostream& operator<<(std::ostream& os, const GuestMode& guest_mode) { | 79 std::ostream& operator<<(std::ostream& os, const GuestMode& guest_mode) { |
79 return os << (guest_mode == IN_GUEST_MODE ? | 80 return os << (guest_mode == IN_GUEST_MODE ? |
80 "IN_GUEST_MODE" : "NOT_IN_GUEST_MODE"); | 81 "IN_GUEST_MODE" : "NOT_IN_GUEST_MODE"); |
81 } | 82 } |
82 | 83 |
83 // Maps the given string to EntryType. Returns true on success. | 84 // Maps the given string to EntryType. Returns true on success. |
84 bool MapStringToEntryType(const base::StringPiece& value, EntryType* output) { | 85 bool MapStringToEntryType(const base::StringPiece& value, EntryType* output) { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 580 |
580 void FileManagerBrowserTestBase::SetUpOnMainThread() { | 581 void FileManagerBrowserTestBase::SetUpOnMainThread() { |
581 ExtensionApiTest::SetUpOnMainThread(); | 582 ExtensionApiTest::SetUpOnMainThread(); |
582 ASSERT_TRUE(local_volume_->Mount(profile())); | 583 ASSERT_TRUE(local_volume_->Mount(profile())); |
583 | 584 |
584 if (GetGuestModeParam() != IN_GUEST_MODE) { | 585 if (GetGuestModeParam() != IN_GUEST_MODE) { |
585 // Install the web server to serve the mocked share dialog. | 586 // Install the web server to serve the mocked share dialog. |
586 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 587 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
587 const GURL share_url_base(embedded_test_server()->GetURL( | 588 const GURL share_url_base(embedded_test_server()->GetURL( |
588 "/chromeos/file_manager/share_dialog_mock/index.html")); | 589 "/chromeos/file_manager/share_dialog_mock/index.html")); |
589 drive_volume_ = drive_volumes_[profile()]; | 590 drive_volume_ = drive_volumes_[profile()->GetOriginalProfile()]; |
590 drive_volume_->ConfigureShareUrlBase(share_url_base); | 591 drive_volume_->ConfigureShareUrlBase(share_url_base); |
591 test_util::WaitUntilDriveMountPointIsAdded(profile()); | 592 test_util::WaitUntilDriveMountPointIsAdded(profile()); |
592 } | 593 } |
593 } | 594 } |
594 | 595 |
595 void FileManagerBrowserTestBase::SetUpCommandLine(CommandLine* command_line) { | 596 void FileManagerBrowserTestBase::SetUpCommandLine(CommandLine* command_line) { |
596 if (GetGuestModeParam() == IN_GUEST_MODE) { | 597 if (GetGuestModeParam() == IN_GUEST_MODE) { |
597 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 598 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
598 command_line->AppendSwitchNative(chromeos::switches::kLoginUser, ""); | 599 command_line->AppendSwitchNative(chromeos::switches::kLoginUser, ""); |
599 command_line->AppendSwitch(switches::kIncognito); | 600 command_line->AppendSwitch(switches::kIncognito); |
600 } | 601 } |
| 602 if (GetGuestModeParam() == IN_INCOGNITO) { |
| 603 command_line->AppendSwitch(switches::kIncognito); |
| 604 } |
601 ExtensionApiTest::SetUpCommandLine(command_line); | 605 ExtensionApiTest::SetUpCommandLine(command_line); |
602 } | 606 } |
603 | 607 |
604 void FileManagerBrowserTestBase::StartTest() { | 608 void FileManagerBrowserTestBase::StartTest() { |
605 // Launch the extension. | 609 // Launch the extension. |
606 const base::FilePath path = | 610 const base::FilePath path = |
607 test_data_dir_.AppendASCII("file_manager_browsertest"); | 611 test_data_dir_.AppendASCII("file_manager_browsertest"); |
608 const extensions::Extension* const extension = | 612 const extensions::Extension* const extension = |
609 LoadExtensionAsComponentWithManifest(path, GetTestManifestName()); | 613 LoadExtensionAsComponentWithManifest(path, GetTestManifestName()); |
610 ASSERT_TRUE(extension); | 614 ASSERT_TRUE(extension); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 res->SetString("downloads", | 657 res->SetString("downloads", |
654 "/" + util::GetDownloadsMountPointName(profile())); | 658 "/" + util::GetDownloadsMountPointName(profile())); |
655 res->SetString("drive", | 659 res->SetString("drive", |
656 "/" + drive::util::GetDriveMountPointPath(profile() | 660 "/" + drive::util::GetDriveMountPointPath(profile() |
657 ).BaseName().AsUTF8Unsafe() + "/root"); | 661 ).BaseName().AsUTF8Unsafe() + "/root"); |
658 std::string jsonString; | 662 std::string jsonString; |
659 base::JSONWriter::Write(res.get(), &jsonString); | 663 base::JSONWriter::Write(res.get(), &jsonString); |
660 return jsonString; | 664 return jsonString; |
661 } else if (name == "isInGuestMode") { | 665 } else if (name == "isInGuestMode") { |
662 // Obtain whether the test is in guest mode or not. | 666 // Obtain whether the test is in guest mode or not. |
663 return GetGuestModeParam() ? "true" : "false"; | 667 return GetGuestModeParam() != NOT_IN_GUEST_MODE ? "true" : "false"; |
664 } else if (name == "getCwsWidgetContainerMockUrl") { | 668 } else if (name == "getCwsWidgetContainerMockUrl") { |
665 // Obtain whether the test is in guest mode or not. | 669 // Obtain whether the test is in guest mode or not. |
666 const GURL url = embedded_test_server()->GetURL( | 670 const GURL url = embedded_test_server()->GetURL( |
667 "/chromeos/file_manager/cws_container_mock/index.html"); | 671 "/chromeos/file_manager/cws_container_mock/index.html"); |
668 std::string origin = url.GetOrigin().spec(); | 672 std::string origin = url.GetOrigin().spec(); |
669 | 673 |
670 // Removes trailing a slash. | 674 // Removes trailing a slash. |
671 if (*origin.rbegin() == '/') | 675 if (*origin.rbegin() == '/') |
672 origin.resize(origin.length() - 1); | 676 origin.resize(origin.length() - 1); |
673 | 677 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 if (!mtp_volume_->PrepareTestEntries(profile())) | 719 if (!mtp_volume_->PrepareTestEntries(profile())) |
716 return "false"; | 720 return "false"; |
717 mtp_volume_->Mount(profile()); | 721 mtp_volume_->Mount(profile()); |
718 return "true"; | 722 return "true"; |
719 } | 723 } |
720 return "unknownMessage"; | 724 return "unknownMessage"; |
721 } | 725 } |
722 | 726 |
723 drive::DriveIntegrationService* | 727 drive::DriveIntegrationService* |
724 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { | 728 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { |
725 drive_volumes_[profile].reset(new DriveTestVolume()); | 729 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume()); |
726 return drive_volumes_[profile]->CreateDriveIntegrationService(profile); | 730 return drive_volumes_[profile->GetOriginalProfile()]-> |
| 731 CreateDriveIntegrationService(profile); |
727 } | 732 } |
728 | 733 |
729 // Parameter of FileManagerBrowserTest. | 734 // Parameter of FileManagerBrowserTest. |
730 // The second value is the case name of JavaScript. | 735 // The second value is the case name of JavaScript. |
731 typedef std::tr1::tuple<GuestMode, const char*> TestParameter; | 736 typedef std::tr1::tuple<GuestMode, const char*> TestParameter; |
732 | 737 |
733 // Test fixture class for normal (not multi-profile related) tests. | 738 // Test fixture class for normal (not multi-profile related) tests. |
734 class FileManagerBrowserTest : | 739 class FileManagerBrowserTest : |
735 public FileManagerBrowserTestBase, | 740 public FileManagerBrowserTestBase, |
736 public ::testing::WithParamInterface<TestParameter> { | 741 public ::testing::WithParamInterface<TestParameter> { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 #define MAYBE_OpenFileDialog OpenFileDialog | 1037 #define MAYBE_OpenFileDialog OpenFileDialog |
1033 #endif | 1038 #endif |
1034 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1039 WRAPPED_INSTANTIATE_TEST_CASE_P( |
1035 MAYBE_OpenFileDialog, | 1040 MAYBE_OpenFileDialog, |
1036 FileManagerBrowserTest, | 1041 FileManagerBrowserTest, |
1037 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, | 1042 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, |
1038 "openFileDialogOnDownloads"), | 1043 "openFileDialogOnDownloads"), |
1039 TestParameter(IN_GUEST_MODE, | 1044 TestParameter(IN_GUEST_MODE, |
1040 "openFileDialogOnDownloads"), | 1045 "openFileDialogOnDownloads"), |
1041 TestParameter(NOT_IN_GUEST_MODE, | 1046 TestParameter(NOT_IN_GUEST_MODE, |
| 1047 "openFileDialogOnDrive"), |
| 1048 TestParameter(IN_INCOGNITO, |
| 1049 "openFileDialogOnDownloads"), |
| 1050 TestParameter(IN_INCOGNITO, |
1042 "openFileDialogOnDrive"))); | 1051 "openFileDialogOnDrive"))); |
1043 | 1052 |
1044 // Slow tests are disabled on debug build. http://crbug.com/327719 | 1053 // Slow tests are disabled on debug build. http://crbug.com/327719 |
1045 #if !defined(NDEBUG) | 1054 #if !defined(NDEBUG) |
1046 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows | 1055 #define MAYBE_CopyBetweenWindows DISABLED_CopyBetweenWindows |
1047 #else | 1056 #else |
1048 #define MAYBE_CopyBetweenWindows CopyBetweenWindows | 1057 #define MAYBE_CopyBetweenWindows CopyBetweenWindows |
1049 #endif | 1058 #endif |
1050 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1059 WRAPPED_INSTANTIATE_TEST_CASE_P( |
1051 MAYBE_CopyBetweenWindows, | 1060 MAYBE_CopyBetweenWindows, |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 } | 1445 } |
1437 | 1446 |
1438 IN_PROC_BROWSER_TEST_F(GalleryBrowserTest, CropImageOnDrive) { | 1447 IN_PROC_BROWSER_TEST_F(GalleryBrowserTest, CropImageOnDrive) { |
1439 AddScript("gallery/photo_editor.js"); | 1448 AddScript("gallery/photo_editor.js"); |
1440 set_test_case_name("cropImageOnDrive"); | 1449 set_test_case_name("cropImageOnDrive"); |
1441 StartTest(); | 1450 StartTest(); |
1442 } | 1451 } |
1443 | 1452 |
1444 } // namespace | 1453 } // namespace |
1445 } // namespace file_manager | 1454 } // namespace file_manager |
OLD | NEW |