Chromium Code Reviews| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 bool ok = 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); | 142 DCHECK(ok); |
| 143 | 143 |
| 144 // If the condition was already met before FilePathWatcher was launched, | 144 // 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 (condition_.Run(path_)) { |
|
hashimoto
2013/05/23 06:45:09
How about "if (!ok || condition_.Run(path_)) { fai
mtomasz
2013/05/23 07:07:32
(1) Can't we just do failed_ = !watcher->Watch(...
hashimoto
2013/05/23 07:17:31
It also looks good.
mtomasz
2013/05/23 07:43:42
There are some edge cases they don't report the sa
| |
| 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 Loading... | |
| 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 DriveTestVolume drive_volume_; | 767 DriveTestVolume drive_volume_; |
| 769 }; | 768 }; |
| 770 | 769 |
| 771 // FileManagerBrowserTransferTest depends on Drive and Drive is not supported in | 770 // FileManagerBrowserTransferTest depends on Drive and Drive is not supported in |
| 772 // the guest mode. | 771 // the guest mode. |
| 773 INSTANTIATE_TEST_CASE_P(InNonGuestMode, | 772 INSTANTIATE_TEST_CASE_P(InNonGuestMode, |
| 774 FileManagerBrowserTransferTest, | 773 FileManagerBrowserTransferTest, |
| 775 ::testing::Values(false)); | 774 ::testing::Values(false)); |
| 776 | 775 |
| 777 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { | 776 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { |
| 778 PrepareVolume(); | 777 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 779 DoTestFileDisplay(&volume_); | 778 DoTestFileDisplay(&volume_); |
| 780 } | 779 } |
| 781 | 780 |
| 782 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardCopy) { | 781 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardCopy) { |
| 783 PrepareVolume(); | 782 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 784 DoTestKeyboardCopy(&volume_); | 783 DoTestKeyboardCopy(&volume_); |
| 785 } | 784 } |
| 786 | 785 |
| 787 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardDelete) { | 786 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestKeyboardDelete) { |
| 788 PrepareVolume(); | 787 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 789 DoTestKeyboardDelete(&volume_); | 788 DoTestKeyboardDelete(&volume_); |
| 790 } | 789 } |
| 791 | 790 |
| 792 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) { | 791 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenRecent) { |
| 793 PrepareVolume(); | 792 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 794 ResultCatcher catcher; | 793 ResultCatcher catcher; |
| 795 StartTest("openSidebarRecent"); | 794 ASSERT_NO_FATAL_FAILURE(StartTest("openSidebarRecent")); |
| 796 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 795 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 797 } | 796 } |
| 798 | 797 |
| 799 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 | 798 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 |
| 800 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, DISABLED_TestOpenOffline) { | 799 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, DISABLED_TestOpenOffline) { |
| 801 PrepareVolume(); | 800 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 802 ResultCatcher catcher; | 801 ResultCatcher catcher; |
| 803 StartTest("openSidebarOffline"); | 802 ASSERT_NO_FATAL_FAILURE(StartTest("openSidebarOffline")); |
| 804 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 803 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 805 } | 804 } |
| 806 | 805 |
| 807 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenSharedWithMe) { | 806 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestOpenSharedWithMe) { |
| 808 PrepareVolume(); | 807 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 809 ResultCatcher catcher; | 808 ResultCatcher catcher; |
| 810 StartTest("openSidebarSharedWithMe"); | 809 ASSERT_NO_FATAL_FAILURE(StartTest("openSidebarSharedWithMe")); |
| 811 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 810 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 812 } | 811 } |
| 813 | 812 |
| 814 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) { | 813 IN_PROC_BROWSER_TEST_P(FileManagerBrowserDriveTest, TestAutocomplete) { |
| 815 PrepareVolume(); | 814 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 816 ResultCatcher catcher; | 815 ResultCatcher catcher; |
| 817 StartTest("autocomplete"); | 816 ASSERT_NO_FATAL_FAILURE(StartTest("autocomplete")); |
| 818 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 817 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 819 } | 818 } |
| 820 | 819 |
| 821 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 820 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 822 TransferFromDriveToDownloads) { | 821 TransferFromDriveToDownloads) { |
| 823 PrepareVolume(); | 822 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 824 ResultCatcher catcher; | 823 ResultCatcher catcher; |
| 825 StartTest("transferFromDriveToDownloads"); | 824 ASSERT_NO_FATAL_FAILURE( |
| 825 StartTest("transferFromDriveToDownloads")); | |
| 826 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 826 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 827 } | 827 } |
| 828 | 828 |
| 829 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 829 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 830 TransferFromDownloadsToDrive) { | 830 TransferFromDownloadsToDrive) { |
| 831 PrepareVolume(); | 831 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 832 ResultCatcher catcher; | 832 ResultCatcher catcher; |
| 833 StartTest("transferFromDownloadsToDrive"); | 833 ASSERT_NO_FATAL_FAILURE( |
| 834 StartTest("transferFromDownloadsToDrive")); | |
| 834 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 835 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 835 } | 836 } |
| 836 | 837 |
| 837 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 838 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 838 TransferFromSharedToDownloads) { | 839 TransferFromSharedToDownloads) { |
| 839 PrepareVolume(); | 840 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 840 ResultCatcher catcher; | 841 ResultCatcher catcher; |
| 841 StartTest("transferFromSharedToDownloads"); | 842 StartTest("transferFromSharedToDownloads"); |
|
hirono
2013/05/23 06:40:46
Could you add ASSERT_NO_FATAL_FAILURE here?
mtomasz
2013/05/23 07:07:32
Done.
| |
| 842 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 843 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 843 } | 844 } |
| 844 | 845 |
| 845 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 846 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 846 TransferFromSharedToDrive) { | 847 TransferFromSharedToDrive) { |
| 847 PrepareVolume(); | 848 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 848 ResultCatcher catcher; | 849 ResultCatcher catcher; |
| 849 StartTest("transferFromSharedToDrive"); | 850 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromSharedToDrive")); |
| 850 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 851 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 851 } | 852 } |
| 852 | 853 |
| 853 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 854 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 854 TransferFromRecentToDownloads) { | 855 TransferFromRecentToDownloads) { |
| 855 PrepareVolume(); | 856 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 856 ResultCatcher catcher; | 857 ResultCatcher catcher; |
| 857 StartTest("transferFromRecentToDownloads"); | 858 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromRecentToDownloads")); |
| 858 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 859 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 859 } | 860 } |
| 860 | 861 |
| 861 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 862 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 862 TransferFromRecentToDrive) { | 863 TransferFromRecentToDrive) { |
| 863 PrepareVolume(); | 864 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 864 ResultCatcher catcher; | 865 ResultCatcher catcher; |
| 865 StartTest("transferFromRecentToDrive"); | 866 StartTest("transferFromRecentToDrive"); |
|
hirono
2013/05/23 06:38:44
Could you add ASSERT_NO_FATAL_FAILURE here?
mtomasz
2013/05/23 07:07:32
Done.
| |
| 866 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 867 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 867 } | 868 } |
| 868 | 869 |
| 869 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 | 870 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 |
| 870 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 871 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 871 DISABLED_TransferFromOfflineToDownloads) { | 872 DISABLED_TransferFromOfflineToDownloads) { |
| 872 PrepareVolume(); | 873 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 873 ResultCatcher catcher; | 874 ResultCatcher catcher; |
| 874 StartTest("transferFromOfflineToDownloads"); | 875 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromOfflineToDownloads")); |
| 875 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 876 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 876 } | 877 } |
| 877 | 878 |
| 878 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 | 879 // TODO(hirono): Bring back the offline feature. http://crbug.com/238545 |
| 879 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, | 880 IN_PROC_BROWSER_TEST_P(FileManagerBrowserTransferTest, |
| 880 DISABLED_TransferFromOfflineToDrive) { | 881 DISABLED_TransferFromOfflineToDrive) { |
| 881 PrepareVolume(); | 882 ASSERT_NO_FATAL_FAILURE(PrepareVolume()); |
| 882 ResultCatcher catcher; | 883 ResultCatcher catcher; |
| 883 StartTest("transferFromOfflineToDrive"); | 884 ASSERT_NO_FATAL_FAILURE(StartTest("transferFromOfflineToDrive")); |
| 884 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 885 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 885 } | 886 } |
| 886 } // namespace | 887 } // namespace |
| OLD | NEW |