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

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: 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
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 sharedWithMe,
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, "text/plain", length, false,
mtomasz 2013/04/18 09:46:03 Add a comment what is this false or use enum.
Haruki Sato 2013/04/18 11:33:44 Done.
514 modification_time);
513 } 515 }
514 516
515 void FileManagerBrowserDriveTest::CreateTestFileWithMimeType( 517 void FileManagerBrowserDriveTest::CreateTestFileWithMimeType(
516 const std::string& name, 518 const std::string& name,
517 const std::string& mime_type, 519 const std::string& mime_type,
518 int64 length, 520 int64 length,
521 bool sharedWithMe,
mtomasz 2013/04/18 09:46:03 sharedWithMe -> shared_with_me here and in other p
Haruki Sato 2013/04/18 11:33:44 Done.
519 const std::string& modification_time) { 522 const std::string& modification_time) {
520 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 523 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
521 scoped_ptr<google_apis::ResourceEntry> resource_entry; 524 scoped_ptr<google_apis::ResourceEntry> resource_entry;
522 fake_drive_service_->AddNewFile( 525 fake_drive_service_->AddNewFile(
523 mime_type, 526 mime_type,
524 length, 527 length,
525 fake_drive_service_->GetRootResourceId(), 528 fake_drive_service_->GetRootResourceId(),
526 name, 529 name,
530 sharedWithMe,
527 google_apis::test_util::CreateCopyResultCallback(&error, 531 google_apis::test_util::CreateCopyResultCallback(&error,
528 &resource_entry)); 532 &resource_entry));
529 MessageLoop::current()->RunUntilIdle(); 533 MessageLoop::current()->RunUntilIdle();
530 ASSERT_EQ(google_apis::HTTP_CREATED, error); 534 ASSERT_EQ(google_apis::HTTP_CREATED, error);
531 ASSERT_TRUE(resource_entry); 535 ASSERT_TRUE(resource_entry);
532 536
533 base::Time time; 537 base::Time time;
534 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); 538 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time));
535 fake_drive_service_->SetLastModifiedTime( 539 fake_drive_service_->SetLastModifiedTime(
536 resource_entry->resource_id(), 540 resource_entry->resource_id(),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 "chromeos/gdata/empty_feed.json"); 668 "chromeos/gdata/empty_feed.json");
665 fake_drive_service_->LoadAccountMetadataForWapi( 669 fake_drive_service_->LoadAccountMetadataForWapi(
666 "chromeos/gdata/account_metadata.json"); 670 "chromeos/gdata/account_metadata.json");
667 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); 671 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json");
668 672
669 // Create test files and directories inside the fake drive service. 673 // Create test files and directories inside the fake drive service.
670 CreateTestFilesAndDirectories(); 674 CreateTestFilesAndDirectories();
671 675
672 // For testing Drive, create more entries with Drive specific attributes. 676 // For testing Drive, create more entries with Drive specific attributes.
673 // TODO(haruki): Add a case for an entry cached by DriveCache. 677 // 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", 678 CreateTestFileWithMimeType("Test Document",
676 "application/vnd.google-apps.document", 679 "application/vnd.google-apps.document",
677 0, 680 0,
681 false,
678 "10 Apr 2013 16:20:00"); 682 "10 Apr 2013 16:20:00");
683 CreateTestFileWithMimeType("Test Shared Document",
684 "application/vnd.google-apps.document",
685 0,
686 true,
687 "20 Mar 2013 22:40:00");
679 688
680 system_service_ = new drive::DriveSystemService(profile, 689 system_service_ = new drive::DriveSystemService(profile,
681 fake_drive_service_, 690 fake_drive_service_,
682 test_cache_root_.path(), 691 test_cache_root_.path(),
683 NULL); 692 NULL);
684 system_service_->file_system()->AddObserver(this); 693 system_service_->file_system()->AddObserver(this);
685 694
686 return system_service_; 695 return system_service_;
687 } 696 }
688 697
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 732 }
724 733
725 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) { 734 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) {
726 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); 735 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
727 736
728 ResultCatcher catcher; 737 ResultCatcher catcher;
729 StartTest("openSidebarRecent"); 738 StartTest("openSidebarRecent");
730 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 739 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
731 } 740 }
732 741
742 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenOffline) {
743 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
744
745 ResultCatcher catcher;
746 StartTest("openSidebarOffline");
747 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
748 }
749
750 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenSharedWithMe) {
751 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
752
753 ResultCatcher catcher;
754 StartTest("openSidebarSharedWithMe");
755 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
756 }
757
733 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) { 758 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) {
734 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); 759 drive_test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
735 760
736 ResultCatcher catcher; 761 ResultCatcher catcher;
737 StartTest("autocomplete"); 762 StartTest("autocomplete");
738 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 763 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
739 } 764 }
740 765
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 766 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service.h » ('j') | chrome/browser/google_apis/fake_drive_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698