| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 481 |
| 482 EXPECT_EQ(HTTP_NOT_FOUND, result_code); | 482 EXPECT_EQ(HTTP_NOT_FOUND, result_code); |
| 483 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 483 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 484 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json", | 484 EXPECT_EQ("/feeds/default/private/full/%3Cinvalid%3E?v=3&alt=json", |
| 485 http_request_.relative_url); | 485 http_request_.relative_url); |
| 486 ASSERT_FALSE(result_data); | 486 ASSERT_FALSE(result_data); |
| 487 } | 487 } |
| 488 | 488 |
| 489 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { | 489 TEST_F(GDataWapiOperationsTest, GetAccountMetadataOperation) { |
| 490 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 490 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 491 scoped_ptr<base::Value> result_data; | 491 scoped_ptr<AccountMetadataFeed> result_data; |
| 492 | 492 |
| 493 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( | 493 GetAccountMetadataOperation* operation = new GetAccountMetadataOperation( |
| 494 &operation_registry_, | 494 &operation_registry_, |
| 495 request_context_getter_.get(), | 495 request_context_getter_.get(), |
| 496 *url_generator_, | 496 *url_generator_, |
| 497 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, | 497 base::Bind(&test_util::CopyResultsFromGetAccountMetadataCallbackAndQuit, |
| 498 &result_code, | 498 &result_code, &result_data)); |
| 499 &result_data)); | |
| 500 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 499 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 501 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 500 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 502 MessageLoop::current()->Run(); | 501 MessageLoop::current()->Run(); |
| 503 | 502 |
| 504 EXPECT_EQ(HTTP_SUCCESS, result_code); | 503 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 505 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 504 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 506 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&include-installed-apps=true", | 505 EXPECT_EQ("/feeds/metadata/default?v=3&alt=json&include-installed-apps=true", |
| 507 http_request_.relative_url); | 506 http_request_.relative_url); |
| 508 EXPECT_TRUE(test_util::VerifyJsonData( | 507 |
| 509 test_util::GetTestFilePath("gdata/account_metadata.json"), | 508 scoped_ptr<AccountMetadataFeed> expected( |
| 510 result_data.get())); | 509 AccountMetadataFeed::CreateFrom( |
| 510 *test_util::LoadJSONFile("gdata/account_metadata.json"))); |
| 511 |
| 512 ASSERT_TRUE(result_data.get()); |
| 513 EXPECT_EQ(expected->largest_changestamp(), |
| 514 result_data->largest_changestamp()); |
| 515 EXPECT_EQ(expected->quota_bytes_total(), |
| 516 result_data->quota_bytes_total()); |
| 517 EXPECT_EQ(expected->quota_bytes_used(), |
| 518 result_data->quota_bytes_used()); |
| 519 |
| 520 // Sanity check for installed apps. |
| 521 EXPECT_EQ(expected->installed_apps().size(), |
| 522 result_data->installed_apps().size()); |
| 511 } | 523 } |
| 512 | 524 |
| 513 TEST_F(GDataWapiOperationsTest, DeleteResourceOperation) { | 525 TEST_F(GDataWapiOperationsTest, DeleteResourceOperation) { |
| 514 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 526 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 515 | 527 |
| 516 DeleteResourceOperation* operation = new DeleteResourceOperation( | 528 DeleteResourceOperation* operation = new DeleteResourceOperation( |
| 517 &operation_registry_, | 529 &operation_registry_, |
| 518 request_context_getter_.get(), | 530 request_context_getter_.get(), |
| 519 *url_generator_, | 531 *url_generator_, |
| 520 base::Bind(&test_util::CopyResultFromEntryActionCallbackAndQuit, | 532 base::Bind(&test_util::CopyResultFromEntryActionCallbackAndQuit, |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1419 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1408 http_request_.headers["X-Upload-Content-Length"]); | 1420 http_request_.headers["X-Upload-Content-Length"]); |
| 1409 // For updating an existing file, an empty body should be attached (PUT | 1421 // For updating an existing file, an empty body should be attached (PUT |
| 1410 // requires a body) | 1422 // requires a body) |
| 1411 EXPECT_TRUE(http_request_.has_content); | 1423 EXPECT_TRUE(http_request_.has_content); |
| 1412 EXPECT_EQ("", http_request_.content); | 1424 EXPECT_EQ("", http_request_.content); |
| 1413 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1425 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1414 } | 1426 } |
| 1415 | 1427 |
| 1416 } // namespace google_apis | 1428 } // namespace google_apis |
| OLD | NEW |