| 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 "google_apis/drive/test_util.h" | 5 #include "google_apis/drive/test_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Returns a HttpResponse created from the given file path. | 91 // Returns a HttpResponse created from the given file path. |
| 92 scoped_ptr<net::test_server::BasicHttpResponse> CreateHttpResponseFromFile( | 92 scoped_ptr<net::test_server::BasicHttpResponse> CreateHttpResponseFromFile( |
| 93 const base::FilePath& file_path) { | 93 const base::FilePath& file_path) { |
| 94 std::string content; | 94 std::string content; |
| 95 if (!base::ReadFileToString(file_path, &content)) | 95 if (!base::ReadFileToString(file_path, &content)) |
| 96 return scoped_ptr<net::test_server::BasicHttpResponse>(); | 96 return scoped_ptr<net::test_server::BasicHttpResponse>(); |
| 97 | 97 |
| 98 std::string content_type = "text/plain"; | 98 std::string content_type = "text/plain"; |
| 99 if (EndsWith(file_path.AsUTF8Unsafe(), ".json", true /* case sensitive */)) | 99 if (base::EndsWith(file_path.AsUTF8Unsafe(), ".json", |
| 100 true /* case sensitive */)) |
| 100 content_type = "application/json"; | 101 content_type = "application/json"; |
| 101 | 102 |
| 102 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 103 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 103 new net::test_server::BasicHttpResponse); | 104 new net::test_server::BasicHttpResponse); |
| 104 http_response->set_code(net::HTTP_OK); | 105 http_response->set_code(net::HTTP_OK); |
| 105 http_response->set_content(content); | 106 http_response->set_content(content); |
| 106 http_response->set_content_type(content_type); | 107 http_response->set_content_type(content_type); |
| 107 return http_response.Pass(); | 108 return http_response.Pass(); |
| 108 } | 109 } |
| 109 | 110 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return result; | 173 return result; |
| 173 } | 174 } |
| 174 | 175 |
| 175 void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error, | 176 void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error, |
| 176 scoped_ptr<std::string> data) { | 177 scoped_ptr<std::string> data) { |
| 177 data_.push_back(data.release()); | 178 data_.push_back(data.release()); |
| 178 } | 179 } |
| 179 | 180 |
| 180 } // namespace test_util | 181 } // namespace test_util |
| 181 } // namespace google_apis | 182 } // namespace google_apis |
| OLD | NEW |