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

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

Issue 23549003: Refactor GetChangelistRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 request_sender_->StartRequestWithRetry(request); 475 request_sender_->StartRequestWithRetry(request);
476 run_loop.Run(); 476 run_loop.Run();
477 } 477 }
478 478
479 EXPECT_EQ(HTTP_SUCCESS, error); 479 EXPECT_EQ(HTTP_SUCCESS, error);
480 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 480 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
481 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); 481 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url);
482 EXPECT_TRUE(app_list); 482 EXPECT_TRUE(app_list);
483 } 483 }
484 484
485 TEST_F(DriveApiRequestsTest, GetChangelistRequest) { 485 TEST_F(DriveApiRequestsTest, ChangesListRequest) {
486 // Set an expected data file containing valid result. 486 // Set an expected data file containing valid result.
487 expected_data_file_path_ = test_util::GetTestFilePath( 487 expected_data_file_path_ = test_util::GetTestFilePath(
488 "drive/changelist.json"); 488 "drive/changelist.json");
489 489
490 GDataErrorCode error = GDATA_OTHER_ERROR; 490 GDataErrorCode error = GDATA_OTHER_ERROR;
491 scoped_ptr<base::Value> result; 491 scoped_ptr<ChangeList> result;
492 492
493 { 493 {
494 base::RunLoop run_loop; 494 base::RunLoop run_loop;
495 GetChangelistRequest* request = new GetChangelistRequest( 495 drive::ChangesListRequest* request = new drive::ChangesListRequest(
496 request_sender_.get(), 496 request_sender_.get(), *url_generator_,
497 *url_generator_,
498 true, // include deleted
499 100, // start changestamp
500 500, // max results
501 test_util::CreateQuitCallback( 497 test_util::CreateQuitCallback(
502 &run_loop, 498 &run_loop,
503 test_util::CreateCopyResultCallback(&error, &result))); 499 test_util::CreateCopyResultCallback(&error, &result)));
500 request->set_include_deleted(true);
501 request->set_start_change_id(100);
502 request->set_max_results(500);
504 request_sender_->StartRequestWithRetry(request); 503 request_sender_->StartRequestWithRetry(request);
505 run_loop.Run(); 504 run_loop.Run();
506 } 505 }
507 506
508 EXPECT_EQ(HTTP_SUCCESS, error); 507 EXPECT_EQ(HTTP_SUCCESS, error);
509 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 508 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
510 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", 509 EXPECT_EQ("/drive/v2/changes?maxResults=500&startChangeId=100",
511 http_request_.relative_url); 510 http_request_.relative_url);
512 EXPECT_TRUE(result); 511 EXPECT_TRUE(result);
513 } 512 }
514 513
515 TEST_F(DriveApiRequestsTest, FilesListRequest) { 514 TEST_F(DriveApiRequestsTest, FilesListRequest) {
516 // Set an expected data file containing valid result. 515 // Set an expected data file containing valid result.
517 expected_data_file_path_ = test_util::GetTestFilePath( 516 expected_data_file_path_ = test_util::GetTestFilePath(
518 "drive/filelist.json"); 517 "drive/filelist.json");
519 518
520 GDataErrorCode error = GDATA_OTHER_ERROR; 519 GDataErrorCode error = GDATA_OTHER_ERROR;
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 EXPECT_EQ(HTTP_SUCCESS, result_code); 1597 EXPECT_EQ(HTTP_SUCCESS, result_code);
1599 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); 1598 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method);
1600 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url); 1599 EXPECT_EQ(kTestDownloadPathPrefix + kTestId, http_request_.relative_url);
1601 EXPECT_EQ(kDownloadedFilePath, temp_file); 1600 EXPECT_EQ(kDownloadedFilePath, temp_file);
1602 1601
1603 const std::string expected_contents = kTestId + kTestId + kTestId; 1602 const std::string expected_contents = kTestId + kTestId + kTestId;
1604 EXPECT_EQ(expected_contents, contents); 1603 EXPECT_EQ(expected_contents, contents);
1605 } 1604 }
1606 1605
1607 } // namespace google_apis 1606 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_api_requests.cc ('k') | chrome/browser/google_apis/drive_api_url_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698