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

Side by Side Diff: chrome/browser/google_apis/test_util.cc

Issue 11824020: google_apis: Implement DownloadFile in FakeDriveService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add DownloadFile_NonexistingFile test Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/google_apis/test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698