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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), | 379 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/a/d/e")), |
378 "extension_2"); | 380 "extension_2"); |
379 event_router_->RemoveFileWatch( | 381 event_router_->RemoveFileWatch( |
380 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), | 382 base::FilePath(FILE_PATH_LITERAL("/no-existing-fs/root/aaa")), |
381 "extension_3"); | 383 "extension_3"); |
382 | 384 |
383 // event_router->removeFileWatch create some tasks which are performed on | 385 // event_router->removeFileWatch create some tasks which are performed on |
384 // message loop of BrowserThread::FILE. Wait until they are done. | 386 // message loop of BrowserThread::FILE. Wait until they are done. |
385 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 387 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
386 } | 388 } |
389 | |
390 bool InitializeLocalFileSystem(std::string mount_point_name, | |
mtomasz
2015/01/08 00:38:40
This can go to an anonymous namespace.
Ben Kwa
2015/01/08 19:29:14
Done.
| |
391 base::ScopedTempDir *tmp_dir, | |
mtomasz
2015/01/08 00:38:40
nit: tmp_dir -> temp_dir for consistency with the
Ben Kwa
2015/01/08 19:29:14
Done.
| |
392 base::FilePath* mount_point_dir) { | |
393 const char kTestFileContent[] = "The five boxing wizards jumped quickly"; | |
394 if (!tmp_dir->CreateUniqueTempDir()) | |
395 return false; | |
396 | |
397 *mount_point_dir = tmp_dir->path().AppendASCII(mount_point_name); | |
398 // Create the mount point. | |
399 if (!base::CreateDirectory(*mount_point_dir)) | |
400 return false; | |
401 | |
402 base::FilePath test_dir = mount_point_dir->AppendASCII("test_dir"); | |
mtomasz
2015/01/08 00:38:40
nit: This can be const
Ben Kwa
2015/01/08 19:29:13
Done.
| |
403 if (!base::CreateDirectory(test_dir)) | |
404 return false; | |
405 | |
406 base::FilePath test_file = test_dir.AppendASCII("test_file.txt"); | |
mtomasz
2015/01/08 00:38:40
nit: ditto
Ben Kwa
2015/01/08 19:29:14
Done.
| |
407 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent)) | |
408 return false; | |
409 | |
410 return true; | |
411 } | |
412 | |
413 IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) { | |
414 base::ScopedTempDir tmp_dir; | |
415 base::FilePath mount_point_dir; | |
416 const char kLocalMountPointName[] = "local"; | |
417 | |
418 ASSERT_TRUE(InitializeLocalFileSystem( | |
419 kLocalMountPointName, &tmp_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(RunExtensionTestIgnoreManifestWarnings( | |
mtomasz
2015/01/08 00:38:40
Is RunComponentExtensionTest enough? We don't expe
Ben Kwa
2015/01/08 19:29:14
Done.
| |
434 "file_browser/content_checksum_test")); | |
435 } | |
OLD | NEW |