| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <map> | 6 #include <map> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); | 286 "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 // Change the code to RESUME_INCOMPLETE if upload is not complete. | 289 // Change the code to RESUME_INCOMPLETE if upload is not complete. |
| 290 if (received_bytes_ < content_length_) | 290 if (received_bytes_ < content_length_) |
| 291 response->set_code(test_server::RESUME_INCOMPLETE); | 291 response->set_code(test_server::RESUME_INCOMPLETE); |
| 292 | 292 |
| 293 return response.Pass(); | 293 return response.Pass(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 MessageLoopForUI message_loop_; | 296 base::MessageLoopForUI message_loop_; |
| 297 content::TestBrowserThread ui_thread_; | 297 content::TestBrowserThread ui_thread_; |
| 298 content::TestBrowserThread file_thread_; | 298 content::TestBrowserThread file_thread_; |
| 299 content::TestBrowserThread io_thread_; | 299 content::TestBrowserThread io_thread_; |
| 300 test_server::HttpServer test_server_; | 300 test_server::HttpServer test_server_; |
| 301 scoped_ptr<TestingProfile> profile_; | 301 scoped_ptr<TestingProfile> profile_; |
| 302 OperationRegistry operation_registry_; | 302 OperationRegistry operation_registry_; |
| 303 scoped_ptr<GDataWapiUrlGenerator> url_generator_; | 303 scoped_ptr<GDataWapiUrlGenerator> url_generator_; |
| 304 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 304 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
| 305 | 305 |
| 306 // These fields are used to keep the current upload state during a | 306 // These fields are used to keep the current upload state during a |
| (...skipping 22 matching lines...) Expand all Loading... |
| 329 *url_generator_, | 329 *url_generator_, |
| 330 GURL(), // Pass an empty URL to use the default feed | 330 GURL(), // Pass an empty URL to use the default feed |
| 331 0, // start changestamp | 331 0, // start changestamp |
| 332 std::string(), // search string | 332 std::string(), // search string |
| 333 std::string(), // directory resource ID | 333 std::string(), // directory resource ID |
| 334 CreateComposedCallback( | 334 CreateComposedCallback( |
| 335 base::Bind(&test_util::RunAndQuit), | 335 base::Bind(&test_util::RunAndQuit), |
| 336 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 336 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 337 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 337 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 338 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 338 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 339 MessageLoop::current()->Run(); | 339 base::MessageLoop::current()->Run(); |
| 340 | 340 |
| 341 EXPECT_EQ(HTTP_SUCCESS, result_code); | 341 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 342 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 342 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 343 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 343 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
| 344 "showfolders=true&include-shared=true&max-results=500", | 344 "showfolders=true&include-shared=true&max-results=500", |
| 345 http_request_.relative_url); | 345 http_request_.relative_url); |
| 346 | 346 |
| 347 // Sanity check of the result. | 347 // Sanity check of the result. |
| 348 scoped_ptr<ResourceList> expected( | 348 scoped_ptr<ResourceList> expected( |
| 349 ResourceList::ExtractAndParse( | 349 ResourceList::ExtractAndParse( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 362 *url_generator_, | 362 *url_generator_, |
| 363 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), | 363 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), |
| 364 0, // start changestamp | 364 0, // start changestamp |
| 365 std::string(), // search string | 365 std::string(), // search string |
| 366 std::string(), // directory resource ID | 366 std::string(), // directory resource ID |
| 367 CreateComposedCallback( | 367 CreateComposedCallback( |
| 368 base::Bind(&test_util::RunAndQuit), | 368 base::Bind(&test_util::RunAndQuit), |
| 369 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 369 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 370 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 370 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 371 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 371 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 372 MessageLoop::current()->Run(); | 372 base::MessageLoop::current()->Run(); |
| 373 | 373 |
| 374 EXPECT_EQ(HTTP_SUCCESS, result_code); | 374 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 375 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 375 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 376 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" | 376 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" |
| 377 "showfolders=true&include-shared=true&max-results=500", | 377 "showfolders=true&include-shared=true&max-results=500", |
| 378 http_request_.relative_url); | 378 http_request_.relative_url); |
| 379 | 379 |
| 380 scoped_ptr<ResourceList> expected( | 380 scoped_ptr<ResourceList> expected( |
| 381 ResourceList::ExtractAndParse( | 381 ResourceList::ExtractAndParse( |
| 382 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); | 382 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 396 *url_generator_, | 396 *url_generator_, |
| 397 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 397 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
| 398 0, // start changestamp | 398 0, // start changestamp |
| 399 std::string(), // search string | 399 std::string(), // search string |
| 400 std::string(), // directory resource ID | 400 std::string(), // directory resource ID |
| 401 CreateComposedCallback( | 401 CreateComposedCallback( |
| 402 base::Bind(&test_util::RunAndQuit), | 402 base::Bind(&test_util::RunAndQuit), |
| 403 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 403 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 404 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 404 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 405 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 405 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 406 MessageLoop::current()->Run(); | 406 base::MessageLoop::current()->Run(); |
| 407 | 407 |
| 408 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 408 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
| 409 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 409 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 410 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" | 410 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" |
| 411 "showfolders=true&include-shared=true&max-results=500", | 411 "showfolders=true&include-shared=true&max-results=500", |
| 412 http_request_.relative_url); | 412 http_request_.relative_url); |
| 413 EXPECT_FALSE(result_data); | 413 EXPECT_FALSE(result_data); |
| 414 } | 414 } |
| 415 | 415 |
| 416 TEST_F(GDataWapiOperationsTest, SearchByTitleOperation) { | 416 TEST_F(GDataWapiOperationsTest, SearchByTitleOperation) { |
| 417 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 417 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 418 scoped_ptr<ResourceList> result_data; | 418 scoped_ptr<ResourceList> result_data; |
| 419 | 419 |
| 420 SearchByTitleOperation* operation = new SearchByTitleOperation( | 420 SearchByTitleOperation* operation = new SearchByTitleOperation( |
| 421 &operation_registry_, | 421 &operation_registry_, |
| 422 request_context_getter_.get(), | 422 request_context_getter_.get(), |
| 423 *url_generator_, | 423 *url_generator_, |
| 424 "search-title", | 424 "search-title", |
| 425 std::string(), // directory resource id | 425 std::string(), // directory resource id |
| 426 CreateComposedCallback( | 426 CreateComposedCallback( |
| 427 base::Bind(&test_util::RunAndQuit), | 427 base::Bind(&test_util::RunAndQuit), |
| 428 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 428 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 429 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 429 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 430 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 430 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 431 MessageLoop::current()->Run(); | 431 base::MessageLoop::current()->Run(); |
| 432 | 432 |
| 433 EXPECT_EQ(HTTP_SUCCESS, result_code); | 433 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 434 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 434 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 435 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 435 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
| 436 "showfolders=true&include-shared=true&max-results=500" | 436 "showfolders=true&include-shared=true&max-results=500" |
| 437 "&title=search-title&title-exact=true", | 437 "&title=search-title&title-exact=true", |
| 438 http_request_.relative_url); | 438 http_request_.relative_url); |
| 439 EXPECT_TRUE(result_data); | 439 EXPECT_TRUE(result_data); |
| 440 } | 440 } |
| 441 | 441 |
| 442 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { | 442 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { |
| 443 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 443 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 444 scoped_ptr<base::Value> result_data; | 444 scoped_ptr<base::Value> result_data; |
| 445 | 445 |
| 446 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 446 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
| 447 &operation_registry_, | 447 &operation_registry_, |
| 448 request_context_getter_.get(), | 448 request_context_getter_.get(), |
| 449 *url_generator_, | 449 *url_generator_, |
| 450 "file:2_file_resource_id", // resource ID | 450 "file:2_file_resource_id", // resource ID |
| 451 CreateComposedCallback( | 451 CreateComposedCallback( |
| 452 base::Bind(&test_util::RunAndQuit), | 452 base::Bind(&test_util::RunAndQuit), |
| 453 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 453 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 454 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 454 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 455 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 455 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 456 MessageLoop::current()->Run(); | 456 base::MessageLoop::current()->Run(); |
| 457 | 457 |
| 458 EXPECT_EQ(HTTP_SUCCESS, result_code); | 458 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 459 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 459 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 460 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 460 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
| 461 "?v=3&alt=json&showroot=true", | 461 "?v=3&alt=json&showroot=true", |
| 462 http_request_.relative_url); | 462 http_request_.relative_url); |
| 463 EXPECT_TRUE(test_util::VerifyJsonData( | 463 EXPECT_TRUE(test_util::VerifyJsonData( |
| 464 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), | 464 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), |
| 465 result_data.get())); | 465 result_data.get())); |
| 466 } | 466 } |
| 467 | 467 |
| 468 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { | 468 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { |
| 469 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 469 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 470 scoped_ptr<base::Value> result_data; | 470 scoped_ptr<base::Value> result_data; |
| 471 | 471 |
| 472 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 472 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
| 473 &operation_registry_, | 473 &operation_registry_, |
| 474 request_context_getter_.get(), | 474 request_context_getter_.get(), |
| 475 *url_generator_, | 475 *url_generator_, |
| 476 "<invalid>", // resource ID | 476 "<invalid>", // resource ID |
| 477 CreateComposedCallback( | 477 CreateComposedCallback( |
| 478 base::Bind(&test_util::RunAndQuit), | 478 base::Bind(&test_util::RunAndQuit), |
| 479 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 479 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 480 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 480 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 481 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 481 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 482 MessageLoop::current()->Run(); | 482 base::MessageLoop::current()->Run(); |
| 483 | 483 |
| 484 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 484 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
| 485 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 485 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 486 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" | 486 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" |
| 487 "&showroot=true", | 487 "&showroot=true", |
| 488 http_request_.relative_url); | 488 http_request_.relative_url); |
| 489 ASSERT_FALSE(result_data); | 489 ASSERT_FALSE(result_data); |
| 490 } | 490 } |
| 491 | 491 |
| 492 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { | 492 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { |
| 493 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 493 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 494 scoped_ptr<AccountMetadata> result_data; | 494 scoped_ptr<AccountMetadata> result_data; |
| 495 | 495 |
| 496 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 496 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
| 497 &operation_registry_, | 497 &operation_registry_, |
| 498 request_context_getter_.get(), | 498 request_context_getter_.get(), |
| 499 *url_generator_, | 499 *url_generator_, |
| 500 CreateComposedCallback( | 500 CreateComposedCallback( |
| 501 base::Bind(&test_util::RunAndQuit), | 501 base::Bind(&test_util::RunAndQuit), |
| 502 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 502 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 503 true); // Include installed apps. | 503 true); // Include installed apps. |
| 504 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 504 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 505 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 505 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 506 MessageLoop::current()->Run(); | 506 base::MessageLoop::current()->Run(); |
| 507 | 507 |
| 508 EXPECT_EQ(HTTP_SUCCESS, result_code); | 508 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 509 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 509 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 510 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true" | 510 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true" |
| 511 "&include-installed-apps=true", | 511 "&include-installed-apps=true", |
| 512 http_request_.relative_url); | 512 http_request_.relative_url); |
| 513 | 513 |
| 514 scoped_ptr<AccountMetadata> expected( | 514 scoped_ptr<AccountMetadata> expected( |
| 515 AccountMetadata::CreateFrom( | 515 AccountMetadata::CreateFrom( |
| 516 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); | 516 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 536 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 536 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
| 537 &operation_registry_, | 537 &operation_registry_, |
| 538 request_context_getter_.get(), | 538 request_context_getter_.get(), |
| 539 *url_generator_, | 539 *url_generator_, |
| 540 CreateComposedCallback( | 540 CreateComposedCallback( |
| 541 base::Bind(&test_util::RunAndQuit), | 541 base::Bind(&test_util::RunAndQuit), |
| 542 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 542 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 543 false); // Exclude installed apps. | 543 false); // Exclude installed apps. |
| 544 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 544 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 545 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 545 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 546 MessageLoop::current()->Run(); | 546 base::MessageLoop::current()->Run(); |
| 547 | 547 |
| 548 EXPECT_EQ(HTTP_SUCCESS, result_code); | 548 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 549 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 549 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 550 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true", | 550 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true", |
| 551 http_request_.relative_url); | 551 http_request_.relative_url); |
| 552 | 552 |
| 553 scoped_ptr<AccountMetadata> expected( | 553 scoped_ptr<AccountMetadata> expected( |
| 554 AccountMetadata::CreateFrom( | 554 AccountMetadata::CreateFrom( |
| 555 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); | 555 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); |
| 556 | 556 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 573 &operation_registry_, | 573 &operation_registry_, |
| 574 request_context_getter_.get(), | 574 request_context_getter_.get(), |
| 575 *url_generator_, | 575 *url_generator_, |
| 576 CreateComposedCallback(base::Bind(&test_util::RunAndQuit), | 576 CreateComposedCallback(base::Bind(&test_util::RunAndQuit), |
| 577 test_util::CreateCopyResultCallback(&result_code)), | 577 test_util::CreateCopyResultCallback(&result_code)), |
| 578 "file:2_file_resource_id", | 578 "file:2_file_resource_id", |
| 579 std::string()); | 579 std::string()); |
| 580 | 580 |
| 581 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 581 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 582 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 582 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 583 MessageLoop::current()->Run(); | 583 base::MessageLoop::current()->Run(); |
| 584 | 584 |
| 585 EXPECT_EQ(HTTP_SUCCESS, result_code); | 585 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 586 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); | 586 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); |
| 587 EXPECT_EQ( | 587 EXPECT_EQ( |
| 588 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 588 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
| 589 "&showroot=true", | 589 "&showroot=true", |
| 590 http_request_.relative_url); | 590 http_request_.relative_url); |
| 591 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 591 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 592 } | 592 } |
| 593 | 593 |
| 594 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { | 594 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { |
| 595 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 595 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 596 | 596 |
| 597 DeleteResourceOperation* operation = new DeleteResourceOperation( | 597 DeleteResourceOperation* operation = new DeleteResourceOperation( |
| 598 &operation_registry_, | 598 &operation_registry_, |
| 599 request_context_getter_.get(), | 599 request_context_getter_.get(), |
| 600 *url_generator_, | 600 *url_generator_, |
| 601 CreateComposedCallback( | 601 CreateComposedCallback( |
| 602 base::Bind(&test_util::RunAndQuit), | 602 base::Bind(&test_util::RunAndQuit), |
| 603 test_util::CreateCopyResultCallback(&result_code)), | 603 test_util::CreateCopyResultCallback(&result_code)), |
| 604 "file:2_file_resource_id", | 604 "file:2_file_resource_id", |
| 605 "etag"); | 605 "etag"); |
| 606 | 606 |
| 607 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 607 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 608 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 608 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 609 MessageLoop::current()->Run(); | 609 base::MessageLoop::current()->Run(); |
| 610 | 610 |
| 611 EXPECT_EQ(HTTP_SUCCESS, result_code); | 611 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 612 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); | 612 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); |
| 613 EXPECT_EQ( | 613 EXPECT_EQ( |
| 614 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 614 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
| 615 "&showroot=true", | 615 "&showroot=true", |
| 616 http_request_.relative_url); | 616 http_request_.relative_url); |
| 617 EXPECT_EQ("etag", http_request_.headers["If-Match"]); | 617 EXPECT_EQ("etag", http_request_.headers["If-Match"]); |
| 618 } | 618 } |
| 619 | 619 |
| 620 TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) { | 620 TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) { |
| 621 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 621 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 622 scoped_ptr<base::Value> result_data; | 622 scoped_ptr<base::Value> result_data; |
| 623 | 623 |
| 624 // Create "new directory" in the root directory. | 624 // Create "new directory" in the root directory. |
| 625 CreateDirectoryOperation* operation = new CreateDirectoryOperation( | 625 CreateDirectoryOperation* operation = new CreateDirectoryOperation( |
| 626 &operation_registry_, | 626 &operation_registry_, |
| 627 request_context_getter_.get(), | 627 request_context_getter_.get(), |
| 628 *url_generator_, | 628 *url_generator_, |
| 629 CreateComposedCallback( | 629 CreateComposedCallback( |
| 630 base::Bind(&test_util::RunAndQuit), | 630 base::Bind(&test_util::RunAndQuit), |
| 631 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 631 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 632 "folder:root", | 632 "folder:root", |
| 633 "new directory"); | 633 "new directory"); |
| 634 | 634 |
| 635 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 635 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 636 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 636 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 637 MessageLoop::current()->Run(); | 637 base::MessageLoop::current()->Run(); |
| 638 | 638 |
| 639 EXPECT_EQ(HTTP_SUCCESS, result_code); | 639 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 640 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 640 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 641 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" | 641 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" |
| 642 "&showroot=true", | 642 "&showroot=true", |
| 643 http_request_.relative_url); | 643 http_request_.relative_url); |
| 644 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 644 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 645 | 645 |
| 646 EXPECT_TRUE(http_request_.has_content); | 646 EXPECT_TRUE(http_request_.has_content); |
| 647 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 647 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 663 request_context_getter_.get(), | 663 request_context_getter_.get(), |
| 664 *url_generator_, | 664 *url_generator_, |
| 665 CreateComposedCallback( | 665 CreateComposedCallback( |
| 666 base::Bind(&test_util::RunAndQuit), | 666 base::Bind(&test_util::RunAndQuit), |
| 667 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 667 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 668 "document:5_document_resource_id", // source resource ID | 668 "document:5_document_resource_id", // source resource ID |
| 669 "New Document"); | 669 "New Document"); |
| 670 | 670 |
| 671 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 671 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 672 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 672 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 673 MessageLoop::current()->Run(); | 673 base::MessageLoop::current()->Run(); |
| 674 | 674 |
| 675 EXPECT_EQ(HTTP_SUCCESS, result_code); | 675 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 676 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 676 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 677 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true", | 677 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true", |
| 678 http_request_.relative_url); | 678 http_request_.relative_url); |
| 679 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 679 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 680 | 680 |
| 681 EXPECT_TRUE(http_request_.has_content); | 681 EXPECT_TRUE(http_request_.has_content); |
| 682 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 682 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
| 683 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" | 683 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 696 request_context_getter_.get(), | 696 request_context_getter_.get(), |
| 697 *url_generator_, | 697 *url_generator_, |
| 698 CreateComposedCallback( | 698 CreateComposedCallback( |
| 699 base::Bind(&test_util::RunAndQuit), | 699 base::Bind(&test_util::RunAndQuit), |
| 700 test_util::CreateCopyResultCallback(&result_code)), | 700 test_util::CreateCopyResultCallback(&result_code)), |
| 701 "file:2_file_resource_id", | 701 "file:2_file_resource_id", |
| 702 "New File"); | 702 "New File"); |
| 703 | 703 |
| 704 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 704 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 705 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 705 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 706 MessageLoop::current()->Run(); | 706 base::MessageLoop::current()->Run(); |
| 707 | 707 |
| 708 EXPECT_EQ(HTTP_SUCCESS, result_code); | 708 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 709 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 709 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 710 EXPECT_EQ( | 710 EXPECT_EQ( |
| 711 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 711 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
| 712 "&showroot=true", | 712 "&showroot=true", |
| 713 http_request_.relative_url); | 713 http_request_.relative_url); |
| 714 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 714 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 715 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 715 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 716 | 716 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 732 request_context_getter_.get(), | 732 request_context_getter_.get(), |
| 733 *url_generator_, | 733 *url_generator_, |
| 734 CreateComposedCallback( | 734 CreateComposedCallback( |
| 735 base::Bind(&test_util::RunAndQuit), | 735 base::Bind(&test_util::RunAndQuit), |
| 736 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 736 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 737 "file:2_file_resource_id", | 737 "file:2_file_resource_id", |
| 738 "APP_ID"); | 738 "APP_ID"); |
| 739 | 739 |
| 740 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 740 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 741 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 741 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 742 MessageLoop::current()->Run(); | 742 base::MessageLoop::current()->Run(); |
| 743 | 743 |
| 744 EXPECT_EQ(HTTP_SUCCESS, result_code); | 744 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 745 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 745 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 746 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 746 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
| 747 "?v=3&alt=json&showroot=true", | 747 "?v=3&alt=json&showroot=true", |
| 748 http_request_.relative_url); | 748 http_request_.relative_url); |
| 749 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 749 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 750 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 750 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 751 | 751 |
| 752 EXPECT_TRUE(http_request_.has_content); | 752 EXPECT_TRUE(http_request_.has_content); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 768 request_context_getter_.get(), | 768 request_context_getter_.get(), |
| 769 *url_generator_, | 769 *url_generator_, |
| 770 CreateComposedCallback( | 770 CreateComposedCallback( |
| 771 base::Bind(&test_util::RunAndQuit), | 771 base::Bind(&test_util::RunAndQuit), |
| 772 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 772 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 773 "invalid_resource_id", | 773 "invalid_resource_id", |
| 774 "APP_ID"); | 774 "APP_ID"); |
| 775 | 775 |
| 776 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 776 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 777 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 777 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 778 MessageLoop::current()->Run(); | 778 base::MessageLoop::current()->Run(); |
| 779 | 779 |
| 780 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 780 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
| 781 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 781 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 782 EXPECT_EQ("/feeds/default/private/full/invalid_resource_id" | 782 EXPECT_EQ("/feeds/default/private/full/invalid_resource_id" |
| 783 "?v=3&alt=json&showroot=true", | 783 "?v=3&alt=json&showroot=true", |
| 784 http_request_.relative_url); | 784 http_request_.relative_url); |
| 785 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 785 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 786 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 786 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 787 | 787 |
| 788 EXPECT_TRUE(http_request_.has_content); | 788 EXPECT_TRUE(http_request_.has_content); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 804 request_context_getter_.get(), | 804 request_context_getter_.get(), |
| 805 *url_generator_, | 805 *url_generator_, |
| 806 CreateComposedCallback( | 806 CreateComposedCallback( |
| 807 base::Bind(&test_util::RunAndQuit), | 807 base::Bind(&test_util::RunAndQuit), |
| 808 test_util::CreateCopyResultCallback(&result_code)), | 808 test_util::CreateCopyResultCallback(&result_code)), |
| 809 "folder:root", | 809 "folder:root", |
| 810 "file:2_file_resource_id"); | 810 "file:2_file_resource_id"); |
| 811 | 811 |
| 812 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 812 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 813 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 813 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 814 MessageLoop::current()->Run(); | 814 base::MessageLoop::current()->Run(); |
| 815 | 815 |
| 816 EXPECT_EQ(HTTP_SUCCESS, result_code); | 816 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 817 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 817 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 818 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" | 818 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" |
| 819 "&showroot=true", | 819 "&showroot=true", |
| 820 http_request_.relative_url); | 820 http_request_.relative_url); |
| 821 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 821 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 822 | 822 |
| 823 EXPECT_TRUE(http_request_.has_content); | 823 EXPECT_TRUE(http_request_.has_content); |
| 824 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 824 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 839 request_context_getter_.get(), | 839 request_context_getter_.get(), |
| 840 *url_generator_, | 840 *url_generator_, |
| 841 CreateComposedCallback( | 841 CreateComposedCallback( |
| 842 base::Bind(&test_util::RunAndQuit), | 842 base::Bind(&test_util::RunAndQuit), |
| 843 test_util::CreateCopyResultCallback(&result_code)), | 843 test_util::CreateCopyResultCallback(&result_code)), |
| 844 "folder:root", | 844 "folder:root", |
| 845 "file:2_file_resource_id"); | 845 "file:2_file_resource_id"); |
| 846 | 846 |
| 847 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 847 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 848 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 848 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 849 MessageLoop::current()->Run(); | 849 base::MessageLoop::current()->Run(); |
| 850 | 850 |
| 851 EXPECT_EQ(HTTP_SUCCESS, result_code); | 851 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 852 // DELETE method should be used, without the body content. | 852 // DELETE method should be used, without the body content. |
| 853 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); | 853 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); |
| 854 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" | 854 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" |
| 855 "file%3A2_file_resource_id?v=3&alt=json&showroot=true", | 855 "file%3A2_file_resource_id?v=3&alt=json&showroot=true", |
| 856 http_request_.relative_url); | 856 http_request_.relative_url); |
| 857 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 857 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 858 EXPECT_FALSE(http_request_.has_content); | 858 EXPECT_FALSE(http_request_.has_content); |
| 859 } | 859 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 876 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 876 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 877 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 877 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 878 "text/plain", | 878 "text/plain", |
| 879 kUploadContent.size(), | 879 kUploadContent.size(), |
| 880 "folder:id", | 880 "folder:id", |
| 881 "New file"); | 881 "New file"); |
| 882 | 882 |
| 883 initiate_operation->Start( | 883 initiate_operation->Start( |
| 884 kTestGDataAuthToken, kTestUserAgent, | 884 kTestGDataAuthToken, kTestUserAgent, |
| 885 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 885 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 886 MessageLoop::current()->Run(); | 886 base::MessageLoop::current()->Run(); |
| 887 | 887 |
| 888 EXPECT_EQ(HTTP_SUCCESS, result_code); | 888 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 889 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 889 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
| 890 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 890 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 891 // convert=false should be passed as files should be uploaded as-is. | 891 // convert=false should be passed as files should be uploaded as-is. |
| 892 EXPECT_EQ( | 892 EXPECT_EQ( |
| 893 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 893 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
| 894 "?convert=false&v=3&alt=json&showroot=true", | 894 "?convert=false&v=3&alt=json&showroot=true", |
| 895 http_request_.relative_url); | 895 http_request_.relative_url); |
| 896 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 896 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 924 upload_url, | 924 upload_url, |
| 925 0, // start_position | 925 0, // start_position |
| 926 kUploadContent.size(), // end_position (exclusive) | 926 kUploadContent.size(), // end_position (exclusive) |
| 927 kUploadContent.size(), // content_length, | 927 kUploadContent.size(), // content_length, |
| 928 "text/plain", // content_type | 928 "text/plain", // content_type |
| 929 buffer); | 929 buffer); |
| 930 | 930 |
| 931 resume_operation->Start( | 931 resume_operation->Start( |
| 932 kTestGDataAuthToken, kTestUserAgent, | 932 kTestGDataAuthToken, kTestUserAgent, |
| 933 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 933 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 934 MessageLoop::current()->Run(); | 934 base::MessageLoop::current()->Run(); |
| 935 | 935 |
| 936 // METHOD_PUT should be used to upload data. | 936 // METHOD_PUT should be used to upload data. |
| 937 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 937 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 938 // Request should go to the upload URL. | 938 // Request should go to the upload URL. |
| 939 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 939 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 940 // Content-Range header should be added. | 940 // Content-Range header should be added. |
| 941 EXPECT_EQ("bytes 0-" + | 941 EXPECT_EQ("bytes 0-" + |
| 942 base::Int64ToString(kUploadContent.size() -1) + "/" + | 942 base::Int64ToString(kUploadContent.size() -1) + "/" + |
| 943 base::Int64ToString(kUploadContent.size()), | 943 base::Int64ToString(kUploadContent.size()), |
| 944 http_request_.headers["Content-Range"]); | 944 http_request_.headers["Content-Range"]); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 978 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 979 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 979 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 980 "text/plain", | 980 "text/plain", |
| 981 kUploadContent.size(), | 981 kUploadContent.size(), |
| 982 "folder:id", | 982 "folder:id", |
| 983 "New file"); | 983 "New file"); |
| 984 | 984 |
| 985 initiate_operation->Start( | 985 initiate_operation->Start( |
| 986 kTestGDataAuthToken, kTestUserAgent, | 986 kTestGDataAuthToken, kTestUserAgent, |
| 987 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 987 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 988 MessageLoop::current()->Run(); | 988 base::MessageLoop::current()->Run(); |
| 989 | 989 |
| 990 EXPECT_EQ(HTTP_SUCCESS, result_code); | 990 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 991 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 991 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
| 992 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 992 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 993 // convert=false should be passed as files should be uploaded as-is. | 993 // convert=false should be passed as files should be uploaded as-is. |
| 994 EXPECT_EQ( | 994 EXPECT_EQ( |
| 995 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 995 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
| 996 "?convert=false&v=3&alt=json&showroot=true", | 996 "?convert=false&v=3&alt=json&showroot=true", |
| 997 http_request_.relative_url); | 997 http_request_.relative_url); |
| 998 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 998 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1023 CreateComposedCallback( | 1023 CreateComposedCallback( |
| 1024 base::Bind(&test_util::RunAndQuit), | 1024 base::Bind(&test_util::RunAndQuit), |
| 1025 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1025 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1026 UPLOAD_NEW_FILE, | 1026 UPLOAD_NEW_FILE, |
| 1027 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1027 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1028 upload_url, | 1028 upload_url, |
| 1029 kUploadContent.size()); | 1029 kUploadContent.size()); |
| 1030 get_upload_status_operation->Start( | 1030 get_upload_status_operation->Start( |
| 1031 kTestGDataAuthToken, kTestUserAgent, | 1031 kTestGDataAuthToken, kTestUserAgent, |
| 1032 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1032 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1033 MessageLoop::current()->Run(); | 1033 base::MessageLoop::current()->Run(); |
| 1034 | 1034 |
| 1035 // METHOD_PUT should be used to upload data. | 1035 // METHOD_PUT should be used to upload data. |
| 1036 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1036 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1037 // Request should go to the upload URL. | 1037 // Request should go to the upload URL. |
| 1038 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1038 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1039 // Content-Range header should be added. | 1039 // Content-Range header should be added. |
| 1040 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), | 1040 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), |
| 1041 http_request_.headers["Content-Range"]); | 1041 http_request_.headers["Content-Range"]); |
| 1042 EXPECT_TRUE(http_request_.has_content); | 1042 EXPECT_TRUE(http_request_.has_content); |
| 1043 EXPECT_TRUE(http_request_.content.empty()); | 1043 EXPECT_TRUE(http_request_.content.empty()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 upload_url, | 1079 upload_url, |
| 1080 start_position, | 1080 start_position, |
| 1081 end_position, | 1081 end_position, |
| 1082 kUploadContent.size(), // content_length, | 1082 kUploadContent.size(), // content_length, |
| 1083 "text/plain", // content_type | 1083 "text/plain", // content_type |
| 1084 buffer); | 1084 buffer); |
| 1085 | 1085 |
| 1086 resume_operation->Start( | 1086 resume_operation->Start( |
| 1087 kTestGDataAuthToken, kTestUserAgent, | 1087 kTestGDataAuthToken, kTestUserAgent, |
| 1088 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1088 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1089 MessageLoop::current()->Run(); | 1089 base::MessageLoop::current()->Run(); |
| 1090 | 1090 |
| 1091 // METHOD_PUT should be used to upload data. | 1091 // METHOD_PUT should be used to upload data. |
| 1092 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1092 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1093 // Request should go to the upload URL. | 1093 // Request should go to the upload URL. |
| 1094 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1094 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1095 // Content-Range header should be added. | 1095 // Content-Range header should be added. |
| 1096 EXPECT_EQ("bytes " + | 1096 EXPECT_EQ("bytes " + |
| 1097 base::Int64ToString(start_position) + "-" + | 1097 base::Int64ToString(start_position) + "-" + |
| 1098 base::Int64ToString(end_position - 1) + "/" + | 1098 base::Int64ToString(end_position - 1) + "/" + |
| 1099 base::Int64ToString(kUploadContent.size()), | 1099 base::Int64ToString(kUploadContent.size()), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1126 CreateComposedCallback( | 1126 CreateComposedCallback( |
| 1127 base::Bind(&test_util::RunAndQuit), | 1127 base::Bind(&test_util::RunAndQuit), |
| 1128 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1128 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1129 UPLOAD_NEW_FILE, | 1129 UPLOAD_NEW_FILE, |
| 1130 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1130 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1131 upload_url, | 1131 upload_url, |
| 1132 kUploadContent.size()); | 1132 kUploadContent.size()); |
| 1133 get_upload_status_operation->Start( | 1133 get_upload_status_operation->Start( |
| 1134 kTestGDataAuthToken, kTestUserAgent, | 1134 kTestGDataAuthToken, kTestUserAgent, |
| 1135 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1135 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1136 MessageLoop::current()->Run(); | 1136 base::MessageLoop::current()->Run(); |
| 1137 | 1137 |
| 1138 // METHOD_PUT should be used to upload data. | 1138 // METHOD_PUT should be used to upload data. |
| 1139 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1139 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1140 // Request should go to the upload URL. | 1140 // Request should go to the upload URL. |
| 1141 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1141 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1142 // Content-Range header should be added. | 1142 // Content-Range header should be added. |
| 1143 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), | 1143 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), |
| 1144 http_request_.headers["Content-Range"]); | 1144 http_request_.headers["Content-Range"]); |
| 1145 EXPECT_TRUE(http_request_.has_content); | 1145 EXPECT_TRUE(http_request_.has_content); |
| 1146 EXPECT_TRUE(http_request_.content.empty()); | 1146 EXPECT_TRUE(http_request_.content.empty()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1176 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1176 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1177 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1177 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1178 "text/plain", | 1178 "text/plain", |
| 1179 kUploadContent.size(), | 1179 kUploadContent.size(), |
| 1180 "folder:id", | 1180 "folder:id", |
| 1181 "New file"); | 1181 "New file"); |
| 1182 | 1182 |
| 1183 initiate_operation->Start( | 1183 initiate_operation->Start( |
| 1184 kTestGDataAuthToken, kTestUserAgent, | 1184 kTestGDataAuthToken, kTestUserAgent, |
| 1185 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1185 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1186 MessageLoop::current()->Run(); | 1186 base::MessageLoop::current()->Run(); |
| 1187 | 1187 |
| 1188 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1188 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1189 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 1189 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
| 1190 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 1190 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 1191 // convert=false should be passed as files should be uploaded as-is. | 1191 // convert=false should be passed as files should be uploaded as-is. |
| 1192 EXPECT_EQ( | 1192 EXPECT_EQ( |
| 1193 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 1193 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
| 1194 "?convert=false&v=3&alt=json&showroot=true", | 1194 "?convert=false&v=3&alt=json&showroot=true", |
| 1195 http_request_.relative_url); | 1195 http_request_.relative_url); |
| 1196 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1196 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1224 upload_url, | 1224 upload_url, |
| 1225 0, // start_position | 1225 0, // start_position |
| 1226 kUploadContent.size(), // end_position (exclusive) | 1226 kUploadContent.size(), // end_position (exclusive) |
| 1227 kUploadContent.size(), // content_length, | 1227 kUploadContent.size(), // content_length, |
| 1228 "text/plain", // content_type | 1228 "text/plain", // content_type |
| 1229 buffer); | 1229 buffer); |
| 1230 | 1230 |
| 1231 resume_operation->Start( | 1231 resume_operation->Start( |
| 1232 kTestGDataAuthToken, kTestUserAgent, | 1232 kTestGDataAuthToken, kTestUserAgent, |
| 1233 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1233 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1234 MessageLoop::current()->Run(); | 1234 base::MessageLoop::current()->Run(); |
| 1235 | 1235 |
| 1236 // METHOD_PUT should be used to upload data. | 1236 // METHOD_PUT should be used to upload data. |
| 1237 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1237 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1238 // Request should go to the upload URL. | 1238 // Request should go to the upload URL. |
| 1239 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1239 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1240 // Content-Range header should not exit if the content is empty. | 1240 // Content-Range header should not exit if the content is empty. |
| 1241 // We should not generate the header with an invalid value "bytes 0--1/0". | 1241 // We should not generate the header with an invalid value "bytes 0--1/0". |
| 1242 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 1242 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
| 1243 // The upload content should be set in the HTTP request. | 1243 // The upload content should be set in the HTTP request. |
| 1244 EXPECT_TRUE(http_request_.has_content); | 1244 EXPECT_TRUE(http_request_.has_content); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1269 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1269 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1270 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1270 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1271 "text/plain", | 1271 "text/plain", |
| 1272 kUploadContent.size(), | 1272 kUploadContent.size(), |
| 1273 "file:foo", | 1273 "file:foo", |
| 1274 std::string() /* etag */); | 1274 std::string() /* etag */); |
| 1275 | 1275 |
| 1276 initiate_operation->Start( | 1276 initiate_operation->Start( |
| 1277 kTestGDataAuthToken, kTestUserAgent, | 1277 kTestGDataAuthToken, kTestUserAgent, |
| 1278 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1278 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1279 MessageLoop::current()->Run(); | 1279 base::MessageLoop::current()->Run(); |
| 1280 | 1280 |
| 1281 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1281 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1282 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); | 1282 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); |
| 1283 // For updating an existing file, METHOD_PUT should be used. | 1283 // For updating an existing file, METHOD_PUT should be used. |
| 1284 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1284 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1285 // convert=false should be passed as files should be uploaded as-is. | 1285 // convert=false should be passed as files should be uploaded as-is. |
| 1286 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1286 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
| 1287 "?convert=false&v=3&alt=json&showroot=true", | 1287 "?convert=false&v=3&alt=json&showroot=true", |
| 1288 http_request_.relative_url); | 1288 http_request_.relative_url); |
| 1289 // Even though the body is empty, the content type should be set to | 1289 // Even though the body is empty, the content type should be set to |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1316 upload_url, | 1316 upload_url, |
| 1317 0, // start_position | 1317 0, // start_position |
| 1318 kUploadContent.size(), // end_position (exclusive) | 1318 kUploadContent.size(), // end_position (exclusive) |
| 1319 kUploadContent.size(), // content_length, | 1319 kUploadContent.size(), // content_length, |
| 1320 "text/plain", // content_type | 1320 "text/plain", // content_type |
| 1321 buffer); | 1321 buffer); |
| 1322 | 1322 |
| 1323 resume_operation->Start( | 1323 resume_operation->Start( |
| 1324 kTestGDataAuthToken, kTestUserAgent, | 1324 kTestGDataAuthToken, kTestUserAgent, |
| 1325 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1325 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1326 MessageLoop::current()->Run(); | 1326 base::MessageLoop::current()->Run(); |
| 1327 | 1327 |
| 1328 // METHOD_PUT should be used to upload data. | 1328 // METHOD_PUT should be used to upload data. |
| 1329 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1329 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1330 // Request should go to the upload URL. | 1330 // Request should go to the upload URL. |
| 1331 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1331 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1332 // Content-Range header should be added. | 1332 // Content-Range header should be added. |
| 1333 EXPECT_EQ("bytes 0-" + | 1333 EXPECT_EQ("bytes 0-" + |
| 1334 base::Int64ToString(kUploadContent.size() -1) + "/" + | 1334 base::Int64ToString(kUploadContent.size() -1) + "/" + |
| 1335 base::Int64ToString(kUploadContent.size()), | 1335 base::Int64ToString(kUploadContent.size()), |
| 1336 http_request_.headers["Content-Range"]); | 1336 http_request_.headers["Content-Range"]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1363 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1363 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1364 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1364 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1365 "text/plain", | 1365 "text/plain", |
| 1366 kUploadContent.size(), | 1366 kUploadContent.size(), |
| 1367 "file:foo", | 1367 "file:foo", |
| 1368 kTestETag); | 1368 kTestETag); |
| 1369 | 1369 |
| 1370 initiate_operation->Start( | 1370 initiate_operation->Start( |
| 1371 kTestGDataAuthToken, kTestUserAgent, | 1371 kTestGDataAuthToken, kTestUserAgent, |
| 1372 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1372 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1373 MessageLoop::current()->Run(); | 1373 base::MessageLoop::current()->Run(); |
| 1374 | 1374 |
| 1375 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1375 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1376 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); | 1376 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); |
| 1377 // For updating an existing file, METHOD_PUT should be used. | 1377 // For updating an existing file, METHOD_PUT should be used. |
| 1378 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1378 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1379 // convert=false should be passed as files should be uploaded as-is. | 1379 // convert=false should be passed as files should be uploaded as-is. |
| 1380 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1380 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
| 1381 "?convert=false&v=3&alt=json&showroot=true", | 1381 "?convert=false&v=3&alt=json&showroot=true", |
| 1382 http_request_.relative_url); | 1382 http_request_.relative_url); |
| 1383 // Even though the body is empty, the content type should be set to | 1383 // Even though the body is empty, the content type should be set to |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1410 upload_url, | 1410 upload_url, |
| 1411 0, // start_position | 1411 0, // start_position |
| 1412 kUploadContent.size(), // end_position (exclusive) | 1412 kUploadContent.size(), // end_position (exclusive) |
| 1413 kUploadContent.size(), // content_length, | 1413 kUploadContent.size(), // content_length, |
| 1414 "text/plain", // content_type | 1414 "text/plain", // content_type |
| 1415 buffer); | 1415 buffer); |
| 1416 | 1416 |
| 1417 resume_operation->Start( | 1417 resume_operation->Start( |
| 1418 kTestGDataAuthToken, kTestUserAgent, | 1418 kTestGDataAuthToken, kTestUserAgent, |
| 1419 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1419 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1420 MessageLoop::current()->Run(); | 1420 base::MessageLoop::current()->Run(); |
| 1421 | 1421 |
| 1422 // METHOD_PUT should be used to upload data. | 1422 // METHOD_PUT should be used to upload data. |
| 1423 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1423 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1424 // Request should go to the upload URL. | 1424 // Request should go to the upload URL. |
| 1425 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1425 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1426 // Content-Range header should be added. | 1426 // Content-Range header should be added. |
| 1427 EXPECT_EQ("bytes 0-" + | 1427 EXPECT_EQ("bytes 0-" + |
| 1428 base::Int64ToString(kUploadContent.size() -1) + "/" + | 1428 base::Int64ToString(kUploadContent.size() -1) + "/" + |
| 1429 base::Int64ToString(kUploadContent.size()), | 1429 base::Int64ToString(kUploadContent.size()), |
| 1430 http_request_.headers["Content-Range"]); | 1430 http_request_.headers["Content-Range"]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1457 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1457 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1458 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1458 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1459 "text/plain", | 1459 "text/plain", |
| 1460 kUploadContent.size(), | 1460 kUploadContent.size(), |
| 1461 "file:foo", | 1461 "file:foo", |
| 1462 kWrongETag); | 1462 kWrongETag); |
| 1463 | 1463 |
| 1464 initiate_operation->Start( | 1464 initiate_operation->Start( |
| 1465 kTestGDataAuthToken, kTestUserAgent, | 1465 kTestGDataAuthToken, kTestUserAgent, |
| 1466 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1466 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1467 MessageLoop::current()->Run(); | 1467 base::MessageLoop::current()->Run(); |
| 1468 | 1468 |
| 1469 EXPECT_EQ(HTTP_PRECONDITION, result_code); | 1469 EXPECT_EQ(HTTP_PRECONDITION, result_code); |
| 1470 // For updating an existing file, METHOD_PUT should be used. | 1470 // For updating an existing file, METHOD_PUT should be used. |
| 1471 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1471 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1472 // convert=false should be passed as files should be uploaded as-is. | 1472 // convert=false should be passed as files should be uploaded as-is. |
| 1473 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1473 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
| 1474 "?convert=false&v=3&alt=json&showroot=true", | 1474 "?convert=false&v=3&alt=json&showroot=true", |
| 1475 http_request_.relative_url); | 1475 http_request_.relative_url); |
| 1476 // Even though the body is empty, the content type should be set to | 1476 // Even though the body is empty, the content type should be set to |
| 1477 // "text/plain". | 1477 // "text/plain". |
| 1478 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); | 1478 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); |
| 1479 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1479 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| 1480 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1480 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1481 http_request_.headers["X-Upload-Content-Length"]); | 1481 http_request_.headers["X-Upload-Content-Length"]); |
| 1482 // For updating an existing file, an empty body should be attached (PUT | 1482 // For updating an existing file, an empty body should be attached (PUT |
| 1483 // requires a body) | 1483 // requires a body) |
| 1484 EXPECT_TRUE(http_request_.has_content); | 1484 EXPECT_TRUE(http_request_.has_content); |
| 1485 EXPECT_EQ("", http_request_.content); | 1485 EXPECT_EQ("", http_request_.content); |
| 1486 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1486 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 } // namespace google_apis | 1489 } // namespace google_apis |
| OLD | NEW |