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

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

Issue 11444024: Clarify the use of the term "Document" in gdata_wapi_operations.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment on DeleteResourceOperation. Created 8 years 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 MessageLoop::current()->Run(); 487 MessageLoop::current()->Run();
488 488
489 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); 489 EXPECT_EQ(GDATA_PARSE_ERROR, result_code);
490 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 490 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
491 EXPECT_EQ("/files/gdata/testfile.txt?v=3&alt=json&showfolders=true" 491 EXPECT_EQ("/files/gdata/testfile.txt?v=3&alt=json&showfolders=true"
492 "&max-results=500&include-installed-apps=true", 492 "&max-results=500&include-installed-apps=true",
493 http_request_.relative_url); 493 http_request_.relative_url);
494 EXPECT_FALSE(result_data); 494 EXPECT_FALSE(result_data);
495 } 495 }
496 496
497 TEST_F(GDataWapiOperationsTest, GetDocumentEntryOperation_ValidResourceId) { 497 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) {
498 GDataErrorCode result_code = GDATA_OTHER_ERROR; 498 GDataErrorCode result_code = GDATA_OTHER_ERROR;
499 scoped_ptr<base::Value> result_data; 499 scoped_ptr<base::Value> result_data;
500 500
501 GetDocumentEntryOperation* operation = new GetDocumentEntryOperation( 501 GetResourceEntryOperation* operation = new GetResourceEntryOperation(
502 &operation_registry_, 502 &operation_registry_,
503 request_context_getter_.get(), 503 request_context_getter_.get(),
504 *url_generator_, 504 *url_generator_,
505 "file:2_file_resource_id", // resource ID 505 "file:2_file_resource_id", // resource ID
506 base::Bind(&CopyResultsFromGetDataCallbackAndQuit, 506 base::Bind(&CopyResultsFromGetDataCallbackAndQuit,
507 &result_code, 507 &result_code,
508 &result_data)); 508 &result_data));
509 operation->Start(kTestGDataAuthToken, kTestUserAgent); 509 operation->Start(kTestGDataAuthToken, kTestUserAgent);
510 MessageLoop::current()->Run(); 510 MessageLoop::current()->Run();
511 511
512 EXPECT_EQ(HTTP_SUCCESS, result_code); 512 EXPECT_EQ(HTTP_SUCCESS, result_code);
513 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 513 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
514 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id" 514 EXPECT_EQ("/feeds/default/private/full/file%3A2_file_resource_id"
515 "?v=3&alt=json", 515 "?v=3&alt=json",
516 http_request_.relative_url); 516 http_request_.relative_url);
517 ASSERT_TRUE(result_data); 517 ASSERT_TRUE(result_data);
518 EXPECT_TRUE(VerifyJsonData( 518 EXPECT_TRUE(VerifyJsonData(
519 test_util::GetTestFilePath("gdata/file_entry.json"), 519 test_util::GetTestFilePath("gdata/file_entry.json"),
520 result_data.get())); 520 result_data.get()));
521 } 521 }
522 522
523 TEST_F(GDataWapiOperationsTest, GetDocumentEntryOperation_InvalidResourceId) { 523 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_InvalidResourceId) {
524 GDataErrorCode result_code = GDATA_OTHER_ERROR; 524 GDataErrorCode result_code = GDATA_OTHER_ERROR;
525 scoped_ptr<base::Value> result_data; 525 scoped_ptr<base::Value> result_data;
526 526
527 GetDocumentEntryOperation* operation = new GetDocumentEntryOperation( 527 GetResourceEntryOperation* operation = new GetResourceEntryOperation(
528 &operation_registry_, 528 &operation_registry_,
529 request_context_getter_.get(), 529 request_context_getter_.get(),
530 *url_generator_, 530 *url_generator_,
531 "<invalid>", // resource ID 531 "<invalid>", // resource ID
532 base::Bind(&CopyResultsFromGetDataCallbackAndQuit, 532 base::Bind(&CopyResultsFromGetDataCallbackAndQuit,
533 &result_code, 533 &result_code,
534 &result_data)); 534 &result_data));
535 operation->Start(kTestGDataAuthToken, kTestUserAgent); 535 operation->Start(kTestGDataAuthToken, kTestUserAgent);
536 MessageLoop::current()->Run(); 536 MessageLoop::current()->Run();
537 537
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 FilePath::FromUTF8Unsafe("cache_no-such-file.txt"))); 608 FilePath::FromUTF8Unsafe("cache_no-such-file.txt")));
609 operation->Start(kTestGDataAuthToken, kTestUserAgent); 609 operation->Start(kTestGDataAuthToken, kTestUserAgent);
610 MessageLoop::current()->Run(); 610 MessageLoop::current()->Run();
611 611
612 EXPECT_EQ(HTTP_NOT_FOUND, result_code); 612 EXPECT_EQ(HTTP_NOT_FOUND, result_code);
613 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); 613 EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
614 EXPECT_EQ("/files/gdata/no-such-file.txt", http_request_.relative_url); 614 EXPECT_EQ("/files/gdata/no-such-file.txt", http_request_.relative_url);
615 // Do not verify the not found message. 615 // Do not verify the not found message.
616 } 616 }
617 617
618 TEST_F(GDataWapiOperationsTest, DeleteDocumentOperation) { 618 TEST_F(GDataWapiOperationsTest, DeleteResourceOperation) {
619 GDataErrorCode result_code = GDATA_OTHER_ERROR; 619 GDataErrorCode result_code = GDATA_OTHER_ERROR;
620 620
621 DeleteDocumentOperation* operation = new DeleteDocumentOperation( 621 DeleteResourceOperation* operation = new DeleteResourceOperation(
622 &operation_registry_, 622 &operation_registry_,
623 request_context_getter_.get(), 623 request_context_getter_.get(),
624 base::Bind(&CopyResultFromEntryActionCallbackAndQuit, 624 base::Bind(&CopyResultFromEntryActionCallbackAndQuit,
625 &result_code), 625 &result_code),
626 test_server_.GetURL( 626 test_server_.GetURL(
627 "/feeds/default/private/full/file:2_file_resource_id")); 627 "/feeds/default/private/full/file:2_file_resource_id"));
628 628
629 operation->Start(kTestGDataAuthToken, kTestUserAgent); 629 operation->Start(kTestGDataAuthToken, kTestUserAgent);
630 MessageLoop::current()->Run(); 630 MessageLoop::current()->Run();
631 631
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 EXPECT_TRUE(http_request_.has_content); 663 EXPECT_TRUE(http_request_.has_content);
664 EXPECT_EQ("<?xml version=\"1.0\"?>\n" 664 EXPECT_EQ("<?xml version=\"1.0\"?>\n"
665 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n" 665 "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
666 " <category scheme=\"http://schemas.google.com/g/2005#kind\" " 666 " <category scheme=\"http://schemas.google.com/g/2005#kind\" "
667 "term=\"http://schemas.google.com/docs/2007#folder\"/>\n" 667 "term=\"http://schemas.google.com/docs/2007#folder\"/>\n"
668 " <title>new directory</title>\n" 668 " <title>new directory</title>\n"
669 "</entry>\n", 669 "</entry>\n",
670 http_request_.content); 670 http_request_.content);
671 } 671 }
672 672
673 TEST_F(GDataWapiOperationsTest, CopyDocumentOperation) { 673 TEST_F(GDataWapiOperationsTest, CopyHostedDocumentOperation) {
674 GDataErrorCode result_code = GDATA_OTHER_ERROR; 674 GDataErrorCode result_code = GDATA_OTHER_ERROR;
675 scoped_ptr<base::Value> result_data; 675 scoped_ptr<base::Value> result_data;
676 676
677 // Copy a document with a new name "New Document". 677 // Copy a document with a new name "New Document".
678 CopyDocumentOperation* operation = new CopyDocumentOperation( 678 CopyHostedDocumentOperation* operation = new CopyHostedDocumentOperation(
679 &operation_registry_, 679 &operation_registry_,
680 request_context_getter_.get(), 680 request_context_getter_.get(),
681 *url_generator_, 681 *url_generator_,
682 base::Bind(&CopyResultsFromGetDataCallbackAndQuit, 682 base::Bind(&CopyResultsFromGetDataCallbackAndQuit,
683 &result_code, 683 &result_code,
684 &result_data), 684 &result_data),
685 "document:5_document_resource_id", // source resource ID 685 "document:5_document_resource_id", // source resource ID
686 FILE_PATH_LITERAL("New Document")); 686 FILE_PATH_LITERAL("New Document"));
687 687
688 operation->Start(kTestGDataAuthToken, kTestUserAgent); 688 operation->Start(kTestGDataAuthToken, kTestUserAgent);
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 EXPECT_EQ(kUploadContent, http_request_.content); 1253 EXPECT_EQ(kUploadContent, http_request_.content);
1254 1254
1255 // Check the response. 1255 // Check the response.
1256 EXPECT_EQ(HTTP_SUCCESS, response.code); // Because it's an existing file. 1256 EXPECT_EQ(HTTP_SUCCESS, response.code); // Because it's an existing file.
1257 // The start and end positions should be set to -1, if an upload is complete. 1257 // The start and end positions should be set to -1, if an upload is complete.
1258 EXPECT_EQ(-1, response.start_range_received); 1258 EXPECT_EQ(-1, response.start_range_received);
1259 EXPECT_EQ(-1, response.end_range_received); 1259 EXPECT_EQ(-1, response.end_range_received);
1260 } 1260 }
1261 1261
1262 } // namespace google_apis 1262 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698