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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_operations_unittest.cc

Issue 12585003: drive: Add showroot=true to WAPI feed URLs and ignore "no parent" entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 "", // directory resource ID 340 "", // directory resource ID
341 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 341 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
342 &result_code, 342 &result_code,
343 &result_data)); 343 &result_data));
344 operation->Start(kTestGDataAuthToken, kTestUserAgent, 344 operation->Start(kTestGDataAuthToken, kTestUserAgent,
345 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 345 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
346 MessageLoop::current()->Run(); 346 MessageLoop::current()->Run();
347 347
348 EXPECT_EQ(HTTP_SUCCESS, result_code); 348 EXPECT_EQ(HTTP_SUCCESS, result_code);
349 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 349 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
350 EXPECT_EQ("/feeds/default/private/full/-/mine?v=3&alt=json&showfolders=true" 350 EXPECT_EQ("/feeds/default/private/full/-/mine?v=3&alt=json&showroot=true&"
351 "&max-results=500&include-installed-apps=true", 351 "showfolders=true&max-results=500&include-installed-apps=true",
352 http_request_.relative_url); 352 http_request_.relative_url);
353 EXPECT_TRUE(test_util::VerifyJsonData( 353 EXPECT_TRUE(test_util::VerifyJsonData(
354 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), 354 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"),
355 result_data.get())); 355 result_data.get()));
356 } 356 }
357 357
358 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) { 358 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) {
359 GDataErrorCode result_code = GDATA_OTHER_ERROR; 359 GDataErrorCode result_code = GDATA_OTHER_ERROR;
360 scoped_ptr<base::Value> result_data; 360 scoped_ptr<base::Value> result_data;
361 361
362 GetResourceListOperation* operation = new GetResourceListOperation( 362 GetResourceListOperation* operation = new GetResourceListOperation(
363 &operation_registry_, 363 &operation_registry_,
364 request_context_getter_.get(), 364 request_context_getter_.get(),
365 *url_generator_, 365 *url_generator_,
366 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), 366 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"),
367 0, // start changestamp 367 0, // start changestamp
368 "", // search string 368 "", // search string
369 false, // shared with me 369 false, // shared with me
370 "", // directory resource ID 370 "", // directory resource ID
371 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 371 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
372 &result_code, 372 &result_code,
373 &result_data)); 373 &result_data));
374 operation->Start(kTestGDataAuthToken, kTestUserAgent, 374 operation->Start(kTestGDataAuthToken, kTestUserAgent,
375 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 375 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
376 MessageLoop::current()->Run(); 376 MessageLoop::current()->Run();
377 377
378 EXPECT_EQ(HTTP_SUCCESS, result_code); 378 EXPECT_EQ(HTTP_SUCCESS, result_code);
379 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 379 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
380 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showfolders=true" 380 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&"
381 "&max-results=500&include-installed-apps=true", 381 "showfolders=true&max-results=500&include-installed-apps=true",
382 http_request_.relative_url); 382 http_request_.relative_url);
383 EXPECT_TRUE(test_util::VerifyJsonData( 383 EXPECT_TRUE(test_util::VerifyJsonData(
384 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), 384 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"),
385 result_data.get())); 385 result_data.get()));
386 } 386 }
387 387
388 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) { 388 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) {
389 // testfile.txt exists but the response is not JSON, so it should 389 // testfile.txt exists but the response is not JSON, so it should
390 // emit a parse error instead. 390 // emit a parse error instead.
391 GDataErrorCode result_code = GDATA_OTHER_ERROR; 391 GDataErrorCode result_code = GDATA_OTHER_ERROR;
(...skipping 10 matching lines...) Expand all
402 "", // directory resource ID 402 "", // directory resource ID
403 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 403 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
404 &result_code, 404 &result_code,
405 &result_data)); 405 &result_data));
406 operation->Start(kTestGDataAuthToken, kTestUserAgent, 406 operation->Start(kTestGDataAuthToken, kTestUserAgent,
407 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 407 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
408 MessageLoop::current()->Run(); 408 MessageLoop::current()->Run();
409 409
410 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); 410 EXPECT_EQ(GDATA_PARSE_ERROR, result_code);
411 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 411 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
412 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showfolders=true" 412 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&"
413 "&max-results=500&include-installed-apps=true", 413 "showfolders=true&max-results=500&include-installed-apps=true",
414 http_request_.relative_url); 414 http_request_.relative_url);
415 EXPECT_FALSE(result_data); 415 EXPECT_FALSE(result_data);
416 } 416 }
417 417
418 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { 418 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) {
419 GDataErrorCode result_code = GDATA_OTHER_ERROR; 419 GDataErrorCode result_code = GDATA_OTHER_ERROR;
420 scoped_ptr<base::Value> result_data; 420 scoped_ptr<base::Value> result_data;
421 421
422 GetResourceEntryOperation* operation = new GetResourceEntryOperation( 422 GetResourceEntryOperation* operation = new GetResourceEntryOperation(
423 &operation_registry_, 423 &operation_registry_,
424 request_context_getter_.get(), 424 request_context_getter_.get(),
425 *url_generator_, 425 *url_generator_,
426 "file:2_file_resource_id", // resource ID 426 "file:2_file_resource_id", // resource ID
427 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 427 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
428 &result_code, 428 &result_code,
429 &result_data)); 429 &result_data));
430 operation->Start(kTestGDataAuthToken, kTestUserAgent, 430 operation->Start(kTestGDataAuthToken, kTestUserAgent,
431 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 431 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
432 MessageLoop::current()->Run(); 432 MessageLoop::current()->Run();
433 433
434 EXPECT_EQ(HTTP_SUCCESS, result_code); 434 EXPECT_EQ(HTTP_SUCCESS, result_code);
435 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 435 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
436 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" 436 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id"
437 "?v=3&alt=json", 437 "?v=3&alt=json&showroot=true",
438 http_request_.relative_url); 438 http_request_.relative_url);
439 EXPECT_TRUE(test_util::VerifyJsonData( 439 EXPECT_TRUE(test_util::VerifyJsonData(
440 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"), 440 test_util::GetTestFilePath("chromeos/gdata/file_entry.json"),
441 result_data.get())); 441 result_data.get()));
442 } 442 }
443 443
444 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) { 444 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) {
445 GDataErrorCode result_code = GDATA_OTHER_ERROR; 445 GDataErrorCode result_code = GDATA_OTHER_ERROR;
446 scoped_ptr<base::Value> result_data; 446 scoped_ptr<base::Value> result_data;
447 447
448 GetResourceEntryOperation* operation = new GetResourceEntryOperation( 448 GetResourceEntryOperation* operation = new GetResourceEntryOperation(
449 &operation_registry_, 449 &operation_registry_,
450 request_context_getter_.get(), 450 request_context_getter_.get(),
451 *url_generator_, 451 *url_generator_,
452 "<invalid>", // resource ID 452 "<invalid>", // resource ID
453 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 453 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
454 &result_code, 454 &result_code,
455 &result_data)); 455 &result_data));
456 operation->Start(kTestGDataAuthToken, kTestUserAgent, 456 operation->Start(kTestGDataAuthToken, kTestUserAgent,
457 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 457 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
458 MessageLoop::current()->Run(); 458 MessageLoop::current()->Run();
459 459
460 EXPECT_EQ(HTTP_NOT_FOUND, result_code); 460 EXPECT_EQ(HTTP_NOT_FOUND, result_code);
461 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 461 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
462 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json", 462 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json"
463 "&showroot=true",
463 http_request_.relative_url); 464 http_request_.relative_url);
464 ASSERT_FALSE(result_data); 465 ASSERT_FALSE(result_data);
465 } 466 }
466 467
467 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { 468 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) {
468 GDataErrorCode result_code = GDATA_OTHER_ERROR; 469 GDataErrorCode result_code = GDATA_OTHER_ERROR;
469 scoped_ptr<AccountMetadata> result_data; 470 scoped_ptr<AccountMetadata> result_data;
470 471
471 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( 472 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation(
472 &operation_registry_, 473 &operation_registry_,
473 request_context_getter_.get(), 474 request_context_getter_.get(),
474 *url_generator_, 475 *url_generator_,
475 base::Bind(&test_util::CopyResultsFromGetAccountMetadataCallbackAndQuit, 476 base::Bind(&test_util::CopyResultsFromGetAccountMetadataCallbackAndQuit,
476 &result_code, &result_data), 477 &result_code, &result_data),
477 true); // Include installed apps. 478 true); // Include installed apps.
478 operation->Start(kTestGDataAuthToken, kTestUserAgent, 479 operation->Start(kTestGDataAuthToken, kTestUserAgent,
479 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 480 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
480 MessageLoop::current()->Run(); 481 MessageLoop::current()->Run();
481 482
482 EXPECT_EQ(HTTP_SUCCESS, result_code); 483 EXPECT_EQ(HTTP_SUCCESS, result_code);
483 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 484 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
484 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&include-installed-apps=true", 485 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true"
486 "&include-installed-apps=true",
485 http_request_.relative_url); 487 http_request_.relative_url);
486 488
487 scoped_ptr<AccountMetadata> expected( 489 scoped_ptr<AccountMetadata> expected(
488 AccountMetadata::CreateFrom( 490 AccountMetadata::CreateFrom(
489 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); 491 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json")));
490 492
491 ASSERT_TRUE(result_data.get()); 493 ASSERT_TRUE(result_data.get());
492 EXPECT_EQ(expected->largest_changestamp(), 494 EXPECT_EQ(expected->largest_changestamp(),
493 result_data->largest_changestamp()); 495 result_data->largest_changestamp());
494 EXPECT_EQ(expected->quota_bytes_total(), 496 EXPECT_EQ(expected->quota_bytes_total(),
(...skipping 17 matching lines...) Expand all
512 *url_generator_, 514 *url_generator_,
513 base::Bind(&test_util::CopyResultsFromGetAccountMetadataCallbackAndQuit, 515 base::Bind(&test_util::CopyResultsFromGetAccountMetadataCallbackAndQuit,
514 &result_code, &result_data), 516 &result_code, &result_data),
515 false); // Exclude installed apps. 517 false); // Exclude installed apps.
516 operation->Start(kTestGDataAuthToken, kTestUserAgent, 518 operation->Start(kTestGDataAuthToken, kTestUserAgent,
517 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 519 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
518 MessageLoop::current()->Run(); 520 MessageLoop::current()->Run();
519 521
520 EXPECT_EQ(HTTP_SUCCESS, result_code); 522 EXPECT_EQ(HTTP_SUCCESS, result_code);
521 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 523 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
522 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json", 524 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&showroot=true",
523 http_request_.relative_url); 525 http_request_.relative_url);
524 526
525 scoped_ptr<AccountMetadata> expected( 527 scoped_ptr<AccountMetadata> expected(
526 AccountMetadata::CreateFrom( 528 AccountMetadata::CreateFrom(
527 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"))); 529 *test_util::LoadJSONFile("chromeos/gdata/account_metadata.json")));
528 530
529 ASSERT_TRUE(result_data.get()); 531 ASSERT_TRUE(result_data.get());
530 EXPECT_EQ(expected->largest_changestamp(), 532 EXPECT_EQ(expected->largest_changestamp(),
531 result_data->largest_changestamp()); 533 result_data->largest_changestamp());
532 EXPECT_EQ(expected->quota_bytes_total(), 534 EXPECT_EQ(expected->quota_bytes_total(),
(...skipping 17 matching lines...) Expand all
550 "file:2_file_resource_id", 552 "file:2_file_resource_id",
551 ""); 553 "");
552 554
553 operation->Start(kTestGDataAuthToken, kTestUserAgent, 555 operation->Start(kTestGDataAuthToken, kTestUserAgent,
554 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 556 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
555 MessageLoop::current()->Run(); 557 MessageLoop::current()->Run();
556 558
557 EXPECT_EQ(HTTP_SUCCESS, result_code); 559 EXPECT_EQ(HTTP_SUCCESS, result_code);
558 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); 560 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method);
559 EXPECT_EQ( 561 EXPECT_EQ(
560 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json", 562 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json"
563 "&showroot=true",
561 http_request_.relative_url); 564 http_request_.relative_url);
562 EXPECT_EQ("*", http_request_.headers["If-Match"]); 565 EXPECT_EQ("*", http_request_.headers["If-Match"]);
563 } 566 }
564 567
565 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) { 568 TEST_F(GDataWapiOperationsTest, DeleteResourceOperationWithETag) {
566 GDataErrorCode result_code = GDATA_OTHER_ERROR; 569 GDataErrorCode result_code = GDATA_OTHER_ERROR;
567 570
568 DeleteResourceOperation* operation = new DeleteResourceOperation( 571 DeleteResourceOperation* operation = new DeleteResourceOperation(
569 &operation_registry_, 572 &operation_registry_,
570 request_context_getter_.get(), 573 request_context_getter_.get(),
571 *url_generator_, 574 *url_generator_,
572 base::Bind(&test_util::CopyResultFromEntryActionCallbackAndQuit, 575 base::Bind(&test_util::CopyResultFromEntryActionCallbackAndQuit,
573 &result_code), 576 &result_code),
574 "file:2_file_resource_id", 577 "file:2_file_resource_id",
575 "etag"); 578 "etag");
576 579
577 operation->Start(kTestGDataAuthToken, kTestUserAgent, 580 operation->Start(kTestGDataAuthToken, kTestUserAgent,
578 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 581 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
579 MessageLoop::current()->Run(); 582 MessageLoop::current()->Run();
580 583
581 EXPECT_EQ(HTTP_SUCCESS, result_code); 584 EXPECT_EQ(HTTP_SUCCESS, result_code);
582 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); 585 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method);
583 EXPECT_EQ( 586 EXPECT_EQ(
584 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json", 587 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json"
588 "&showroot=true",
585 http_request_.relative_url); 589 http_request_.relative_url);
586 EXPECT_EQ("etag", http_request_.headers["If-Match"]); 590 EXPECT_EQ("etag", http_request_.headers["If-Match"]);
587 } 591 }
588 592
589 TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) { 593 TEST_F(GDataWapiOperationsTest, CreateDirectoryOperation) {
590 GDataErrorCode result_code = GDATA_OTHER_ERROR; 594 GDataErrorCode result_code = GDATA_OTHER_ERROR;
591 scoped_ptr<base::Value> result_data; 595 scoped_ptr<base::Value> result_data;
592 596
593 // Create "new directory" in the root directory. 597 // Create "new directory" in the root directory.
594 CreateDirectoryOperation* operation = new CreateDirectoryOperation( 598 CreateDirectoryOperation* operation = new CreateDirectoryOperation(
595 &operation_registry_, 599 &operation_registry_,
596 request_context_getter_.get(), 600 request_context_getter_.get(),
597 *url_generator_, 601 *url_generator_,
598 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, 602 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit,
599 &result_code, 603 &result_code,
600 &result_data), 604 &result_data),
601 "folder:root", 605 "folder:root",
602 "new directory"); 606 "new directory");
603 607
604 operation->Start(kTestGDataAuthToken, kTestUserAgent, 608 operation->Start(kTestGDataAuthToken, kTestUserAgent,
605 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 609 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
606 MessageLoop::current()->Run(); 610 MessageLoop::current()->Run();
607 611
608 EXPECT_EQ(HTTP_SUCCESS, result_code); 612 EXPECT_EQ(HTTP_SUCCESS, result_code);
609 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); 613 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
610 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json", 614 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json"
615 "&showroot=true",
611 http_request_.relative_url); 616 http_request_.relative_url);
612 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 617 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
613 618
614 EXPECT_TRUE(http_request_.has_content); 619 EXPECT_TRUE(http_request_.has_content);
615 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 620 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
616 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" 621 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
617 " <category scheme=\"http://schemas.google.com/g/2005#kind\" " 622 " <category scheme=\"http://schemas.google.com/g/2005#kind\" "
618 "term=\"http://schemas.google.com/docs/2007#folder\"/>\n" 623 "term=\"http://schemas.google.com/docs/2007#folder\"/>\n"
619 " <title>new directory</title>\n" 624 " <title>new directory</title>\n"
620 "</entry>\n", 625 "</entry>\n",
(...skipping 14 matching lines...) Expand all
635 &result_data), 640 &result_data),
636 "document:5_document_resource_id", // source resource ID 641 "document:5_document_resource_id", // source resource ID
637 "New Document"); 642 "New Document");
638 643
639 operation->Start(kTestGDataAuthToken, kTestUserAgent, 644 operation->Start(kTestGDataAuthToken, kTestUserAgent,
640 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 645 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
641 MessageLoop::current()->Run(); 646 MessageLoop::current()->Run();
642 647
643 EXPECT_EQ(HTTP_SUCCESS, result_code); 648 EXPECT_EQ(HTTP_SUCCESS, result_code);
644 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); 649 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
645 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json", 650 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true",
646 http_request_.relative_url); 651 http_request_.relative_url);
647 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 652 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
648 653
649 EXPECT_TRUE(http_request_.has_content); 654 EXPECT_TRUE(http_request_.has_content);
650 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 655 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
651 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" 656 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
652 " <id>document:5_document_resource_id</id>\n" 657 " <id>document:5_document_resource_id</id>\n"
653 " <title>New Document</title>\n" 658 " <title>New Document</title>\n"
654 "</entry>\n", 659 "</entry>\n",
655 http_request_.content); 660 http_request_.content);
(...skipping 12 matching lines...) Expand all
668 "file:2_file_resource_id", 673 "file:2_file_resource_id",
669 "New File"); 674 "New File");
670 675
671 operation->Start(kTestGDataAuthToken, kTestUserAgent, 676 operation->Start(kTestGDataAuthToken, kTestUserAgent,
672 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 677 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
673 MessageLoop::current()->Run(); 678 MessageLoop::current()->Run();
674 679
675 EXPECT_EQ(HTTP_SUCCESS, result_code); 680 EXPECT_EQ(HTTP_SUCCESS, result_code);
676 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 681 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
677 EXPECT_EQ( 682 EXPECT_EQ(
678 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json", 683 "/feeds/default/private/full/file%3A2_file_resource_id?v=3&alt=json"
684 "&showroot=true",
679 http_request_.relative_url); 685 http_request_.relative_url);
680 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 686 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
681 EXPECT_EQ("*", http_request_.headers["If-Match"]); 687 EXPECT_EQ("*", http_request_.headers["If-Match"]);
682 688
683 EXPECT_TRUE(http_request_.has_content); 689 EXPECT_TRUE(http_request_.has_content);
684 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 690 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
685 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" 691 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
686 " <title>New File</title>\n" 692 " <title>New File</title>\n"
687 "</entry>\n", 693 "</entry>\n",
688 http_request_.content); 694 http_request_.content);
(...skipping 13 matching lines...) Expand all
702 test_server_.GetURL( 708 test_server_.GetURL(
703 "/feeds/default/private/full/file:2_file_resource_id"), 709 "/feeds/default/private/full/file:2_file_resource_id"),
704 "APP_ID"); 710 "APP_ID");
705 711
706 operation->Start(kTestGDataAuthToken, kTestUserAgent, 712 operation->Start(kTestGDataAuthToken, kTestUserAgent,
707 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 713 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
708 MessageLoop::current()->Run(); 714 MessageLoop::current()->Run();
709 715
710 EXPECT_EQ(HTTP_SUCCESS, result_code); 716 EXPECT_EQ(HTTP_SUCCESS, result_code);
711 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 717 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
712 EXPECT_EQ("/feeds/default/private/full/file:2_file_resource_id?v=3&alt=json", 718 EXPECT_EQ("/feeds/default/private/full/file:2_file_resource_id?v=3&alt=json"
719 "&showroot=true",
713 http_request_.relative_url); 720 http_request_.relative_url);
714 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 721 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
715 EXPECT_EQ("*", http_request_.headers["If-Match"]); 722 EXPECT_EQ("*", http_request_.headers["If-Match"]);
716 723
717 EXPECT_TRUE(http_request_.has_content); 724 EXPECT_TRUE(http_request_.has_content);
718 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 725 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
719 "<entry xmlns=\"http://www.w3.org/2005/Atom\" " 726 "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
720 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n" 727 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n"
721 " <docs:authorizedApp>APP_ID</docs:authorizedApp>\n" 728 " <docs:authorizedApp>APP_ID</docs:authorizedApp>\n"
722 "</entry>\n", 729 "</entry>\n",
(...skipping 13 matching lines...) Expand all
736 &result_data), 743 &result_data),
737 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"), 744 test_server_.GetURL("/files/chromeos/gdata/testfile.txt"),
738 "APP_ID"); 745 "APP_ID");
739 746
740 operation->Start(kTestGDataAuthToken, kTestUserAgent, 747 operation->Start(kTestGDataAuthToken, kTestUserAgent,
741 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 748 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
742 MessageLoop::current()->Run(); 749 MessageLoop::current()->Run();
743 750
744 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); 751 EXPECT_EQ(GDATA_PARSE_ERROR, result_code);
745 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 752 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
746 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json", 753 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true",
747 http_request_.relative_url); 754 http_request_.relative_url);
748 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 755 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
749 EXPECT_EQ("*", http_request_.headers["If-Match"]); 756 EXPECT_EQ("*", http_request_.headers["If-Match"]);
750 757
751 EXPECT_TRUE(http_request_.has_content); 758 EXPECT_TRUE(http_request_.has_content);
752 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 759 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
753 "<entry xmlns=\"http://www.w3.org/2005/Atom\" " 760 "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
754 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n" 761 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n"
755 " <docs:authorizedApp>APP_ID</docs:authorizedApp>\n" 762 " <docs:authorizedApp>APP_ID</docs:authorizedApp>\n"
756 "</entry>\n", 763 "</entry>\n",
(...skipping 13 matching lines...) Expand all
770 &result_code), 777 &result_code),
771 "folder:root", 778 "folder:root",
772 "file:2_file_resource_id"); 779 "file:2_file_resource_id");
773 780
774 operation->Start(kTestGDataAuthToken, kTestUserAgent, 781 operation->Start(kTestGDataAuthToken, kTestUserAgent,
775 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 782 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
776 MessageLoop::current()->Run(); 783 MessageLoop::current()->Run();
777 784
778 EXPECT_EQ(HTTP_SUCCESS, result_code); 785 EXPECT_EQ(HTTP_SUCCESS, result_code);
779 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); 786 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
780 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json", 787 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents?v=3&alt=json"
788 "&showroot=true",
781 http_request_.relative_url); 789 http_request_.relative_url);
782 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 790 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
783 791
784 EXPECT_TRUE(http_request_.has_content); 792 EXPECT_TRUE(http_request_.has_content);
785 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 793 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
786 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" 794 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
787 " <id>http://127.0.0.1:8040/feeds/default/private/full/" 795 " <id>http://127.0.0.1:8040/feeds/default/private/full/"
788 "file%3A2_file_resource_id</id>\n" 796 "file%3A2_file_resource_id</id>\n"
789 "</entry>\n", 797 "</entry>\n",
790 http_request_.content); 798 http_request_.content);
(...skipping 14 matching lines...) Expand all
805 "file:2_file_resource_id"); 813 "file:2_file_resource_id");
806 814
807 operation->Start(kTestGDataAuthToken, kTestUserAgent, 815 operation->Start(kTestGDataAuthToken, kTestUserAgent,
808 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 816 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
809 MessageLoop::current()->Run(); 817 MessageLoop::current()->Run();
810 818
811 EXPECT_EQ(HTTP_SUCCESS, result_code); 819 EXPECT_EQ(HTTP_SUCCESS, result_code);
812 // DELETE method should be used, without the body content. 820 // DELETE method should be used, without the body content.
813 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); 821 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method);
814 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/" 822 EXPECT_EQ("/feeds/default/private/full/folder%3Aroot/contents/"
815 "file%3A2_file_resource_id?v=3&alt=json", 823 "file%3A2_file_resource_id?v=3&alt=json&showroot=true",
816 http_request_.relative_url); 824 http_request_.relative_url);
817 EXPECT_EQ("*", http_request_.headers["If-Match"]); 825 EXPECT_EQ("*", http_request_.headers["If-Match"]);
818 EXPECT_FALSE(http_request_.has_content); 826 EXPECT_FALSE(http_request_.has_content);
819 } 827 }
820 828
821 // This test exercises InitiateUploadNewFileOperation and 829 // This test exercises InitiateUploadNewFileOperation and
822 // ResumeUploadOperation for a scenario of uploading a new file. 830 // ResumeUploadOperation for a scenario of uploading a new file.
823 TEST_F(GDataWapiOperationsTest, UploadNewFile) { 831 TEST_F(GDataWapiOperationsTest, UploadNewFile) {
824 const std::string kUploadContent = "hello"; 832 const std::string kUploadContent = "hello";
825 GDataErrorCode result_code = GDATA_OTHER_ERROR; 833 GDataErrorCode result_code = GDATA_OTHER_ERROR;
(...skipping 18 matching lines...) Expand all
844 kTestGDataAuthToken, kTestUserAgent, 852 kTestGDataAuthToken, kTestUserAgent,
845 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 853 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
846 MessageLoop::current()->Run(); 854 MessageLoop::current()->Run();
847 855
848 EXPECT_EQ(HTTP_SUCCESS, result_code); 856 EXPECT_EQ(HTTP_SUCCESS, result_code);
849 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); 857 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url);
850 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); 858 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
851 // convert=false should be passed as files should be uploaded as-is. 859 // convert=false should be passed as files should be uploaded as-is.
852 EXPECT_EQ( 860 EXPECT_EQ(
853 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" 861 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents"
854 "?convert=false&v=3&alt=json", 862 "?convert=false&v=3&alt=json&showroot=true",
855 http_request_.relative_url); 863 http_request_.relative_url);
856 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); 864 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]);
857 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 865 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
858 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 866 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
859 http_request_.headers["X-Upload-Content-Length"]); 867 http_request_.headers["X-Upload-Content-Length"]);
860 868
861 EXPECT_TRUE(http_request_.has_content); 869 EXPECT_TRUE(http_request_.has_content);
862 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 870 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
863 "<entry xmlns=\"http://www.w3.org/2005/Atom\" " 871 "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
864 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n" 872 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 kTestGDataAuthToken, kTestUserAgent, 953 kTestGDataAuthToken, kTestUserAgent,
946 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 954 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
947 MessageLoop::current()->Run(); 955 MessageLoop::current()->Run();
948 956
949 EXPECT_EQ(HTTP_SUCCESS, result_code); 957 EXPECT_EQ(HTTP_SUCCESS, result_code);
950 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); 958 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url);
951 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); 959 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
952 // convert=false should be passed as files should be uploaded as-is. 960 // convert=false should be passed as files should be uploaded as-is.
953 EXPECT_EQ( 961 EXPECT_EQ(
954 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" 962 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents"
955 "?convert=false&v=3&alt=json", 963 "?convert=false&v=3&alt=json&showroot=true",
956 http_request_.relative_url); 964 http_request_.relative_url);
957 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); 965 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]);
958 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 966 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
959 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 967 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
960 http_request_.headers["X-Upload-Content-Length"]); 968 http_request_.headers["X-Upload-Content-Length"]);
961 969
962 EXPECT_TRUE(http_request_.has_content); 970 EXPECT_TRUE(http_request_.has_content);
963 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 971 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
964 "<entry xmlns=\"http://www.w3.org/2005/Atom\" " 972 "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
965 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n" 973 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 kTestGDataAuthToken, kTestUserAgent, 1150 kTestGDataAuthToken, kTestUserAgent,
1143 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 1151 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
1144 MessageLoop::current()->Run(); 1152 MessageLoop::current()->Run();
1145 1153
1146 EXPECT_EQ(HTTP_SUCCESS, result_code); 1154 EXPECT_EQ(HTTP_SUCCESS, result_code);
1147 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url); 1155 EXPECT_EQ(test_server_.GetURL("/upload_new_file"), upload_url);
1148 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); 1156 EXPECT_EQ(test_server::METHOD_POST, http_request_.method);
1149 // convert=false should be passed as files should be uploaded as-is. 1157 // convert=false should be passed as files should be uploaded as-is.
1150 EXPECT_EQ( 1158 EXPECT_EQ(
1151 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents" 1159 "/feeds/upload/create-session/default/private/full/folder%3Aid/contents"
1152 "?convert=false&v=3&alt=json", 1160 "?convert=false&v=3&alt=json&showroot=true",
1153 http_request_.relative_url); 1161 http_request_.relative_url);
1154 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); 1162 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]);
1155 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]); 1163 EXPECT_EQ("application/atom+xml", http_request_.headers["Content-Type"]);
1156 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 1164 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
1157 http_request_.headers["X-Upload-Content-Length"]); 1165 http_request_.headers["X-Upload-Content-Length"]);
1158 1166
1159 EXPECT_TRUE(http_request_.has_content); 1167 EXPECT_TRUE(http_request_.has_content);
1160 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 1168 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
1161 "<entry xmlns=\"http://www.w3.org/2005/Atom\" " 1169 "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
1162 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n" 1170 "xmlns:docs=\"http://schemas.google.com/docs/2007\">\n"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 kTestGDataAuthToken, kTestUserAgent, 1242 kTestGDataAuthToken, kTestUserAgent,
1235 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 1243 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
1236 MessageLoop::current()->Run(); 1244 MessageLoop::current()->Run();
1237 1245
1238 EXPECT_EQ(HTTP_SUCCESS, result_code); 1246 EXPECT_EQ(HTTP_SUCCESS, result_code);
1239 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); 1247 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url);
1240 // For updating an existing file, METHOD_PUT should be used. 1248 // For updating an existing file, METHOD_PUT should be used.
1241 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 1249 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
1242 // convert=false should be passed as files should be uploaded as-is. 1250 // convert=false should be passed as files should be uploaded as-is.
1243 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" 1251 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo"
1244 "?convert=false&v=3&alt=json", 1252 "?convert=false&v=3&alt=json&showroot=true",
1245 http_request_.relative_url); 1253 http_request_.relative_url);
1246 // Even though the body is empty, the content type should be set to 1254 // Even though the body is empty, the content type should be set to
1247 // "text/plain". 1255 // "text/plain".
1248 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); 1256 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]);
1249 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); 1257 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]);
1250 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 1258 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
1251 http_request_.headers["X-Upload-Content-Length"]); 1259 http_request_.headers["X-Upload-Content-Length"]);
1252 // For updating an existing file, an empty body should be attached (PUT 1260 // For updating an existing file, an empty body should be attached (PUT
1253 // requires a body) 1261 // requires a body)
1254 EXPECT_TRUE(http_request_.has_content); 1262 EXPECT_TRUE(http_request_.has_content);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 kTestGDataAuthToken, kTestUserAgent, 1335 kTestGDataAuthToken, kTestUserAgent,
1328 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 1336 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
1329 MessageLoop::current()->Run(); 1337 MessageLoop::current()->Run();
1330 1338
1331 EXPECT_EQ(HTTP_SUCCESS, result_code); 1339 EXPECT_EQ(HTTP_SUCCESS, result_code);
1332 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url); 1340 EXPECT_EQ(test_server_.GetURL("/upload_existing_file"), upload_url);
1333 // For updating an existing file, METHOD_PUT should be used. 1341 // For updating an existing file, METHOD_PUT should be used.
1334 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 1342 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
1335 // convert=false should be passed as files should be uploaded as-is. 1343 // convert=false should be passed as files should be uploaded as-is.
1336 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" 1344 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo"
1337 "?convert=false&v=3&alt=json", 1345 "?convert=false&v=3&alt=json&showroot=true",
1338 http_request_.relative_url); 1346 http_request_.relative_url);
1339 // Even though the body is empty, the content type should be set to 1347 // Even though the body is empty, the content type should be set to
1340 // "text/plain". 1348 // "text/plain".
1341 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); 1349 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]);
1342 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); 1350 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]);
1343 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 1351 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
1344 http_request_.headers["X-Upload-Content-Length"]); 1352 http_request_.headers["X-Upload-Content-Length"]);
1345 // For updating an existing file, an empty body should be attached (PUT 1353 // For updating an existing file, an empty body should be attached (PUT
1346 // requires a body) 1354 // requires a body)
1347 EXPECT_TRUE(http_request_.has_content); 1355 EXPECT_TRUE(http_request_.has_content);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 initiate_operation->Start( 1427 initiate_operation->Start(
1420 kTestGDataAuthToken, kTestUserAgent, 1428 kTestGDataAuthToken, kTestUserAgent,
1421 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); 1429 base::Bind(&test_util::DoNothingForReAuthenticateCallback));
1422 MessageLoop::current()->Run(); 1430 MessageLoop::current()->Run();
1423 1431
1424 EXPECT_EQ(HTTP_PRECONDITION, result_code); 1432 EXPECT_EQ(HTTP_PRECONDITION, result_code);
1425 // For updating an existing file, METHOD_PUT should be used. 1433 // For updating an existing file, METHOD_PUT should be used.
1426 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); 1434 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method);
1427 // convert=false should be passed as files should be uploaded as-is. 1435 // convert=false should be passed as files should be uploaded as-is.
1428 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo" 1436 EXPECT_EQ("/feeds/upload/create-session/default/private/full/file%3Afoo"
1429 "?convert=false&v=3&alt=json", 1437 "?convert=false&v=3&alt=json&showroot=true",
1430 http_request_.relative_url); 1438 http_request_.relative_url);
1431 // Even though the body is empty, the content type should be set to 1439 // Even though the body is empty, the content type should be set to
1432 // "text/plain". 1440 // "text/plain".
1433 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]); 1441 EXPECT_EQ("text/plain", http_request_.headers["Content-Type"]);
1434 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]); 1442 EXPECT_EQ("text/plain", http_request_.headers["X-Upload-Content-Type"]);
1435 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), 1443 EXPECT_EQ(base::Int64ToString(kUploadContent.size()),
1436 http_request_.headers["X-Upload-Content-Length"]); 1444 http_request_.headers["X-Upload-Content-Length"]);
1437 // For updating an existing file, an empty body should be attached (PUT 1445 // For updating an existing file, an empty body should be attached (PUT
1438 // requires a body) 1446 // requires a body)
1439 EXPECT_TRUE(http_request_.has_content); 1447 EXPECT_TRUE(http_request_.has_content);
1440 EXPECT_EQ("", http_request_.content); 1448 EXPECT_EQ("", http_request_.content);
1441 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); 1449 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]);
1442 } 1450 }
1443 1451
1444 } // namespace google_apis 1452 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/fake_drive_service_unittest.cc ('k') | chrome/browser/google_apis/gdata_wapi_url_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698