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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/truncate_operation_unittest.cc

Issue 102873002: Move GetFileSize, NormalizeFilePath to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 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 "chrome/browser/chromeos/drive/file_system/truncate_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/truncate_operation.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "chrome/browser/chromeos/drive/drive.pb.h" 10 #include "chrome/browser/chromeos/drive/drive.pb.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(&internal::FileCache::GetFile, 54 base::Bind(&internal::FileCache::GetFile,
55 base::Unretained(cache()), 55 base::Unretained(cache()),
56 GetLocalId(file_in_root), &local_path), 56 GetLocalId(file_in_root), &local_path),
57 google_apis::test_util::CreateCopyResultCallback(&error)); 57 google_apis::test_util::CreateCopyResultCallback(&error));
58 test_util::RunBlockingPoolTask(); 58 test_util::RunBlockingPoolTask();
59 ASSERT_EQ(FILE_ERROR_OK, error); 59 ASSERT_EQ(FILE_ERROR_OK, error);
60 60
61 // The local file should be truncated. 61 // The local file should be truncated.
62 int64 local_file_size = 0; 62 int64 local_file_size = 0;
63 file_util::GetFileSize(local_path, &local_file_size); 63 base::GetFileSize(local_path, &local_file_size);
64 EXPECT_EQ(1, local_file_size); 64 EXPECT_EQ(1, local_file_size);
65 } 65 }
66 66
67 TEST_F(TruncateOperationTest, NegativeSize) { 67 TEST_F(TruncateOperationTest, NegativeSize) {
68 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); 68 base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt"));
69 ResourceEntry src_entry; 69 ResourceEntry src_entry;
70 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry)); 70 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(file_in_root, &src_entry));
71 const int64 file_size = src_entry.file_info().size(); 71 const int64 file_size = src_entry.file_info().size();
72 72
73 // Make sure the file has at least 2 bytes. 73 // Make sure the file has at least 2 bytes.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // The local file should be truncated. 124 // The local file should be truncated.
125 std::string content; 125 std::string content;
126 ASSERT_TRUE(base::ReadFileToString(local_path, &content)); 126 ASSERT_TRUE(base::ReadFileToString(local_path, &content));
127 127
128 EXPECT_EQ(file_size + 10, static_cast<int64>(content.size())); 128 EXPECT_EQ(file_size + 10, static_cast<int64>(content.size()));
129 // All trailing 10 bytes should be '\0'. 129 // All trailing 10 bytes should be '\0'.
130 EXPECT_EQ(std::string(10, '\0'), content.substr(file_size)); 130 EXPECT_EQ(std::string(10, '\0'), content.substr(file_size));
131 } 131 }
132 132
133 } // namespace file_system 133 } // namespace file_system
134 } // namespace drive 134 } // namespace drive
viettrungluu 2013/12/03 21:20:19 I got bored here. I assume the rest is okay.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698