| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" | 11 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" |
| 12 #include "chrome/browser/chromeos/file_manager/file_watcher.h" | 12 #include "chrome/browser/chromeos/file_manager/file_watcher.h" |
| 13 #include "chrome/browser/chromeos/file_manager/mount_test_util.h" | 13 #include "chrome/browser/chromeos/file_manager/mount_test_util.h" |
| 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" | 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_info
.h" |
| 15 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
| 16 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" | 16 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "chromeos/dbus/cros_disks_client.h" | 19 #include "chromeos/dbus/cros_disks_client.h" |
| 19 #include "chromeos/disks/mock_disk_mount_manager.h" | 20 #include "chromeos/disks/mock_disk_mount_manager.h" |
| 20 #include "components/drive/file_change.h" | 21 #include "components/drive/file_change.h" |
| 21 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 22 #include "extensions/common/install_warning.h" | 23 #include "extensions/common/install_warning.h" |
| 23 #include "google_apis/drive/test_util.h" | 24 #include "google_apis/drive/test_util.h" |
| 24 #include "storage/browser/fileapi/external_mount_points.h" | 25 #include "storage/browser/fileapi/external_mount_points.h" |
| 25 | 26 |
| 26 using ::testing::_; | 27 using ::testing::_; |
| 27 using ::testing::ReturnRef; | 28 using ::testing::ReturnRef; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 event_router_->AddFileWatch( | 372 event_router_->AddFileWatch( |
| 372 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), | 373 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), |
| 373 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/a/d/e")), | 374 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/a/d/e")), |
| 374 "extension_2", base::Bind(&AddFileWatchCallback)); | 375 "extension_2", base::Bind(&AddFileWatchCallback)); |
| 375 | 376 |
| 376 event_router_->AddFileWatch( | 377 event_router_->AddFileWatch( |
| 377 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), | 378 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), |
| 378 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/aaa")), | 379 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs-hash/root/aaa")), |
| 379 "extension_3", base::Bind(&AddFileWatchCallback)); | 380 "extension_3", base::Bind(&AddFileWatchCallback)); |
| 380 | 381 |
| 381 // event_router->addFileWatch create some tasks which are performed on | 382 // event_router->addFileWatch create some tasks which are performed on message |
| 382 // TaskScheduler. Wait until they are done. | 383 // loop of BrowserThread::FILE. Wait until they are done. |
| 383 base::TaskScheduler::GetInstance()->FlushForTesting(); | 384 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 384 // We also wait the UI thread here, since some tasks which are performed | 385 // We also wait the UI thread here, since some tasks which are performed above |
| 385 // above message loop back results to the UI thread. | 386 // message loop back results to the UI thread. |
| 386 base::RunLoop().RunUntilIdle(); | 387 base::RunLoop().RunUntilIdle(); |
| 387 | 388 |
| 388 // When /a is deleted (1 and 2 is notified). | 389 // When /a is deleted (1 and 2 is notified). |
| 389 FileChange first_change; | 390 FileChange first_change; |
| 390 first_change.Update( | 391 first_change.Update( |
| 391 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a")), | 392 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a")), |
| 392 FileType::FILE_TYPE_DIRECTORY, ChangeType::CHANGE_TYPE_DELETE); | 393 FileType::FILE_TYPE_DIRECTORY, ChangeType::CHANGE_TYPE_DELETE); |
| 393 event_router_->OnFileChanged(first_change); | 394 event_router_->OnFileChanged(first_change); |
| 394 EXPECT_EQ(2, counter); | 395 EXPECT_EQ(2, counter); |
| 395 | 396 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 413 event_router_->RemoveFileWatch( | 414 event_router_->RemoveFileWatch( |
| 414 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/b/c")), | 415 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/b/c")), |
| 415 "extension_1"); | 416 "extension_1"); |
| 416 event_router_->RemoveFileWatch( | 417 event_router_->RemoveFileWatch( |
| 417 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), | 418 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), |
| 418 "extension_2"); | 419 "extension_2"); |
| 419 event_router_->RemoveFileWatch( | 420 event_router_->RemoveFileWatch( |
| 420 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), | 421 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), |
| 421 "extension_3"); | 422 "extension_3"); |
| 422 | 423 |
| 423 // event_router->addFileWatch create some tasks which are performed on | 424 // event_router->removeFileWatch create some tasks which are performed on |
| 424 // TaskScheduler. Wait until they are done. | 425 // message loop of BrowserThread::FILE. Wait until they are done. |
| 425 base::TaskScheduler::GetInstance()->FlushForTesting(); | 426 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 426 } | 427 } |
| 427 | 428 |
| 428 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) { | 429 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) { |
| 429 base::ScopedTempDir temp_dir; | 430 base::ScopedTempDir temp_dir; |
| 430 base::FilePath mount_point_dir; | 431 base::FilePath mount_point_dir; |
| 431 const char kLocalMountPointName[] = "local"; | 432 const char kLocalMountPointName[] = "local"; |
| 432 | 433 |
| 433 ASSERT_TRUE(InitializeLocalFileSystem(kLocalMountPointName, &temp_dir, | 434 ASSERT_TRUE(InitializeLocalFileSystem(kLocalMountPointName, &temp_dir, |
| 434 &mount_point_dir)) | 435 &mount_point_dir)) |
| 435 << "Failed to initialize test file system"; | 436 << "Failed to initialize test file system"; |
| 436 | 437 |
| 437 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) | 438 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) |
| 438 ->RegisterFileSystem( | 439 ->RegisterFileSystem( |
| 439 kLocalMountPointName, storage::kFileSystemTypeNativeLocal, | 440 kLocalMountPointName, storage::kFileSystemTypeNativeLocal, |
| 440 storage::FileSystemMountOption(), mount_point_dir)); | 441 storage::FileSystemMountOption(), mount_point_dir)); |
| 441 file_manager::VolumeManager::Get(browser()->profile()) | 442 file_manager::VolumeManager::Get(browser()->profile()) |
| 442 ->AddVolumeForTesting(mount_point_dir, file_manager::VOLUME_TYPE_TESTING, | 443 ->AddVolumeForTesting(mount_point_dir, file_manager::VOLUME_TYPE_TESTING, |
| 443 chromeos::DEVICE_TYPE_UNKNOWN, | 444 chromeos::DEVICE_TYPE_UNKNOWN, |
| 444 false /* read_only */); | 445 false /* read_only */); |
| 445 | 446 |
| 446 ASSERT_TRUE(RunComponentExtensionTest("file_browser/content_checksum_test")); | 447 ASSERT_TRUE(RunComponentExtensionTest("file_browser/content_checksum_test")); |
| 447 } | 448 } |
| OLD | NEW |