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 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/file_path_watcher.h" | 17 #include "base/files/file_path_watcher.h" |
| 18 #include "base/path_service.h" | |
| 18 #include "base/platform_file.h" | 19 #include "base/platform_file.h" |
| 19 #include "base/threading/platform_thread.h" | 20 #include "base/threading/platform_thread.h" |
| 20 #include "base/time.h" | 21 #include "base/time.h" |
| 21 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 23 #include "chrome/browser/chromeos/drive/drive_file_system.h" | |
| 24 #include "chrome/browser/chromeos/drive/drive_system_service.h" | |
| 22 #include "chrome/browser/extensions/component_loader.h" | 25 #include "chrome/browser/extensions/component_loader.h" |
| 23 #include "chrome/browser/extensions/extension_apitest.h" | 26 #include "chrome/browser/extensions/extension_apitest.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 25 #include "chrome/browser/extensions/extension_test_message_listener.h" | 28 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 29 #include "chrome/browser/google_apis/fake_drive_service.h" | |
| 30 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | |
| 31 #include "chrome/browser/google_apis/test_util.h" | |
| 26 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/extensions/extension.h" | 36 #include "chrome/common/extensions/extension.h" |
| 31 #include "chrome/test/base/ui_test_utils.h" | 37 #include "chrome/test/base/ui_test_utils.h" |
| 32 #include "content/public/browser/browser_context.h" | 38 #include "content/public/browser/browser_context.h" |
| 33 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
| 34 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
| 35 #include "webkit/fileapi/external_mount_points.h" | 41 #include "webkit/fileapi/external_mount_points.h" |
| 36 | 42 |
| 37 namespace { | 43 namespace { |
| 38 | 44 |
| 39 const char kFileManagerExtensionId[] = "hhaomjibdihmijegdhdafkllkbggdgoj"; | 45 const char kFileManagerExtensionId[] = "hhaomjibdihmijegdhdafkllkbggdgoj"; |
| 40 | 46 |
| 41 const char kKeyboardTestFileName[] = "world.mpeg"; | 47 const char kKeyboardTestFileName[] = "world.mpeg"; |
| 42 const int kKeyboardTestFileSize = 1000; | 48 const int kKeyboardTestFileSize = 1000; |
| 43 const char kKeyboardTestFileCopyName[] = "world (1).mpeg"; | 49 const char kKeyboardTestFileCopyName[] = "world (1).mpeg"; |
| 44 | 50 |
| 51 struct TestFileInfo { | |
| 52 const char* base_name; | |
| 53 int64 file_size; | |
| 54 const char* last_modified_time_as_string; | |
| 55 } kTestFiles[] = { | |
| 56 { "hello.txt", 123, "4 Sep 1998 12:34:56" }, | |
| 57 { "My Desktop Background.png", 1024, "18 Jan 2038 01:02:03" }, | |
| 58 { kKeyboardTestFileName, kKeyboardTestFileSize, "4 July 2012 10:35:00" }, | |
| 59 }; | |
| 60 | |
| 61 struct TestDirectoryInfo { | |
| 62 const char* base_name; | |
| 63 const char* last_modified_time_as_string; | |
| 64 } kTestDirectories[] = { | |
| 65 { "photos", "1 Jan 1980 23:59:59" }, | |
| 66 // Files starting with . are filtered out in | |
| 67 // file_manager/js/directory_contents.js, so this should not be shown. | |
| 68 { ".warez", "26 Oct 1985 13:39" }, | |
| 69 }; | |
| 70 | |
| 45 // The base test class. Used by FileManagerBrowserLocalTest and | 71 // The base test class. Used by FileManagerBrowserLocalTest and |
| 46 // FileManagerBrowserDriveTest. | 72 // FileManagerBrowserDriveTest. |
| 47 // TODO(satorux): Add the latter: crbug.com/224534. | 73 // TODO(satorux): Add the latter: crbug.com/224534. |
| 48 class FileManagerBrowserTestBase : public ExtensionApiTest { | 74 class FileManagerBrowserTestBase : public ExtensionApiTest { |
| 49 protected: | 75 protected: |
| 50 // Loads the file manager extension, navigating it to |directory_path| for | 76 // Loads the file manager extension, navigating it to |directory_path| for |
| 51 // testing, and waits for it to finish initializing. This is invoked at the | 77 // testing, and waits for it to finish initializing. This is invoked at the |
| 52 // start of each test (it crashes if run in SetUp). | 78 // start of each test (it crashes if run in SetUp). |
| 53 void StartFileManager(const std::string& directory_path); | 79 void StartFileManager(const std::string& directory_path); |
| 54 | 80 |
| 55 // Loads our testing extension and sends it a string identifying the current | 81 // Loads our testing extension and sends it a string identifying the current |
| 56 // test. | 82 // test. |
| 57 void StartTest(const std::string& test_name); | 83 void StartTest(const std::string& test_name); |
| 84 | |
| 85 // Creates test files and directories. | |
| 86 void CreateTestFilesAndDirectories(); | |
| 87 | |
| 88 // Creates a file with the given |name|, |length|, and |modification_time|. | |
| 89 virtual void CreateTestFile(const std::string& name, | |
| 90 int length, | |
|
kinaba
2013/04/04 06:33:17
int64 instead of int is used for file size everywh
satorux1
2013/04/05 02:24:04
Done.
| |
| 91 const std::string& modification_time) = 0; | |
| 92 | |
| 93 // Creates an empty directory with the given |name| and |modification_time|. | |
| 94 virtual void CreateTestDirectory( | |
| 95 const std::string& name, | |
| 96 const std::string& modification_time) = 0; | |
| 97 | |
| 98 // Runs the file display test, shared by sub classes. | |
| 99 void DoTestFileDisplay(); | |
| 58 }; | 100 }; |
| 59 | 101 |
| 60 void FileManagerBrowserTestBase::StartFileManager( | 102 void FileManagerBrowserTestBase::StartFileManager( |
| 61 const std::string& directory_path) { | 103 const std::string& directory_path) { |
| 62 std::string file_manager_url = | 104 std::string file_manager_url = |
| 63 (std::string("chrome-extension://") + | 105 (std::string("chrome-extension://") + |
| 64 kFileManagerExtensionId + | 106 kFileManagerExtensionId + |
| 65 "/main.html#" + | 107 "/main.html#" + |
| 66 net::EscapeQueryParamValue(directory_path, false /* use_plus */)); | 108 net::EscapeQueryParamValue(directory_path, false /* use_plus */)); |
| 67 | 109 |
| 68 ui_test_utils::NavigateToURL(browser(), GURL(file_manager_url)); | 110 ui_test_utils::NavigateToURL(browser(), GURL(file_manager_url)); |
| 69 | 111 |
| 70 // This is sent by the file manager when it's finished initializing. | 112 // This is sent by the file manager when it's finished initializing. |
| 71 ExtensionTestMessageListener listener("worker-initialized", false); | 113 ExtensionTestMessageListener listener("worker-initialized", false); |
| 72 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 114 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 73 } | 115 } |
| 74 | 116 |
| 75 void FileManagerBrowserTestBase::StartTest(const std::string& test_name) { | 117 void FileManagerBrowserTestBase::StartTest(const std::string& test_name) { |
| 76 base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest"); | 118 base::FilePath path = test_data_dir_.AppendASCII("file_manager_browsertest"); |
| 77 const extensions::Extension* extension = LoadExtensionAsComponent(path); | 119 const extensions::Extension* extension = LoadExtensionAsComponent(path); |
| 78 ASSERT_TRUE(extension); | 120 ASSERT_TRUE(extension); |
| 79 | 121 |
| 80 ExtensionTestMessageListener listener("which test", true); | 122 ExtensionTestMessageListener listener("which test", true); |
| 81 ASSERT_TRUE(listener.WaitUntilSatisfied()); | 123 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 82 listener.Reply(test_name); | 124 listener.Reply(test_name); |
| 83 } | 125 } |
| 84 | 126 |
| 127 void FileManagerBrowserTestBase::CreateTestFilesAndDirectories() { | |
| 128 for (size_t i = 0; i < arraysize(kTestFiles); ++i) { | |
| 129 CreateTestFile(kTestFiles[i].base_name, | |
| 130 kTestFiles[i].file_size, | |
| 131 kTestFiles[i].last_modified_time_as_string); | |
| 132 } | |
| 133 for (size_t i = 0; i < arraysize(kTestDirectories); ++i) { | |
| 134 CreateTestDirectory(kTestDirectories[i].base_name, | |
| 135 kTestDirectories[i].last_modified_time_as_string); | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 void FileManagerBrowserTestBase::DoTestFileDisplay() { | |
| 140 ResultCatcher catcher; | |
| 141 | |
| 142 StartTest("file display"); | |
| 143 | |
| 144 ExtensionTestMessageListener listener("initial check done", true); | |
| 145 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
| 146 CreateTestFile("newly added file.mp3", 2000, "4 Sep 1998 00:00:00"); | |
| 147 listener.Reply("file added"); | |
| 148 | |
| 149 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
| 150 } | |
| 151 | |
| 85 // The boolean parameter, retrieved by GetParam(), is true if testing in the | 152 // The boolean parameter, retrieved by GetParam(), is true if testing in the |
| 86 // guest mode. See SetUpCommandLine() below for details. | 153 // guest mode. See SetUpCommandLine() below for details. |
| 87 class FileManagerBrowserLocalTest : public FileManagerBrowserTestBase, | 154 class FileManagerBrowserLocalTest : public FileManagerBrowserTestBase, |
| 88 public ::testing::WithParamInterface<bool> { | 155 public ::testing::WithParamInterface<bool> { |
| 89 public: | 156 public: |
| 90 virtual void SetUp() OVERRIDE { | 157 virtual void SetUp() OVERRIDE { |
| 91 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); | 158 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); |
| 92 | 159 |
| 93 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 160 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 94 downloads_path_ = tmp_dir_.path().Append("Downloads"); | 161 downloads_path_ = tmp_dir_.path().Append("Downloads"); |
| 95 ASSERT_TRUE(file_util::CreateDirectory(downloads_path_)); | 162 ASSERT_TRUE(file_util::CreateDirectory(downloads_path_)); |
| 96 | 163 |
| 97 CreateTestFile("hello.txt", 123, "4 Sep 1998 12:34:56"); | 164 CreateTestFilesAndDirectories(); |
| 98 CreateTestFile("My Desktop Background.png", 1024, "18 Jan 2038 01:02:03"); | |
| 99 CreateTestFile(kKeyboardTestFileName, kKeyboardTestFileSize, | |
| 100 "4 July 2012 10:35:00"); | |
| 101 CreateTestDirectory("photos", "1 Jan 1980 23:59:59"); | |
| 102 // Files starting with . are filtered out in | |
| 103 // file_manager/js/directory_contents.js, so this should not be shown. | |
| 104 CreateTestDirectory(".warez", "26 Oct 1985 13:39"); | |
| 105 | 165 |
| 106 ExtensionApiTest::SetUp(); | 166 ExtensionApiTest::SetUp(); |
| 107 } | 167 } |
| 108 | 168 |
| 109 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 169 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 110 bool in_guest_mode = GetParam(); | 170 bool in_guest_mode = GetParam(); |
| 111 if (in_guest_mode) { | 171 if (in_guest_mode) { |
| 112 command_line->AppendSwitch(switches::kGuestSession); | 172 command_line->AppendSwitch(switches::kGuestSession); |
| 113 command_line->AppendSwitch(switches::kIncognito); | 173 command_line->AppendSwitch(switches::kIncognito); |
| 114 } | 174 } |
| 115 ExtensionApiTest::SetUpCommandLine(command_line); | 175 ExtensionApiTest::SetUpCommandLine(command_line); |
| 116 } | 176 } |
| 117 | 177 |
| 118 protected: | 178 protected: |
| 119 // Creates a file with the given |name|, |length|, and |modification_time|. | 179 // FileManagerBrowserTestBase overrides. |
| 120 void CreateTestFile(const std::string& name, | 180 virtual void CreateTestFile(const std::string& name, |
| 121 int length, | 181 int length, |
| 122 const std::string& modification_time); | 182 const std::string& modification_time) OVERRIDE; |
| 123 | 183 virtual void CreateTestDirectory( |
| 124 // Creates an empty directory with the given |name| and |modification_time|. | 184 const std::string& name, |
| 125 void CreateTestDirectory(const std::string& name, | 185 const std::string& modification_time) OVERRIDE; |
| 126 const std::string& modification_time); | |
| 127 | 186 |
| 128 // Add a mount point to the fake Downloads directory. Should be called | 187 // Add a mount point to the fake Downloads directory. Should be called |
| 129 // before StartFileManager(). | 188 // before StartFileManager(). |
| 130 void AddMountPointToFakeDownloads(); | 189 void AddMountPointToFakeDownloads(); |
| 131 | 190 |
| 132 // Path to the fake Downloads directory used in the test. | 191 // Path to the fake Downloads directory used in the test. |
| 133 base::FilePath downloads_path_; | 192 base::FilePath downloads_path_; |
| 134 | 193 |
| 135 private: | 194 private: |
| 136 base::ScopedTempDir tmp_dir_; | 195 base::ScopedTempDir tmp_dir_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 235 |
| 177 void FileManagerBrowserLocalTest::AddMountPointToFakeDownloads() { | 236 void FileManagerBrowserLocalTest::AddMountPointToFakeDownloads() { |
| 178 // Install our fake Downloads mount point first. | 237 // Install our fake Downloads mount point first. |
| 179 fileapi::ExternalMountPoints* mount_points = | 238 fileapi::ExternalMountPoints* mount_points = |
| 180 content::BrowserContext::GetMountPoints(profile()); | 239 content::BrowserContext::GetMountPoints(profile()); |
| 181 ASSERT_TRUE(mount_points->RevokeFileSystem("Downloads")); | 240 ASSERT_TRUE(mount_points->RevokeFileSystem("Downloads")); |
| 182 ASSERT_TRUE(mount_points->RegisterFileSystem( | 241 ASSERT_TRUE(mount_points->RegisterFileSystem( |
| 183 "Downloads", fileapi::kFileSystemTypeNativeLocal, downloads_path_)); | 242 "Downloads", fileapi::kFileSystemTypeNativeLocal, downloads_path_)); |
| 184 } | 243 } |
| 185 | 244 |
| 245 class FileManagerBrowserDriveTest : public FileManagerBrowserTestBase { | |
| 246 public: | |
| 247 FileManagerBrowserDriveTest() | |
| 248 : fake_drive_service_(NULL), | |
| 249 system_service_(NULL) { | |
| 250 } | |
| 251 | |
| 252 virtual void SetUp() OVERRIDE { | |
| 253 extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); | |
| 254 | |
| 255 base::FilePath tmp_dir_path; | |
| 256 PathService::Get(base::DIR_TEMP, &tmp_dir_path); | |
| 257 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDirUnderPath(tmp_dir_path)); | |
|
kinaba
2013/04/04 06:33:17
test_cache_root_.CreateUniqueTempDir()
should crea
satorux1
2013/04/05 02:24:04
Done. thanks!
| |
| 258 | |
| 259 drive::DriveSystemServiceFactory::SetFactoryForTest( | |
| 260 base::Bind(&FileManagerBrowserDriveTest::CreateDriveSystemService, | |
| 261 base::Unretained(this))); | |
| 262 | |
| 263 ExtensionApiTest::SetUp(); | |
| 264 } | |
| 265 | |
| 266 protected: | |
| 267 // FileManagerBrowserTestBase overrides. | |
| 268 virtual void CreateTestFile(const std::string& name, | |
| 269 int length, | |
| 270 const std::string& modification_time) OVERRIDE; | |
| 271 virtual void CreateTestDirectory( | |
| 272 const std::string& name, | |
| 273 const std::string& modification_time) OVERRIDE; | |
| 274 | |
| 275 // Notifies DriveFileSystem that the contents in FakeDriveService are | |
| 276 // changed, hence the new contents should be fetched. | |
| 277 void CheckForUpdates(); | |
| 278 | |
| 279 // DriveSystemService factory function for this test. | |
| 280 drive::DriveSystemService* CreateDriveSystemService(Profile* profile); | |
| 281 | |
| 282 base::ScopedTempDir test_cache_root_; | |
| 283 google_apis::FakeDriveService* fake_drive_service_; | |
| 284 drive::DriveSystemService* system_service_; | |
| 285 }; | |
| 286 | |
| 287 void FileManagerBrowserDriveTest::CreateTestFile( | |
| 288 const std::string& name, | |
| 289 int length, | |
| 290 const std::string& modification_time) { | |
| 291 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | |
| 292 scoped_ptr<google_apis::ResourceEntry> resource_entry; | |
| 293 fake_drive_service_->AddNewFile( | |
| 294 "text/plain", | |
| 295 length, | |
| 296 fake_drive_service_->GetRootResourceId(), | |
| 297 name, | |
| 298 google_apis::test_util::CreateCopyResultCallback(&error, | |
| 299 &resource_entry)); | |
| 300 MessageLoop::current()->RunUntilIdle(); | |
| 301 ASSERT_EQ(google_apis::HTTP_CREATED, error); | |
| 302 ASSERT_TRUE(resource_entry); | |
| 303 | |
| 304 base::Time time; | |
| 305 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); | |
| 306 fake_drive_service_->SetLastModifiedTime( | |
| 307 resource_entry->resource_id(), | |
| 308 time, | |
| 309 google_apis::test_util::CreateCopyResultCallback(&error, | |
| 310 &resource_entry)); | |
| 311 MessageLoop::current()->RunUntilIdle(); | |
| 312 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); | |
| 313 ASSERT_TRUE(resource_entry); | |
| 314 | |
| 315 CheckForUpdates(); | |
| 316 } | |
| 317 | |
| 318 void FileManagerBrowserDriveTest::CreateTestDirectory( | |
| 319 const std::string& name, | |
| 320 const std::string& modification_time) { | |
| 321 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; | |
| 322 scoped_ptr<google_apis::ResourceEntry> resource_entry; | |
| 323 fake_drive_service_->AddNewDirectory( | |
| 324 fake_drive_service_->GetRootResourceId(), | |
| 325 name, | |
| 326 google_apis::test_util::CreateCopyResultCallback(&error, | |
| 327 &resource_entry)); | |
| 328 MessageLoop::current()->RunUntilIdle(); | |
| 329 ASSERT_EQ(google_apis::HTTP_CREATED, error); | |
| 330 ASSERT_TRUE(resource_entry); | |
| 331 | |
| 332 base::Time time; | |
| 333 ASSERT_TRUE(base::Time::FromString(modification_time.c_str(), &time)); | |
| 334 fake_drive_service_->SetLastModifiedTime( | |
| 335 resource_entry->resource_id(), | |
| 336 time, | |
| 337 google_apis::test_util::CreateCopyResultCallback(&error, | |
| 338 &resource_entry)); | |
| 339 MessageLoop::current()->RunUntilIdle(); | |
| 340 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); | |
| 341 ASSERT_TRUE(resource_entry); | |
| 342 | |
| 343 CheckForUpdates(); | |
| 344 } | |
| 345 | |
| 346 void FileManagerBrowserDriveTest::CheckForUpdates() { | |
| 347 if (system_service_ && system_service_->file_system()) { | |
| 348 system_service_->file_system()->CheckForUpdates(); | |
| 349 } | |
| 350 } | |
| 351 | |
| 352 drive::DriveSystemService* | |
| 353 FileManagerBrowserDriveTest::CreateDriveSystemService(Profile* profile) { | |
| 354 fake_drive_service_ = new google_apis::FakeDriveService; | |
| 355 fake_drive_service_->LoadResourceListForWapi( | |
| 356 "chromeos/gdata/empty_feed.json"); | |
| 357 fake_drive_service_->LoadAccountMetadataForWapi( | |
| 358 "chromeos/gdata/account_metadata.json"); | |
| 359 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); | |
| 360 | |
| 361 // Create test files and directories inside the fake drive service. | |
| 362 CreateTestFilesAndDirectories(); | |
| 363 | |
| 364 system_service_ = new drive::DriveSystemService(profile, | |
| 365 fake_drive_service_, | |
| 366 test_cache_root_.path(), | |
| 367 NULL); | |
| 368 | |
| 369 return system_service_; | |
| 370 } | |
| 371 | |
| 186 // Monitors changes to a single file until the supplied condition callback | 372 // Monitors changes to a single file until the supplied condition callback |
| 187 // returns true. Usage: | 373 // returns true. Usage: |
| 188 // TestFilePathWatcher watcher(path_to_file, MyConditionCallback); | 374 // TestFilePathWatcher watcher(path_to_file, MyConditionCallback); |
| 189 // watcher.StartAndWaitUntilReady(); | 375 // watcher.StartAndWaitUntilReady(); |
| 190 // ... trigger filesystem modification ... | 376 // ... trigger filesystem modification ... |
| 191 // watcher.RunMessageLoopUntilConditionSatisfied(); | 377 // watcher.RunMessageLoopUntilConditionSatisfied(); |
| 192 class TestFilePathWatcher { | 378 class TestFilePathWatcher { |
| 193 public: | 379 public: |
| 194 typedef base::Callback<bool(const base::FilePath& file_path)> | 380 typedef base::Callback<bool(const base::FilePath& file_path)> |
| 195 ConditionCallback; | 381 ConditionCallback; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 } | 480 } |
| 295 | 481 |
| 296 bool DeletedFileGone(const base::FilePath& path) { | 482 bool DeletedFileGone(const base::FilePath& path) { |
| 297 return !file_util::PathExists(path); | 483 return !file_util::PathExists(path); |
| 298 }; | 484 }; |
| 299 | 485 |
| 300 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { | 486 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestFileDisplay) { |
| 301 AddMountPointToFakeDownloads(); | 487 AddMountPointToFakeDownloads(); |
| 302 StartFileManager("/Downloads"); | 488 StartFileManager("/Downloads"); |
| 303 | 489 |
| 304 ResultCatcher catcher; | 490 DoTestFileDisplay(); |
| 305 | |
| 306 StartTest("file display"); | |
| 307 | |
| 308 ExtensionTestMessageListener listener("initial check done", true); | |
| 309 ASSERT_TRUE(listener.WaitUntilSatisfied()); | |
| 310 CreateTestFile("newly added file.mp3", 2000, "4 Sep 1998 00:00:00"); | |
| 311 listener.Reply("file added"); | |
| 312 | |
| 313 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
| 314 } | 491 } |
| 315 | 492 |
| 316 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestKeyboardCopy) { | 493 IN_PROC_BROWSER_TEST_P(FileManagerBrowserLocalTest, TestKeyboardCopy) { |
| 317 AddMountPointToFakeDownloads(); | 494 AddMountPointToFakeDownloads(); |
| 318 StartFileManager("/Downloads"); | 495 StartFileManager("/Downloads"); |
| 319 | 496 |
| 320 base::FilePath copy_path = | 497 base::FilePath copy_path = |
| 321 downloads_path_.AppendASCII(kKeyboardTestFileCopyName); | 498 downloads_path_.AppendASCII(kKeyboardTestFileCopyName); |
| 322 ASSERT_FALSE(file_util::PathExists(copy_path)); | 499 ASSERT_FALSE(file_util::PathExists(copy_path)); |
| 323 TestFilePathWatcher watcher(copy_path, base::Bind(CopiedFilePresent)); | 500 TestFilePathWatcher watcher(copy_path, base::Bind(CopiedFilePresent)); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 345 TestFilePathWatcher watcher(delete_path, base::Bind(DeletedFileGone)); | 522 TestFilePathWatcher watcher(delete_path, base::Bind(DeletedFileGone)); |
| 346 watcher.StartAndWaitUntilReady(); | 523 watcher.StartAndWaitUntilReady(); |
| 347 | 524 |
| 348 ResultCatcher catcher; | 525 ResultCatcher catcher; |
| 349 StartTest("keyboard delete"); | 526 StartTest("keyboard delete"); |
| 350 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 527 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 351 | 528 |
| 352 ASSERT_TRUE(watcher.RunMessageLoopUntilConditionSatisfied()); | 529 ASSERT_TRUE(watcher.RunMessageLoopUntilConditionSatisfied()); |
| 353 } | 530 } |
| 354 | 531 |
| 532 IN_PROC_BROWSER_TEST_F(FileManagerBrowserDriveTest, TestFileDisplay) { | |
| 533 StartFileManager("/drive"); | |
| 534 | |
| 535 DoTestFileDisplay(); | |
| 536 } | |
| 537 | |
| 355 } // namespace | 538 } // namespace |
| OLD | NEW |