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

Side by Side Diff: content/browser/fileapi/file_system_operation_impl_unittest.cc

Issue 536453007: Add truncation to StreamCopyOrMoveImpl and test case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | webkit/browser/fileapi/copy_or_move_operation_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webkit/browser/fileapi/file_system_operation_impl.h" 5 #include "webkit/browser/fileapi/file_system_operation_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace { 43 namespace {
44 44
45 const int kFileOperationStatusNotSet = 1; 45 const int kFileOperationStatusNotSet = 1;
46 46
47 void AssertFileErrorEq(const tracked_objects::Location& from_here, 47 void AssertFileErrorEq(const tracked_objects::Location& from_here,
48 base::File::Error expected, 48 base::File::Error expected,
49 base::File::Error actual) { 49 base::File::Error actual) {
50 ASSERT_EQ(expected, actual) << from_here.ToString(); 50 ASSERT_EQ(expected, actual) << from_here.ToString();
51 } 51 }
52 52
53 void AssertFileErrorEqWithClosure(
54 const tracked_objects::Location& from_here,
55 base::File::Error expected,
56 base::Closure closure,
57 base::File::Error actual) {
58 ASSERT_EQ(expected, actual) << from_here.ToString();
59 closure.Run();
60 }
61
53 } // namespace 62 } // namespace
54 63
55 // Test class for FileSystemOperationImpl. 64 // Test class for FileSystemOperationImpl.
56 class FileSystemOperationImplTest 65 class FileSystemOperationImplTest
57 : public testing::Test { 66 : public testing::Test {
58 public: 67 public:
59 FileSystemOperationImplTest() 68 FileSystemOperationImplTest()
60 : status_(kFileOperationStatusNotSet), 69 : status_(kFileOperationStatusNotSet),
61 weak_factory_(this) {} 70 weak_factory_(this) {}
62 71
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); 1289 base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK));
1281 base::RunLoop().RunUntilIdle(); 1290 base::RunLoop().RunUntilIdle();
1282 1291
1283 expected_usage += grandchild_file_size + grandchild_path_cost; 1292 expected_usage += grandchild_file_size + grandchild_path_cost;
1284 usage = GetUsage(); 1293 usage = GetUsage();
1285 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, 1294 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size,
1286 GetDataSizeOnDisk()); 1295 GetDataSizeOnDisk());
1287 EXPECT_EQ(expected_usage, usage); 1296 EXPECT_EQ(expected_usage, usage);
1288 } 1297 }
1289 1298
1299 TEST_F(FileSystemOperationImplTest,
1300 TestCopySuccessSrcFileWithDifferentFileSize) {
1301 FileSystemURL src_file(CreateFile("src"));
1302 FileSystemURL dest_file(CreateFile("dest"));
1303
1304 {
1305 base::RunLoop run_loop;
1306 operation_runner()->Truncate(
1307 dest_file, 6,
1308 base::Bind(&AssertFileErrorEqWithClosure,
1309 FROM_HERE,
1310 base::File::FILE_OK,
1311 run_loop.QuitClosure()));
1312 run_loop.Run();
1313 }
1314
1315 {
1316 base::RunLoop run_loop;
1317 operation_runner()->Copy(
1318 src_file, dest_file, FileSystemOperation::OPTION_NONE,
1319 FileSystemOperationRunner::CopyProgressCallback(),
1320 base::Bind(&AssertFileErrorEqWithClosure,
1321 FROM_HERE,
1322 base::File::FILE_OK,
1323 run_loop.QuitClosure()));
1324 run_loop.Run();
1325 }
1326 EXPECT_EQ(0, GetFileSize("dest"));
1327 }
1328
1290 } // namespace content 1329 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | webkit/browser/fileapi/copy_or_move_operation_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698