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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return scoped_ptr<net::test_server::HttpResponse>(); 180 return scoped_ptr<net::test_server::HttpResponse>();
181 } 181 }
182 182
183 http_request_ = request; 183 http_request_ = request;
184 184
185 scoped_ptr<net::test_server::BasicHttpResponse> response( 185 scoped_ptr<net::test_server::BasicHttpResponse> response(
186 new net::test_server::BasicHttpResponse); 186 new net::test_server::BasicHttpResponse);
187 response->set_code(net::HTTP_PRECONDITION_FAILED); 187 response->set_code(net::HTTP_PRECONDITION_FAILED);
188 188
189 std::string content; 189 std::string content;
190 if (file_util::ReadFileToString(expected_precondition_failed_file_path_, 190 if (base::ReadFileToString(expected_precondition_failed_file_path_,
191 &content)) { 191 &content)) {
192 response->set_content(content); 192 response->set_content(content);
193 response->set_content_type("application/json"); 193 response->set_content_type("application/json");
194 } 194 }
195 195
196 return response.PassAs<net::test_server::HttpResponse>(); 196 return response.PassAs<net::test_server::HttpResponse>();
197 } 197 }
198 198
199 // Returns the response based on set expected upload url. 199 // Returns the response based on set expected upload url.
200 // The response contains the url in its "Location: " header. Also, it doesn't 200 // The response contains the url in its "Location: " header. Also, it doesn't
201 // have any content. 201 // have any content.
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 test_util::CreateQuitCallback( 1581 test_util::CreateQuitCallback(
1582 &run_loop, 1582 &run_loop,
1583 test_util::CreateCopyResultCallback(&result_code, &temp_file)), 1583 test_util::CreateCopyResultCallback(&result_code, &temp_file)),
1584 GetContentCallback(), 1584 GetContentCallback(),
1585 ProgressCallback()); 1585 ProgressCallback());
1586 request_sender_->StartRequestWithRetry(request); 1586 request_sender_->StartRequestWithRetry(request);
1587 run_loop.Run(); 1587 run_loop.Run();
1588 } 1588 }
1589 1589
1590 std::string contents; 1590 std::string contents;
1591 file_util::ReadFileToString(temp_file, &contents); 1591 base::ReadFileToString(temp_file, &contents);
1592 base::DeleteFile(temp_file, false); 1592 base::DeleteFile(temp_file, false);
1593 1593
1594 EXPECT_EQ(HTTP_SUCCESS, result_code); 1594 EXPECT_EQ(HTTP_SUCCESS, result_code);
1595 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 1595 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
1596 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); 1596 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url);
1597 EXPECT_EQ(kDownloadedFilePath, temp_file); 1597 EXPECT_EQ(kDownloadedFilePath, temp_file);
1598 1598
1599 const std::string expected_contents = kTestId + kTestId + kTestId; 1599 const std::string expected_contents = kTestId + kTestId + kTestId;
1600 EXPECT_EQ(expected_contents, contents); 1600 EXPECT_EQ(expected_contents, contents);
1601 } 1601 }
1602 1602
1603 } // namespace google_apis 1603 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698