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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/copy_entry_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/copy_entry.h" 5 #include "chrome/browser/chromeos/file_system_provider/operations/copy_entry.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 base::FilePath::FromUTF8Unsafe(kSourcePath), 101 base::FilePath::FromUTF8Unsafe(kSourcePath),
102 base::FilePath::FromUTF8Unsafe(kTargetPath), 102 base::FilePath::FromUTF8Unsafe(kTargetPath),
103 base::Bind(&util::LogStatusCallback, &callback_log)); 103 base::Bind(&util::LogStatusCallback, &callback_log));
104 copy_entry.SetDispatchEventImplForTesting( 104 copy_entry.SetDispatchEventImplForTesting(
105 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, 105 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
106 base::Unretained(&dispatcher))); 106 base::Unretained(&dispatcher)));
107 107
108 EXPECT_FALSE(copy_entry.Execute(kRequestId)); 108 EXPECT_FALSE(copy_entry.Execute(kRequestId));
109 } 109 }
110 110
111 TEST_F(FileSystemProviderOperationsCopyEntryTest, Execute_ReadOnly) {
112 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
113 util::StatusCallbackLog callback_log;
114
115 const ProvidedFileSystemInfo read_only_file_system_info(
116 kExtensionId,
117 kFileSystemId,
118 "" /* file_system_name */,
119 false /* writable */,
120 base::FilePath() /* mount_path */);
121
122 CopyEntry copy_entry(NULL,
123 read_only_file_system_info,
124 base::FilePath::FromUTF8Unsafe(kSourcePath),
125 base::FilePath::FromUTF8Unsafe(kTargetPath),
126 base::Bind(&util::LogStatusCallback, &callback_log));
127 copy_entry.SetDispatchEventImplForTesting(
128 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl,
129 base::Unretained(&dispatcher)));
130
131 EXPECT_FALSE(copy_entry.Execute(kRequestId));
132 }
133
111 TEST_F(FileSystemProviderOperationsCopyEntryTest, OnSuccess) { 134 TEST_F(FileSystemProviderOperationsCopyEntryTest, OnSuccess) {
112 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 135 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
113 util::StatusCallbackLog callback_log; 136 util::StatusCallbackLog callback_log;
114 137
115 CopyEntry copy_entry(NULL, 138 CopyEntry copy_entry(NULL,
116 file_system_info_, 139 file_system_info_,
117 base::FilePath::FromUTF8Unsafe(kSourcePath), 140 base::FilePath::FromUTF8Unsafe(kSourcePath),
118 base::FilePath::FromUTF8Unsafe(kTargetPath), 141 base::FilePath::FromUTF8Unsafe(kTargetPath),
119 base::Bind(&util::LogStatusCallback, &callback_log)); 142 base::Bind(&util::LogStatusCallback, &callback_log));
120 copy_entry.SetDispatchEventImplForTesting( 143 copy_entry.SetDispatchEventImplForTesting(
(...skipping 27 matching lines...) Expand all
148 copy_entry.OnError(kRequestId, 171 copy_entry.OnError(kRequestId,
149 scoped_ptr<RequestValue>(new RequestValue()), 172 scoped_ptr<RequestValue>(new RequestValue()),
150 base::File::FILE_ERROR_TOO_MANY_OPENED); 173 base::File::FILE_ERROR_TOO_MANY_OPENED);
151 ASSERT_EQ(1u, callback_log.size()); 174 ASSERT_EQ(1u, callback_log.size());
152 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); 175 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]);
153 } 176 }
154 177
155 } // namespace operations 178 } // namespace operations
156 } // namespace file_system_provider 179 } // namespace file_system_provider
157 } // namespace chromeos 180 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698