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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 void CopyResultsFromGetAccountMetadataCallback( | 111 void CopyResultsFromGetAccountMetadataCallback( |
112 GDataErrorCode* error_out, | 112 GDataErrorCode* error_out, |
113 scoped_ptr<AccountMetadataFeed>* account_metadata_out, | 113 scoped_ptr<AccountMetadataFeed>* account_metadata_out, |
114 GDataErrorCode error_in, | 114 GDataErrorCode error_in, |
115 scoped_ptr<AccountMetadataFeed> account_metadata_in) { | 115 scoped_ptr<AccountMetadataFeed> account_metadata_in) { |
116 account_metadata_out->swap(account_metadata_in); | 116 account_metadata_out->swap(account_metadata_in); |
117 *error_out = error_in; | 117 *error_out = error_in; |
118 } | 118 } |
119 | 119 |
| 120 void CopyResultsFromDownloadActionCallback( |
| 121 GDataErrorCode* error_out, |
| 122 FilePath* temp_file_out, |
| 123 GDataErrorCode error_in, |
| 124 const FilePath& temp_file_in) { |
| 125 *error_out = error_in; |
| 126 *temp_file_out = temp_file_in; |
| 127 } |
| 128 |
120 // Returns a HttpResponse created from the given file path. | 129 // Returns a HttpResponse created from the given file path. |
121 scoped_ptr<test_server::HttpResponse> CreateHttpResponseFromFile( | 130 scoped_ptr<test_server::HttpResponse> CreateHttpResponseFromFile( |
122 const FilePath& file_path) { | 131 const FilePath& file_path) { |
123 std::string content; | 132 std::string content; |
124 if (!file_util::ReadFileToString(file_path, &content)) | 133 if (!file_util::ReadFileToString(file_path, &content)) |
125 return scoped_ptr<test_server::HttpResponse>(); | 134 return scoped_ptr<test_server::HttpResponse>(); |
126 | 135 |
127 std::string content_type = "text/plain"; | 136 std::string content_type = "text/plain"; |
128 if (EndsWith(file_path.AsUTF8Unsafe(), ".json", true /* case sensitive */)) { | 137 if (EndsWith(file_path.AsUTF8Unsafe(), ".json", true /* case sensitive */)) { |
129 content_type = "application/json"; | 138 content_type = "application/json"; |
130 } else if (EndsWith(file_path.AsUTF8Unsafe(), ".xml", true)) { | 139 } else if (EndsWith(file_path.AsUTF8Unsafe(), ".xml", true)) { |
131 content_type = "application/atom+xml"; | 140 content_type = "application/atom+xml"; |
132 } | 141 } |
133 | 142 |
134 scoped_ptr<test_server::HttpResponse> http_response( | 143 scoped_ptr<test_server::HttpResponse> http_response( |
135 new test_server::HttpResponse); | 144 new test_server::HttpResponse); |
136 http_response->set_code(test_server::SUCCESS); | 145 http_response->set_code(test_server::SUCCESS); |
137 http_response->set_content(content); | 146 http_response->set_content(content); |
138 http_response->set_content_type(content_type); | 147 http_response->set_content_type(content_type); |
139 return http_response.Pass(); | 148 return http_response.Pass(); |
140 } | 149 } |
141 | 150 |
142 } // namespace test_util | 151 } // namespace test_util |
143 } // namespace google_apis | 152 } // namespace google_apis |
OLD | NEW |