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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/close_file_unittest.cc

Issue 335753004: [fsp] Cleanup handling errors for operation requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 6 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 kOpenRequestId, 137 kOpenRequestId,
138 base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr())); 138 base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
139 close_file.SetDispatchEventImplForTesting( 139 close_file.SetDispatchEventImplForTesting(
140 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, 140 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
141 base::Unretained(&dispatcher))); 141 base::Unretained(&dispatcher)));
142 142
143 EXPECT_FALSE(close_file.Execute(kRequestId)); 143 EXPECT_FALSE(close_file.Execute(kRequestId));
144 } 144 }
145 145
146 TEST_F(FileSystemProviderOperationsCloseFileTest, OnSuccess) { 146 TEST_F(FileSystemProviderOperationsCloseFileTest, OnSuccess) {
147 using extensions::api::file_system_provider_internal::
148 CloseFileRequestedSuccess::Params;
149
150 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 147 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
151 CallbackLogger callback_logger; 148 CallbackLogger callback_logger;
152 149
153 CloseFile close_file( 150 CloseFile close_file(
154 NULL, 151 NULL,
155 file_system_info_, 152 file_system_info_,
156 kOpenRequestId, 153 kOpenRequestId,
157 base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr())); 154 base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
158 close_file.SetDispatchEventImplForTesting( 155 close_file.SetDispatchEventImplForTesting(
159 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, 156 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
160 base::Unretained(&dispatcher))); 157 base::Unretained(&dispatcher)));
161 158
162 EXPECT_TRUE(close_file.Execute(kRequestId)); 159 EXPECT_TRUE(close_file.Execute(kRequestId));
163 160
164 close_file.OnSuccess(kRequestId, 161 close_file.OnSuccess(kRequestId,
165 scoped_ptr<RequestValue>(new RequestValue()), 162 scoped_ptr<RequestValue>(new RequestValue()),
166 false /* has_more */); 163 false /* has_more */);
167 ASSERT_EQ(1u, callback_logger.events().size()); 164 ASSERT_EQ(1u, callback_logger.events().size());
168 EXPECT_EQ(base::File::FILE_OK, callback_logger.events()[0]); 165 EXPECT_EQ(base::File::FILE_OK, callback_logger.events()[0]);
169 } 166 }
170 167
171 TEST_F(FileSystemProviderOperationsCloseFileTest, OnError) { 168 TEST_F(FileSystemProviderOperationsCloseFileTest, OnError) {
172 using extensions::api::file_system_provider_internal::
173 CloseFileRequestedError::Params;
174
175 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); 169 LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */);
176 CallbackLogger callback_logger; 170 CallbackLogger callback_logger;
177 171
178 CloseFile close_file( 172 CloseFile close_file(
179 NULL, 173 NULL,
180 file_system_info_, 174 file_system_info_,
181 kOpenRequestId, 175 kOpenRequestId,
182 base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr())); 176 base::Bind(&CallbackLogger::OnCloseFile, callback_logger.GetWeakPtr()));
183 close_file.SetDispatchEventImplForTesting( 177 close_file.SetDispatchEventImplForTesting(
184 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl, 178 base::Bind(&LoggingDispatchEventImpl::OnDispatchEventImpl,
185 base::Unretained(&dispatcher))); 179 base::Unretained(&dispatcher)));
186 180
187 EXPECT_TRUE(close_file.Execute(kRequestId)); 181 EXPECT_TRUE(close_file.Execute(kRequestId));
188 182
189 close_file.OnError(kRequestId, base::File::FILE_ERROR_TOO_MANY_OPENED); 183 close_file.OnError(kRequestId,
184 scoped_ptr<RequestValue>(new RequestValue()),
185 base::File::FILE_ERROR_TOO_MANY_OPENED);
190 ASSERT_EQ(1u, callback_logger.events().size()); 186 ASSERT_EQ(1u, callback_logger.events().size());
191 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, 187 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED,
192 callback_logger.events()[0]); 188 callback_logger.events()[0]);
193 } 189 }
194 190
195 } // namespace operations 191 } // namespace operations
196 } // namespace file_system_provider 192 } // namespace file_system_provider
197 } // namespace chromeos 193 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698