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

Side by Side Diff: chrome/browser/google_apis/base_requests_server_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 "chrome/browser/google_apis/base_requests.h" 5 #include "chrome/browser/google_apis/base_requests.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 GetContentCallback(), 83 GetContentCallback(),
84 ProgressCallback(), 84 ProgressCallback(),
85 test_server_.GetURL("/files/gdata/testfile.txt"), 85 test_server_.GetURL("/files/gdata/testfile.txt"),
86 GetTestCachedFilePath( 86 GetTestCachedFilePath(
87 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); 87 base::FilePath::FromUTF8Unsafe("cached_testfile.txt")));
88 request_sender_->StartRequestWithRetry(request); 88 request_sender_->StartRequestWithRetry(request);
89 run_loop.Run(); 89 run_loop.Run();
90 } 90 }
91 91
92 std::string contents; 92 std::string contents;
93 file_util::ReadFileToString(temp_file, &contents); 93 base::ReadFileToString(temp_file, &contents);
94 base::DeleteFile(temp_file, false); 94 base::DeleteFile(temp_file, false);
95 95
96 EXPECT_EQ(HTTP_SUCCESS, result_code); 96 EXPECT_EQ(HTTP_SUCCESS, result_code);
97 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 97 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
98 EXPECT_EQ("/files/gdata/testfile.txt", http_request_.relative_url); 98 EXPECT_EQ("/files/gdata/testfile.txt", http_request_.relative_url);
99 99
100 const base::FilePath expected_path = 100 const base::FilePath expected_path =
101 test_util::GetTestFilePath("gdata/testfile.txt"); 101 test_util::GetTestFilePath("gdata/testfile.txt");
102 std::string expected_contents; 102 std::string expected_contents;
103 file_util::ReadFileToString(expected_path, &expected_contents); 103 base::ReadFileToString(expected_path, &expected_contents);
104 EXPECT_EQ(expected_contents, contents); 104 EXPECT_EQ(expected_contents, contents);
105 } 105 }
106 106
107 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) { 107 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) {
108 GDataErrorCode result_code = GDATA_OTHER_ERROR; 108 GDataErrorCode result_code = GDATA_OTHER_ERROR;
109 base::FilePath temp_file; 109 base::FilePath temp_file;
110 { 110 {
111 base::RunLoop run_loop; 111 base::RunLoop run_loop;
112 DownloadFileRequestBase* request = new DownloadFileRequestBase( 112 DownloadFileRequestBase* request = new DownloadFileRequestBase(
113 request_sender_.get(), 113 request_sender_.get(),
114 test_util::CreateQuitCallback( 114 test_util::CreateQuitCallback(
115 &run_loop, 115 &run_loop,
116 test_util::CreateCopyResultCallback(&result_code, &temp_file)), 116 test_util::CreateCopyResultCallback(&result_code, &temp_file)),
117 GetContentCallback(), 117 GetContentCallback(),
118 ProgressCallback(), 118 ProgressCallback(),
119 test_server_.GetURL("/files/gdata/no-such-file.txt"), 119 test_server_.GetURL("/files/gdata/no-such-file.txt"),
120 GetTestCachedFilePath( 120 GetTestCachedFilePath(
121 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); 121 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt")));
122 request_sender_->StartRequestWithRetry(request); 122 request_sender_->StartRequestWithRetry(request);
123 run_loop.Run(); 123 run_loop.Run();
124 } 124 }
125 EXPECT_EQ(HTTP_NOT_FOUND, result_code); 125 EXPECT_EQ(HTTP_NOT_FOUND, result_code);
126 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 126 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
127 EXPECT_EQ("/files/gdata/no-such-file.txt", 127 EXPECT_EQ("/files/gdata/no-such-file.txt",
128 http_request_.relative_url); 128 http_request_.relative_url);
129 // Do not verify the not found message. 129 // Do not verify the not found message.
130 } 130 }
131 131
132 } // namespace google_apis 132 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google/google_util_chromeos.cc ('k') | chrome/browser/google_apis/drive_api_requests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698