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

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: Sync with master. 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f400f9d70ad7059f44a0d99ac38891d4adc67fa5 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;
@@ -128,6 +130,29 @@ void DispatchDirectoryChangeEventImpl(
void AddFileWatchCallback(bool success) {}
+bool InitializeLocalFileSystem(std::string mount_point_name,
+ base::ScopedTempDir* temp_dir,
+ base::FilePath* mount_point_dir) {
+ const char kTestFileContent[] = "The five boxing wizards jumped quickly";
+ if (!temp_dir->CreateUniqueTempDir())
+ return false;
+
+ *mount_point_dir = temp_dir->path().AppendASCII(mount_point_name);
+ // Create the mount point.
+ if (!base::CreateDirectory(*mount_point_dir))
+ return false;
+
+ const base::FilePath test_dir = mount_point_dir->AppendASCII("test_dir");
+ if (!base::CreateDirectory(test_dir))
+ return false;
+
+ const base::FilePath test_file = test_dir.AppendASCII("test_file.txt");
+ if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
+ return false;
+
+ return true;
+}
+
} // namespace
class FileManagerPrivateApiTest : public ExtensionApiTest {
@@ -384,3 +409,24 @@ IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, OnFileChanged) {
// message loop of BrowserThread::FILE. Wait until they are done.
content::RunAllPendingInMessageLoop(content::BrowserThread::FILE);
}
+
+IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiTest, ContentChecksum) {
+ base::ScopedTempDir temp_dir;
+ base::FilePath mount_point_dir;
+ const char kLocalMountPointName[] = "local";
+
+ ASSERT_TRUE(InitializeLocalFileSystem(kLocalMountPointName, &temp_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(RunComponentExtensionTest("file_browser/content_checksum_test"));
+}
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_manager/private_api_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698