| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); | 295 "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 // Change the code to RESUME_INCOMPLETE if upload is not complete. | 298 // Change the code to RESUME_INCOMPLETE if upload is not complete. |
| 299 if (received_bytes_ < content_length_) | 299 if (received_bytes_ < content_length_) |
| 300 response->set_code(net::test_server::RESUME_INCOMPLETE); | 300 response->set_code(net::test_server::RESUME_INCOMPLETE); |
| 301 | 301 |
| 302 return response.Pass(); | 302 return response.Pass(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 MessageLoopForUI message_loop_; | 305 base::MessageLoopForUI message_loop_; |
| 306 content::TestBrowserThread ui_thread_; | 306 content::TestBrowserThread ui_thread_; |
| 307 content::TestBrowserThread file_thread_; | 307 content::TestBrowserThread file_thread_; |
| 308 content::TestBrowserThread io_thread_; | 308 content::TestBrowserThread io_thread_; |
| 309 net::test_server::EmbeddedTestServer test_server_; | 309 net::test_server::EmbeddedTestServer test_server_; |
| 310 scoped_ptr<TestingProfile> profile_; | 310 scoped_ptr<TestingProfile> profile_; |
| 311 scoped_ptr<OperationRunner> operation_runner_; | 311 scoped_ptr<OperationRunner> operation_runner_; |
| 312 scoped_ptr<GDataWapiUrlGenerator> url_generator_; | 312 scoped_ptr<GDataWapiUrlGenerator> url_generator_; |
| 313 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 313 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
| 314 base::ScopedTempDir temp_dir_; | 314 base::ScopedTempDir temp_dir_; |
| 315 | 315 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 338 request_context_getter_.get(), | 338 request_context_getter_.get(), |
| 339 *url_generator_, | 339 *url_generator_, |
| 340 GURL(), // Pass an empty URL to use the default feed | 340 GURL(), // Pass an empty URL to use the default feed |
| 341 0, // start changestamp | 341 0, // start changestamp |
| 342 std::string(), // search string | 342 std::string(), // search string |
| 343 std::string(), // directory resource ID | 343 std::string(), // directory resource ID |
| 344 CreateComposedCallback( | 344 CreateComposedCallback( |
| 345 base::Bind(&test_util::RunAndQuit), | 345 base::Bind(&test_util::RunAndQuit), |
| 346 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 346 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 347 operation_runner_->StartOperationWithRetry(operation); | 347 operation_runner_->StartOperationWithRetry(operation); |
| 348 MessageLoop::current()->Run(); | 348 base::MessageLoop::current()->Run(); |
| 349 | 349 |
| 350 EXPECT_EQ(HTTP_SUCCESS, result_code); | 350 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 351 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 351 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 352 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 352 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
| 353 "showfolders=true&include-shared=true&max-results=500", | 353 "showfolders=true&include-shared=true&max-results=500", |
| 354 http_request_.relative_url); | 354 http_request_.relative_url); |
| 355 | 355 |
| 356 // Sanity check of the result. | 356 // Sanity check of the result. |
| 357 scoped_ptr<ResourceList> expected( | 357 scoped_ptr<ResourceList> expected( |
| 358 ResourceList::ExtractAndParse( | 358 ResourceList::ExtractAndParse( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 370 request_context_getter_.get(), | 370 request_context_getter_.get(), |
| 371 *url_generator_, | 371 *url_generator_, |
| 372 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), | 372 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), |
| 373 0, // start changestamp | 373 0, // start changestamp |
| 374 std::string(), // search string | 374 std::string(), // search string |
| 375 std::string(), // directory resource ID | 375 std::string(), // directory resource ID |
| 376 CreateComposedCallback( | 376 CreateComposedCallback( |
| 377 base::Bind(&test_util::RunAndQuit), | 377 base::Bind(&test_util::RunAndQuit), |
| 378 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 378 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 379 operation_runner_->StartOperationWithRetry(operation); | 379 operation_runner_->StartOperationWithRetry(operation); |
| 380 MessageLoop::current()->Run(); | 380 base::MessageLoop::current()->Run(); |
| 381 | 381 |
| 382 EXPECT_EQ(HTTP_SUCCESS, result_code); | 382 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 383 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 383 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 384 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" | 384 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" |
| 385 "showfolders=true&include-shared=true&max-results=500", | 385 "showfolders=true&include-shared=true&max-results=500", |
| 386 http_request_.relative_url); | 386 http_request_.relative_url); |
| 387 | 387 |
| 388 scoped_ptr<ResourceList> expected( | 388 scoped_ptr<ResourceList> expected( |
| 389 ResourceList::ExtractAndParse( | 389 ResourceList::ExtractAndParse( |
| 390 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); | 390 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 403 request_context_getter_.get(), | 403 request_context_getter_.get(), |
| 404 *url_generator_, | 404 *url_generator_, |
| 405 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 405 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
| 406 0, // start changestamp | 406 0, // start changestamp |
| 407 std::string(), // search string | 407 std::string(), // search string |
| 408 std::string(), // directory resource ID | 408 std::string(), // directory resource ID |
| 409 CreateComposedCallback( | 409 CreateComposedCallback( |
| 410 base::Bind(&test_util::RunAndQuit), | 410 base::Bind(&test_util::RunAndQuit), |
| 411 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 411 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 412 operation_runner_->StartOperationWithRetry(operation); | 412 operation_runner_->StartOperationWithRetry(operation); |
| 413 MessageLoop::current()->Run(); | 413 base::MessageLoop::current()->Run(); |
| 414 | 414 |
| 415 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 415 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
| 416 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 416 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 417 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" | 417 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" |
| 418 "showfolders=true&include-shared=true&max-results=500", | 418 "showfolders=true&include-shared=true&max-results=500", |
| 419 http_request_.relative_url); | 419 http_request_.relative_url); |
| 420 EXPECT_FALSE(result_data); | 420 EXPECT_FALSE(result_data); |
| 421 } | 421 } |
| 422 | 422 |
| 423 TEST_F(GDataWapiOperationsTest, SearchByTitleOperation) { | 423 TEST_F(GDataWapiOperationsTest, SearchByTitleOperation) { |
| 424 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 424 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 425 scoped_ptr<ResourceList> result_data; | 425 scoped_ptr<ResourceList> result_data; |
| 426 | 426 |
| 427 SearchByTitleOperation* operation = new SearchByTitleOperation( | 427 SearchByTitleOperation* operation = new SearchByTitleOperation( |
| 428 operation_runner_.get(), | 428 operation_runner_.get(), |
| 429 request_context_getter_.get(), | 429 request_context_getter_.get(), |
| 430 *url_generator_, | 430 *url_generator_, |
| 431 "search-title", | 431 "search-title", |
| 432 std::string(), // directory resource id | 432 std::string(), // directory resource id |
| 433 CreateComposedCallback( | 433 CreateComposedCallback( |
| 434 base::Bind(&test_util::RunAndQuit), | 434 base::Bind(&test_util::RunAndQuit), |
| 435 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 435 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 436 operation_runner_->StartOperationWithRetry(operation); | 436 operation_runner_->StartOperationWithRetry(operation); |
| 437 MessageLoop::current()->Run(); | 437 base::MessageLoop::current()->Run(); |
| 438 | 438 |
| 439 EXPECT_EQ(HTTP_SUCCESS, result_code); | 439 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 440 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 440 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 441 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 441 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
| 442 "showfolders=true&include-shared=true&max-results=500" | 442 "showfolders=true&include-shared=true&max-results=500" |
| 443 "&title=search-title&title-exact=true", | 443 "&title=search-title&title-exact=true", |
| 444 http_request_.relative_url); | 444 http_request_.relative_url); |
| 445 EXPECT_TRUE(result_data); | 445 EXPECT_TRUE(result_data); |
| 446 } | 446 } |
| 447 | 447 |
| 448 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { | 448 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { |
| 449 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 449 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 450 scoped_ptr<base::Value> result_data; | 450 scoped_ptr<base::Value> result_data; |
| 451 | 451 |
| 452 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 452 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
| 453 operation_runner_.get(), | 453 operation_runner_.get(), |
| 454 request_context_getter_.get(), | 454 request_context_getter_.get(), |
| 455 *url_generator_, | 455 *url_generator_, |
| 456 "file:2_file_resource_id", // resource ID | 456 "file:2_file_resource_id", // resource ID |
| 457 CreateComposedCallback( | 457 CreateComposedCallback( |
| 458 base::Bind(&test_util::RunAndQuit), | 458 base::Bind(&test_util::RunAndQuit), |
| 459 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 459 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 460 operation_runner_->StartOperationWithRetry(operation); | 460 operation_runner_->StartOperationWithRetry(operation); |
| 461 MessageLoop::current()->Run(); | 461 base::MessageLoop::current()->Run(); |
| 462 | 462 |
| 463 EXPECT_EQ(HTTP_SUCCESS, result_code); | 463 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 464 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 464 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 465 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 465 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
| 466 "?v=3&alt=json&showroot=true", | 466 "?v=3&alt=json&showroot=true", |
| 467 http_request_.relative_url); | 467 http_request_.relative_url); |
| 468 EXPECT_TRUE(test_util::VerifyJsonData( | 468 EXPECT_TRUE(test_util::VerifyJsonData( |
| 469 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), | 469 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), |
| 470 result_data.get())); | 470 result_data.get())); |
| 471 } | 471 } |
| 472 | 472 |
| 473 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { | 473 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { |
| 474 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 474 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 475 scoped_ptr<base::Value> result_data; | 475 scoped_ptr<base::Value> result_data; |
| 476 | 476 |
| 477 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 477 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
| 478 operation_runner_.get(), | 478 operation_runner_.get(), |
| 479 request_context_getter_.get(), | 479 request_context_getter_.get(), |
| 480 *url_generator_, | 480 *url_generator_, |
| 481 "<invalid>", // resource ID | 481 "<invalid>", // resource ID |
| 482 CreateComposedCallback( | 482 CreateComposedCallback( |
| 483 base::Bind(&test_util::RunAndQuit), | 483 base::Bind(&test_util::RunAndQuit), |
| 484 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 484 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 485 operation_runner_->StartOperationWithRetry(operation); | 485 operation_runner_->StartOperationWithRetry(operation); |
| 486 MessageLoop::current()->Run(); | 486 base::MessageLoop::current()->Run(); |
| 487 | 487 |
| 488 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 488 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
| 489 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 489 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 490 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" | 490 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" |
| 491 "&showroot=true", | 491 "&showroot=true", |
| 492 http_request_.relative_url); | 492 http_request_.relative_url); |
| 493 ASSERT_FALSE(result_data); | 493 ASSERT_FALSE(result_data); |
| 494 } | 494 } |
| 495 | 495 |
| 496 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { | 496 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { |
| 497 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 497 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 498 scoped_ptr<AccountMetadata> result_data; | 498 scoped_ptr<AccountMetadata> result_data; |
| 499 | 499 |
| 500 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 500 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
| 501 operation_runner_.get(), | 501 operation_runner_.get(), |
| 502 request_context_getter_.get(), | 502 request_context_getter_.get(), |
| 503 *url_generator_, | 503 *url_generator_, |
| 504 CreateComposedCallback( | 504 CreateComposedCallback( |
| 505 base::Bind(&test_util::RunAndQuit), | 505 base::Bind(&test_util::RunAndQuit), |
| 506 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 506 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 507 true); // Include installed apps. | 507 true); // Include installed apps. |
| 508 operation_runner_->StartOperationWithRetry(operation); | 508 operation_runner_->StartOperationWithRetry(operation); |
| 509 MessageLoop::current()->Run(); | 509 base::MessageLoop::current()->Run(); |
| 510 | 510 |
| 511 EXPECT_EQ(HTTP_SUCCESS, result_code); | 511 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 512 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 512 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 513 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true" | 513 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true" |
| 514 "&include-installed-apps=true", | 514 "&include-installed-apps=true", |
| 515 http_request_.relative_url); | 515 http_request_.relative_url); |
| 516 | 516 |
| 517 scoped_ptr<AccountMetadata> expected( | 517 scoped_ptr<AccountMetadata> expected( |
| 518 AccountMetadata::CreateFrom( | 518 AccountMetadata::CreateFrom( |
| 519 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); | 519 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 538 | 538 |
| 539 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 539 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
| 540 operation_runner_.get(), | 540 operation_runner_.get(), |
| 541 request_context_getter_.get(), | 541 request_context_getter_.get(), |
| 542 *url_generator_, | 542 *url_generator_, |
| 543 CreateComposedCallback( | 543 CreateComposedCallback( |
| 544 base::Bind(&test_util::RunAndQuit), | 544 base::Bind(&test_util::RunAndQuit), |
| 545 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 545 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 546 false); // Exclude installed apps. | 546 false); // Exclude installed apps. |
| 547 operation_runner_->StartOperationWithRetry(operation); | 547 operation_runner_->StartOperationWithRetry(operation); |
| 548 MessageLoop::current()->Run(); | 548 base::MessageLoop::current()->Run(); |
| 549 | 549 |
| 550 EXPECT_EQ(HTTP_SUCCESS, result_code); | 550 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 551 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 551 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 552 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true", | 552 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true", |
| 553 http_request_.relative_url); | 553 http_request_.relative_url); |
| 554 | 554 |
| 555 scoped_ptr<AccountMetadata> expected( | 555 scoped_ptr<AccountMetadata> expected( |
| 556 AccountMetadata::CreateFrom( | 556 AccountMetadata::CreateFrom( |
| 557 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); | 557 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); |
| 558 | 558 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 574 DeleteResourceOperation* operation = new DeleteResourceOperation( | 574 DeleteResourceOperation* operation = new DeleteResourceOperation( |
| 575 operation_runner_.get(), | 575 operation_runner_.get(), |
| 576 request_context_getter_.get(), | 576 request_context_getter_.get(), |
| 577 *url_generator_, | 577 *url_generator_, |
| 578 CreateComposedCallback(base::Bind(&test_util::RunAndQuit), | 578 CreateComposedCallback(base::Bind(&test_util::RunAndQuit), |
| 579 test_util::CreateCopyResultCallback(&result_code)), | 579 test_util::CreateCopyResultCallback(&result_code)), |
| 580 "file:2_file_resource_id", | 580 "file:2_file_resource_id", |
| 581 std::string()); | 581 std::string()); |
| 582 | 582 |
| 583 operation_runner_->StartOperationWithRetry(operation); | 583 operation_runner_->StartOperationWithRetry(operation); |
| 584 MessageLoop::current()->Run(); | 584 base::MessageLoop::current()->Run(); |
| 585 | 585 |
| 586 EXPECT_EQ(HTTP_SUCCESS, result_code); | 586 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 587 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 587 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
| 588 EXPECT_EQ( | 588 EXPECT_EQ( |
| 589 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 589 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
| 590 "&showroot=true", | 590 "&showroot=true", |
| 591 http_request_.relative_url); | 591 http_request_.relative_url); |
| 592 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 592 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 593 } | 593 } |
| 594 | 594 |
| 595 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { | 595 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { |
| 596 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 596 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 597 | 597 |
| 598 DeleteResourceOperation* operation = new DeleteResourceOperation( | 598 DeleteResourceOperation* operation = new DeleteResourceOperation( |
| 599 operation_runner_.get(), | 599 operation_runner_.get(), |
| 600 request_context_getter_.get(), | 600 request_context_getter_.get(), |
| 601 *url_generator_, | 601 *url_generator_, |
| 602 CreateComposedCallback( | 602 CreateComposedCallback( |
| 603 base::Bind(&test_util::RunAndQuit), | 603 base::Bind(&test_util::RunAndQuit), |
| 604 test_util::CreateCopyResultCallback(&result_code)), | 604 test_util::CreateCopyResultCallback(&result_code)), |
| 605 "file:2_file_resource_id", | 605 "file:2_file_resource_id", |
| 606 "etag"); | 606 "etag"); |
| 607 | 607 |
| 608 operation_runner_->StartOperationWithRetry(operation); | 608 operation_runner_->StartOperationWithRetry(operation); |
| 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(net::test_server::METHOD_DELETE, http_request_.method); | 612 EXPECT_EQ(net::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_runner_.get(), | 626 operation_runner_.get(), |
| 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_runner_->StartOperationWithRetry(operation); | 635 operation_runner_->StartOperationWithRetry(operation); |
| 636 MessageLoop::current()->Run(); | 636 base::MessageLoop::current()->Run(); |
| 637 | 637 |
| 638 EXPECT_EQ(HTTP_SUCCESS, result_code); | 638 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 639 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 639 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 640 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" | 640 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" |
| 641 "&showroot=true", | 641 "&showroot=true", |
| 642 http_request_.relative_url); | 642 http_request_.relative_url); |
| 643 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 643 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 644 | 644 |
| 645 EXPECT_TRUE(http_request_.has_content); | 645 EXPECT_TRUE(http_request_.has_content); |
| 646 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 646 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 661 operation_runner_.get(), | 661 operation_runner_.get(), |
| 662 request_context_getter_.get(), | 662 request_context_getter_.get(), |
| 663 *url_generator_, | 663 *url_generator_, |
| 664 CreateComposedCallback( | 664 CreateComposedCallback( |
| 665 base::Bind(&test_util::RunAndQuit), | 665 base::Bind(&test_util::RunAndQuit), |
| 666 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 666 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 667 "document:5_document_resource_id", // source resource ID | 667 "document:5_document_resource_id", // source resource ID |
| 668 "New Document"); | 668 "New Document"); |
| 669 | 669 |
| 670 operation_runner_->StartOperationWithRetry(operation); | 670 operation_runner_->StartOperationWithRetry(operation); |
| 671 MessageLoop::current()->Run(); | 671 base::MessageLoop::current()->Run(); |
| 672 | 672 |
| 673 EXPECT_EQ(HTTP_SUCCESS, result_code); | 673 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 674 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 674 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 675 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true", | 675 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true", |
| 676 http_request_.relative_url); | 676 http_request_.relative_url); |
| 677 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 677 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 678 | 678 |
| 679 EXPECT_TRUE(http_request_.has_content); | 679 EXPECT_TRUE(http_request_.has_content); |
| 680 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 680 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
| 681 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" | 681 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 693 operation_runner_.get(), | 693 operation_runner_.get(), |
| 694 request_context_getter_.get(), | 694 request_context_getter_.get(), |
| 695 *url_generator_, | 695 *url_generator_, |
| 696 CreateComposedCallback( | 696 CreateComposedCallback( |
| 697 base::Bind(&test_util::RunAndQuit), | 697 base::Bind(&test_util::RunAndQuit), |
| 698 test_util::CreateCopyResultCallback(&result_code)), | 698 test_util::CreateCopyResultCallback(&result_code)), |
| 699 "file:2_file_resource_id", | 699 "file:2_file_resource_id", |
| 700 "New File"); | 700 "New File"); |
| 701 | 701 |
| 702 operation_runner_->StartOperationWithRetry(operation); | 702 operation_runner_->StartOperationWithRetry(operation); |
| 703 MessageLoop::current()->Run(); | 703 base::MessageLoop::current()->Run(); |
| 704 | 704 |
| 705 EXPECT_EQ(HTTP_SUCCESS, result_code); | 705 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 706 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 706 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 707 EXPECT_EQ( | 707 EXPECT_EQ( |
| 708 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 708 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
| 709 "&showroot=true", | 709 "&showroot=true", |
| 710 http_request_.relative_url); | 710 http_request_.relative_url); |
| 711 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 711 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 712 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 712 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 713 | 713 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 728 operation_runner_.get(), | 728 operation_runner_.get(), |
| 729 request_context_getter_.get(), | 729 request_context_getter_.get(), |
| 730 *url_generator_, | 730 *url_generator_, |
| 731 CreateComposedCallback( | 731 CreateComposedCallback( |
| 732 base::Bind(&test_util::RunAndQuit), | 732 base::Bind(&test_util::RunAndQuit), |
| 733 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 733 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 734 "file:2_file_resource_id", | 734 "file:2_file_resource_id", |
| 735 "the_app_id"); | 735 "the_app_id"); |
| 736 | 736 |
| 737 operation_runner_->StartOperationWithRetry(operation); | 737 operation_runner_->StartOperationWithRetry(operation); |
| 738 MessageLoop::current()->Run(); | 738 base::MessageLoop::current()->Run(); |
| 739 | 739 |
| 740 EXPECT_EQ(HTTP_SUCCESS, result_code); | 740 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 741 EXPECT_EQ(GURL("https://entry1_open_with_link/"), result_data); | 741 EXPECT_EQ(GURL("https://entry1_open_with_link/"), result_data); |
| 742 | 742 |
| 743 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 743 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 744 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 744 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
| 745 "?v=3&alt=json&showroot=true", | 745 "?v=3&alt=json&showroot=true", |
| 746 http_request_.relative_url); | 746 http_request_.relative_url); |
| 747 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 747 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 748 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 748 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 765 operation_runner_.get(), | 765 operation_runner_.get(), |
| 766 request_context_getter_.get(), | 766 request_context_getter_.get(), |
| 767 *url_generator_, | 767 *url_generator_, |
| 768 CreateComposedCallback( | 768 CreateComposedCallback( |
| 769 base::Bind(&test_util::RunAndQuit), | 769 base::Bind(&test_util::RunAndQuit), |
| 770 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 770 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 771 "file:2_file_resource_id", | 771 "file:2_file_resource_id", |
| 772 "unauthorized_app_id"); | 772 "unauthorized_app_id"); |
| 773 | 773 |
| 774 operation_runner_->StartOperationWithRetry(operation); | 774 operation_runner_->StartOperationWithRetry(operation); |
| 775 MessageLoop::current()->Run(); | 775 base::MessageLoop::current()->Run(); |
| 776 | 776 |
| 777 EXPECT_EQ(GDATA_OTHER_ERROR, result_code); | 777 EXPECT_EQ(GDATA_OTHER_ERROR, result_code); |
| 778 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 778 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 779 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 779 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
| 780 "?v=3&alt=json&showroot=true", | 780 "?v=3&alt=json&showroot=true", |
| 781 http_request_.relative_url); | 781 http_request_.relative_url); |
| 782 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 782 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 783 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 783 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 784 | 784 |
| 785 EXPECT_TRUE(http_request_.has_content); | 785 EXPECT_TRUE(http_request_.has_content); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 800 operation_runner_.get(), | 800 operation_runner_.get(), |
| 801 request_context_getter_.get(), | 801 request_context_getter_.get(), |
| 802 *url_generator_, | 802 *url_generator_, |
| 803 CreateComposedCallback( | 803 CreateComposedCallback( |
| 804 base::Bind(&test_util::RunAndQuit), | 804 base::Bind(&test_util::RunAndQuit), |
| 805 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 805 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
| 806 "invalid_resource_id", | 806 "invalid_resource_id", |
| 807 "APP_ID"); | 807 "APP_ID"); |
| 808 | 808 |
| 809 operation_runner_->StartOperationWithRetry(operation); | 809 operation_runner_->StartOperationWithRetry(operation); |
| 810 MessageLoop::current()->Run(); | 810 base::MessageLoop::current()->Run(); |
| 811 | 811 |
| 812 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 812 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
| 813 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 813 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 814 EXPECT_EQ("/feeds/default/private/full/invalid_resource_id" | 814 EXPECT_EQ("/feeds/default/private/full/invalid_resource_id" |
| 815 "?v=3&alt=json&showroot=true", | 815 "?v=3&alt=json&showroot=true", |
| 816 http_request_.relative_url); | 816 http_request_.relative_url); |
| 817 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 817 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 818 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 818 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 819 | 819 |
| 820 EXPECT_TRUE(http_request_.has_content); | 820 EXPECT_TRUE(http_request_.has_content); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 835 operation_runner_.get(), | 835 operation_runner_.get(), |
| 836 request_context_getter_.get(), | 836 request_context_getter_.get(), |
| 837 *url_generator_, | 837 *url_generator_, |
| 838 CreateComposedCallback( | 838 CreateComposedCallback( |
| 839 base::Bind(&test_util::RunAndQuit), | 839 base::Bind(&test_util::RunAndQuit), |
| 840 test_util::CreateCopyResultCallback(&result_code)), | 840 test_util::CreateCopyResultCallback(&result_code)), |
| 841 "folder:root", | 841 "folder:root", |
| 842 "file:2_file_resource_id"); | 842 "file:2_file_resource_id"); |
| 843 | 843 |
| 844 operation_runner_->StartOperationWithRetry(operation); | 844 operation_runner_->StartOperationWithRetry(operation); |
| 845 MessageLoop::current()->Run(); | 845 base::MessageLoop::current()->Run(); |
| 846 | 846 |
| 847 EXPECT_EQ(HTTP_SUCCESS, result_code); | 847 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 848 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 848 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 849 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" | 849 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" |
| 850 "&showroot=true", | 850 "&showroot=true", |
| 851 http_request_.relative_url); | 851 http_request_.relative_url); |
| 852 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 852 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
| 853 | 853 |
| 854 EXPECT_TRUE(http_request_.has_content); | 854 EXPECT_TRUE(http_request_.has_content); |
| 855 EXPECT_EQ(base::StringPrintf("<?xml version=\"1.0\"?>\n" | 855 EXPECT_EQ(base::StringPrintf("<?xml version=\"1.0\"?>\n" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 870 operation_runner_.get(), | 870 operation_runner_.get(), |
| 871 request_context_getter_.get(), | 871 request_context_getter_.get(), |
| 872 *url_generator_, | 872 *url_generator_, |
| 873 CreateComposedCallback( | 873 CreateComposedCallback( |
| 874 base::Bind(&test_util::RunAndQuit), | 874 base::Bind(&test_util::RunAndQuit), |
| 875 test_util::CreateCopyResultCallback(&result_code)), | 875 test_util::CreateCopyResultCallback(&result_code)), |
| 876 "folder:root", | 876 "folder:root", |
| 877 "file:2_file_resource_id"); | 877 "file:2_file_resource_id"); |
| 878 | 878 |
| 879 operation_runner_->StartOperationWithRetry(operation); | 879 operation_runner_->StartOperationWithRetry(operation); |
| 880 MessageLoop::current()->Run(); | 880 base::MessageLoop::current()->Run(); |
| 881 | 881 |
| 882 EXPECT_EQ(HTTP_SUCCESS, result_code); | 882 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 883 // DELETE method should be used, without the body content. | 883 // DELETE method should be used, without the body content. |
| 884 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 884 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
| 885 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" | 885 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" |
| 886 "file%3A2_file_resource_id?v=3&alt=json&showroot=true", | 886 "file%3A2_file_resource_id?v=3&alt=json&showroot=true", |
| 887 http_request_.relative_url); | 887 http_request_.relative_url); |
| 888 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 888 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 889 EXPECT_FALSE(http_request_.has_content); | 889 EXPECT_FALSE(http_request_.has_content); |
| 890 } | 890 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 909 CreateComposedCallback( | 909 CreateComposedCallback( |
| 910 base::Bind(&test_util::RunAndQuit), | 910 base::Bind(&test_util::RunAndQuit), |
| 911 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 911 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 912 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 912 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 913 "text/plain", | 913 "text/plain", |
| 914 kUploadContent.size(), | 914 kUploadContent.size(), |
| 915 "folder:id", | 915 "folder:id", |
| 916 "New file"); | 916 "New file"); |
| 917 | 917 |
| 918 operation_runner_->StartOperationWithRetry(initiate_operation); | 918 operation_runner_->StartOperationWithRetry(initiate_operation); |
| 919 MessageLoop::current()->Run(); | 919 base::MessageLoop::current()->Run(); |
| 920 | 920 |
| 921 EXPECT_EQ(HTTP_SUCCESS, result_code); | 921 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 922 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 922 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
| 923 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 923 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 924 // convert=false should be passed as files should be uploaded as-is. | 924 // convert=false should be passed as files should be uploaded as-is. |
| 925 EXPECT_EQ( | 925 EXPECT_EQ( |
| 926 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 926 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
| 927 "?convert=false&v=3&alt=json&showroot=true", | 927 "?convert=false&v=3&alt=json&showroot=true", |
| 928 http_request_.relative_url); | 928 http_request_.relative_url); |
| 929 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 929 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 952 ProgressCallback(), | 952 ProgressCallback(), |
| 953 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 953 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 954 upload_url, | 954 upload_url, |
| 955 0, // start_position | 955 0, // start_position |
| 956 kUploadContent.size(), // end_position (exclusive) | 956 kUploadContent.size(), // end_position (exclusive) |
| 957 kUploadContent.size(), // content_length, | 957 kUploadContent.size(), // content_length, |
| 958 "text/plain", // content_type | 958 "text/plain", // content_type |
| 959 kTestFilePath); | 959 kTestFilePath); |
| 960 | 960 |
| 961 operation_runner_->StartOperationWithRetry(resume_operation); | 961 operation_runner_->StartOperationWithRetry(resume_operation); |
| 962 MessageLoop::current()->Run(); | 962 base::MessageLoop::current()->Run(); |
| 963 | 963 |
| 964 // METHOD_PUT should be used to upload data. | 964 // METHOD_PUT should be used to upload data. |
| 965 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 965 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 966 // Request should go to the upload URL. | 966 // Request should go to the upload URL. |
| 967 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 967 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 968 // Content-Range header should be added. | 968 // Content-Range header should be added. |
| 969 EXPECT_EQ("bytes 0-" + | 969 EXPECT_EQ("bytes 0-" + |
| 970 base::Int64ToString(kUploadContent.size() -1) + "/" + | 970 base::Int64ToString(kUploadContent.size() -1) + "/" + |
| 971 base::Int64ToString(kUploadContent.size()), | 971 base::Int64ToString(kUploadContent.size()), |
| 972 http_request_.headers["Content-Range"]); | 972 http_request_.headers["Content-Range"]); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 CreateComposedCallback( | 1011 CreateComposedCallback( |
| 1012 base::Bind(&test_util::RunAndQuit), | 1012 base::Bind(&test_util::RunAndQuit), |
| 1013 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1013 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1014 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1014 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1015 "text/plain", | 1015 "text/plain", |
| 1016 kUploadContent.size(), | 1016 kUploadContent.size(), |
| 1017 "folder:id", | 1017 "folder:id", |
| 1018 "New file"); | 1018 "New file"); |
| 1019 | 1019 |
| 1020 operation_runner_->StartOperationWithRetry(initiate_operation); | 1020 operation_runner_->StartOperationWithRetry(initiate_operation); |
| 1021 MessageLoop::current()->Run(); | 1021 base::MessageLoop::current()->Run(); |
| 1022 | 1022 |
| 1023 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1023 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1024 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 1024 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
| 1025 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1025 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 1026 // convert=false should be passed as files should be uploaded as-is. | 1026 // convert=false should be passed as files should be uploaded as-is. |
| 1027 EXPECT_EQ( | 1027 EXPECT_EQ( |
| 1028 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 1028 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
| 1029 "?convert=false&v=3&alt=json&showroot=true", | 1029 "?convert=false&v=3&alt=json&showroot=true", |
| 1030 http_request_.relative_url); | 1030 http_request_.relative_url); |
| 1031 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1031 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1054 new GetUploadStatusOperation( | 1054 new GetUploadStatusOperation( |
| 1055 operation_runner_.get(), | 1055 operation_runner_.get(), |
| 1056 request_context_getter_.get(), | 1056 request_context_getter_.get(), |
| 1057 CreateComposedCallback( | 1057 CreateComposedCallback( |
| 1058 base::Bind(&test_util::RunAndQuit), | 1058 base::Bind(&test_util::RunAndQuit), |
| 1059 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1059 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1060 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1060 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1061 upload_url, | 1061 upload_url, |
| 1062 kUploadContent.size()); | 1062 kUploadContent.size()); |
| 1063 operation_runner_->StartOperationWithRetry(get_upload_status_operation); | 1063 operation_runner_->StartOperationWithRetry(get_upload_status_operation); |
| 1064 MessageLoop::current()->Run(); | 1064 base::MessageLoop::current()->Run(); |
| 1065 | 1065 |
| 1066 // METHOD_PUT should be used to upload data. | 1066 // METHOD_PUT should be used to upload data. |
| 1067 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1067 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1068 // Request should go to the upload URL. | 1068 // Request should go to the upload URL. |
| 1069 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1069 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1070 // Content-Range header should be added. | 1070 // Content-Range header should be added. |
| 1071 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), | 1071 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), |
| 1072 http_request_.headers["Content-Range"]); | 1072 http_request_.headers["Content-Range"]); |
| 1073 EXPECT_TRUE(http_request_.has_content); | 1073 EXPECT_TRUE(http_request_.has_content); |
| 1074 EXPECT_TRUE(http_request_.content.empty()); | 1074 EXPECT_TRUE(http_request_.content.empty()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 ProgressCallback(), | 1106 ProgressCallback(), |
| 1107 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1107 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1108 upload_url, | 1108 upload_url, |
| 1109 start_position, | 1109 start_position, |
| 1110 end_position, | 1110 end_position, |
| 1111 kUploadContent.size(), // content_length, | 1111 kUploadContent.size(), // content_length, |
| 1112 "text/plain", // content_type | 1112 "text/plain", // content_type |
| 1113 kTestFilePath); | 1113 kTestFilePath); |
| 1114 | 1114 |
| 1115 operation_runner_->StartOperationWithRetry(resume_operation); | 1115 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1116 MessageLoop::current()->Run(); | 1116 base::MessageLoop::current()->Run(); |
| 1117 | 1117 |
| 1118 // METHOD_PUT should be used to upload data. | 1118 // METHOD_PUT should be used to upload data. |
| 1119 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1119 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1120 // Request should go to the upload URL. | 1120 // Request should go to the upload URL. |
| 1121 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1121 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1122 // Content-Range header should be added. | 1122 // Content-Range header should be added. |
| 1123 EXPECT_EQ("bytes " + | 1123 EXPECT_EQ("bytes " + |
| 1124 base::Int64ToString(start_position) + "-" + | 1124 base::Int64ToString(start_position) + "-" + |
| 1125 base::Int64ToString(end_position - 1) + "/" + | 1125 base::Int64ToString(end_position - 1) + "/" + |
| 1126 base::Int64ToString(kUploadContent.size()), | 1126 base::Int64ToString(kUploadContent.size()), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1151 new GetUploadStatusOperation( | 1151 new GetUploadStatusOperation( |
| 1152 operation_runner_.get(), | 1152 operation_runner_.get(), |
| 1153 request_context_getter_.get(), | 1153 request_context_getter_.get(), |
| 1154 CreateComposedCallback( | 1154 CreateComposedCallback( |
| 1155 base::Bind(&test_util::RunAndQuit), | 1155 base::Bind(&test_util::RunAndQuit), |
| 1156 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1156 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1157 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1157 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1158 upload_url, | 1158 upload_url, |
| 1159 kUploadContent.size()); | 1159 kUploadContent.size()); |
| 1160 operation_runner_->StartOperationWithRetry(get_upload_operation); | 1160 operation_runner_->StartOperationWithRetry(get_upload_operation); |
| 1161 MessageLoop::current()->Run(); | 1161 base::MessageLoop::current()->Run(); |
| 1162 | 1162 |
| 1163 // METHOD_PUT should be used to upload data. | 1163 // METHOD_PUT should be used to upload data. |
| 1164 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1164 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1165 // Request should go to the upload URL. | 1165 // Request should go to the upload URL. |
| 1166 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1166 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1167 // Content-Range header should be added. | 1167 // Content-Range header should be added. |
| 1168 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), | 1168 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), |
| 1169 http_request_.headers["Content-Range"]); | 1169 http_request_.headers["Content-Range"]); |
| 1170 EXPECT_TRUE(http_request_.has_content); | 1170 EXPECT_TRUE(http_request_.has_content); |
| 1171 EXPECT_TRUE(http_request_.content.empty()); | 1171 EXPECT_TRUE(http_request_.content.empty()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 CreateComposedCallback( | 1204 CreateComposedCallback( |
| 1205 base::Bind(&test_util::RunAndQuit), | 1205 base::Bind(&test_util::RunAndQuit), |
| 1206 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1206 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1207 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1207 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1208 "text/plain", | 1208 "text/plain", |
| 1209 kUploadContent.size(), | 1209 kUploadContent.size(), |
| 1210 "folder:id", | 1210 "folder:id", |
| 1211 "New file"); | 1211 "New file"); |
| 1212 | 1212 |
| 1213 operation_runner_->StartOperationWithRetry(initiate_operation); | 1213 operation_runner_->StartOperationWithRetry(initiate_operation); |
| 1214 MessageLoop::current()->Run(); | 1214 base::MessageLoop::current()->Run(); |
| 1215 | 1215 |
| 1216 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1216 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1217 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 1217 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
| 1218 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1218 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 1219 // convert=false should be passed as files should be uploaded as-is. | 1219 // convert=false should be passed as files should be uploaded as-is. |
| 1220 EXPECT_EQ( | 1220 EXPECT_EQ( |
| 1221 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 1221 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
| 1222 "?convert=false&v=3&alt=json&showroot=true", | 1222 "?convert=false&v=3&alt=json&showroot=true", |
| 1223 http_request_.relative_url); | 1223 http_request_.relative_url); |
| 1224 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1224 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1247 ProgressCallback(), | 1247 ProgressCallback(), |
| 1248 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1248 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
| 1249 upload_url, | 1249 upload_url, |
| 1250 0, // start_position | 1250 0, // start_position |
| 1251 kUploadContent.size(), // end_position (exclusive) | 1251 kUploadContent.size(), // end_position (exclusive) |
| 1252 kUploadContent.size(), // content_length, | 1252 kUploadContent.size(), // content_length, |
| 1253 "text/plain", // content_type | 1253 "text/plain", // content_type |
| 1254 kTestFilePath); | 1254 kTestFilePath); |
| 1255 | 1255 |
| 1256 operation_runner_->StartOperationWithRetry(resume_operation); | 1256 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1257 MessageLoop::current()->Run(); | 1257 base::MessageLoop::current()->Run(); |
| 1258 | 1258 |
| 1259 // METHOD_PUT should be used to upload data. | 1259 // METHOD_PUT should be used to upload data. |
| 1260 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1260 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1261 // Request should go to the upload URL. | 1261 // Request should go to the upload URL. |
| 1262 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1262 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1263 // Content-Range header should not exit if the content is empty. | 1263 // Content-Range header should not exit if the content is empty. |
| 1264 // We should not generate the header with an invalid value "bytes 0--1/0". | 1264 // We should not generate the header with an invalid value "bytes 0--1/0". |
| 1265 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 1265 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
| 1266 // The upload content should be set in the HTTP request. | 1266 // The upload content should be set in the HTTP request. |
| 1267 EXPECT_TRUE(http_request_.has_content); | 1267 EXPECT_TRUE(http_request_.has_content); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1294 CreateComposedCallback( | 1294 CreateComposedCallback( |
| 1295 base::Bind(&test_util::RunAndQuit), | 1295 base::Bind(&test_util::RunAndQuit), |
| 1296 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1296 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1297 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1297 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1298 "text/plain", | 1298 "text/plain", |
| 1299 kUploadContent.size(), | 1299 kUploadContent.size(), |
| 1300 "file:foo", | 1300 "file:foo", |
| 1301 std::string() /* etag */); | 1301 std::string() /* etag */); |
| 1302 | 1302 |
| 1303 operation_runner_->StartOperationWithRetry(initiate_operation); | 1303 operation_runner_->StartOperationWithRetry(initiate_operation); |
| 1304 MessageLoop::current()->Run(); | 1304 base::MessageLoop::current()->Run(); |
| 1305 | 1305 |
| 1306 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1306 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1307 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); | 1307 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); |
| 1308 // For updating an existing file, METHOD_PUT should be used. | 1308 // For updating an existing file, METHOD_PUT should be used. |
| 1309 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1309 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1310 // convert=false should be passed as files should be uploaded as-is. | 1310 // convert=false should be passed as files should be uploaded as-is. |
| 1311 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1311 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
| 1312 "?convert=false&v=3&alt=json&showroot=true", | 1312 "?convert=false&v=3&alt=json&showroot=true", |
| 1313 http_request_.relative_url); | 1313 http_request_.relative_url); |
| 1314 // Even though the body is empty, the content type should be set to | 1314 // Even though the body is empty, the content type should be set to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1336 ProgressCallback(), | 1336 ProgressCallback(), |
| 1337 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1337 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1338 upload_url, | 1338 upload_url, |
| 1339 0, // start_position | 1339 0, // start_position |
| 1340 kUploadContent.size(), // end_position (exclusive) | 1340 kUploadContent.size(), // end_position (exclusive) |
| 1341 kUploadContent.size(), // content_length, | 1341 kUploadContent.size(), // content_length, |
| 1342 "text/plain", // content_type | 1342 "text/plain", // content_type |
| 1343 kTestFilePath); | 1343 kTestFilePath); |
| 1344 | 1344 |
| 1345 operation_runner_->StartOperationWithRetry(resume_operation); | 1345 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1346 MessageLoop::current()->Run(); | 1346 base::MessageLoop::current()->Run(); |
| 1347 | 1347 |
| 1348 // METHOD_PUT should be used to upload data. | 1348 // METHOD_PUT should be used to upload data. |
| 1349 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1349 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1350 // Request should go to the upload URL. | 1350 // Request should go to the upload URL. |
| 1351 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1351 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1352 // Content-Range header should be added. | 1352 // Content-Range header should be added. |
| 1353 EXPECT_EQ("bytes 0-" + | 1353 EXPECT_EQ("bytes 0-" + |
| 1354 base::Int64ToString(kUploadContent.size() -1) + "/" + | 1354 base::Int64ToString(kUploadContent.size() -1) + "/" + |
| 1355 base::Int64ToString(kUploadContent.size()), | 1355 base::Int64ToString(kUploadContent.size()), |
| 1356 http_request_.headers["Content-Range"]); | 1356 http_request_.headers["Content-Range"]); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1385 CreateComposedCallback( | 1385 CreateComposedCallback( |
| 1386 base::Bind(&test_util::RunAndQuit), | 1386 base::Bind(&test_util::RunAndQuit), |
| 1387 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1387 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1388 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1388 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1389 "text/plain", | 1389 "text/plain", |
| 1390 kUploadContent.size(), | 1390 kUploadContent.size(), |
| 1391 "file:foo", | 1391 "file:foo", |
| 1392 kTestETag); | 1392 kTestETag); |
| 1393 | 1393 |
| 1394 operation_runner_->StartOperationWithRetry(initiate_operation); | 1394 operation_runner_->StartOperationWithRetry(initiate_operation); |
| 1395 MessageLoop::current()->Run(); | 1395 base::MessageLoop::current()->Run(); |
| 1396 | 1396 |
| 1397 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1397 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 1398 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); | 1398 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); |
| 1399 // For updating an existing file, METHOD_PUT should be used. | 1399 // For updating an existing file, METHOD_PUT should be used. |
| 1400 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1400 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1401 // convert=false should be passed as files should be uploaded as-is. | 1401 // convert=false should be passed as files should be uploaded as-is. |
| 1402 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1402 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
| 1403 "?convert=false&v=3&alt=json&showroot=true", | 1403 "?convert=false&v=3&alt=json&showroot=true", |
| 1404 http_request_.relative_url); | 1404 http_request_.relative_url); |
| 1405 // Even though the body is empty, the content type should be set to | 1405 // Even though the body is empty, the content type should be set to |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1427 ProgressCallback(), | 1427 ProgressCallback(), |
| 1428 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1428 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1429 upload_url, | 1429 upload_url, |
| 1430 0, // start_position | 1430 0, // start_position |
| 1431 kUploadContent.size(), // end_position (exclusive) | 1431 kUploadContent.size(), // end_position (exclusive) |
| 1432 kUploadContent.size(), // content_length, | 1432 kUploadContent.size(), // content_length, |
| 1433 "text/plain", // content_type | 1433 "text/plain", // content_type |
| 1434 kTestFilePath); | 1434 kTestFilePath); |
| 1435 | 1435 |
| 1436 operation_runner_->StartOperationWithRetry(resume_operation); | 1436 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1437 MessageLoop::current()->Run(); | 1437 base::MessageLoop::current()->Run(); |
| 1438 | 1438 |
| 1439 // METHOD_PUT should be used to upload data. | 1439 // METHOD_PUT should be used to upload data. |
| 1440 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1440 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1441 // Request should go to the upload URL. | 1441 // Request should go to the upload URL. |
| 1442 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1442 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1443 // Content-Range header should be added. | 1443 // Content-Range header should be added. |
| 1444 EXPECT_EQ("bytes 0-" + | 1444 EXPECT_EQ("bytes 0-" + |
| 1445 base::Int64ToString(kUploadContent.size() -1) + "/" + | 1445 base::Int64ToString(kUploadContent.size() -1) + "/" + |
| 1446 base::Int64ToString(kUploadContent.size()), | 1446 base::Int64ToString(kUploadContent.size()), |
| 1447 http_request_.headers["Content-Range"]); | 1447 http_request_.headers["Content-Range"]); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1472 CreateComposedCallback( | 1472 CreateComposedCallback( |
| 1473 base::Bind(&test_util::RunAndQuit), | 1473 base::Bind(&test_util::RunAndQuit), |
| 1474 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1474 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
| 1475 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1475 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
| 1476 "text/plain", | 1476 "text/plain", |
| 1477 kUploadContent.size(), | 1477 kUploadContent.size(), |
| 1478 "file:foo", | 1478 "file:foo", |
| 1479 kWrongETag); | 1479 kWrongETag); |
| 1480 | 1480 |
| 1481 operation_runner_->StartOperationWithRetry(initiate_operation); | 1481 operation_runner_->StartOperationWithRetry(initiate_operation); |
| 1482 MessageLoop::current()->Run(); | 1482 base::MessageLoop::current()->Run(); |
| 1483 | 1483 |
| 1484 EXPECT_EQ(HTTP_PRECONDITION, result_code); | 1484 EXPECT_EQ(HTTP_PRECONDITION, result_code); |
| 1485 // For updating an existing file, METHOD_PUT should be used. | 1485 // For updating an existing file, METHOD_PUT should be used. |
| 1486 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1486 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1487 // convert=false should be passed as files should be uploaded as-is. | 1487 // convert=false should be passed as files should be uploaded as-is. |
| 1488 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1488 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
| 1489 "?convert=false&v=3&alt=json&showroot=true", | 1489 "?convert=false&v=3&alt=json&showroot=true", |
| 1490 http_request_.relative_url); | 1490 http_request_.relative_url); |
| 1491 // Even though the body is empty, the content type should be set to | 1491 // Even though the body is empty, the content type should be set to |
| 1492 // "text/plain". | 1492 // "text/plain". |
| 1493 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); | 1493 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); |
| 1494 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1494 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
| 1495 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1495 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1496 http_request_.headers["X-Upload-Content-Length"]); | 1496 http_request_.headers["X-Upload-Content-Length"]); |
| 1497 // For updating an existing file, an empty body should be attached (PUT | 1497 // For updating an existing file, an empty body should be attached (PUT |
| 1498 // requires a body) | 1498 // requires a body) |
| 1499 EXPECT_TRUE(http_request_.has_content); | 1499 EXPECT_TRUE(http_request_.has_content); |
| 1500 EXPECT_EQ("", http_request_.content); | 1500 EXPECT_EQ("", http_request_.content); |
| 1501 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1501 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 } // namespace google_apis | 1504 } // namespace google_apis |
| OLD | NEW |