OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/google_apis/test_util.h" | 5 #include "chrome/browser/google_apis/test_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 bool WriteStringToFile(const base::FilePath& file_path, | 58 bool WriteStringToFile(const base::FilePath& file_path, |
59 const std::string& content) { | 59 const std::string& content) { |
60 int result = file_util::WriteFile(file_path, content.data(), content.size()); | 60 int result = file_util::WriteFile(file_path, content.data(), content.size()); |
61 return content.size() == static_cast<size_t>(result); | 61 return content.size() == static_cast<size_t>(result); |
62 } | 62 } |
63 | 63 |
64 bool CreateFileOfSpecifiedSize(const base::FilePath& temp_dir, | 64 bool CreateFileOfSpecifiedSize(const base::FilePath& temp_dir, |
65 size_t size, | 65 size_t size, |
66 base::FilePath* path, | 66 base::FilePath* path, |
67 std::string* data) { | 67 std::string* data) { |
68 if (!file_util::CreateTemporaryFileInDir(temp_dir, path)) | 68 if (!base::CreateTemporaryFileInDir(temp_dir, path)) |
69 return false; | 69 return false; |
70 | 70 |
71 if (size == 0) { | 71 if (size == 0) { |
72 // Note: RandBytesAsString doesn't support generating an empty string. | 72 // Note: RandBytesAsString doesn't support generating an empty string. |
73 data->clear(); | 73 data->clear(); |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 *data = base::RandBytesAsString(size); | 77 *data = base::RandBytesAsString(size); |
78 return WriteStringToFile(*path, *data); | 78 return WriteStringToFile(*path, *data); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return result; | 174 return result; |
175 } | 175 } |
176 | 176 |
177 void TestGetContentCallback::OnGetContent(google_apis::GDataErrorCode error, | 177 void TestGetContentCallback::OnGetContent(google_apis::GDataErrorCode error, |
178 scoped_ptr<std::string> data) { | 178 scoped_ptr<std::string> data) { |
179 data_.push_back(data.release()); | 179 data_.push_back(data.release()); |
180 } | 180 } |
181 | 181 |
182 } // namespace test_util | 182 } // namespace test_util |
183 } // namespace google_apis | 183 } // namespace google_apis |
OLD | NEW |