| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, | 331 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, |
| 332 &result_code, | 332 &result_code, |
| 333 &result_data)); | 333 &result_data)); |
| 334 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 334 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 335 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 335 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 336 MessageLoop::current()->Run(); | 336 MessageLoop::current()->Run(); |
| 337 | 337 |
| 338 EXPECT_EQ(HTTP_SUCCESS, result_code); | 338 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 339 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 339 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 340 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" | 340 EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" |
| 341 "showfolders=true&max-results=500&include-installed-apps=true", | 341 "showfolders=true&include-shared=true&max-results=500&" |
| 342 "include-installed-apps=true", |
| 342 http_request_.relative_url); | 343 http_request_.relative_url); |
| 343 EXPECT_TRUE(test_util::VerifyJsonData( | 344 EXPECT_TRUE(test_util::VerifyJsonData( |
| 344 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), | 345 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), |
| 345 result_data.get())); | 346 result_data.get())); |
| 346 } | 347 } |
| 347 | 348 |
| 348 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) { | 349 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) { |
| 349 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 350 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 350 scoped_ptr<base::Value> result_data; | 351 scoped_ptr<base::Value> result_data; |
| 351 | 352 |
| 352 GetResourceListOperation* operation = new GetResourceListOperation( | 353 GetResourceListOperation* operation = new GetResourceListOperation( |
| 353 &operation_registry_, | 354 &operation_registry_, |
| 354 request_context_getter_.get(), | 355 request_context_getter_.get(), |
| 355 *url_generator_, | 356 *url_generator_, |
| 356 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), | 357 test_server_.GetURL("/files/chromeos/gdata/root_feed.json"), |
| 357 0, // start changestamp | 358 0, // start changestamp |
| 358 "", // search string | 359 "", // search string |
| 359 false, // shared with me | 360 false, // shared with me |
| 360 "", // directory resource ID | 361 "", // directory resource ID |
| 361 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, | 362 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, |
| 362 &result_code, | 363 &result_code, |
| 363 &result_data)); | 364 &result_data)); |
| 364 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 365 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 365 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 366 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 366 MessageLoop::current()->Run(); | 367 MessageLoop::current()->Run(); |
| 367 | 368 |
| 368 EXPECT_EQ(HTTP_SUCCESS, result_code); | 369 EXPECT_EQ(HTTP_SUCCESS, result_code); |
| 369 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 370 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 370 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" | 371 EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" |
| 371 "showfolders=true&max-results=500&include-installed-apps=true", | 372 "showfolders=true&include-shared=true&max-results=500" |
| 373 "&include-installed-apps=true", |
| 372 http_request_.relative_url); | 374 http_request_.relative_url); |
| 373 EXPECT_TRUE(test_util::VerifyJsonData( | 375 EXPECT_TRUE(test_util::VerifyJsonData( |
| 374 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), | 376 test_util::GetTestFilePath("chromeos/gdata/root_feed.json"), |
| 375 result_data.get())); | 377 result_data.get())); |
| 376 } | 378 } |
| 377 | 379 |
| 378 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) { | 380 TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) { |
| 379 // testfile.txt exists but the response is not JSON, so it should | 381 // testfile.txt exists but the response is not JSON, so it should |
| 380 // emit a parse error instead. | 382 // emit a parse error instead. |
| 381 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 383 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 393 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, | 395 base::Bind(&test_util::CopyResultsFromGetDataCallbackAndQuit, |
| 394 &result_code, | 396 &result_code, |
| 395 &result_data)); | 397 &result_data)); |
| 396 operation->Start(kTestGDataAuthToken, kTestUserAgent, | 398 operation->Start(kTestGDataAuthToken, kTestUserAgent, |
| 397 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 399 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 398 MessageLoop::current()->Run(); | 400 MessageLoop::current()->Run(); |
| 399 | 401 |
| 400 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); | 402 EXPECT_EQ(GDATA_PARSE_ERROR, result_code); |
| 401 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 403 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 402 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" | 404 EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" |
| 403 "showfolders=true&max-results=500&include-installed-apps=true", | 405 "showfolders=true&include-shared=true&max-results=500&" |
| 406 "include-installed-apps=true", |
| 404 http_request_.relative_url); | 407 http_request_.relative_url); |
| 405 EXPECT_FALSE(result_data); | 408 EXPECT_FALSE(result_data); |
| 406 } | 409 } |
| 407 | 410 |
| 408 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { | 411 TEST_F(GDataWapiOperationsTest, GetResourceEntryOperation_ValidResourceId) { |
| 409 GDataErrorCode result_code = GDATA_OTHER_ERROR; | 412 GDataErrorCode result_code = GDATA_OTHER_ERROR; |
| 410 scoped_ptr<base::Value> result_data; | 413 scoped_ptr<base::Value> result_data; |
| 411 | 414 |
| 412 GetResourceEntryOperation* operation = new GetResourceEntryOperation( | 415 GetResourceEntryOperation* operation = new GetResourceEntryOperation( |
| 413 &operation_registry_, | 416 &operation_registry_, |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), | 1436 EXPECT_EQ(base::Int64ToString(kUploadContent.size()), |
| 1434 http_request_.headers["X-Upload-Content-Length"]); | 1437 http_request_.headers["X-Upload-Content-Length"]); |
| 1435 // For updating an existing file, an empty body should be attached (PUT | 1438 // For updating an existing file, an empty body should be attached (PUT |
| 1436 // requires a body) | 1439 // requires a body) |
| 1437 EXPECT_TRUE(http_request_.has_content); | 1440 EXPECT_TRUE(http_request_.has_content); |
| 1438 EXPECT_EQ("", http_request_.content); | 1441 EXPECT_EQ("", http_request_.content); |
| 1439 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); | 1442 EXPECT_EQ(kWrongETag, http_request_.headers["If-Match"]); |
| 1440 } | 1443 } |
| 1441 | 1444 |
| 1442 } // namespace google_apis | 1445 } // namespace google_apis |
| OLD | NEW |