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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 protected: | 517 protected: |
518 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 518 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
519 | 519 |
520 virtual void SetUpOnMainThread() OVERRIDE; | 520 virtual void SetUpOnMainThread() OVERRIDE; |
521 | 521 |
522 // Adds an incognito and guest-mode flags for tests in the guest mode. | 522 // Adds an incognito and guest-mode flags for tests in the guest mode. |
523 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 523 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
524 | 524 |
525 // Loads our testing extension and sends it a string identifying the current | 525 // Loads our testing extension and sends it a string identifying the current |
526 // test. | 526 // test. |
527 void StartTest(); | 527 virtual void StartTest(); |
528 void RunTestMessageLoop(); | |
528 | 529 |
529 // Overriding point for test configurations. | 530 // Overriding point for test configurations. |
531 virtual const char* GetTestManifestName() const { | |
532 return "file_manager_manifest.json"; | |
yoshiki
2014/06/02 21:30:16
nit: I think manifest.json should be under file_ma
hirono
2014/06/03 01:48:41
I renamed the files.
| |
533 } | |
530 virtual GuestMode GetGuestModeParam() const = 0; | 534 virtual GuestMode GetGuestModeParam() const = 0; |
531 virtual const char* GetTestCaseNameParam() const = 0; | 535 virtual const char* GetTestCaseNameParam() const = 0; |
532 virtual std::string OnMessage(const std::string& name, | 536 virtual std::string OnMessage(const std::string& name, |
533 const base::Value* value); | 537 const base::Value* value); |
534 | 538 |
535 scoped_ptr<LocalTestVolume> local_volume_; | 539 scoped_ptr<LocalTestVolume> local_volume_; |
536 linked_ptr<DriveTestVolume> drive_volume_; | 540 linked_ptr<DriveTestVolume> drive_volume_; |
537 std::map<Profile*, linked_ptr<DriveTestVolume> > drive_volumes_; | 541 std::map<Profile*, linked_ptr<DriveTestVolume> > drive_volumes_; |
538 scoped_ptr<LocalTestVolume> usb_volume_; | 542 scoped_ptr<LocalTestVolume> usb_volume_; |
539 | 543 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 585 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
582 command_line->AppendSwitchNative(chromeos::switches::kLoginUser, ""); | 586 command_line->AppendSwitchNative(chromeos::switches::kLoginUser, ""); |
583 command_line->AppendSwitch(switches::kIncognito); | 587 command_line->AppendSwitch(switches::kIncognito); |
584 } | 588 } |
585 ExtensionApiTest::SetUpCommandLine(command_line); | 589 ExtensionApiTest::SetUpCommandLine(command_line); |
586 } | 590 } |
587 | 591 |
588 void FileManagerBrowserTestBase::StartTest() { | 592 void FileManagerBrowserTestBase::StartTest() { |
589 // Launch the extension. | 593 // Launch the extension. |
590 base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest"); | 594 base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest"); |
591 const extensions::Extension* extension = LoadExtensionAsComponent(path); | 595 const extensions::Extension* extension = LoadExtensionAsComponentWithManifest( |
596 path, GetTestManifestName()); | |
592 ASSERT_TRUE(extension); | 597 ASSERT_TRUE(extension); |
593 | 598 |
599 RunTestMessageLoop(); | |
600 } | |
601 | |
602 void FileManagerBrowserTestBase::RunTestMessageLoop() { | |
594 // Handle the messages from JavaScript. | 603 // Handle the messages from JavaScript. |
595 // The while loop is break when the test is passed or failed. | 604 // The while loop is break when the test is passed or failed. |
596 FileManagerTestListener listener; | 605 FileManagerTestListener listener; |
597 while (true) { | 606 while (true) { |
598 FileManagerTestListener::Message entry = listener.GetNextMessage(); | 607 FileManagerTestListener::Message entry = listener.GetNextMessage(); |
599 if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_PASSED) { | 608 if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_PASSED) { |
600 // Test succeed. | 609 // Test succeed. |
601 break; | 610 break; |
602 } else if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_FAILED) { | 611 } else if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_FAILED) { |
603 // Test failed. | 612 // Test failed. |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 // in and checks that nothing goes wrong. Here, the primary user (alice) logs | 1070 // in and checks that nothing goes wrong. Here, the primary user (alice) logs |
1062 // in first, then the "extra" users follow, and then lastly the other users | 1071 // in first, then the "extra" users follow, and then lastly the other users |
1063 // (bob and charlie) are added in the test. Thus the existing test verifies | 1072 // (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. | 1073 // that the feature is effectively working with lastly logged in users. |
1065 AddExtraUsersForStressTesting(); | 1074 AddExtraUsersForStressTesting(); |
1066 | 1075 |
1067 set_test_case_name("multiProfileVisitDesktopMenu"); | 1076 set_test_case_name("multiProfileVisitDesktopMenu"); |
1068 StartTest(); | 1077 StartTest(); |
1069 } | 1078 } |
1070 | 1079 |
1080 template<GuestMode M> | |
1081 class GalleryBrowserTestBase : public FileManagerBrowserTestBase { | |
1082 public: | |
1083 virtual GuestMode GetGuestModeParam() const OVERRIDE { return M; } | |
1084 virtual const char* GetTestCaseNameParam() const OVERRIDE { | |
1085 return test_case_name_.c_str(); | |
1086 } | |
1087 | |
1088 protected: | |
1089 virtual std::string OnMessage(const std::string& name, | |
1090 const base::Value* value) OVERRIDE; | |
1091 | |
1092 virtual const char* GetTestManifestName() const OVERRIDE { | |
1093 return "gallery_manifest.json"; | |
yoshiki
2014/06/02 21:30:16
ditto
hirono
2014/06/03 01:48:41
Done.
| |
1094 } | |
1095 | |
1096 void AddScript(const std::string& name) { | |
1097 scripts_.AppendString( | |
1098 "chrome-extension://ejhcmmdhhpdhhgmifplfmjobgegbibkn/" + name); | |
1099 } | |
1100 | |
1101 void set_test_case_name(const std::string& name) { | |
1102 test_case_name_ = name; | |
1103 } | |
1104 | |
1105 private: | |
1106 base::ListValue scripts_; | |
1107 std::string test_case_name_; | |
1108 }; | |
1109 | |
1110 template<GuestMode M> | |
1111 std::string GalleryBrowserTestBase<M>::OnMessage(const std::string& name, | |
1112 const base::Value* value) { | |
1113 if (name == "getScripts") { | |
1114 std::string jsonString; | |
1115 base::JSONWriter::Write(&scripts_, &jsonString); | |
1116 return jsonString; | |
1117 } | |
1118 return FileManagerBrowserTestBase::OnMessage(name, value); | |
1119 } | |
1120 | |
1121 typedef GalleryBrowserTestBase<NOT_IN_GUEST_MODE> GalleryBrowserTest; | |
1122 typedef GalleryBrowserTestBase<IN_GUEST_MODE> GalleryBrowserTestInGuestMode; | |
1123 | |
1124 IN_PROC_BROWSER_TEST_F(GalleryBrowserTest, OpenSingleImageOnDownloads) { | |
1125 AddScript("gallery/open_image_files.js"); | |
1126 set_test_case_name("openSingleImageOnDownloads"); | |
1127 StartTest(); | |
1128 } | |
1129 | |
1130 IN_PROC_BROWSER_TEST_F(GalleryBrowserTestInGuestMode, | |
1131 OpenSingleImageOnDownloads) { | |
1132 AddScript("gallery/open_image_files.js"); | |
1133 set_test_case_name("openSingleImageOnDownloads"); | |
1134 StartTest(); | |
1135 } | |
1136 | |
1137 IN_PROC_BROWSER_TEST_F(GalleryBrowserTest, OpenSingleImageOnDrive) { | |
1138 AddScript("gallery/open_image_files.js"); | |
1139 set_test_case_name("openSingleImageOnDrive"); | |
1140 StartTest(); | |
1141 } | |
1142 | |
1071 } // namespace | 1143 } // namespace |
1072 } // namespace file_manager | 1144 } // namespace file_manager |
OLD | NEW |