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

Side by Side Diff: google_apis/drive/base_requests_unittest.cc

Issue 1218773003: Implement a DRIVE_REQUEST_TOO_LARGE backoff. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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
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 "google_apis/drive/base_requests.h" 5 #include "google_apis/drive/base_requests.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 " \"message\": \"Rate Limit Exceeded\"\n" 168 " \"message\": \"Rate Limit Exceeded\"\n"
169 " }\n" 169 " }\n"
170 " ],\n" 170 " ],\n"
171 " \"code\": 403,\n" 171 " \"code\": 403,\n"
172 " \"message\": \"Rate Limit Exceeded\"\n" 172 " \"message\": \"Rate Limit Exceeded\"\n"
173 " }\n" 173 " }\n"
174 "}\n"; 174 "}\n";
175 175
176 DriveApiErrorCode error = DRIVE_OTHER_ERROR; 176 DriveApiErrorCode error = DRIVE_OTHER_ERROR;
177 base::RunLoop run_loop; 177 base::RunLoop run_loop;
178 sender_->StartRequestWithRetry( 178 sender_->StartRequestWithAuthRetry(new FakeUrlFetchRequest(
179 new FakeUrlFetchRequest( 179 sender_.get(),
180 sender_.get(), 180 test_util::CreateQuitCallback(
181 test_util::CreateQuitCallback( 181 &run_loop, test_util::CreateCopyResultCallback(&error)),
182 &run_loop, test_util::CreateCopyResultCallback(&error)), 182 test_server_.base_url()));
183 test_server_.base_url()));
184 run_loop.Run(); 183 run_loop.Run();
185 184
186 // HTTP_FORBIDDEN (403) is overridden by the error reason. 185 // HTTP_FORBIDDEN (403) is overridden by the error reason.
187 EXPECT_EQ(HTTP_SERVICE_UNAVAILABLE, error); 186 EXPECT_EQ(HTTP_SERVICE_UNAVAILABLE, error);
188 } 187 }
189 188
190 TEST_F(MultipartUploadRequestBaseTest, Basic) { 189 TEST_F(MultipartUploadRequestBaseTest, Basic) {
191 response_code_ = net::HTTP_OK; 190 response_code_ = net::HTTP_OK;
192 response_body_ = "{\"kind\": \"drive#file\", \"id\": \"file_id\"}"; 191 response_body_ = "{\"kind\": \"drive#file\", \"id\": \"file_id\"}";
193 scoped_ptr<google_apis::FileResource> file; 192 scoped_ptr<google_apis::FileResource> file;
194 DriveApiErrorCode error = DRIVE_OTHER_ERROR; 193 DriveApiErrorCode error = DRIVE_OTHER_ERROR;
195 base::RunLoop run_loop; 194 base::RunLoop run_loop;
196 const base::FilePath source_path = 195 const base::FilePath source_path =
197 google_apis::test_util::GetTestFilePath("chromeos/file_manager/text.txt"); 196 google_apis::test_util::GetTestFilePath("chromeos/file_manager/text.txt");
198 std::string upload_content_type; 197 std::string upload_content_type;
199 std::string upload_content_data; 198 std::string upload_content_data;
200 FakeMultipartUploadRequest* const multipart_request = 199 FakeMultipartUploadRequest* const multipart_request =
201 new FakeMultipartUploadRequest( 200 new FakeMultipartUploadRequest(
202 sender_->blocking_task_runner(), "{json:\"test\"}", "text/plain", 10, 201 sender_->blocking_task_runner(), "{json:\"test\"}", "text/plain", 10,
203 source_path, 202 source_path,
204 test_util::CreateQuitCallback( 203 test_util::CreateQuitCallback(
205 &run_loop, test_util::CreateCopyResultCallback(&error, &file)), 204 &run_loop, test_util::CreateCopyResultCallback(&error, &file)),
206 ProgressCallback(), test_server_.base_url(), &upload_content_type, 205 ProgressCallback(), test_server_.base_url(), &upload_content_type,
207 &upload_content_data); 206 &upload_content_data);
208 multipart_request->SetBoundaryForTesting("TESTBOUNDARY"); 207 multipart_request->SetBoundaryForTesting("TESTBOUNDARY");
209 scoped_ptr<drive::SingleBatchableDelegateRequest> request( 208 scoped_ptr<drive::SingleBatchableDelegateRequest> request(
210 new drive::SingleBatchableDelegateRequest( 209 new drive::SingleBatchableDelegateRequest(
211 sender_.get(), multipart_request)); 210 sender_.get(), multipart_request));
212 sender_->StartRequestWithRetry(request.release()); 211 sender_->StartRequestWithAuthRetry(request.release());
213 run_loop.Run(); 212 run_loop.Run();
214 EXPECT_EQ("multipart/related; boundary=TESTBOUNDARY", upload_content_type); 213 EXPECT_EQ("multipart/related; boundary=TESTBOUNDARY", upload_content_type);
215 EXPECT_EQ( 214 EXPECT_EQ(
216 "--TESTBOUNDARY\n" 215 "--TESTBOUNDARY\n"
217 "Content-Type: application/json\n" 216 "Content-Type: application/json\n"
218 "\n" 217 "\n"
219 "{json:\"test\"}\n" 218 "{json:\"test\"}\n"
220 "--TESTBOUNDARY\n" 219 "--TESTBOUNDARY\n"
221 "Content-Type: text/plain\n" 220 "Content-Type: text/plain\n"
222 "\n" 221 "\n"
223 "This is a sample file. I like chocolate and chips.\n" 222 "This is a sample file. I like chocolate and chips.\n"
224 "\n" 223 "\n"
225 "--TESTBOUNDARY--", 224 "--TESTBOUNDARY--",
226 upload_content_data); 225 upload_content_data);
227 ASSERT_EQ(HTTP_SUCCESS, error); 226 ASSERT_EQ(HTTP_SUCCESS, error);
228 EXPECT_EQ("file_id", file->file_id()); 227 EXPECT_EQ("file_id", file->file_id());
229 } 228 }
230 229
231 } // Namespace google_apis 230 } // Namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698