| Index: google_apis/drive/drive_api_requests_unittest.cc
|
| diff --git a/google_apis/drive/drive_api_requests_unittest.cc b/google_apis/drive/drive_api_requests_unittest.cc
|
| index 064ec76e918ad793d37874cbf4f92f8f8f69b888..566bd67f6170598ae3af1fb8d50d68197b87b450 100644
|
| --- a/google_apis/drive/drive_api_requests_unittest.cc
|
| +++ b/google_apis/drive/drive_api_requests_unittest.cc
|
| @@ -410,6 +410,29 @@ class DriveApiRequestsTest : public testing::Test {
|
| scoped_ptr<net::test_server::BasicHttpResponse> response(
|
| new net::test_server::BasicHttpResponse);
|
| response->set_code(net::HTTP_OK);
|
| + response->set_content("{}");
|
| + response->set_content_type("text/plain");
|
| + response->set_content(
|
| + "--BOUNDARY\r\n"
|
| + "Content-Type: application/http\r\n"
|
| + "\r\n"
|
| + "HTTP/1.1 200 OK\r\n"
|
| + "Content-Type: application/json; charset=UTF-8\r\n"
|
| + "\r\n"
|
| + "{\r\n"
|
| + " \"kind\": \"drive#file\",\r\n"
|
| + " \"id\": \"file_id_1\"\r\n"
|
| + "}\r\n"
|
| + "\r\n"
|
| + "--BOUNDARY\r\n"
|
| + "Content-Type: application/http\r\n"
|
| + "\r\n"
|
| + "HTTP/1.1 503 Service Unavailable\r\n"
|
| + "Content-Type: application/json; charset=UTF-8\r\n"
|
| + "\r\n"
|
| + "{}\r\n"
|
| + "\r\n"
|
| + "--BOUNDARY--\r\n");
|
| return response.Pass();
|
| }
|
|
|
| @@ -1916,33 +1939,25 @@ TEST_F(DriveApiRequestsTest, BatchUploadRequest) {
|
| ASSERT_TRUE(test_util::WriteStringToFile(kTestFilePath, kTestContent));
|
|
|
| // Create batch request.
|
| - drive::BatchUploadRequest* const request = new drive::BatchUploadRequest(
|
| - request_sender_.get(), *url_generator_);
|
| + drive::BatchUploadRequest* const request =
|
| + new drive::BatchUploadRequest(request_sender_.get(), *url_generator_);
|
| request->SetBoundaryForTesting("OUTERBOUNDARY");
|
| request_sender_->StartRequestWithRetry(request);
|
|
|
| // Create child request.
|
| - DriveApiErrorCode error = DRIVE_OTHER_ERROR;
|
| - scoped_ptr<FileResource> file_resource;
|
| + DriveApiErrorCode errors[] = {DRIVE_OTHER_ERROR, DRIVE_OTHER_ERROR};
|
| + scoped_ptr<FileResource> file_resources[2];
|
| base::RunLoop run_loop[2];
|
| for (int i = 0; i < 2; ++i) {
|
| const FileResourceCallback callback = test_util::CreateQuitCallback(
|
| &run_loop[i],
|
| - test_util::CreateCopyResultCallback(&error, &file_resource));
|
| + test_util::CreateCopyResultCallback(&errors[i], &file_resources[i]));
|
| drive::MultipartUploadNewFileRequest* const child_request =
|
| new drive::MultipartUploadNewFileRequest(
|
| - request_sender_.get(),
|
| - base::StringPrintf("new file title %d", i),
|
| - "parent_resource_id",
|
| - kTestContentType,
|
| - kTestContent.size(),
|
| - base::Time(),
|
| - base::Time(),
|
| - kTestFilePath,
|
| - drive::Properties(),
|
| - *url_generator_,
|
| - callback,
|
| - ProgressCallback());
|
| + request_sender_.get(), base::StringPrintf("new file title %d", i),
|
| + "parent_resource_id", kTestContentType, kTestContent.size(),
|
| + base::Time(), base::Time(), kTestFilePath, drive::Properties(),
|
| + *url_generator_, callback, ProgressCallback());
|
| child_request->SetBoundaryForTesting("INNERBOUNDARY");
|
| request->AddRequest(child_request);
|
| }
|
| @@ -1954,49 +1969,55 @@ TEST_F(DriveApiRequestsTest, BatchUploadRequest) {
|
| EXPECT_EQ("batch", http_request_.headers["X-Goog-Upload-Protocol"]);
|
| EXPECT_EQ("multipart/mixed; boundary=OUTERBOUNDARY",
|
| http_request_.headers["Content-Type"]);
|
| - EXPECT_EQ("--OUTERBOUNDARY\n"
|
| - "Content-Type: application/http\n"
|
| - "\n"
|
| - "POST /upload/drive/v2/files HTTP/1.1\n"
|
| - "Host: 127.0.0.1\n"
|
| - "X-Goog-Upload-Protocol: multipart\n"
|
| - "Content-Type: multipart/related; boundary=INNERBOUNDARY\n"
|
| - "\n"
|
| - "--INNERBOUNDARY\n"
|
| - "Content-Type: application/json\n"
|
| - "\n"
|
| - "{\"parents\":[{\"id\":\"parent_resource_id\","
|
| - "\"kind\":\"drive#fileLink\"}],\"title\":\"new file title 0\"}\n"
|
| - "--INNERBOUNDARY\n"
|
| - "Content-Type: text/plain\n"
|
| - "\n"
|
| - "aaaaaaaaaa\n"
|
| - "--INNERBOUNDARY--\n"
|
| - "--OUTERBOUNDARY\n"
|
| - "Content-Type: application/http\n"
|
| - "\n"
|
| - "POST /upload/drive/v2/files HTTP/1.1\n"
|
| - "Host: 127.0.0.1\n"
|
| - "X-Goog-Upload-Protocol: multipart\n"
|
| - "Content-Type: multipart/related; boundary=INNERBOUNDARY\n"
|
| - "\n"
|
| - "--INNERBOUNDARY\n"
|
| - "Content-Type: application/json\n"
|
| - "\n"
|
| - "{\"parents\":[{\"id\":\"parent_resource_id\","
|
| - "\"kind\":\"drive#fileLink\"}],\"title\":\"new file title 1\"}\n"
|
| - "--INNERBOUNDARY\n"
|
| - "Content-Type: text/plain\n"
|
| - "\n"
|
| - "aaaaaaaaaa\n"
|
| - "--INNERBOUNDARY--\n"
|
| - "--OUTERBOUNDARY--",
|
| - http_request_.content);
|
| + EXPECT_EQ(
|
| + "--OUTERBOUNDARY\n"
|
| + "Content-Type: application/http\n"
|
| + "\n"
|
| + "POST /upload/drive/v2/files HTTP/1.1\n"
|
| + "Host: 127.0.0.1\n"
|
| + "X-Goog-Upload-Protocol: multipart\n"
|
| + "Content-Type: multipart/related; boundary=INNERBOUNDARY\n"
|
| + "\n"
|
| + "--INNERBOUNDARY\n"
|
| + "Content-Type: application/json\n"
|
| + "\n"
|
| + "{\"parents\":[{\"id\":\"parent_resource_id\","
|
| + "\"kind\":\"drive#fileLink\"}],\"title\":\"new file title 0\"}\n"
|
| + "--INNERBOUNDARY\n"
|
| + "Content-Type: text/plain\n"
|
| + "\n"
|
| + "aaaaaaaaaa\n"
|
| + "--INNERBOUNDARY--\n"
|
| + "--OUTERBOUNDARY\n"
|
| + "Content-Type: application/http\n"
|
| + "\n"
|
| + "POST /upload/drive/v2/files HTTP/1.1\n"
|
| + "Host: 127.0.0.1\n"
|
| + "X-Goog-Upload-Protocol: multipart\n"
|
| + "Content-Type: multipart/related; boundary=INNERBOUNDARY\n"
|
| + "\n"
|
| + "--INNERBOUNDARY\n"
|
| + "Content-Type: application/json\n"
|
| + "\n"
|
| + "{\"parents\":[{\"id\":\"parent_resource_id\","
|
| + "\"kind\":\"drive#fileLink\"}],\"title\":\"new file title 1\"}\n"
|
| + "--INNERBOUNDARY\n"
|
| + "Content-Type: text/plain\n"
|
| + "\n"
|
| + "aaaaaaaaaa\n"
|
| + "--INNERBOUNDARY--\n"
|
| + "--OUTERBOUNDARY--",
|
| + http_request_.content);
|
| + EXPECT_EQ(HTTP_SUCCESS, errors[0]);
|
| + ASSERT_TRUE(file_resources[0]);
|
| + EXPECT_EQ("file_id_1", file_resources[0]->file_id());
|
| + ASSERT_FALSE(file_resources[1]);
|
| + EXPECT_EQ(DRIVE_PARSE_ERROR, errors[1]);
|
| }
|
|
|
| TEST_F(DriveApiRequestsTest, EmptyBatchUploadRequest) {
|
| - drive::BatchUploadRequest* const request = new drive::BatchUploadRequest(
|
| - request_sender_.get(), *url_generator_);
|
| + drive::BatchUploadRequest* const request =
|
| + new drive::BatchUploadRequest(request_sender_.get(), *url_generator_);
|
| EXPECT_DEATH(request->Commit(), "Check failed");
|
| }
|
|
|
|
|