| 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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 // The base test class. | 539 // The base test class. |
| 540 class FileManagerBrowserTestBase : public ExtensionApiTest { | 540 class FileManagerBrowserTestBase : public ExtensionApiTest { |
| 541 protected: | 541 protected: |
| 542 void SetUpInProcessBrowserTestFixture() override; | 542 void SetUpInProcessBrowserTestFixture() override; |
| 543 | 543 |
| 544 void SetUpOnMainThread() override; | 544 void SetUpOnMainThread() override; |
| 545 | 545 |
| 546 // Adds an incognito and guest-mode flags for tests in the guest mode. | 546 // Adds an incognito and guest-mode flags for tests in the guest mode. |
| 547 void SetUpCommandLine(base::CommandLine* command_line) override; | 547 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 548 | 548 |
| 549 // Installs an extension at the specified |path| using the |manifest_name| |
| 550 // manifest. |
| 551 void InstallExtension(const base::FilePath& path, const char* manifest_name); |
| 549 // Loads our testing extension and sends it a string identifying the current | 552 // Loads our testing extension and sends it a string identifying the current |
| 550 // test. | 553 // test. |
| 551 virtual void StartTest(); | 554 virtual void StartTest(); |
| 552 void RunTestMessageLoop(); | 555 void RunTestMessageLoop(); |
| 553 | 556 |
| 554 // Overriding point for test configurations. | 557 // Overriding point for test configurations. |
| 555 virtual const char* GetTestManifestName() const { | 558 virtual const char* GetTestManifestName() const { |
| 556 return "file_manager_test_manifest.json"; | 559 return "file_manager_test_manifest.json"; |
| 557 } | 560 } |
| 558 virtual GuestMode GetGuestModeParam() const = 0; | 561 virtual GuestMode GetGuestModeParam() const = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 617 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 615 command_line->AppendSwitchNative(chromeos::switches::kLoginUser, ""); | 618 command_line->AppendSwitchNative(chromeos::switches::kLoginUser, ""); |
| 616 command_line->AppendSwitch(switches::kIncognito); | 619 command_line->AppendSwitch(switches::kIncognito); |
| 617 } | 620 } |
| 618 if (GetGuestModeParam() == IN_INCOGNITO) { | 621 if (GetGuestModeParam() == IN_INCOGNITO) { |
| 619 command_line->AppendSwitch(switches::kIncognito); | 622 command_line->AppendSwitch(switches::kIncognito); |
| 620 } | 623 } |
| 621 ExtensionApiTest::SetUpCommandLine(command_line); | 624 ExtensionApiTest::SetUpCommandLine(command_line); |
| 622 } | 625 } |
| 623 | 626 |
| 624 void FileManagerBrowserTestBase::StartTest() { | 627 void FileManagerBrowserTestBase::InstallExtension(const base::FilePath& path, |
| 628 const char* manifest_name) { |
| 625 base::FilePath root_path; | 629 base::FilePath root_path; |
| 626 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &root_path)); | 630 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &root_path)); |
| 627 | 631 |
| 628 // Launch the extension. | 632 // Launch the extension. |
| 629 const base::FilePath path = | 633 const base::FilePath absolute_path = root_path.Append(path); |
| 630 root_path.Append(FILE_PATH_LITERAL("ui/file_manager/integration_tests")); | |
| 631 const extensions::Extension* const extension = | 634 const extensions::Extension* const extension = |
| 632 LoadExtensionAsComponentWithManifest(path, GetTestManifestName()); | 635 LoadExtensionAsComponentWithManifest(absolute_path, manifest_name); |
| 633 ASSERT_TRUE(extension); | 636 ASSERT_TRUE(extension); |
| 637 } |
| 634 | 638 |
| 639 void FileManagerBrowserTestBase::StartTest() { |
| 640 InstallExtension( |
| 641 base::FilePath(FILE_PATH_LITERAL("ui/file_manager/integration_tests")), |
| 642 GetTestManifestName()); |
| 635 RunTestMessageLoop(); | 643 RunTestMessageLoop(); |
| 636 } | 644 } |
| 637 | 645 |
| 638 void FileManagerBrowserTestBase::RunTestMessageLoop() { | 646 void FileManagerBrowserTestBase::RunTestMessageLoop() { |
| 639 // Handle the messages from JavaScript. | 647 // Handle the messages from JavaScript. |
| 640 // The while loop is break when the test is passed or failed. | 648 // The while loop is break when the test is passed or failed. |
| 641 FileManagerTestListener listener; | 649 FileManagerTestListener listener; |
| 642 while (true) { | 650 while (true) { |
| 643 FileManagerTestListener::Message entry = listener.GetNextMessage(); | 651 FileManagerTestListener::Message entry = listener.GetNextMessage(); |
| 644 if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_PASSED) { | 652 if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_PASSED) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 786 |
| 779 const std::string delegate_id = extension_id + "-" + notification_id; | 787 const std::string delegate_id = extension_id + "-" + notification_id; |
| 780 const Notification* notification = g_browser_process-> | 788 const Notification* notification = g_browser_process-> |
| 781 notification_ui_manager()->FindById(delegate_id, profile()); | 789 notification_ui_manager()->FindById(delegate_id, profile()); |
| 782 ASSERT_TRUE(notification); | 790 ASSERT_TRUE(notification); |
| 783 | 791 |
| 784 notification->delegate()->ButtonClick(index); | 792 notification->delegate()->ButtonClick(index); |
| 785 return; | 793 return; |
| 786 } | 794 } |
| 787 | 795 |
| 796 if (name == "installProviderExtension") { |
| 797 InstallExtension(base::FilePath(FILE_PATH_LITERAL( |
| 798 "ui/file_manager/integration_tests/testing_provider")), |
| 799 "manifest.json"); |
| 800 return; |
| 801 } |
| 802 |
| 788 FAIL() << "Unknown test message: " << name; | 803 FAIL() << "Unknown test message: " << name; |
| 789 } | 804 } |
| 790 | 805 |
| 791 drive::DriveIntegrationService* | 806 drive::DriveIntegrationService* |
| 792 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { | 807 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { |
| 793 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume()); | 808 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume()); |
| 794 return drive_volumes_[profile->GetOriginalProfile()]-> | 809 return drive_volumes_[profile->GetOriginalProfile()]-> |
| 795 CreateDriveIntegrationService(profile); | 810 CreateDriveIntegrationService(profile); |
| 796 } | 811 } |
| 797 | 812 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 #else | 1217 #else |
| 1203 #define MAYBE_ShowGridView ShowGridView | 1218 #define MAYBE_ShowGridView ShowGridView |
| 1204 #endif | 1219 #endif |
| 1205 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1220 WRAPPED_INSTANTIATE_TEST_CASE_P( |
| 1206 MAYBE_ShowGridView, | 1221 MAYBE_ShowGridView, |
| 1207 FileManagerBrowserTest, | 1222 FileManagerBrowserTest, |
| 1208 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "showGridViewDownloads"), | 1223 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "showGridViewDownloads"), |
| 1209 TestParameter(IN_GUEST_MODE, "showGridViewDownloads"), | 1224 TestParameter(IN_GUEST_MODE, "showGridViewDownloads"), |
| 1210 TestParameter(NOT_IN_GUEST_MODE, "showGridViewDrive"))); | 1225 TestParameter(NOT_IN_GUEST_MODE, "showGridViewDrive"))); |
| 1211 | 1226 |
| 1227 WRAPPED_INSTANTIATE_TEST_CASE_P( |
| 1228 Providers, |
| 1229 FileManagerBrowserTest, |
| 1230 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "requestMount"))); |
| 1231 |
| 1212 // Structure to describe an account info. | 1232 // Structure to describe an account info. |
| 1213 struct TestAccountInfo { | 1233 struct TestAccountInfo { |
| 1214 const char* const gaia_id; | 1234 const char* const gaia_id; |
| 1215 const char* const email; | 1235 const char* const email; |
| 1216 const char* const hash; | 1236 const char* const hash; |
| 1217 const char* const display_name; | 1237 const char* const display_name; |
| 1218 }; | 1238 }; |
| 1219 | 1239 |
| 1220 enum { | 1240 enum { |
| 1221 DUMMY_ACCOUNT_INDEX = 0, | 1241 DUMMY_ACCOUNT_INDEX = 0, |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 StartTest(); | 1566 StartTest(); |
| 1547 } | 1567 } |
| 1548 | 1568 |
| 1549 IN_PROC_BROWSER_TEST_F(VideoPlayerBrowserTest, OpenSingleVideoOnDrive) { | 1569 IN_PROC_BROWSER_TEST_F(VideoPlayerBrowserTest, OpenSingleVideoOnDrive) { |
| 1550 set_test_case_name("openSingleVideoOnDrive"); | 1570 set_test_case_name("openSingleVideoOnDrive"); |
| 1551 StartTest(); | 1571 StartTest(); |
| 1552 } | 1572 } |
| 1553 | 1573 |
| 1554 } // namespace | 1574 } // namespace |
| 1555 } // namespace file_manager | 1575 } // namespace file_manager |
| OLD | NEW |