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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_unittest.cc

Issue 845083005: [fsp] Simplify aborting logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests. 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 unified diff | Download patch
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/fileapi/file_stream_write r.h" 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_write r.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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 std::vector<int> cancel_log; 180 std::vector<int> cancel_log;
181 const int cancel_result = writer.Cancel(base::Bind(&LogValue, &cancel_log)); 181 const int cancel_result = writer.Cancel(base::Bind(&LogValue, &cancel_log));
182 EXPECT_EQ(net::ERR_IO_PENDING, cancel_result); 182 EXPECT_EQ(net::ERR_IO_PENDING, cancel_result);
183 base::RunLoop().RunUntilIdle(); 183 base::RunLoop().RunUntilIdle();
184 184
185 EXPECT_EQ(0u, write_log.size()); 185 EXPECT_EQ(0u, write_log.size());
186 ASSERT_EQ(1u, cancel_log.size()); 186 ASSERT_EQ(1u, cancel_log.size());
187 EXPECT_EQ(net::OK, cancel_log[0]); 187 EXPECT_EQ(net::OK, cancel_log[0]);
188 } 188 }
189 189
190 TEST_F(FileSystemProviderFileStreamWriter, Cancel_NotRunning) {
191 std::vector<int> write_log;
192
193 const int64 initial_offset = 0;
194 FileStreamWriter writer(file_url_, initial_offset);
195 scoped_refptr<net::IOBuffer> io_buffer(new net::StringIOBuffer(kTextToWrite));
196
197 std::vector<int> cancel_log;
198 const int cancel_result = writer.Cancel(base::Bind(&LogValue, &cancel_log));
199 EXPECT_EQ(net::ERR_IO_PENDING, cancel_result);
200 base::RunLoop().RunUntilIdle();
201
202 EXPECT_EQ(0u, write_log.size());
203 ASSERT_EQ(1u, cancel_log.size());
204 EXPECT_EQ(net::ERR_UNEXPECTED, cancel_log[0]);
205 }
206
190 TEST_F(FileSystemProviderFileStreamWriter, Write_WrongFile) { 207 TEST_F(FileSystemProviderFileStreamWriter, Write_WrongFile) {
191 std::vector<int> write_log; 208 std::vector<int> write_log;
192 209
193 const int64 initial_offset = 0; 210 const int64 initial_offset = 0;
194 FileStreamWriter writer(wrong_file_url_, initial_offset); 211 FileStreamWriter writer(wrong_file_url_, initial_offset);
195 scoped_refptr<net::IOBuffer> io_buffer(new net::StringIOBuffer(kTextToWrite)); 212 scoped_refptr<net::IOBuffer> io_buffer(new net::StringIOBuffer(kTextToWrite));
196 213
197 const int result = writer.Write(io_buffer.get(), 214 const int result = writer.Write(io_buffer.get(),
198 sizeof(kTextToWrite) - 1, 215 sizeof(kTextToWrite) - 1,
199 base::Bind(&LogValue, &write_log)); 216 base::Bind(&LogValue, &write_log));
(...skipping 26 matching lines...) Expand all
226 243
227 ASSERT_EQ(1u, write_log.size()); 244 ASSERT_EQ(1u, write_log.size());
228 EXPECT_EQ(sizeof(kTextToWrite) - 1, static_cast<size_t>(write_log[0])); 245 EXPECT_EQ(sizeof(kTextToWrite) - 1, static_cast<size_t>(write_log[0]));
229 246
230 const std::string expected_contents = original_contents + kTextToWrite; 247 const std::string expected_contents = original_contents + kTextToWrite;
231 EXPECT_EQ(expected_contents, entry->contents); 248 EXPECT_EQ(expected_contents, entry->contents);
232 } 249 }
233 250
234 } // namespace file_system_provider 251 } // namespace file_system_provider
235 } // namespace chromeos 252 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698