| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
| 7 #include "chrome/browser/chromeos/drive/file_change.h" | 7 #include "chrome/browser/chromeos/drive/file_change.h" |
| 8 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" | 8 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" |
| 9 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" | 9 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" |
| 10 #include "chrome/browser/chromeos/file_manager/file_watcher.h" | 10 #include "chrome/browser/chromeos/file_manager/file_watcher.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "chromeos/dbus/cros_disks_client.h" | 14 #include "chromeos/dbus/cros_disks_client.h" |
| 14 #include "chromeos/disks/mock_disk_mount_manager.h" | 15 #include "chromeos/disks/mock_disk_mount_manager.h" |
| 15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/install_warning.h" | 17 #include "extensions/common/install_warning.h" |
| 17 | 18 |
| 18 using ::testing::_; | 19 using ::testing::_; |
| 19 using ::testing::ReturnRef; | 20 using ::testing::ReturnRef; |
| 20 | 21 |
| 21 using chromeos::disks::DiskMountManager; | 22 using chromeos::disks::DiskMountManager; |
| 22 | 23 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), | 332 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), |
| 332 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/a/d/e")), | 333 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/a/d/e")), |
| 333 "extension_2", base::Bind(&AddFileWatchCallback)); | 334 "extension_2", base::Bind(&AddFileWatchCallback)); |
| 334 | 335 |
| 335 event_router_->AddFileWatch( | 336 event_router_->AddFileWatch( |
| 336 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), | 337 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), |
| 337 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/aaa")), | 338 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/aaa")), |
| 338 "extension_3", base::Bind(&AddFileWatchCallback)); | 339 "extension_3", base::Bind(&AddFileWatchCallback)); |
| 339 | 340 |
| 340 // event_router->addFileWatch create some tasks which are performed on message | 341 // event_router->addFileWatch create some tasks which are performed on message |
| 341 // loop. Wait until they are done. | 342 // loop of BrowserThread::FILE. Wait until they are done. |
| 343 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 344 // We also wait the UI thread here, since some tasks which are performed above |
| 345 // message loop back results to the UI thread. |
| 342 base::RunLoop().RunUntilIdle(); | 346 base::RunLoop().RunUntilIdle(); |
| 343 | 347 |
| 344 // When /a is deleted (1 and 2 is notified). | 348 // When /a is deleted (1 and 2 is notified). |
| 345 FileChange first_change; | 349 FileChange first_change; |
| 346 first_change.Update( | 350 first_change.Update( |
| 347 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a")), | 351 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a")), |
| 348 FileType::FILE_TYPE_DIRECTORY, ChangeType::DELETE); | 352 FileType::FILE_TYPE_DIRECTORY, ChangeType::DELETE); |
| 349 event_router_->OnFileChanged(first_change); | 353 event_router_->OnFileChanged(first_change); |
| 350 EXPECT_EQ(2, counter); | 354 EXPECT_EQ(2, counter); |
| 351 | 355 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 370 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/b/c")), | 374 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/b/c")), |
| 371 "extension_1"); | 375 "extension_1"); |
| 372 event_router_->RemoveFileWatch( | 376 event_router_->RemoveFileWatch( |
| 373 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), | 377 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), |
| 374 "extension_2"); | 378 "extension_2"); |
| 375 event_router_->RemoveFileWatch( | 379 event_router_->RemoveFileWatch( |
| 376 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), | 380 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), |
| 377 "extension_3"); | 381 "extension_3"); |
| 378 | 382 |
| 379 // event_router->removeFileWatch create some tasks which are performed on | 383 // event_router->removeFileWatch create some tasks which are performed on |
| 380 // message loop. wait until they are done. | 384 // message loop of BrowserThread::FILE. Wait until they are done. |
| 381 base::RunLoop().RunUntilIdle(); | 385 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 382 } | 386 } |
| OLD | NEW |