Chromium Code Reviews| 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 "chrome/test/base/ui_test_utils.h" |
| 14 #include "chromeos/dbus/cros_disks_client.h" | 14 #include "chromeos/dbus/cros_disks_client.h" |
| 15 #include "chromeos/disks/mock_disk_mount_manager.h" | 15 #include "chromeos/disks/mock_disk_mount_manager.h" |
| 16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 17 #include "extensions/common/install_warning.h" | 17 #include "extensions/common/install_warning.h" |
| 18 #include "google_apis/drive/test_util.h" | |
| 19 #include "storage/browser/fileapi/external_mount_points.h" | |
| 18 | 20 |
| 19 using ::testing::_; | 21 using ::testing::_; |
| 20 using ::testing::ReturnRef; | 22 using ::testing::ReturnRef; |
| 21 | 23 |
| 22 using chromeos::disks::DiskMountManager; | 24 using chromeos::disks::DiskMountManager; |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 struct TestDiskInfo { | 28 struct TestDiskInfo { |
| 27 const char* system_path; | 29 const char* system_path; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 int* counter, | 123 int* counter, |
| 122 const base::FilePath& virtual_path, | 124 const base::FilePath& virtual_path, |
| 123 const drive::FileChange* list, | 125 const drive::FileChange* list, |
| 124 bool got_error, | 126 bool got_error, |
| 125 const std::vector<std::string>& extension_ids) { | 127 const std::vector<std::string>& extension_ids) { |
| 126 ++(*counter); | 128 ++(*counter); |
| 127 } | 129 } |
| 128 | 130 |
| 129 void AddFileWatchCallback(bool success) {} | 131 void AddFileWatchCallback(bool success) {} |
| 130 | 132 |
| 133 bool InitializeLocalFileSystem(std::string mount_point_name, | |
| 134 base::ScopedTempDir *temp_dir, | |
|
mtomasz
2015/01/09 05:11:28
nit: Pointer asterisk glue to the type name, not v
Ben Kwa
2015/01/09 06:24:18
Done.
| |
| 135 base::FilePath* mount_point_dir) { | |
| 136 const char kTestFileContent[] = "The five boxing wizards jumped quickly"; | |
| 137 if (!temp_dir->CreateUniqueTempDir()) | |
| 138 return false; | |
| 139 | |
| 140 *mount_point_dir = temp_dir->path().AppendASCII(mount_point_name); | |
| 141 // Create the mount point. | |
| 142 if (!base::CreateDirectory(*mount_point_dir)) | |
| 143 return false; | |
| 144 | |
| 145 const base::FilePath test_dir = mount_point_dir->AppendASCII("test_dir"); | |
| 146 if (!base::CreateDirectory(test_dir)) | |
| 147 return false; | |
| 148 | |
| 149 const base::FilePath test_file = test_dir.AppendASCII("test_file.txt"); | |
| 150 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent)) | |
| 151 return false; | |
| 152 | |
| 153 return true; | |
| 154 } | |
| 155 | |
| 131 } // namespace | 156 } // namespace |
| 132 | 157 |
| 133 class FileManagerPrivateApiTest : public ExtensionApiTest { | 158 class FileManagerPrivateApiTest : public ExtensionApiTest { |
| 134 public: | 159 public: |
| 135 FileManagerPrivateApiTest() | 160 FileManagerPrivateApiTest() |
| 136 : disk_mount_manager_mock_(NULL) { | 161 : disk_mount_manager_mock_(NULL) { |
| 137 InitMountPoints(); | 162 InitMountPoints(); |
| 138 } | 163 } |
| 139 | 164 |
| 140 virtual ~FileManagerPrivateApiTest() { | 165 virtual ~FileManagerPrivateApiTest() { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), | 402 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), |
| 378 "extension_2"); | 403 "extension_2"); |
| 379 event_router_->RemoveFileWatch( | 404 event_router_->RemoveFileWatch( |
| 380 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), | 405 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), |
| 381 "extension_3"); | 406 "extension_3"); |
| 382 | 407 |
| 383 // event_router->removeFileWatch create some tasks which are performed on | 408 // event_router->removeFileWatch create some tasks which are performed on |
| 384 // message loop of BrowserThread::FILE. Wait until they are done. | 409 // message loop of BrowserThread::FILE. Wait until they are done. |
| 385 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 410 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 386 } | 411 } |
| 412 | |
| 413 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) { | |
| 414 base::ScopedTempDir temp_dir; | |
| 415 base::FilePath mount_point_dir; | |
| 416 const char kLocalMountPointName[] = "local"; | |
| 417 | |
| 418 ASSERT_TRUE(InitializeLocalFileSystem( | |
| 419 kLocalMountPointName, &temp_dir, &mount_point_dir)) | |
| 420 << "Failed to initialize test file system"; | |
| 421 | |
| 422 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) | |
| 423 ->RegisterFileSystem(kLocalMountPointName, | |
| 424 storage::kFileSystemTypeNativeLocal, | |
| 425 storage::FileSystemMountOption(), | |
| 426 mount_point_dir)); | |
| 427 file_manager::VolumeManager::Get( | |
| 428 browser()->profile())->AddVolumeInfoForTesting( | |
| 429 mount_point_dir, | |
| 430 file_manager::VOLUME_TYPE_TESTING, | |
| 431 chromeos::DEVICE_TYPE_UNKNOWN); | |
| 432 | |
| 433 ASSERT_TRUE(RunComponentExtensionTest("file_browser/content_checksum_test")); | |
| 434 } | |
| OLD | NEW |