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

Unified Diff: chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc

Issue 427493002: [fsp] Do not allow write operations on read only file systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/file_system_provider/operations/open_file_unittest.cc
diff --git a/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc b/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc
index db3d84d96ef40dc7cedc2ce989903933d09ed34a..749f40249d01e67aeadc9b18883b914090708467 100644
--- a/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc
+++ b/chrome/browser/chromeos/file_system_provider/operations/open_file_unittest.cc
@@ -147,6 +147,48 @@ TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_NoListener) {
EXPECT_FALSE(open_file.Execute(kRequestId));
}
+TEST_F(FileSystemProviderOperationsOpenFileTest, Execute_ReadOnly) {
+ util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
+ CallbackLogger callback_logger;
+
+ const ProvidedFileSystemInfo read_only_file_system_info(
+ kExtensionId,
+ kFileSystemId,
+ "" /* file_system_name */,
+ false /* writable */,
+ base::FilePath() /* mount_path */);
+
+ // Opening for read on a read-only file system is allowed.
+ {
+ OpenFile open_file(NULL,
+ read_only_file_system_info,
+ base::FilePath::FromUTF8Unsafe(kFilePath),
+ ProvidedFileSystemInterface::OPEN_FILE_MODE_READ,
+ base::Bind(&CallbackLogger::OnOpenFile,
+ base::Unretained(&callback_logger)));
+ open_file.SetDispatchEventImplForTesting(
+ base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
+ base::Unretained(&dispatcher)));
+
+ EXPECT_TRUE(open_file.Execute(kRequestId));
+ }
+
+ // Opening for write on a read-only file system is forbidden and must fail.
+ {
+ OpenFile open_file(NULL,
+ read_only_file_system_info,
+ base::FilePath::FromUTF8Unsafe(kFilePath),
+ ProvidedFileSystemInterface::OPEN_FILE_MODE_WRITE,
+ base::Bind(&CallbackLogger::OnOpenFile,
+ base::Unretained(&callback_logger)));
+ open_file.SetDispatchEventImplForTesting(
+ base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
+ base::Unretained(&dispatcher)));
+
+ EXPECT_FALSE(open_file.Execute(kRequestId));
+ }
+}
+
TEST_F(FileSystemProviderOperationsOpenFileTest, OnSuccess) {
util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
CallbackLogger callback_logger;

Powered by Google App Engine
This is Rietveld 408576698