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

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

Issue 18211008: Add resource ID based download requests in {GDataWapi/Drive} requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reorder parameters. Created 7 years, 5 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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // parameters like HTTP method (ex. some requests should use DELETE 79 // parameters like HTTP method (ex. some requests should use DELETE
80 // instead of GET). 80 // instead of GET).
81 net::test_server::HttpRequest http_request_; 81 net::test_server::HttpRequest http_request_;
82 }; 82 };
83 83
84 TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) { 84 TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) {
85 GDataErrorCode result_code = GDATA_OTHER_ERROR; 85 GDataErrorCode result_code = GDATA_OTHER_ERROR;
86 base::FilePath temp_file; 86 base::FilePath temp_file;
87 { 87 {
88 base::RunLoop run_loop; 88 base::RunLoop run_loop;
89 DownloadFileRequest* request = new DownloadFileRequest( 89 DownloadFileRequestBase* request = new DownloadFileRequestBase(
90 request_sender_.get(), 90 request_sender_.get(),
91 test_util::CreateQuitCallback( 91 test_util::CreateQuitCallback(
92 &run_loop, 92 &run_loop,
93 test_util::CreateCopyResultCallback(&result_code, &temp_file)), 93 test_util::CreateCopyResultCallback(&result_code, &temp_file)),
94 GetContentCallback(), 94 GetContentCallback(),
95 ProgressCallback(), 95 ProgressCallback(),
96 test_server_.GetURL("/files/gdata/testfile.txt"), 96 test_server_.GetURL("/files/gdata/testfile.txt"),
97 GetTestCachedFilePath( 97 GetTestCachedFilePath(
98 base::FilePath::FromUTF8Unsafe("cached_testfile.txt"))); 98 base::FilePath::FromUTF8Unsafe("cached_testfile.txt")));
99 request_sender_->StartRequestWithRetry(request); 99 request_sender_->StartRequestWithRetry(request);
(...skipping 13 matching lines...) Expand all
113 std::string expected_contents; 113 std::string expected_contents;
114 file_util::ReadFileToString(expected_path, &expected_contents); 114 file_util::ReadFileToString(expected_path, &expected_contents);
115 EXPECT_EQ(expected_contents, contents); 115 EXPECT_EQ(expected_contents, contents);
116 } 116 }
117 117
118 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) { 118 TEST_F(BaseRequestsServerTest, DownloadFileRequest_NonExistentFile) {
119 GDataErrorCode result_code = GDATA_OTHER_ERROR; 119 GDataErrorCode result_code = GDATA_OTHER_ERROR;
120 base::FilePath temp_file; 120 base::FilePath temp_file;
121 { 121 {
122 base::RunLoop run_loop; 122 base::RunLoop run_loop;
123 DownloadFileRequest* request = new DownloadFileRequest( 123 DownloadFileRequestBase* request = new DownloadFileRequestBase(
124 request_sender_.get(), 124 request_sender_.get(),
125 test_util::CreateQuitCallback( 125 test_util::CreateQuitCallback(
126 &run_loop, 126 &run_loop,
127 test_util::CreateCopyResultCallback(&result_code, &temp_file)), 127 test_util::CreateCopyResultCallback(&result_code, &temp_file)),
128 GetContentCallback(), 128 GetContentCallback(),
129 ProgressCallback(), 129 ProgressCallback(),
130 test_server_.GetURL("/files/gdata/no-such-file.txt"), 130 test_server_.GetURL("/files/gdata/no-such-file.txt"),
131 GetTestCachedFilePath( 131 GetTestCachedFilePath(
132 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); 132 base::FilePath::FromUTF8Unsafe("cache_no-such-file.txt")));
133 request_sender_->StartRequestWithRetry(request); 133 request_sender_->StartRequestWithRetry(request);
134 run_loop.Run(); 134 run_loop.Run();
135 } 135 }
136 EXPECT_EQ(HTTP_NOT_FOUND, result_code); 136 EXPECT_EQ(HTTP_NOT_FOUND, result_code);
137 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 137 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
138 EXPECT_EQ("/files/gdata/no-such-file.txt", 138 EXPECT_EQ("/files/gdata/no-such-file.txt",
139 http_request_.relative_url); 139 http_request_.relative_url);
140 // Do not verify the not found message. 140 // Do not verify the not found message.
141 } 141 }
142 142
143 } // namespace google_apis 143 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/base_requests.cc ('k') | chrome/browser/google_apis/drive_api_requests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698