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

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

Issue 15771005: Break test cases on inner asserts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 7 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 | no next file » | 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 : path_(path), 128 : path_(path),
129 condition_(condition), 129 condition_(condition),
130 quit_closure_(run_loop_.QuitClosure()), 130 quit_closure_(run_loop_.QuitClosure()),
131 failed_(false) { 131 failed_(false) {
132 } 132 }
133 133
134 void TestFilePathWatcher::StartWatching() { 134 void TestFilePathWatcher::StartWatching() {
135 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 135 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
136 136
137 watcher_.reset(new base::FilePathWatcher); 137 watcher_.reset(new base::FilePathWatcher);
138 bool ok = watcher_->Watch( 138 failed_ = !watcher_->Watch(
139 path_, false /*recursive*/, 139 path_, false /*recursive*/,
140 base::Bind(&TestFilePathWatcher::FilePathWatcherCallback, 140 base::Bind(&TestFilePathWatcher::FilePathWatcherCallback,
141 base::Unretained(this))); 141 base::Unretained(this)));
142 ASSERT_TRUE(ok);
143 142
144 // If the condition was already met before FilePathWatcher was launched, 143 // If failed to start the watcher, then quit the message loop immediately.
144 // Also, if the condition was already met before FilePathWatcher was launched,
145 // FilePathWatcher won't be able to detect a change, so check the condition 145 // FilePathWatcher won't be able to detect a change, so check the condition
146 // here. 146 // here.
147 if (condition_.Run(path_)) { 147 if (failed_ || condition_.Run(path_)) {
148 watcher_.reset(); 148 watcher_.reset();
149 content::BrowserThread::PostTask(content::BrowserThread::UI, 149 content::BrowserThread::PostTask(content::BrowserThread::UI,
150 FROM_HERE, 150 FROM_HERE,
151 quit_closure_); 151 quit_closure_);
152 return; 152 return;
153 } 153 }
154 } 154 }
155 155
156 void TestFilePathWatcher::FilePathWatcherCallback(const base::FilePath& path, 156 void TestFilePathWatcher::FilePathWatcherCallback(const base::FilePath& path,
157 bool failed) { 157 bool failed) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 CreateFile(entry.source_file_name, entry.target_name, 269 CreateFile(entry.source_file_name, entry.target_name,
270 entry.last_modified_time_as_string); 270 entry.last_modified_time_as_string);
271 } else { 271 } else {
272 NOTREACHED(); 272 NOTREACHED();
273 } 273 }
274 } 274 }
275 275
276 void CreateFile(const std::string& source_file_name, 276 void CreateFile(const std::string& source_file_name,
277 const std::string& target_name, 277 const std::string& target_name,
278 const std::string& modification_time) { 278 const std::string& modification_time) {
279
280 std::string content_data; 279 std::string content_data;
281 base::FilePath test_file_path = 280 base::FilePath test_file_path =
282 google_apis::test_util::GetTestFilePath("chromeos/file_manager"). 281 google_apis::test_util::GetTestFilePath("chromeos/file_manager").
283 AppendASCII(source_file_name); 282 AppendASCII(source_file_name);
284 283
285 base::FilePath path = local_path_.AppendASCII(target_name); 284 base::FilePath path = local_path_.AppendASCII(target_name);
286 ASSERT_TRUE(file_util::PathExists(test_file_path)) 285 ASSERT_TRUE(file_util::PathExists(test_file_path))
287 << "Test file doesn't exist: " << test_file_path.value(); 286 << "Test file doesn't exist: " << test_file_path.value();
288 ASSERT_TRUE(file_util::CopyFile(test_file_path, path)); 287 ASSERT_TRUE(file_util::CopyFile(test_file_path, path));
289 ASSERT_TRUE(file_util::PathExists(path)) 288 ASSERT_TRUE(file_util::PathExists(path))
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 625
627 void FileManagerBrowserTestBase::CreateTestEntries( 626 void FileManagerBrowserTestBase::CreateTestEntries(
628 TestVolume* volume, const TestEntryInfo* entries, size_t num_entries) { 627 TestVolume* volume, const TestEntryInfo* entries, size_t num_entries) {
629 for (size_t i = 0; i < num_entries; ++i) { 628 for (size_t i = 0; i < num_entries; ++i) {
630 volume->CreateEntry(entries[i]); 629 volume->CreateEntry(entries[i]);
631 } 630 }
632 } 631 }
633 632
634 void FileManagerBrowserTestBase::DoTestFileDisplay(TestVolume* volume) { 633 void FileManagerBrowserTestBase::DoTestFileDisplay(TestVolume* volume) {
635 ResultCatcher catcher; 634 ResultCatcher catcher;
636 StartTest("fileDisplay" + volume->GetName()); 635 ASSERT_NO_FATAL_FAILURE(StartTest("fileDisplay" + volume->GetName()));
637 636
638 ExtensionTestMessageListener listener("initial check done", true); 637 ExtensionTestMessageListener listener("initial check done", true);
639 ASSERT_TRUE(listener.WaitUntilSatisfied()); 638 ASSERT_TRUE(listener.WaitUntilSatisfied());
640 const TestEntryInfo entry = { 639 const TestEntryInfo entry = {
641 FILE, 640 FILE,
642 "music.ogg", // Prototype file name. 641 "music.ogg", // Prototype file name.
643 "newly added file.ogg", // Target file name. 642 "newly added file.ogg", // Target file name.
644 "audio/ogg", 643 "audio/ogg",
645 NONE, 644 NONE,
646 "4 Sep 1998 00:00:00" 645 "4 Sep 1998 00:00:00"
647 }; 646 };
648 volume->CreateEntry(entry); 647 volume->CreateEntry(entry);
649 listener.Reply("file added"); 648 listener.Reply("file added");
650 649
651 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 650 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
652 } 651 }
653 652
654 void FileManagerBrowserTestBase::DoTestGalleryOpen(TestVolume* volume) { 653 void FileManagerBrowserTestBase::DoTestGalleryOpen(TestVolume* volume) {
655 ResultCatcher catcher; 654 ResultCatcher catcher;
656 StartTest("galleryOpen" + volume->GetName()); 655 StartTest("galleryOpen" + volume->GetName());
657 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 656 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
658 } 657 }
659 658
660 void FileManagerBrowserTestBase::DoTestKeyboardCopy(TestVolume* volume) { 659 void FileManagerBrowserTestBase::DoTestKeyboardCopy(TestVolume* volume) {
661 base::FilePath copy_path = 660 base::FilePath copy_path =
662 volume->GetRootPath().AppendASCII(kKeyboardTestFileCopyName); 661 volume->GetRootPath().AppendASCII(kKeyboardTestFileCopyName);
663 ASSERT_FALSE(volume->PathExists(copy_path)); 662 ASSERT_FALSE(volume->PathExists(copy_path));
664 663
665 ResultCatcher catcher; 664 ResultCatcher catcher;
666 StartTest("keyboardCopy" + volume->GetName()); 665 ASSERT_NO_FATAL_FAILURE(StartTest("keyboardCopy" + volume->GetName()));
667 666
668 const int64 kKeyboardTestFileSize = 59943; 667 const int64 kKeyboardTestFileSize = 59943;
669 668
670 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 669 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
671 ASSERT_TRUE(volume->WaitUntilFilePresentWithSize( 670 ASSERT_TRUE(volume->WaitUntilFilePresentWithSize(
672 copy_path, kKeyboardTestFileSize)); 671 copy_path, kKeyboardTestFileSize));
673 672
674 // Check that it was a copy, not a move. 673 // Check that it was a copy, not a move.
675 base::FilePath source_path = 674 base::FilePath source_path =
676 volume->GetRootPath().AppendASCII(kKeyboardTestFileName); 675 volume->GetRootPath().AppendASCII(kKeyboardTestFileName);
677 ASSERT_TRUE(volume->PathExists(source_path)); 676 ASSERT_TRUE(volume->PathExists(source_path));
678 } 677 }
679 678
680 void FileManagerBrowserTestBase::DoTestKeyboardDelete(TestVolume* volume) { 679 void FileManagerBrowserTestBase::DoTestKeyboardDelete(TestVolume* volume) {
681 base::FilePath delete_path = 680 base::FilePath delete_path =
682 volume->GetRootPath().AppendASCII(kKeyboardTestFileName); 681 volume->GetRootPath().AppendASCII(kKeyboardTestFileName);
683 ASSERT_TRUE(volume->PathExists(delete_path)); 682 ASSERT_TRUE(volume->PathExists(delete_path));
684 683
685 ResultCatcher catcher; 684 ResultCatcher catcher;
686 StartTest("keyboardDelete" + volume->GetName()); 685 ASSERT_NO_FATAL_FAILURE(StartTest("keyboardDelete" + volume->GetName()));
687 686
688 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 687 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
689 ASSERT_TRUE(volume->WaitUntilFileNotPresent(delete_path)); 688 ASSERT_TRUE(volume->WaitUntilFileNotPresent(delete_path));
690 } 689 }
691 690
692 // A class to test local volumes. 691 // A class to test local volumes.
693 class FileManagerBrowserLocalTest : public FileManagerBrowserTestBase { 692 class FileManagerBrowserLocalTest : public FileManagerBrowserTestBase {
694 public: 693 public:
695 FileManagerBrowserLocalTest() : volume_("Downloads") {} 694 FileManagerBrowserLocalTest() : volume_("Downloads") {}
696 695
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 DriveTestVolume drive_volume_; 776 DriveTestVolume drive_volume_;
778 }; 777 };
779 778
780 // FileManagerBrowserTransferTest depends on Drive and Drive is not supported in 779 // FileManagerBrowserTransferTest depends on Drive and Drive is not supported in
781 // the guest mode. 780 // the guest mode.
782 INSTANTIATE_TEST_CASE_P(InNonGuestMode, 781 INSTANTIATE_TEST_CASE_P(InNonGuestMode,
783 FileManagerBrowserTransferTest, 782 FileManagerBrowserTransferTest,
784 ::testing::Values(false)); 783 ::testing::Values(false));
785 784
786 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { 785 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) {
787 PrepareVolume(); 786 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
788 DoTestFileDisplay(&volume_); 787 DoTestFileDisplay(&volume_);
789 } 788 }
790 789
791 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestGalleryOpen) { 790 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestGalleryOpen) {
792 PrepareVolume(); 791 PrepareVolume();
793 DoTestGalleryOpen(&volume_); 792 DoTestGalleryOpen(&volume_);
794 } 793 }
795 794
796 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestGalleryOpen) { 795 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestGalleryOpen) {
797 PrepareVolume(); 796 PrepareVolume();
798 DoTestGalleryOpen(&volume_); 797 DoTestGalleryOpen(&volume_);
799 } 798 }
800 799
801 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardCopy) { 800 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardCopy) {
802 PrepareVolume(); 801 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
803 DoTestKeyboardCopy(&volume_); 802 DoTestKeyboardCopy(&volume_);
804 } 803 }
805 804
806 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardDelete) { 805 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardDelete) {
807 PrepareVolume(); 806 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
808 DoTestKeyboardDelete(&volume_); 807 DoTestKeyboardDelete(&volume_);
809 } 808 }
810 809
811 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) { 810 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) {
812 PrepareVolume(); 811 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
813 ResultCatcher catcher; 812 ResultCatcher catcher;
814 StartTest("openSidebarRecent"); 813 ASSERT_NO_FATAL_FAILURE(StartTest("openSidebarRecent"));
815 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 814 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
816 } 815 }
817 816
818 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 817 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545
819 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, DISABLED_TestOpenOffline) { 818 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, DISABLED_TestOpenOffline) {
820 PrepareVolume(); 819 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
821 ResultCatcher catcher; 820 ResultCatcher catcher;
822 StartTest("openSidebarOffline"); 821 ASSERT_NO_FATAL_FAILURE(StartTest("openSidebarOffline"));
823 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 822 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
824 } 823 }
825 824
826 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenSharedWithMe) { 825 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenSharedWithMe) {
827 PrepareVolume(); 826 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
828 ResultCatcher catcher; 827 ResultCatcher catcher;
829 StartTest("openSidebarSharedWithMe"); 828 ASSERT_NO_FATAL_FAILURE(StartTest("openSidebarSharedWithMe"));
830 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 829 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
831 } 830 }
832 831
833 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) { 832 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) {
834 PrepareVolume(); 833 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
835 ResultCatcher catcher; 834 ResultCatcher catcher;
836 StartTest("autocomplete"); 835 ASSERT_NO_FATAL_FAILURE(StartTest("autocomplete"));
837 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 836 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
838 } 837 }
839 838
840 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 839 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
841 TransferFromDriveToDownloads) { 840 TransferFromDriveToDownloads) {
842 PrepareVolume(); 841 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
843 ResultCatcher catcher; 842 ResultCatcher catcher;
844 StartTest("transferFromDriveToDownloads"); 843 ASSERT_NO_FATAL_FAILURE(
844 StartTest("transferFromDriveToDownloads"));
845 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 845 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
846 } 846 }
847 847
848 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 848 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
849 TransferFromDownloadsToDrive) { 849 TransferFromDownloadsToDrive) {
850 PrepareVolume(); 850 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
851 ResultCatcher catcher; 851 ResultCatcher catcher;
852 StartTest("transferFromDownloadsToDrive"); 852 ASSERT_NO_FATAL_FAILURE(
853 StartTest("transferFromDownloadsToDrive"));
853 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 854 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
854 } 855 }
855 856
856 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 857 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
857 TransferFromSharedToDownloads) { 858 TransferFromSharedToDownloads) {
858 PrepareVolume(); 859 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
859 ResultCatcher catcher; 860 ResultCatcher catcher;
860 StartTest("transferFromSharedToDownloads"); 861 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromSharedToDownloads"));
861 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 862 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
862 } 863 }
863 864
864 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 865 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
865 TransferFromSharedToDrive) { 866 TransferFromSharedToDrive) {
866 PrepareVolume(); 867 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
867 ResultCatcher catcher; 868 ResultCatcher catcher;
868 StartTest("transferFromSharedToDrive"); 869 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromSharedToDrive"));
869 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 870 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
870 } 871 }
871 872
872 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 873 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
873 TransferFromRecentToDownloads) { 874 TransferFromRecentToDownloads) {
874 PrepareVolume(); 875 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
875 ResultCatcher catcher; 876 ResultCatcher catcher;
876 StartTest("transferFromRecentToDownloads"); 877 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromRecentToDownloads"));
877 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 878 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
878 } 879 }
879 880
880 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 881 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
881 TransferFromRecentToDrive) { 882 TransferFromRecentToDrive) {
882 PrepareVolume(); 883 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
883 ResultCatcher catcher; 884 ResultCatcher catcher;
884 StartTest("transferFromRecentToDrive"); 885 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromRecentToDrive"));
885 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 886 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
886 } 887 }
887 888
888 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 889 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545
889 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 890 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
890 DISABLED_TransferFromOfflineToDownloads) { 891 DISABLED_TransferFromOfflineToDownloads) {
891 PrepareVolume(); 892 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
892 ResultCatcher catcher; 893 ResultCatcher catcher;
893 StartTest("transferFromOfflineToDownloads"); 894 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromOfflineToDownloads"));
894 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 895 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
895 } 896 }
896 897
897 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 898 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545
898 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, 899 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest,
899 DISABLED_TransferFromOfflineToDrive) { 900 DISABLED_TransferFromOfflineToDrive) {
900 PrepareVolume(); 901 ASSERT_NO_FATAL_FAILURE(PrepareVolume());
901 ResultCatcher catcher; 902 ResultCatcher catcher;
902 StartTest("transferFromOfflineToDrive"); 903 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromOfflineToDrive"));
903 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 904 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
904 } 905 }
905 906
906 } // namespace 907 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698