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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); | 308 "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); |
309 } | 309 } |
310 | 310 |
311 // Change the code to RESUME_INCOMPLETE if upload is not complete. | 311 // Change the code to RESUME_INCOMPLETE if upload is not complete. |
312 if (received_bytes_ < content_length_) | 312 if (received_bytes_ < content_length_) |
313 response->set_code(net::test_server::RESUME_INCOMPLETE); | 313 response->set_code(net::test_server::RESUME_INCOMPLETE); |
314 | 314 |
315 return response.PassAs<net::test_server::HttpResponse>(); | 315 return response.PassAs<net::test_server::HttpResponse>(); |
316 } | 316 } |
317 | 317 |
318 MessageLoopForUI message_loop_; | 318 base::MessageLoopForUI message_loop_; |
319 content::TestBrowserThread ui_thread_; | 319 content::TestBrowserThread ui_thread_; |
320 content::TestBrowserThread file_thread_; | 320 content::TestBrowserThread file_thread_; |
321 content::TestBrowserThread io_thread_; | 321 content::TestBrowserThread io_thread_; |
322 net::test_server::EmbeddedTestServer test_server_; | 322 net::test_server::EmbeddedTestServer test_server_; |
323 scoped_ptr<TestingProfile> profile_; | 323 scoped_ptr<TestingProfile> profile_; |
324 scoped_ptr<OperationRunner> operation_runner_; | 324 scoped_ptr<OperationRunner> operation_runner_; |
325 scoped_ptr<GDataWapiUrlGenerator> url_generator_; | 325 scoped_ptr<GDataWapiUrlGenerator> url_generator_; |
326 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 326 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
327 base::ScopedTempDir temp_dir_; | 327 base::ScopedTempDir temp_dir_; |
328 | 328 |
(...skipping 22 matching lines...) Expand all Loading... |
351 request_context_getter_.get(), | 351 request_context_getter_.get(), |
352 *url_generator_, | 352 *url_generator_, |
353 GURL(), // Pass an empty URL to use the default feed | 353 GURL(), // Pass an empty URL to use the default feed |
354 0, // start changestamp | 354 0, // start changestamp |
355 std::string(), // search string | 355 std::string(), // search string |
356 std::string(), // directory resource ID | 356 std::string(), // directory resource ID |
357 CreateComposedCallback( | 357 CreateComposedCallback( |
358 base::Bind(&test_util::RunAndQuit), | 358 base::Bind(&test_util::RunAndQuit), |
359 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 359 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
360 operation_runner_->StartOperationWithRetry(operation); | 360 operation_runner_->StartOperationWithRetry(operation); |
361 MessageLoop::current()->Run(); | 361 base::MessageLoop::current()->Run(); |
362 | 362 |
363 EXPECT_EQ(HTTP_SUCCESS, result_code); | 363 EXPECT_EQ(HTTP_SUCCESS, result_code); |
364 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 364 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
365 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 365 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
366 "showfolders=true&include-shared=true&max-results=500", | 366 "showfolders=true&include-shared=true&max-results=500", |
367 http_request_.relative_url); | 367 http_request_.relative_url); |
368 | 368 |
369 // Sanity check of the result. | 369 // Sanity check of the result. |
370 scoped_ptr<ResourceList> expected( | 370 scoped_ptr<ResourceList> expected( |
371 ResourceList::ExtractAndParse( | 371 ResourceList::ExtractAndParse( |
(...skipping 11 matching lines...) Expand all Loading... |
383 request_context_getter_.get(), | 383 request_context_getter_.get(), |
384 *url_generator_, | 384 *url_generator_, |
385 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), | 385 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), |
386 0, // start changestamp | 386 0, // start changestamp |
387 std::string(), // search string | 387 std::string(), // search string |
388 std::string(), // directory resource ID | 388 std::string(), // directory resource ID |
389 CreateComposedCallback( | 389 CreateComposedCallback( |
390 base::Bind(&test_util::RunAndQuit), | 390 base::Bind(&test_util::RunAndQuit), |
391 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 391 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
392 operation_runner_->StartOperationWithRetry(operation); | 392 operation_runner_->StartOperationWithRetry(operation); |
393 MessageLoop::current()->Run(); | 393 base::MessageLoop::current()->Run(); |
394 | 394 |
395 EXPECT_EQ(HTTP_SUCCESS, result_code); | 395 EXPECT_EQ(HTTP_SUCCESS, result_code); |
396 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 396 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
397 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" | 397 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" |
398 "showfolders=true&include-shared=true&max-results=500", | 398 "showfolders=true&include-shared=true&max-results=500", |
399 http_request_.relative_url); | 399 http_request_.relative_url); |
400 | 400 |
401 scoped_ptr<ResourceList> expected( | 401 scoped_ptr<ResourceList> expected( |
402 ResourceList::ExtractAndParse( | 402 ResourceList::ExtractAndParse( |
403 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); | 403 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); |
(...skipping 12 matching lines...) Expand all Loading... |
416 request_context_getter_.get(), | 416 request_context_getter_.get(), |
417 *url_generator_, | 417 *url_generator_, |
418 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), | 418 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), |
419 0, // start changestamp | 419 0, // start changestamp |
420 std::string(), // search string | 420 std::string(), // search string |
421 std::string(), // directory resource ID | 421 std::string(), // directory resource ID |
422 CreateComposedCallback( | 422 CreateComposedCallback( |
423 base::Bind(&test_util::RunAndQuit), | 423 base::Bind(&test_util::RunAndQuit), |
424 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 424 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
425 operation_runner_->StartOperationWithRetry(operation); | 425 operation_runner_->StartOperationWithRetry(operation); |
426 MessageLoop::current()->Run(); | 426 base::MessageLoop::current()->Run(); |
427 | 427 |
428 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 428 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
429 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 429 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
430 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" | 430 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" |
431 "showfolders=true&include-shared=true&max-results=500", | 431 "showfolders=true&include-shared=true&max-results=500", |
432 http_request_.relative_url); | 432 http_request_.relative_url); |
433 EXPECT_FALSE(result_data); | 433 EXPECT_FALSE(result_data); |
434 } | 434 } |
435 | 435 |
436 TEST_F(GDataWapiOperationsTest, SearchByTitleOperation) { | 436 TEST_F(GDataWapiOperationsTest, SearchByTitleOperation) { |
437 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 437 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
438 scoped_ptr<ResourceList> result_data; | 438 scoped_ptr<ResourceList> result_data; |
439 | 439 |
440 SearchByTitleOperation* operation = new SearchByTitleOperation( | 440 SearchByTitleOperation* operation = new SearchByTitleOperation( |
441 operation_runner_.get(), | 441 operation_runner_.get(), |
442 request_context_getter_.get(), | 442 request_context_getter_.get(), |
443 *url_generator_, | 443 *url_generator_, |
444 "search-title", | 444 "search-title", |
445 std::string(), // directory resource id | 445 std::string(), // directory resource id |
446 CreateComposedCallback( | 446 CreateComposedCallback( |
447 base::Bind(&test_util::RunAndQuit), | 447 base::Bind(&test_util::RunAndQuit), |
448 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 448 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
449 operation_runner_->StartOperationWithRetry(operation); | 449 operation_runner_->StartOperationWithRetry(operation); |
450 MessageLoop::current()->Run(); | 450 base::MessageLoop::current()->Run(); |
451 | 451 |
452 EXPECT_EQ(HTTP_SUCCESS, result_code); | 452 EXPECT_EQ(HTTP_SUCCESS, result_code); |
453 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 453 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
454 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 454 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
455 "showfolders=true&include-shared=true&max-results=500" | 455 "showfolders=true&include-shared=true&max-results=500" |
456 "&title=search-title&title-exact=true", | 456 "&title=search-title&title-exact=true", |
457 http_request_.relative_url); | 457 http_request_.relative_url); |
458 EXPECT_TRUE(result_data); | 458 EXPECT_TRUE(result_data); |
459 } | 459 } |
460 | 460 |
461 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { | 461 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { |
462 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 462 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
463 scoped_ptr<base::Value> result_data; | 463 scoped_ptr<base::Value> result_data; |
464 | 464 |
465 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 465 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
466 operation_runner_.get(), | 466 operation_runner_.get(), |
467 request_context_getter_.get(), | 467 request_context_getter_.get(), |
468 *url_generator_, | 468 *url_generator_, |
469 "file:2_file_resource_id", // resource ID | 469 "file:2_file_resource_id", // resource ID |
470 CreateComposedCallback( | 470 CreateComposedCallback( |
471 base::Bind(&test_util::RunAndQuit), | 471 base::Bind(&test_util::RunAndQuit), |
472 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 472 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
473 operation_runner_->StartOperationWithRetry(operation); | 473 operation_runner_->StartOperationWithRetry(operation); |
474 MessageLoop::current()->Run(); | 474 base::MessageLoop::current()->Run(); |
475 | 475 |
476 EXPECT_EQ(HTTP_SUCCESS, result_code); | 476 EXPECT_EQ(HTTP_SUCCESS, result_code); |
477 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 477 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
478 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 478 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
479 "?v=3&alt=json&showroot=true", | 479 "?v=3&alt=json&showroot=true", |
480 http_request_.relative_url); | 480 http_request_.relative_url); |
481 EXPECT_TRUE(test_util::VerifyJsonData( | 481 EXPECT_TRUE(test_util::VerifyJsonData( |
482 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), | 482 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), |
483 result_data.get())); | 483 result_data.get())); |
484 } | 484 } |
485 | 485 |
486 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { | 486 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { |
487 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 487 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
488 scoped_ptr<base::Value> result_data; | 488 scoped_ptr<base::Value> result_data; |
489 | 489 |
490 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 490 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
491 operation_runner_.get(), | 491 operation_runner_.get(), |
492 request_context_getter_.get(), | 492 request_context_getter_.get(), |
493 *url_generator_, | 493 *url_generator_, |
494 "<invalid>", // resource ID | 494 "<invalid>", // resource ID |
495 CreateComposedCallback( | 495 CreateComposedCallback( |
496 base::Bind(&test_util::RunAndQuit), | 496 base::Bind(&test_util::RunAndQuit), |
497 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 497 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
498 operation_runner_->StartOperationWithRetry(operation); | 498 operation_runner_->StartOperationWithRetry(operation); |
499 MessageLoop::current()->Run(); | 499 base::MessageLoop::current()->Run(); |
500 | 500 |
501 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 501 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
502 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 502 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
503 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" | 503 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json" |
504 "&showroot=true", | 504 "&showroot=true", |
505 http_request_.relative_url); | 505 http_request_.relative_url); |
506 ASSERT_FALSE(result_data); | 506 ASSERT_FALSE(result_data); |
507 } | 507 } |
508 | 508 |
509 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { | 509 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { |
510 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 510 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
511 scoped_ptr<AccountMetadata> result_data; | 511 scoped_ptr<AccountMetadata> result_data; |
512 | 512 |
513 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 513 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
514 operation_runner_.get(), | 514 operation_runner_.get(), |
515 request_context_getter_.get(), | 515 request_context_getter_.get(), |
516 *url_generator_, | 516 *url_generator_, |
517 CreateComposedCallback( | 517 CreateComposedCallback( |
518 base::Bind(&test_util::RunAndQuit), | 518 base::Bind(&test_util::RunAndQuit), |
519 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 519 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
520 true); // Include installed apps. | 520 true); // Include installed apps. |
521 operation_runner_->StartOperationWithRetry(operation); | 521 operation_runner_->StartOperationWithRetry(operation); |
522 MessageLoop::current()->Run(); | 522 base::MessageLoop::current()->Run(); |
523 | 523 |
524 EXPECT_EQ(HTTP_SUCCESS, result_code); | 524 EXPECT_EQ(HTTP_SUCCESS, result_code); |
525 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 525 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
526 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true" | 526 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true" |
527 "&include-installed-apps=true", | 527 "&include-installed-apps=true", |
528 http_request_.relative_url); | 528 http_request_.relative_url); |
529 | 529 |
530 scoped_ptr<AccountMetadata> expected( | 530 scoped_ptr<AccountMetadata> expected( |
531 AccountMetadata::CreateFrom( | 531 AccountMetadata::CreateFrom( |
532 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); | 532 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); |
(...skipping 18 matching lines...) Expand all Loading... |
551 | 551 |
552 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 552 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
553 operation_runner_.get(), | 553 operation_runner_.get(), |
554 request_context_getter_.get(), | 554 request_context_getter_.get(), |
555 *url_generator_, | 555 *url_generator_, |
556 CreateComposedCallback( | 556 CreateComposedCallback( |
557 base::Bind(&test_util::RunAndQuit), | 557 base::Bind(&test_util::RunAndQuit), |
558 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 558 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
559 false); // Exclude installed apps. | 559 false); // Exclude installed apps. |
560 operation_runner_->StartOperationWithRetry(operation); | 560 operation_runner_->StartOperationWithRetry(operation); |
561 MessageLoop::current()->Run(); | 561 base::MessageLoop::current()->Run(); |
562 | 562 |
563 EXPECT_EQ(HTTP_SUCCESS, result_code); | 563 EXPECT_EQ(HTTP_SUCCESS, result_code); |
564 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 564 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
565 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true", | 565 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true", |
566 http_request_.relative_url); | 566 http_request_.relative_url); |
567 | 567 |
568 scoped_ptr<AccountMetadata> expected( | 568 scoped_ptr<AccountMetadata> expected( |
569 AccountMetadata::CreateFrom( | 569 AccountMetadata::CreateFrom( |
570 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); | 570 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); |
571 | 571 |
(...skipping 15 matching lines...) Expand all Loading... |
587 DeleteResourceOperation* operation = new DeleteResourceOperation( | 587 DeleteResourceOperation* operation = new DeleteResourceOperation( |
588 operation_runner_.get(), | 588 operation_runner_.get(), |
589 request_context_getter_.get(), | 589 request_context_getter_.get(), |
590 *url_generator_, | 590 *url_generator_, |
591 CreateComposedCallback(base::Bind(&test_util::RunAndQuit), | 591 CreateComposedCallback(base::Bind(&test_util::RunAndQuit), |
592 test_util::CreateCopyResultCallback(&result_code)), | 592 test_util::CreateCopyResultCallback(&result_code)), |
593 "file:2_file_resource_id", | 593 "file:2_file_resource_id", |
594 std::string()); | 594 std::string()); |
595 | 595 |
596 operation_runner_->StartOperationWithRetry(operation); | 596 operation_runner_->StartOperationWithRetry(operation); |
597 MessageLoop::current()->Run(); | 597 base::MessageLoop::current()->Run(); |
598 | 598 |
599 EXPECT_EQ(HTTP_SUCCESS, result_code); | 599 EXPECT_EQ(HTTP_SUCCESS, result_code); |
600 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 600 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
601 EXPECT_EQ( | 601 EXPECT_EQ( |
602 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 602 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
603 "&showroot=true", | 603 "&showroot=true", |
604 http_request_.relative_url); | 604 http_request_.relative_url); |
605 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 605 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
606 } | 606 } |
607 | 607 |
608 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { | 608 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { |
609 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 609 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
610 | 610 |
611 DeleteResourceOperation* operation = new DeleteResourceOperation( | 611 DeleteResourceOperation* operation = new DeleteResourceOperation( |
612 operation_runner_.get(), | 612 operation_runner_.get(), |
613 request_context_getter_.get(), | 613 request_context_getter_.get(), |
614 *url_generator_, | 614 *url_generator_, |
615 CreateComposedCallback( | 615 CreateComposedCallback( |
616 base::Bind(&test_util::RunAndQuit), | 616 base::Bind(&test_util::RunAndQuit), |
617 test_util::CreateCopyResultCallback(&result_code)), | 617 test_util::CreateCopyResultCallback(&result_code)), |
618 "file:2_file_resource_id", | 618 "file:2_file_resource_id", |
619 "etag"); | 619 "etag"); |
620 | 620 |
621 operation_runner_->StartOperationWithRetry(operation); | 621 operation_runner_->StartOperationWithRetry(operation); |
622 MessageLoop::current()->Run(); | 622 base::MessageLoop::current()->Run(); |
623 | 623 |
624 EXPECT_EQ(HTTP_SUCCESS, result_code); | 624 EXPECT_EQ(HTTP_SUCCESS, result_code); |
625 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 625 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
626 EXPECT_EQ( | 626 EXPECT_EQ( |
627 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 627 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
628 "&showroot=true", | 628 "&showroot=true", |
629 http_request_.relative_url); | 629 http_request_.relative_url); |
630 EXPECT_EQ("etag", http_request_.headers["If-Match"]); | 630 EXPECT_EQ("etag", http_request_.headers["If-Match"]); |
631 } | 631 } |
632 | 632 |
633 TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) { | 633 TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) { |
634 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 634 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
635 scoped_ptr<base::Value> result_data; | 635 scoped_ptr<base::Value> result_data; |
636 | 636 |
637 // Create "new directory" in the root directory. | 637 // Create "new directory" in the root directory. |
638 CreateDirectoryOperation* operation = new CreateDirectoryOperation( | 638 CreateDirectoryOperation* operation = new CreateDirectoryOperation( |
639 operation_runner_.get(), | 639 operation_runner_.get(), |
640 request_context_getter_.get(), | 640 request_context_getter_.get(), |
641 *url_generator_, | 641 *url_generator_, |
642 CreateComposedCallback( | 642 CreateComposedCallback( |
643 base::Bind(&test_util::RunAndQuit), | 643 base::Bind(&test_util::RunAndQuit), |
644 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 644 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
645 "folder:root", | 645 "folder:root", |
646 "new directory"); | 646 "new directory"); |
647 | 647 |
648 operation_runner_->StartOperationWithRetry(operation); | 648 operation_runner_->StartOperationWithRetry(operation); |
649 MessageLoop::current()->Run(); | 649 base::MessageLoop::current()->Run(); |
650 | 650 |
651 EXPECT_EQ(HTTP_SUCCESS, result_code); | 651 EXPECT_EQ(HTTP_SUCCESS, result_code); |
652 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 652 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
653 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" | 653 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" |
654 "&showroot=true", | 654 "&showroot=true", |
655 http_request_.relative_url); | 655 http_request_.relative_url); |
656 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 656 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
657 | 657 |
658 EXPECT_TRUE(http_request_.has_content); | 658 EXPECT_TRUE(http_request_.has_content); |
659 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 659 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
(...skipping 14 matching lines...) Expand all Loading... |
674 operation_runner_.get(), | 674 operation_runner_.get(), |
675 request_context_getter_.get(), | 675 request_context_getter_.get(), |
676 *url_generator_, | 676 *url_generator_, |
677 CreateComposedCallback( | 677 CreateComposedCallback( |
678 base::Bind(&test_util::RunAndQuit), | 678 base::Bind(&test_util::RunAndQuit), |
679 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 679 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
680 "document:5_document_resource_id", // source resource ID | 680 "document:5_document_resource_id", // source resource ID |
681 "New Document"); | 681 "New Document"); |
682 | 682 |
683 operation_runner_->StartOperationWithRetry(operation); | 683 operation_runner_->StartOperationWithRetry(operation); |
684 MessageLoop::current()->Run(); | 684 base::MessageLoop::current()->Run(); |
685 | 685 |
686 EXPECT_EQ(HTTP_SUCCESS, result_code); | 686 EXPECT_EQ(HTTP_SUCCESS, result_code); |
687 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 687 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
688 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true", | 688 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true", |
689 http_request_.relative_url); | 689 http_request_.relative_url); |
690 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 690 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
691 | 691 |
692 EXPECT_TRUE(http_request_.has_content); | 692 EXPECT_TRUE(http_request_.has_content); |
693 EXPECT_EQ("<?xml version=\"1.0\"?>\n" | 693 EXPECT_EQ("<?xml version=\"1.0\"?>\n" |
694 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" | 694 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" |
(...skipping 11 matching lines...) Expand all Loading... |
706 operation_runner_.get(), | 706 operation_runner_.get(), |
707 request_context_getter_.get(), | 707 request_context_getter_.get(), |
708 *url_generator_, | 708 *url_generator_, |
709 CreateComposedCallback( | 709 CreateComposedCallback( |
710 base::Bind(&test_util::RunAndQuit), | 710 base::Bind(&test_util::RunAndQuit), |
711 test_util::CreateCopyResultCallback(&result_code)), | 711 test_util::CreateCopyResultCallback(&result_code)), |
712 "file:2_file_resource_id", | 712 "file:2_file_resource_id", |
713 "New File"); | 713 "New File"); |
714 | 714 |
715 operation_runner_->StartOperationWithRetry(operation); | 715 operation_runner_->StartOperationWithRetry(operation); |
716 MessageLoop::current()->Run(); | 716 base::MessageLoop::current()->Run(); |
717 | 717 |
718 EXPECT_EQ(HTTP_SUCCESS, result_code); | 718 EXPECT_EQ(HTTP_SUCCESS, result_code); |
719 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 719 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
720 EXPECT_EQ( | 720 EXPECT_EQ( |
721 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" | 721 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json" |
722 "&showroot=true", | 722 "&showroot=true", |
723 http_request_.relative_url); | 723 http_request_.relative_url); |
724 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 724 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
725 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 725 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
726 | 726 |
(...skipping 14 matching lines...) Expand all Loading... |
741 operation_runner_.get(), | 741 operation_runner_.get(), |
742 request_context_getter_.get(), | 742 request_context_getter_.get(), |
743 *url_generator_, | 743 *url_generator_, |
744 CreateComposedCallback( | 744 CreateComposedCallback( |
745 base::Bind(&test_util::RunAndQuit), | 745 base::Bind(&test_util::RunAndQuit), |
746 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 746 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
747 "file:2_file_resource_id", | 747 "file:2_file_resource_id", |
748 "the_app_id"); | 748 "the_app_id"); |
749 | 749 |
750 operation_runner_->StartOperationWithRetry(operation); | 750 operation_runner_->StartOperationWithRetry(operation); |
751 MessageLoop::current()->Run(); | 751 base::MessageLoop::current()->Run(); |
752 | 752 |
753 EXPECT_EQ(HTTP_SUCCESS, result_code); | 753 EXPECT_EQ(HTTP_SUCCESS, result_code); |
754 EXPECT_EQ(GURL("https://entry1_open_with_link/"), result_data); | 754 EXPECT_EQ(GURL("https://entry1_open_with_link/"), result_data); |
755 | 755 |
756 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 756 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
757 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 757 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
758 "?v=3&alt=json&showroot=true", | 758 "?v=3&alt=json&showroot=true", |
759 http_request_.relative_url); | 759 http_request_.relative_url); |
760 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 760 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
761 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 761 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
(...skipping 16 matching lines...) Expand all Loading... |
778 operation_runner_.get(), | 778 operation_runner_.get(), |
779 request_context_getter_.get(), | 779 request_context_getter_.get(), |
780 *url_generator_, | 780 *url_generator_, |
781 CreateComposedCallback( | 781 CreateComposedCallback( |
782 base::Bind(&test_util::RunAndQuit), | 782 base::Bind(&test_util::RunAndQuit), |
783 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 783 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
784 "file:2_file_resource_id", | 784 "file:2_file_resource_id", |
785 "unauthorized_app_id"); | 785 "unauthorized_app_id"); |
786 | 786 |
787 operation_runner_->StartOperationWithRetry(operation); | 787 operation_runner_->StartOperationWithRetry(operation); |
788 MessageLoop::current()->Run(); | 788 base::MessageLoop::current()->Run(); |
789 | 789 |
790 EXPECT_EQ(GDATA_OTHER_ERROR, result_code); | 790 EXPECT_EQ(GDATA_OTHER_ERROR, result_code); |
791 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 791 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
792 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" | 792 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" |
793 "?v=3&alt=json&showroot=true", | 793 "?v=3&alt=json&showroot=true", |
794 http_request_.relative_url); | 794 http_request_.relative_url); |
795 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 795 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
796 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 796 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
797 | 797 |
798 EXPECT_TRUE(http_request_.has_content); | 798 EXPECT_TRUE(http_request_.has_content); |
(...skipping 14 matching lines...) Expand all Loading... |
813 operation_runner_.get(), | 813 operation_runner_.get(), |
814 request_context_getter_.get(), | 814 request_context_getter_.get(), |
815 *url_generator_, | 815 *url_generator_, |
816 CreateComposedCallback( | 816 CreateComposedCallback( |
817 base::Bind(&test_util::RunAndQuit), | 817 base::Bind(&test_util::RunAndQuit), |
818 test_util::CreateCopyResultCallback(&result_code, &result_data)), | 818 test_util::CreateCopyResultCallback(&result_code, &result_data)), |
819 "invalid_resource_id", | 819 "invalid_resource_id", |
820 "APP_ID"); | 820 "APP_ID"); |
821 | 821 |
822 operation_runner_->StartOperationWithRetry(operation); | 822 operation_runner_->StartOperationWithRetry(operation); |
823 MessageLoop::current()->Run(); | 823 base::MessageLoop::current()->Run(); |
824 | 824 |
825 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 825 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
826 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 826 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
827 EXPECT_EQ("/feeds/default/private/full/invalid_resource_id" | 827 EXPECT_EQ("/feeds/default/private/full/invalid_resource_id" |
828 "?v=3&alt=json&showroot=true", | 828 "?v=3&alt=json&showroot=true", |
829 http_request_.relative_url); | 829 http_request_.relative_url); |
830 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 830 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
831 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 831 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
832 | 832 |
833 EXPECT_TRUE(http_request_.has_content); | 833 EXPECT_TRUE(http_request_.has_content); |
(...skipping 14 matching lines...) Expand all Loading... |
848 operation_runner_.get(), | 848 operation_runner_.get(), |
849 request_context_getter_.get(), | 849 request_context_getter_.get(), |
850 *url_generator_, | 850 *url_generator_, |
851 CreateComposedCallback( | 851 CreateComposedCallback( |
852 base::Bind(&test_util::RunAndQuit), | 852 base::Bind(&test_util::RunAndQuit), |
853 test_util::CreateCopyResultCallback(&result_code)), | 853 test_util::CreateCopyResultCallback(&result_code)), |
854 "folder:root", | 854 "folder:root", |
855 "file:2_file_resource_id"); | 855 "file:2_file_resource_id"); |
856 | 856 |
857 operation_runner_->StartOperationWithRetry(operation); | 857 operation_runner_->StartOperationWithRetry(operation); |
858 MessageLoop::current()->Run(); | 858 base::MessageLoop::current()->Run(); |
859 | 859 |
860 EXPECT_EQ(HTTP_SUCCESS, result_code); | 860 EXPECT_EQ(HTTP_SUCCESS, result_code); |
861 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 861 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
862 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" | 862 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json" |
863 "&showroot=true", | 863 "&showroot=true", |
864 http_request_.relative_url); | 864 http_request_.relative_url); |
865 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); | 865 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); |
866 | 866 |
867 EXPECT_TRUE(http_request_.has_content); | 867 EXPECT_TRUE(http_request_.has_content); |
868 EXPECT_EQ(base::StringPrintf("<?xml version=\"1.0\"?>\n" | 868 EXPECT_EQ(base::StringPrintf("<?xml version=\"1.0\"?>\n" |
(...skipping 14 matching lines...) Expand all Loading... |
883 operation_runner_.get(), | 883 operation_runner_.get(), |
884 request_context_getter_.get(), | 884 request_context_getter_.get(), |
885 *url_generator_, | 885 *url_generator_, |
886 CreateComposedCallback( | 886 CreateComposedCallback( |
887 base::Bind(&test_util::RunAndQuit), | 887 base::Bind(&test_util::RunAndQuit), |
888 test_util::CreateCopyResultCallback(&result_code)), | 888 test_util::CreateCopyResultCallback(&result_code)), |
889 "folder:root", | 889 "folder:root", |
890 "file:2_file_resource_id"); | 890 "file:2_file_resource_id"); |
891 | 891 |
892 operation_runner_->StartOperationWithRetry(operation); | 892 operation_runner_->StartOperationWithRetry(operation); |
893 MessageLoop::current()->Run(); | 893 base::MessageLoop::current()->Run(); |
894 | 894 |
895 EXPECT_EQ(HTTP_SUCCESS, result_code); | 895 EXPECT_EQ(HTTP_SUCCESS, result_code); |
896 // DELETE method should be used, without the body content. | 896 // DELETE method should be used, without the body content. |
897 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 897 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
898 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" | 898 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" |
899 "file%3A2_file_resource_id?v=3&alt=json&showroot=true", | 899 "file%3A2_file_resource_id?v=3&alt=json&showroot=true", |
900 http_request_.relative_url); | 900 http_request_.relative_url); |
901 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 901 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
902 EXPECT_FALSE(http_request_.has_content); | 902 EXPECT_FALSE(http_request_.has_content); |
903 } | 903 } |
(...skipping 18 matching lines...) Expand all Loading... |
922 CreateComposedCallback( | 922 CreateComposedCallback( |
923 base::Bind(&test_util::RunAndQuit), | 923 base::Bind(&test_util::RunAndQuit), |
924 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 924 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
925 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 925 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
926 "text/plain", | 926 "text/plain", |
927 kUploadContent.size(), | 927 kUploadContent.size(), |
928 "folder:id", | 928 "folder:id", |
929 "New file"); | 929 "New file"); |
930 | 930 |
931 operation_runner_->StartOperationWithRetry(initiate_operation); | 931 operation_runner_->StartOperationWithRetry(initiate_operation); |
932 MessageLoop::current()->Run(); | 932 base::MessageLoop::current()->Run(); |
933 | 933 |
934 EXPECT_EQ(HTTP_SUCCESS, result_code); | 934 EXPECT_EQ(HTTP_SUCCESS, result_code); |
935 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 935 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
936 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 936 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
937 // convert=false should be passed as files should be uploaded as-is. | 937 // convert=false should be passed as files should be uploaded as-is. |
938 EXPECT_EQ( | 938 EXPECT_EQ( |
939 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 939 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
940 "?convert=false&v=3&alt=json&showroot=true", | 940 "?convert=false&v=3&alt=json&showroot=true", |
941 http_request_.relative_url); | 941 http_request_.relative_url); |
942 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 942 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
(...skipping 22 matching lines...) Expand all Loading... |
965 ProgressCallback(), | 965 ProgressCallback(), |
966 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 966 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
967 upload_url, | 967 upload_url, |
968 0, // start_position | 968 0, // start_position |
969 kUploadContent.size(), // end_position (exclusive) | 969 kUploadContent.size(), // end_position (exclusive) |
970 kUploadContent.size(), // content_length, | 970 kUploadContent.size(), // content_length, |
971 "text/plain", // content_type | 971 "text/plain", // content_type |
972 kTestFilePath); | 972 kTestFilePath); |
973 | 973 |
974 operation_runner_->StartOperationWithRetry(resume_operation); | 974 operation_runner_->StartOperationWithRetry(resume_operation); |
975 MessageLoop::current()->Run(); | 975 base::MessageLoop::current()->Run(); |
976 | 976 |
977 // METHOD_PUT should be used to upload data. | 977 // METHOD_PUT should be used to upload data. |
978 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 978 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
979 // Request should go to the upload URL. | 979 // Request should go to the upload URL. |
980 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 980 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
981 // Content-Range header should be added. | 981 // Content-Range header should be added. |
982 EXPECT_EQ("bytes 0-" + | 982 EXPECT_EQ("bytes 0-" + |
983 base::Int64ToString(kUploadContent.size() -1) + "/" + | 983 base::Int64ToString(kUploadContent.size() -1) + "/" + |
984 base::Int64ToString(kUploadContent.size()), | 984 base::Int64ToString(kUploadContent.size()), |
985 http_request_.headers["Content-Range"]); | 985 http_request_.headers["Content-Range"]); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 CreateComposedCallback( | 1024 CreateComposedCallback( |
1025 base::Bind(&test_util::RunAndQuit), | 1025 base::Bind(&test_util::RunAndQuit), |
1026 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1026 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1027 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1027 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
1028 "text/plain", | 1028 "text/plain", |
1029 kUploadContent.size(), | 1029 kUploadContent.size(), |
1030 "folder:id", | 1030 "folder:id", |
1031 "New file"); | 1031 "New file"); |
1032 | 1032 |
1033 operation_runner_->StartOperationWithRetry(initiate_operation); | 1033 operation_runner_->StartOperationWithRetry(initiate_operation); |
1034 MessageLoop::current()->Run(); | 1034 base::MessageLoop::current()->Run(); |
1035 | 1035 |
1036 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1036 EXPECT_EQ(HTTP_SUCCESS, result_code); |
1037 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 1037 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
1038 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1038 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
1039 // convert=false should be passed as files should be uploaded as-is. | 1039 // convert=false should be passed as files should be uploaded as-is. |
1040 EXPECT_EQ( | 1040 EXPECT_EQ( |
1041 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 1041 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
1042 "?convert=false&v=3&alt=json&showroot=true", | 1042 "?convert=false&v=3&alt=json&showroot=true", |
1043 http_request_.relative_url); | 1043 http_request_.relative_url); |
1044 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1044 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
(...skipping 22 matching lines...) Expand all Loading... |
1067 new GetUploadStatusOperation( | 1067 new GetUploadStatusOperation( |
1068 operation_runner_.get(), | 1068 operation_runner_.get(), |
1069 request_context_getter_.get(), | 1069 request_context_getter_.get(), |
1070 CreateComposedCallback( | 1070 CreateComposedCallback( |
1071 base::Bind(&test_util::RunAndQuit), | 1071 base::Bind(&test_util::RunAndQuit), |
1072 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1072 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1073 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1073 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
1074 upload_url, | 1074 upload_url, |
1075 kUploadContent.size()); | 1075 kUploadContent.size()); |
1076 operation_runner_->StartOperationWithRetry(get_upload_status_operation); | 1076 operation_runner_->StartOperationWithRetry(get_upload_status_operation); |
1077 MessageLoop::current()->Run(); | 1077 base::MessageLoop::current()->Run(); |
1078 | 1078 |
1079 // METHOD_PUT should be used to upload data. | 1079 // METHOD_PUT should be used to upload data. |
1080 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1080 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1081 // Request should go to the upload URL. | 1081 // Request should go to the upload URL. |
1082 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1082 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1083 // Content-Range header should be added. | 1083 // Content-Range header should be added. |
1084 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), | 1084 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), |
1085 http_request_.headers["Content-Range"]); | 1085 http_request_.headers["Content-Range"]); |
1086 EXPECT_TRUE(http_request_.has_content); | 1086 EXPECT_TRUE(http_request_.has_content); |
1087 EXPECT_TRUE(http_request_.content.empty()); | 1087 EXPECT_TRUE(http_request_.content.empty()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 ProgressCallback(), | 1119 ProgressCallback(), |
1120 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1120 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
1121 upload_url, | 1121 upload_url, |
1122 start_position, | 1122 start_position, |
1123 end_position, | 1123 end_position, |
1124 kUploadContent.size(), // content_length, | 1124 kUploadContent.size(), // content_length, |
1125 "text/plain", // content_type | 1125 "text/plain", // content_type |
1126 kTestFilePath); | 1126 kTestFilePath); |
1127 | 1127 |
1128 operation_runner_->StartOperationWithRetry(resume_operation); | 1128 operation_runner_->StartOperationWithRetry(resume_operation); |
1129 MessageLoop::current()->Run(); | 1129 base::MessageLoop::current()->Run(); |
1130 | 1130 |
1131 // METHOD_PUT should be used to upload data. | 1131 // METHOD_PUT should be used to upload data. |
1132 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1132 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1133 // Request should go to the upload URL. | 1133 // Request should go to the upload URL. |
1134 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1134 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1135 // Content-Range header should be added. | 1135 // Content-Range header should be added. |
1136 EXPECT_EQ("bytes " + | 1136 EXPECT_EQ("bytes " + |
1137 base::Int64ToString(start_position) + "-" + | 1137 base::Int64ToString(start_position) + "-" + |
1138 base::Int64ToString(end_position - 1) + "/" + | 1138 base::Int64ToString(end_position - 1) + "/" + |
1139 base::Int64ToString(kUploadContent.size()), | 1139 base::Int64ToString(kUploadContent.size()), |
(...skipping 24 matching lines...) Expand all Loading... |
1164 new GetUploadStatusOperation( | 1164 new GetUploadStatusOperation( |
1165 operation_runner_.get(), | 1165 operation_runner_.get(), |
1166 request_context_getter_.get(), | 1166 request_context_getter_.get(), |
1167 CreateComposedCallback( | 1167 CreateComposedCallback( |
1168 base::Bind(&test_util::RunAndQuit), | 1168 base::Bind(&test_util::RunAndQuit), |
1169 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1169 test_util::CreateCopyResultCallback(&response, &new_entry)), |
1170 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1170 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
1171 upload_url, | 1171 upload_url, |
1172 kUploadContent.size()); | 1172 kUploadContent.size()); |
1173 operation_runner_->StartOperationWithRetry(get_upload_operation); | 1173 operation_runner_->StartOperationWithRetry(get_upload_operation); |
1174 MessageLoop::current()->Run(); | 1174 base::MessageLoop::current()->Run(); |
1175 | 1175 |
1176 // METHOD_PUT should be used to upload data. | 1176 // METHOD_PUT should be used to upload data. |
1177 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1177 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1178 // Request should go to the upload URL. | 1178 // Request should go to the upload URL. |
1179 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1179 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1180 // Content-Range header should be added. | 1180 // Content-Range header should be added. |
1181 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), | 1181 EXPECT_EQ("bytes */" + base::Int64ToString(kUploadContent.size()), |
1182 http_request_.headers["Content-Range"]); | 1182 http_request_.headers["Content-Range"]); |
1183 EXPECT_TRUE(http_request_.has_content); | 1183 EXPECT_TRUE(http_request_.has_content); |
1184 EXPECT_TRUE(http_request_.content.empty()); | 1184 EXPECT_TRUE(http_request_.content.empty()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 CreateComposedCallback( | 1217 CreateComposedCallback( |
1218 base::Bind(&test_util::RunAndQuit), | 1218 base::Bind(&test_util::RunAndQuit), |
1219 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1219 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1220 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1220 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
1221 "text/plain", | 1221 "text/plain", |
1222 kUploadContent.size(), | 1222 kUploadContent.size(), |
1223 "folder:id", | 1223 "folder:id", |
1224 "New file"); | 1224 "New file"); |
1225 | 1225 |
1226 operation_runner_->StartOperationWithRetry(initiate_operation); | 1226 operation_runner_->StartOperationWithRetry(initiate_operation); |
1227 MessageLoop::current()->Run(); | 1227 base::MessageLoop::current()->Run(); |
1228 | 1228 |
1229 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1229 EXPECT_EQ(HTTP_SUCCESS, result_code); |
1230 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); | 1230 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); |
1231 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 1231 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
1232 // convert=false should be passed as files should be uploaded as-is. | 1232 // convert=false should be passed as files should be uploaded as-is. |
1233 EXPECT_EQ( | 1233 EXPECT_EQ( |
1234 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" | 1234 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" |
1235 "?convert=false&v=3&alt=json&showroot=true", | 1235 "?convert=false&v=3&alt=json&showroot=true", |
1236 http_request_.relative_url); | 1236 http_request_.relative_url); |
1237 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1237 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
(...skipping 22 matching lines...) Expand all Loading... |
1260 ProgressCallback(), | 1260 ProgressCallback(), |
1261 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), | 1261 base::FilePath::FromUTF8Unsafe("drive/newfile.txt"), |
1262 upload_url, | 1262 upload_url, |
1263 0, // start_position | 1263 0, // start_position |
1264 kUploadContent.size(), // end_position (exclusive) | 1264 kUploadContent.size(), // end_position (exclusive) |
1265 kUploadContent.size(), // content_length, | 1265 kUploadContent.size(), // content_length, |
1266 "text/plain", // content_type | 1266 "text/plain", // content_type |
1267 kTestFilePath); | 1267 kTestFilePath); |
1268 | 1268 |
1269 operation_runner_->StartOperationWithRetry(resume_operation); | 1269 operation_runner_->StartOperationWithRetry(resume_operation); |
1270 MessageLoop::current()->Run(); | 1270 base::MessageLoop::current()->Run(); |
1271 | 1271 |
1272 // METHOD_PUT should be used to upload data. | 1272 // METHOD_PUT should be used to upload data. |
1273 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1273 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1274 // Request should go to the upload URL. | 1274 // Request should go to the upload URL. |
1275 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1275 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1276 // Content-Range header should not exit if the content is empty. | 1276 // Content-Range header should not exit if the content is empty. |
1277 // We should not generate the header with an invalid value "bytes 0--1/0". | 1277 // We should not generate the header with an invalid value "bytes 0--1/0". |
1278 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 1278 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
1279 // The upload content should be set in the HTTP request. | 1279 // The upload content should be set in the HTTP request. |
1280 EXPECT_TRUE(http_request_.has_content); | 1280 EXPECT_TRUE(http_request_.has_content); |
(...skipping 26 matching lines...) Expand all Loading... |
1307 CreateComposedCallback( | 1307 CreateComposedCallback( |
1308 base::Bind(&test_util::RunAndQuit), | 1308 base::Bind(&test_util::RunAndQuit), |
1309 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1309 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1310 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1310 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
1311 "text/plain", | 1311 "text/plain", |
1312 kUploadContent.size(), | 1312 kUploadContent.size(), |
1313 "file:foo", | 1313 "file:foo", |
1314 std::string() /* etag */); | 1314 std::string() /* etag */); |
1315 | 1315 |
1316 operation_runner_->StartOperationWithRetry(initiate_operation); | 1316 operation_runner_->StartOperationWithRetry(initiate_operation); |
1317 MessageLoop::current()->Run(); | 1317 base::MessageLoop::current()->Run(); |
1318 | 1318 |
1319 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1319 EXPECT_EQ(HTTP_SUCCESS, result_code); |
1320 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); | 1320 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); |
1321 // For updating an existing file, METHOD_PUT should be used. | 1321 // For updating an existing file, METHOD_PUT should be used. |
1322 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1322 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1323 // convert=false should be passed as files should be uploaded as-is. | 1323 // convert=false should be passed as files should be uploaded as-is. |
1324 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1324 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
1325 "?convert=false&v=3&alt=json&showroot=true", | 1325 "?convert=false&v=3&alt=json&showroot=true", |
1326 http_request_.relative_url); | 1326 http_request_.relative_url); |
1327 // Even though the body is empty, the content type should be set to | 1327 // Even though the body is empty, the content type should be set to |
(...skipping 21 matching lines...) Expand all Loading... |
1349 ProgressCallback(), | 1349 ProgressCallback(), |
1350 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1350 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
1351 upload_url, | 1351 upload_url, |
1352 0, // start_position | 1352 0, // start_position |
1353 kUploadContent.size(), // end_position (exclusive) | 1353 kUploadContent.size(), // end_position (exclusive) |
1354 kUploadContent.size(), // content_length, | 1354 kUploadContent.size(), // content_length, |
1355 "text/plain", // content_type | 1355 "text/plain", // content_type |
1356 kTestFilePath); | 1356 kTestFilePath); |
1357 | 1357 |
1358 operation_runner_->StartOperationWithRetry(resume_operation); | 1358 operation_runner_->StartOperationWithRetry(resume_operation); |
1359 MessageLoop::current()->Run(); | 1359 base::MessageLoop::current()->Run(); |
1360 | 1360 |
1361 // METHOD_PUT should be used to upload data. | 1361 // METHOD_PUT should be used to upload data. |
1362 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1362 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1363 // Request should go to the upload URL. | 1363 // Request should go to the upload URL. |
1364 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1364 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1365 // Content-Range header should be added. | 1365 // Content-Range header should be added. |
1366 EXPECT_EQ("bytes 0-" + | 1366 EXPECT_EQ("bytes 0-" + |
1367 base::Int64ToString(kUploadContent.size() -1) + "/" + | 1367 base::Int64ToString(kUploadContent.size() -1) + "/" + |
1368 base::Int64ToString(kUploadContent.size()), | 1368 base::Int64ToString(kUploadContent.size()), |
1369 http_request_.headers["Content-Range"]); | 1369 http_request_.headers["Content-Range"]); |
(...skipping 28 matching lines...) Expand all Loading... |
1398 CreateComposedCallback( | 1398 CreateComposedCallback( |
1399 base::Bind(&test_util::RunAndQuit), | 1399 base::Bind(&test_util::RunAndQuit), |
1400 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1400 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1401 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1401 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
1402 "text/plain", | 1402 "text/plain", |
1403 kUploadContent.size(), | 1403 kUploadContent.size(), |
1404 "file:foo", | 1404 "file:foo", |
1405 kTestETag); | 1405 kTestETag); |
1406 | 1406 |
1407 operation_runner_->StartOperationWithRetry(initiate_operation); | 1407 operation_runner_->StartOperationWithRetry(initiate_operation); |
1408 MessageLoop::current()->Run(); | 1408 base::MessageLoop::current()->Run(); |
1409 | 1409 |
1410 EXPECT_EQ(HTTP_SUCCESS, result_code); | 1410 EXPECT_EQ(HTTP_SUCCESS, result_code); |
1411 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); | 1411 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); |
1412 // For updating an existing file, METHOD_PUT should be used. | 1412 // For updating an existing file, METHOD_PUT should be used. |
1413 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1413 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1414 // convert=false should be passed as files should be uploaded as-is. | 1414 // convert=false should be passed as files should be uploaded as-is. |
1415 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1415 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
1416 "?convert=false&v=3&alt=json&showroot=true", | 1416 "?convert=false&v=3&alt=json&showroot=true", |
1417 http_request_.relative_url); | 1417 http_request_.relative_url); |
1418 // Even though the body is empty, the content type should be set to | 1418 // Even though the body is empty, the content type should be set to |
(...skipping 21 matching lines...) Expand all Loading... |
1440 ProgressCallback(), | 1440 ProgressCallback(), |
1441 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1441 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
1442 upload_url, | 1442 upload_url, |
1443 0, // start_position | 1443 0, // start_position |
1444 kUploadContent.size(), // end_position (exclusive) | 1444 kUploadContent.size(), // end_position (exclusive) |
1445 kUploadContent.size(), // content_length, | 1445 kUploadContent.size(), // content_length, |
1446 "text/plain", // content_type | 1446 "text/plain", // content_type |
1447 kTestFilePath); | 1447 kTestFilePath); |
1448 | 1448 |
1449 operation_runner_->StartOperationWithRetry(resume_operation); | 1449 operation_runner_->StartOperationWithRetry(resume_operation); |
1450 MessageLoop::current()->Run(); | 1450 base::MessageLoop::current()->Run(); |
1451 | 1451 |
1452 // METHOD_PUT should be used to upload data. | 1452 // METHOD_PUT should be used to upload data. |
1453 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1453 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1454 // Request should go to the upload URL. | 1454 // Request should go to the upload URL. |
1455 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1455 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
1456 // Content-Range header should be added. | 1456 // Content-Range header should be added. |
1457 EXPECT_EQ("bytes 0-" + | 1457 EXPECT_EQ("bytes 0-" + |
1458 base::Int64ToString(kUploadContent.size() -1) + "/" + | 1458 base::Int64ToString(kUploadContent.size() -1) + "/" + |
1459 base::Int64ToString(kUploadContent.size()), | 1459 base::Int64ToString(kUploadContent.size()), |
1460 http_request_.headers["Content-Range"]); | 1460 http_request_.headers["Content-Range"]); |
(...skipping 24 matching lines...) Expand all Loading... |
1485 CreateComposedCallback( | 1485 CreateComposedCallback( |
1486 base::Bind(&test_util::RunAndQuit), | 1486 base::Bind(&test_util::RunAndQuit), |
1487 test_util::CreateCopyResultCallback(&result_code, &upload_url)), | 1487 test_util::CreateCopyResultCallback(&result_code, &upload_url)), |
1488 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), | 1488 base::FilePath::FromUTF8Unsafe("drive/existingfile.txt"), |
1489 "text/plain", | 1489 "text/plain", |
1490 kUploadContent.size(), | 1490 kUploadContent.size(), |
1491 "file:foo", | 1491 "file:foo", |
1492 kWrongETag); | 1492 kWrongETag); |
1493 | 1493 |
1494 operation_runner_->StartOperationWithRetry(initiate_operation); | 1494 operation_runner_->StartOperationWithRetry(initiate_operation); |
1495 MessageLoop::current()->Run(); | 1495 base::MessageLoop::current()->Run(); |
1496 | 1496 |
1497 EXPECT_EQ(HTTP_PRECONDITION, result_code); | 1497 EXPECT_EQ(HTTP_PRECONDITION, result_code); |
1498 // For updating an existing file, METHOD_PUT should be used. | 1498 // For updating an existing file, METHOD_PUT should be used. |
1499 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1499 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
1500 // convert=false should be passed as files should be uploaded as-is. | 1500 // convert=false should be passed as files should be uploaded as-is. |
1501 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" | 1501 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" |
1502 "?convert=false&v=3&alt=json&showroot=true", | 1502 "?convert=false&v=3&alt=json&showroot=true", |
1503 http_request_.relative_url); | 1503 http_request_.relative_url); |
1504 // Even though the body is empty, the content type should be set to | 1504 // Even though the body is empty, the content type should be set to |
1505 // "text/plain". | 1505 // "text/plain". |
1506 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); | 1506 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); |
1507 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); | 1507 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); |
1508 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1508 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
1509 http_request_.headers["X-Upload-Content-Length"]); | 1509 http_request_.headers["X-Upload-Content-Length"]); |
1510 // For updating an existing file, an empty body should be attached (PUT | 1510 // For updating an existing file, an empty body should be attached (PUT |
1511 // requires a body) | 1511 // requires a body) |
1512 EXPECT_TRUE(http_request_.has_content); | 1512 EXPECT_TRUE(http_request_.has_content); |
1513 EXPECT_EQ("", http_request_.content); | 1513 EXPECT_EQ("", http_request_.content); |
1514 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1514 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
1515 } | 1515 } |
1516 | 1516 |
1517 } // namespace google_apis | 1517 } // namespace google_apis |
OLD | NEW |