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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/create_directory_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, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/file_system_provider/operations/create_directo ry.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/create_directo ry.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 false /* exclusive */, 108 false /* exclusive */,
109 true /* recursive */, 109 true /* recursive */,
110 base::Bind(&util::LogStatusCallback, &callback_log)); 110 base::Bind(&util::LogStatusCallback, &callback_log));
111 create_directory.SetDispatchEventImplForTesting( 111 create_directory.SetDispatchEventImplForTesting(
112 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 112 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
113 base::Unretained(&dispatcher))); 113 base::Unretained(&dispatcher)));
114 114
115 EXPECT_FALSE(create_directory.Execute(kRequestId)); 115 EXPECT_FALSE(create_directory.Execute(kRequestId));
116 } 116 }
117 117
118 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, Execute_ReadOnly) {
119 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
120 util::StatusCallbackLog callback_log;
121
122 const ProvidedFileSystemInfo read_only_file_system_info(
123 kExtensionId,
124 kFileSystemId,
125 "" /* file_system_name */,
126 false /* writable */,
127 base::FilePath() /* mount_path */);
128
129 CreateDirectory create_directory(
130 NULL,
131 read_only_file_system_info,
132 base::FilePath::FromUTF8Unsafe(kDirectoryPath),
133 false /* exclusive */,
134 true /* recursive */,
135 base::Bind(&util::LogStatusCallback, &callback_log));
136 create_directory.SetDispatchEventImplForTesting(
137 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
138 base::Unretained(&dispatcher)));
139
140 EXPECT_FALSE(create_directory.Execute(kRequestId));
141 }
142
118 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, OnSuccess) { 143 TEST_F(FileSystemProviderOperationsCreateDirectoryTest, OnSuccess) {
119 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 144 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
120 util::StatusCallbackLog callback_log; 145 util::StatusCallbackLog callback_log;
121 146
122 CreateDirectory create_directory( 147 CreateDirectory create_directory(
123 NULL, 148 NULL,
124 file_system_info_, 149 file_system_info_,
125 base::FilePath::FromUTF8Unsafe(kDirectoryPath), 150 base::FilePath::FromUTF8Unsafe(kDirectoryPath),
126 false /* exclusive */, 151 false /* exclusive */,
127 true /* recursive */, 152 true /* recursive */,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 create_directory.OnError(kRequestId, 184 create_directory.OnError(kRequestId,
160 scoped_ptr<RequestValue>(new RequestValue()), 185 scoped_ptr<RequestValue>(new RequestValue()),
161 base::File::FILE_ERROR_TOO_MANY_OPENED); 186 base::File::FILE_ERROR_TOO_MANY_OPENED);
162 ASSERT_EQ(1u, callback_log.size()); 187 ASSERT_EQ(1u, callback_log.size());
163 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); 188 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]);
164 } 189 }
165 190
166 } // namespace operations 191 } // namespace operations
167 } // namespace file_system_provider 192 } // namespace file_system_provider
168 } // namespace chromeos 193 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698