| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 CreateComposedCallback( | 332 CreateComposedCallback( |
| 333 base::Bind(&test_util::RunAndQuit), | 333 base::Bind(&test_util::RunAndQuit), |
| 334 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 334 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 335 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 335 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 336 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 336 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 337 MessageLoop::current()->Run(); | 337 MessageLoop::current()->Run(); |
| 338 | 338 |
| 339 EXPECT_EQ(HTTP_SUCCESS, result_code); | 339 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 340 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 340 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 341 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 341 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
| 342 "showfolders=true&include-shared=true&max-results=500&" | 342 "showfolders=true&include-shared=true&max-results=500", |
| 343 "include-installed-apps=true", | |
| 344 http_request_.relative_url); | 343 http_request_.relative_url); |
| 345 | 344 |
| 346 // Sanity check of the result. | 345 // Sanity check of the result. |
| 347 scoped_ptr<ResourceList> expected( | 346 scoped_ptr<ResourceList> expected( |
| 348 ResourceList::ExtractAndParse( | 347 ResourceList::ExtractAndParse( |
| 349 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); | 348 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); |
| 350 ASSERT_TRUE(result_data); | 349 ASSERT_TRUE(result_data); |
| 351 EXPECT_EQ(expected->title(), result_data->title()); | 350 EXPECT_EQ(expected->title(), result_data->title()); |
| 352 } | 351 } |
| 353 | 352 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 366 CreateComposedCallback( | 365 CreateComposedCallback( |
| 367 base::Bind(&test_util::RunAndQuit), | 366 base::Bind(&test_util::RunAndQuit), |
| 368 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 367 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 369 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 368 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 370 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 369 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 371 MessageLoop::current()->Run(); | 370 MessageLoop::current()->Run(); |
| 372 | 371 |
| 373 EXPECT_EQ(HTTP_SUCCESS, result_code); | 372 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 374 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 373 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 375 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" | 374 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" |
| 376 "showfolders=true&include-shared=true&max-results=500" | 375 "showfolders=true&include-shared=true&max-results=500", |
| 377 "&include-installed-apps=true", | |
| 378 http_request_.relative_url); | 376 http_request_.relative_url); |
| 379 | 377 |
| 380 scoped_ptr<ResourceList> expected( | 378 scoped_ptr<ResourceList> expected( |
| 381 ResourceList::ExtractAndParse( | 379 ResourceList::ExtractAndParse( |
| 382 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); | 380 *test_util::LoadJSONFile("chromeos/gdata/root_feed.json"))); |
| 383 ASSERT_TRUE(result_data); | 381 ASSERT_TRUE(result_data); |
| 384 EXPECT_EQ(expected->title(), result_data->title()); | 382 EXPECT_EQ(expected->title(), result_data->title()); |
| 385 } | 383 } |
| 386 | 384 |
| 387 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) { | 385 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 401 CreateComposedCallback( | 399 CreateComposedCallback( |
| 402 base::Bind(&test_util::RunAndQuit), | 400 base::Bind(&test_util::RunAndQuit), |
| 403 test_util::CreateCopyResultCallback(&result_code, &result_data))); | 401 test_util::CreateCopyResultCallback(&result_code, &result_data))); |
| 404 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 402 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 405 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 403 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 406 MessageLoop::current()->Run(); | 404 MessageLoop::current()->Run(); |
| 407 | 405 |
| 408 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 406 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
| 409 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 407 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 410 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" | 408 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" |
| 411 "showfolders=true&include-shared=true&max-results=500&" | 409 "showfolders=true&include-shared=true&max-results=500", |
| 412 "include-installed-apps=true", | |
| 413 http_request_.relative_url); | 410 http_request_.relative_url); |
| 414 EXPECT_FALSE(result_data); | 411 EXPECT_FALSE(result_data); |
| 415 } | 412 } |
| 416 | 413 |
| 417 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { | 414 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { |
| 418 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 415 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 419 scoped_ptr<base::Value> result_data; | 416 scoped_ptr<base::Value> result_data; |
| 420 | 417 |
| 421 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 418 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
| 422 &operation_registry_, | 419 &operation_registry_, |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1452 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1456 http_request_.headers["X-Upload-Content-Length"]); | 1453 http_request_.headers["X-Upload-Content-Length"]); |
| 1457 // For updating an existing file, an empty body should be attached (PUT | 1454 // For updating an existing file, an empty body should be attached (PUT |
| 1458 // requires a body) | 1455 // requires a body) |
| 1459 EXPECT_TRUE(http_request_.has_content); | 1456 EXPECT_TRUE(http_request_.has_content); |
| 1460 EXPECT_EQ("", http_request_.content); | 1457 EXPECT_EQ("", http_request_.content); |
| 1461 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1458 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1462 } | 1459 } |
| 1463 | 1460 |
| 1464 } // namespace google_apis | 1461 } // namespace google_apis |
| OLD | NEW |