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 |
11 #include <deque> | 11 #include <deque> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "apps/app_window.h" | 14 #include "apps/app_window.h" |
15 #include "apps/app_window_registry.h" | 15 #include "apps/app_window_registry.h" |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
19 #include "base/json/json_reader.h" | 19 #include "base/json/json_reader.h" |
20 #include "base/json/json_value_converter.h" | 20 #include "base/json/json_value_converter.h" |
21 #include "base/json/json_writer.h" | 21 #include "base/json/json_writer.h" |
22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
23 #include "base/strings/string_piece.h" | 23 #include "base/strings/string_piece.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "chrome/browser/chrome_notification_types.h" | |
27 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 26 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
28 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 27 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
29 #include "chrome/browser/chromeos/file_manager/app_id.h" | 28 #include "chrome/browser/chromeos/file_manager/app_id.h" |
30 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" | 29 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" |
31 #include "chrome/browser/chromeos/file_manager/path_util.h" | 30 #include "chrome/browser/chromeos/file_manager/path_util.h" |
32 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 31 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
33 #include "chrome/browser/chromeos/login/users/user_manager.h" | 32 #include "chrome/browser/chromeos/login/users/user_manager.h" |
34 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 33 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
35 #include "chrome/browser/drive/fake_drive_service.h" | 34 #include "chrome/browser/drive/fake_drive_service.h" |
36 #include "chrome/browser/extensions/component_loader.h" | 35 #include "chrome/browser/extensions/component_loader.h" |
37 #include "chrome/browser/extensions/extension_apitest.h" | 36 #include "chrome/browser/extensions/extension_apitest.h" |
38 #include "chrome/browser/extensions/extension_test_message_listener.h" | 37 #include "chrome/browser/extensions/extension_test_message_listener.h" |
39 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
40 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 39 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
41 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 40 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
42 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
43 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
44 #include "chromeos/chromeos_switches.h" | 43 #include "chromeos/chromeos_switches.h" |
45 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
46 #include "content/public/test/test_utils.h" | 45 #include "content/public/test/test_utils.h" |
47 #include "extensions/browser/api/test/test_api.h" | 46 #include "extensions/browser/api/test/test_api.h" |
| 47 #include "extensions/browser/notification_types.h" |
48 #include "extensions/common/extension.h" | 48 #include "extensions/common/extension.h" |
49 #include "google_apis/drive/drive_api_parser.h" | 49 #include "google_apis/drive/drive_api_parser.h" |
50 #include "google_apis/drive/test_util.h" | 50 #include "google_apis/drive/test_util.h" |
51 #include "net/test/embedded_test_server/embedded_test_server.h" | 51 #include "net/test/embedded_test_server/embedded_test_server.h" |
52 #include "webkit/browser/fileapi/external_mount_points.h" | 52 #include "webkit/browser/fileapi/external_mount_points.h" |
53 | 53 |
54 using drive::DriveIntegrationServiceFactory; | 54 using drive::DriveIntegrationServiceFactory; |
55 | 55 |
56 namespace file_manager { | 56 namespace file_manager { |
57 namespace { | 57 namespace { |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 class FileManagerTestListener : public content::NotificationObserver { | 478 class FileManagerTestListener : public content::NotificationObserver { |
479 public: | 479 public: |
480 struct Message { | 480 struct Message { |
481 int type; | 481 int type; |
482 std::string message; | 482 std::string message; |
483 scoped_refptr<extensions::TestSendMessageFunction> function; | 483 scoped_refptr<extensions::TestSendMessageFunction> function; |
484 }; | 484 }; |
485 | 485 |
486 FileManagerTestListener() { | 486 FileManagerTestListener() { |
487 registrar_.Add(this, | 487 registrar_.Add(this, |
488 chrome::NOTIFICATION_EXTENSION_TEST_PASSED, | 488 extensions::NOTIFICATION_EXTENSION_TEST_PASSED, |
489 content::NotificationService::AllSources()); | 489 content::NotificationService::AllSources()); |
490 registrar_.Add(this, | 490 registrar_.Add(this, |
491 chrome::NOTIFICATION_EXTENSION_TEST_FAILED, | 491 extensions::NOTIFICATION_EXTENSION_TEST_FAILED, |
492 content::NotificationService::AllSources()); | 492 content::NotificationService::AllSources()); |
493 registrar_.Add(this, | 493 registrar_.Add(this, |
494 chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 494 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
495 content::NotificationService::AllSources()); | 495 content::NotificationService::AllSources()); |
496 } | 496 } |
497 | 497 |
498 Message GetNextMessage() { | 498 Message GetNextMessage() { |
499 if (messages_.empty()) | 499 if (messages_.empty()) |
500 content::RunMessageLoop(); | 500 content::RunMessageLoop(); |
501 const Message entry = messages_.front(); | 501 const Message entry = messages_.front(); |
502 messages_.pop_front(); | 502 messages_.pop_front(); |
503 return entry; | 503 return entry; |
504 } | 504 } |
505 | 505 |
506 virtual void Observe(int type, | 506 virtual void Observe(int type, |
507 const content::NotificationSource& source, | 507 const content::NotificationSource& source, |
508 const content::NotificationDetails& details) OVERRIDE { | 508 const content::NotificationDetails& details) OVERRIDE { |
509 Message entry; | 509 Message entry; |
510 entry.type = type; | 510 entry.type = type; |
511 entry.message = type != chrome::NOTIFICATION_EXTENSION_TEST_PASSED ? | 511 entry.message = type != extensions::NOTIFICATION_EXTENSION_TEST_PASSED |
512 *content::Details<std::string>(details).ptr() : | 512 ? *content::Details<std::string>(details).ptr() |
513 std::string(); | 513 : std::string(); |
514 entry.function = type == chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE ? | 514 entry.function = |
515 content::Source<extensions::TestSendMessageFunction>(source).ptr() : | 515 type == extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE |
516 NULL; | 516 ? content::Source<extensions::TestSendMessageFunction>(source).ptr() |
| 517 : NULL; |
517 messages_.push_back(entry); | 518 messages_.push_back(entry); |
518 base::MessageLoopForUI::current()->Quit(); | 519 base::MessageLoopForUI::current()->Quit(); |
519 } | 520 } |
520 | 521 |
521 private: | 522 private: |
522 std::deque<Message> messages_; | 523 std::deque<Message> messages_; |
523 content::NotificationRegistrar registrar_; | 524 content::NotificationRegistrar registrar_; |
524 }; | 525 }; |
525 | 526 |
526 // The base test class. | 527 // The base test class. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 615 |
615 RunTestMessageLoop(); | 616 RunTestMessageLoop(); |
616 } | 617 } |
617 | 618 |
618 void FileManagerBrowserTestBase::RunTestMessageLoop() { | 619 void FileManagerBrowserTestBase::RunTestMessageLoop() { |
619 // Handle the messages from JavaScript. | 620 // Handle the messages from JavaScript. |
620 // The while loop is break when the test is passed or failed. | 621 // The while loop is break when the test is passed or failed. |
621 FileManagerTestListener listener; | 622 FileManagerTestListener listener; |
622 while (true) { | 623 while (true) { |
623 FileManagerTestListener::Message entry = listener.GetNextMessage(); | 624 FileManagerTestListener::Message entry = listener.GetNextMessage(); |
624 if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_PASSED) { | 625 if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_PASSED) { |
625 // Test succeed. | 626 // Test succeed. |
626 break; | 627 break; |
627 } else if (entry.type == chrome::NOTIFICATION_EXTENSION_TEST_FAILED) { | 628 } else if (entry.type == extensions::NOTIFICATION_EXTENSION_TEST_FAILED) { |
628 // Test failed. | 629 // Test failed. |
629 ADD_FAILURE() << entry.message; | 630 ADD_FAILURE() << entry.message; |
630 break; | 631 break; |
631 } | 632 } |
632 | 633 |
633 // Parse the message value as JSON. | 634 // Parse the message value as JSON. |
634 const scoped_ptr<const base::Value> value( | 635 const scoped_ptr<const base::Value> value( |
635 base::JSONReader::Read(entry.message)); | 636 base::JSONReader::Read(entry.message)); |
636 | 637 |
637 // If the message is not the expected format, just ignore it. | 638 // If the message is not the expected format, just ignore it. |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 } | 1464 } |
1464 | 1465 |
1465 IN_PROC_BROWSER_TEST_F(GalleryBrowserTest, ExposureImageOnDrive) { | 1466 IN_PROC_BROWSER_TEST_F(GalleryBrowserTest, ExposureImageOnDrive) { |
1466 AddScript("gallery/photo_editor.js"); | 1467 AddScript("gallery/photo_editor.js"); |
1467 set_test_case_name("exposureImageOnDrive"); | 1468 set_test_case_name("exposureImageOnDrive"); |
1468 StartTest(); | 1469 StartTest(); |
1469 } | 1470 } |
1470 | 1471 |
1471 } // namespace | 1472 } // namespace |
1472 } // namespace file_manager | 1473 } // namespace file_manager |
OLD | NEW |