Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_manager_browsertest.cc

Issue 13896006: filemanager: Add a browsertest for the sidebar item "Shared with Me". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a merge failure and restore a test case. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 virtual bool WaitUntilFilePresentWithSize(const base::FilePath& file_path, 462 virtual bool WaitUntilFilePresentWithSize(const base::FilePath& file_path,
463 int64 file_size) OVERRIDE; 463 int64 file_size) OVERRIDE;
464 virtual bool WaitUntilFileNotPresent(const base::FilePath& file_path) 464 virtual bool WaitUntilFileNotPresent(const base::FilePath& file_path)
465 OVERRIDE; 465 OVERRIDE;
466 466
467 // Creates a test file with the given spec. This is a utility for 467 // Creates a test file with the given spec. This is a utility for
468 // CreateTestFile() as well. 468 // CreateTestFile() as well.
469 virtual void CreateTestFileWithMimeType(const std::string& name, 469 virtual void CreateTestFileWithMimeType(const std::string& name,
470 const std::string& mime_type, 470 const std::string& mime_type,
471 int64 length, 471 int64 length,
472 bool shared_with_me,
472 const std::string& modification_time); 473 const std::string& modification_time);
473 474
474 // Waits until a notification for a directory change is received. 475 // Waits until a notification for a directory change is received.
475 void WaitUntilDirectoryChanged(); 476 void WaitUntilDirectoryChanged();
476 477
477 // Returns true if a file is not present at |file_path|. 478 // Returns true if a file is not present at |file_path|.
478 bool FileIsNotPresent(const base::FilePath& file_path); 479 bool FileIsNotPresent(const base::FilePath& file_path);
479 480
480 // Returns true if a file of the size |file_size| is present at |file_path|. 481 // Returns true if a file of the size |file_size| is present at |file_path|.
481 bool FileIsPresentWithSize(const base::FilePath& file_path, 482 bool FileIsPresentWithSize(const base::FilePath& file_path,
(...skipping 20 matching lines...) Expand all
502 503
503 // Don't test Drive in the guest mode as it's not supported. 504 // Don't test Drive in the guest mode as it's not supported.
504 INSTANTIATE_TEST_CASE_P(InNonGuestMode, 505 INSTANTIATE_TEST_CASE_P(InNonGuestMode,
505 FileManagerBrowserDriveTest, 506 FileManagerBrowserDriveTest,
506 ::testing::Values(false)); 507 ::testing::Values(false));
507 508
508 void FileManagerBrowserDriveTest::CreateTestFile( 509 void FileManagerBrowserDriveTest::CreateTestFile(
509 const std::string& name, 510 const std::string& name,
510 int64 length, 511 int64 length,
511 const std::string& modification_time) { 512 const std::string& modification_time) {
512 CreateTestFileWithMimeType(name, "text/plain", length, modification_time); 513 CreateTestFileWithMimeType(name,
514 "text/plain",
515 length,
516 false, // shared_with_me
517 modification_time);
513 } 518 }
514 519
515 void FileManagerBrowserDriveTest::CreateTestFileWithMimeType( 520 void FileManagerBrowserDriveTest::CreateTestFileWithMimeType(
516 const std::string& name, 521 const std::string& name,
517 const std::string& mime_type, 522 const std::string& mime_type,
518 int64 length, 523 int64 length,
524 bool shared_with_me,
519 const std::string& modification_time) { 525 const std::string& modification_time) {
520 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 526 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
521 scoped_ptr<google_apis::ResourceEntry> resource_entry; 527 scoped_ptr<google_apis::ResourceEntry> resource_entry;
522 fake_drive_service_->AddNewFile( 528 fake_drive_service_->AddNewFile(
523 mime_type, 529 mime_type,
524 length, 530 length,
525 fake_drive_service_->GetRootResourceId(), 531 fake_drive_service_->GetRootResourceId(),
526 name, 532 name,
533 shared_with_me,
527 google_apis::test_util::CreateCopyResultCallback(&error, 534 google_apis::test_util::CreateCopyResultCallback(&error,
528 &resource_entry)); 535 &resource_entry));
529 MessageLoop::current()->RunUntilIdle(); 536 MessageLoop::current()->RunUntilIdle();
530 ASSERT_EQ(google_apis::HTTP_CREATED, error); 537 ASSERT_EQ(google_apis::HTTP_CREATED, error);
531 ASSERT_TRUE(resource_entry); 538 ASSERT_TRUE(resource_entry);
532 539
533 base::Time time; 540 base::Time time;
534 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); 541 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time));
535 fake_drive_service_->SetLastModifiedTime( 542 fake_drive_service_->SetLastModifiedTime(
536 resource_entry->resource_id(), 543 resource_entry->resource_id(),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 "chromeos/gdata/empty_feed.json"); 671 "chromeos/gdata/empty_feed.json");
665 fake_drive_service_->LoadAccountMetadataForWapi( 672 fake_drive_service_->LoadAccountMetadataForWapi(
666 "chromeos/gdata/account_metadata.json"); 673 "chromeos/gdata/account_metadata.json");
667 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); 674 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json");
668 675
669 // Create test files and directories inside the fake drive service. 676 // Create test files and directories inside the fake drive service.
670 CreateTestFilesAndDirectories(); 677 CreateTestFilesAndDirectories();
671 678
672 // For testing Drive, create more entries with Drive specific attributes. 679 // For testing Drive, create more entries with Drive specific attributes.
673 // TODO(haruki): Add a case for an entry cached by DriveCache. 680 // TODO(haruki): Add a case for an entry cached by DriveCache.
674 // TODO(haruki): Add a case for a shared-with-me entry.
675 CreateTestFileWithMimeType("Test Document", 681 CreateTestFileWithMimeType("Test Document",
676 "application/vnd.google-apps.document", 682 "application/vnd.google-apps.document",
677 0, 683 0,
684 false, // shared_with_me
678 "10 Apr 2013 16:20:00"); 685 "10 Apr 2013 16:20:00");
686 CreateTestFileWithMimeType("Test Shared Document",
687 "application/vnd.google-apps.document",
688 0,
689 true, // shared_with_me
690 "20 Mar 2013 22:40:00");
679 691
680 system_service_ = new drive::DriveSystemService(profile, 692 system_service_ = new drive::DriveSystemService(profile,
681 fake_drive_service_, 693 fake_drive_service_,
682 test_cache_root_.path(), 694 test_cache_root_.path(),
683 NULL); 695 NULL);
684 system_service_->file_system()->AddObserver(this); 696 system_service_->file_system()->AddObserver(this);
685 697
686 return system_service_; 698 return system_service_;
687 } 699 }
688 700
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 735 }
724 736
725 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) { 737 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) {
726 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); 738 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
727 739
728 ResultCatcher catcher; 740 ResultCatcher catcher;
729 StartTest("openSidebarRecent"); 741 StartTest("openSidebarRecent");
730 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 742 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
731 } 743 }
732 744
745 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenOffline) {
746 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
747
748 ResultCatcher catcher;
749 StartTest("openSidebarOffline");
750 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
751 }
752
753 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenSharedWithMe) {
754 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
755
756 ResultCatcher catcher;
757 StartTest("openSidebarSharedWithMe");
758 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
759 }
760
733 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) { 761 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) {
734 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); 762 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
735 763
736 ResultCatcher catcher; 764 ResultCatcher catcher;
737 StartTest("autocomplete"); 765 StartTest("autocomplete");
738 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 766 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
739 } 767 }
740 768
741 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenOffline) {
742 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
743
744 ResultCatcher catcher;
745 StartTest("openSidebarOffline");
746 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
747 }
748
749 } // namespace 769 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698