Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3171)

Unified Diff: chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc

Issue 840843002: Expose computation of md5 content checksums for files via a file manager private API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc b/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
index d0b4541e4916fc44fc962d5f7c96d87366963cda..ba9f2259e50c4499c6d99491a8c7c93ff530acda 100644
--- a/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/file_manager_private_apitest.cc
@@ -15,6 +15,8 @@
#include "chromeos/disks/mock_disk_mount_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/install_warning.h"
+#include "google_apis/drive/test_util.h"
+#include "storage/browser/fileapi/external_mount_points.h"
using ::testing::_;
using ::testing::ReturnRef;
@@ -384,3 +386,50 @@ IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, OnFileChanged) {
// message loop of BrowserThread::FILE. Wait until they are done.
content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
}
+
+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.
+ 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.
+ base::FilePath* mount_point_dir) {
+ const char kTestFileContent[] = "The five boxing wizards jumped quickly";
+ if (!tmp_dir->CreateUniqueTempDir())
+ return false;
+
+ *mount_point_dir = tmp_dir->path().AppendASCII(mount_point_name);
+ // Create the mount point.
+ if (!base::CreateDirectory(*mount_point_dir))
+ return false;
+
+ 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.
+ if (!base::CreateDirectory(test_dir))
+ return false;
+
+ 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.
+ if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
+ return false;
+
+ return true;
+}
+
+IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) {
+ base::ScopedTempDir tmp_dir;
+ base::FilePath mount_point_dir;
+ const char kLocalMountPointName[] = "local";
+
+ ASSERT_TRUE(InitializeLocalFileSystem(
+ kLocalMountPointName, &tmp_dir, &mount_point_dir))
+ << "Failed to initialize test file system";
+
+ EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())
+ ->RegisterFileSystem(kLocalMountPointName,
+ storage::kFileSystemTypeNativeLocal,
+ storage::FileSystemMountOption(),
+ mount_point_dir));
+ file_manager::VolumeManager::Get(
+ browser()->profile())->AddVolumeInfoForTesting(
+ mount_point_dir,
+ file_manager::VOLUME_TYPE_TESTING,
+ chromeos::DEVICE_TYPE_UNKNOWN);
+
+ 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.
+ "file_browser/content_checksum_test"));
+}

Powered by Google App Engine
This is Rietveld 408576698