| OLD | NEW |
| 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 received_bytes_ = 0; | 97 received_bytes_ = 0; |
| 98 content_length_ = 0; | 98 content_length_ = 0; |
| 99 } | 99 } |
| 100 | 100 |
| 101 virtual void TearDown() OVERRIDE { | 101 virtual void TearDown() OVERRIDE { |
| 102 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 102 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
| 103 request_context_getter_ = NULL; | 103 request_context_getter_ = NULL; |
| 104 ResetExpectedResponse(); | 104 ResetExpectedResponse(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 MessageLoopForUI message_loop_; | 107 base::MessageLoopForUI message_loop_; |
| 108 content::TestBrowserThread ui_thread_; | 108 content::TestBrowserThread ui_thread_; |
| 109 content::TestBrowserThread file_thread_; | 109 content::TestBrowserThread file_thread_; |
| 110 content::TestBrowserThread io_thread_; | 110 content::TestBrowserThread io_thread_; |
| 111 net::test_server::EmbeddedTestServer test_server_; | 111 net::test_server::EmbeddedTestServer test_server_; |
| 112 scoped_ptr<TestingProfile> profile_; | 112 scoped_ptr<TestingProfile> profile_; |
| 113 scoped_ptr<OperationRunner> operation_runner_; | 113 scoped_ptr<OperationRunner> operation_runner_; |
| 114 scoped_ptr<DriveApiUrlGenerator> url_generator_; | 114 scoped_ptr<DriveApiUrlGenerator> url_generator_; |
| 115 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 115 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
| 116 base::ScopedTempDir temp_dir_; | 116 base::ScopedTempDir temp_dir_; |
| 117 | 117 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 scoped_ptr<AboutResource> about_resource; | 325 scoped_ptr<AboutResource> about_resource; |
| 326 | 326 |
| 327 GetAboutOperation* operation = new GetAboutOperation( | 327 GetAboutOperation* operation = new GetAboutOperation( |
| 328 operation_runner_.get(), | 328 operation_runner_.get(), |
| 329 request_context_getter_.get(), | 329 request_context_getter_.get(), |
| 330 *url_generator_, | 330 *url_generator_, |
| 331 CreateComposedCallback( | 331 CreateComposedCallback( |
| 332 base::Bind(&test_util::RunAndQuit), | 332 base::Bind(&test_util::RunAndQuit), |
| 333 test_util::CreateCopyResultCallback(&error, &about_resource))); | 333 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 334 operation_runner_->StartOperationWithRetry(operation); | 334 operation_runner_->StartOperationWithRetry(operation); |
| 335 MessageLoop::current()->Run(); | 335 base::MessageLoop::current()->Run(); |
| 336 | 336 |
| 337 EXPECT_EQ(HTTP_SUCCESS, error); | 337 EXPECT_EQ(HTTP_SUCCESS, error); |
| 338 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 338 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 339 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 339 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 340 | 340 |
| 341 scoped_ptr<AboutResource> expected( | 341 scoped_ptr<AboutResource> expected( |
| 342 AboutResource::CreateFrom( | 342 AboutResource::CreateFrom( |
| 343 *test_util::LoadJSONFile("chromeos/drive/about.json"))); | 343 *test_util::LoadJSONFile("chromeos/drive/about.json"))); |
| 344 ASSERT_TRUE(about_resource.get()); | 344 ASSERT_TRUE(about_resource.get()); |
| 345 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); | 345 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 357 scoped_ptr<AboutResource> about_resource; | 357 scoped_ptr<AboutResource> about_resource; |
| 358 | 358 |
| 359 GetAboutOperation* operation = new GetAboutOperation( | 359 GetAboutOperation* operation = new GetAboutOperation( |
| 360 operation_runner_.get(), | 360 operation_runner_.get(), |
| 361 request_context_getter_.get(), | 361 request_context_getter_.get(), |
| 362 *url_generator_, | 362 *url_generator_, |
| 363 CreateComposedCallback( | 363 CreateComposedCallback( |
| 364 base::Bind(&test_util::RunAndQuit), | 364 base::Bind(&test_util::RunAndQuit), |
| 365 test_util::CreateCopyResultCallback(&error, &about_resource))); | 365 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 366 operation_runner_->StartOperationWithRetry(operation); | 366 operation_runner_->StartOperationWithRetry(operation); |
| 367 MessageLoop::current()->Run(); | 367 base::MessageLoop::current()->Run(); |
| 368 | 368 |
| 369 // "parse error" should be returned, and the about resource should be NULL. | 369 // "parse error" should be returned, and the about resource should be NULL. |
| 370 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 370 EXPECT_EQ(GDATA_PARSE_ERROR, error); |
| 371 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 371 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 372 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 372 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 373 EXPECT_FALSE(about_resource.get()); | 373 EXPECT_FALSE(about_resource.get()); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST_F(DriveApiOperationsTest, GetApplistOperation) { | 376 TEST_F(DriveApiOperationsTest, GetApplistOperation) { |
| 377 // Set an expected data file containing valid result. | 377 // Set an expected data file containing valid result. |
| 378 expected_data_file_path_ = test_util::GetTestFilePath( | 378 expected_data_file_path_ = test_util::GetTestFilePath( |
| 379 "chromeos/drive/applist.json"); | 379 "chromeos/drive/applist.json"); |
| 380 | 380 |
| 381 GDataErrorCode error = GDATA_OTHER_ERROR; | 381 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 382 scoped_ptr<base::Value> result; | 382 scoped_ptr<base::Value> result; |
| 383 | 383 |
| 384 GetApplistOperation* operation = new GetApplistOperation( | 384 GetApplistOperation* operation = new GetApplistOperation( |
| 385 operation_runner_.get(), | 385 operation_runner_.get(), |
| 386 request_context_getter_.get(), | 386 request_context_getter_.get(), |
| 387 *url_generator_, | 387 *url_generator_, |
| 388 CreateComposedCallback( | 388 CreateComposedCallback( |
| 389 base::Bind(&test_util::RunAndQuit), | 389 base::Bind(&test_util::RunAndQuit), |
| 390 test_util::CreateCopyResultCallback(&error, &result))); | 390 test_util::CreateCopyResultCallback(&error, &result))); |
| 391 operation_runner_->StartOperationWithRetry(operation); | 391 operation_runner_->StartOperationWithRetry(operation); |
| 392 MessageLoop::current()->Run(); | 392 base::MessageLoop::current()->Run(); |
| 393 | 393 |
| 394 EXPECT_EQ(HTTP_SUCCESS, error); | 394 EXPECT_EQ(HTTP_SUCCESS, error); |
| 395 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 395 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 396 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 396 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
| 397 EXPECT_TRUE(result); | 397 EXPECT_TRUE(result); |
| 398 } | 398 } |
| 399 | 399 |
| 400 TEST_F(DriveApiOperationsTest, GetChangelistOperation) { | 400 TEST_F(DriveApiOperationsTest, GetChangelistOperation) { |
| 401 // Set an expected data file containing valid result. | 401 // Set an expected data file containing valid result. |
| 402 expected_data_file_path_ = test_util::GetTestFilePath( | 402 expected_data_file_path_ = test_util::GetTestFilePath( |
| 403 "chromeos/drive/changelist.json"); | 403 "chromeos/drive/changelist.json"); |
| 404 | 404 |
| 405 GDataErrorCode error = GDATA_OTHER_ERROR; | 405 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 406 scoped_ptr<base::Value> result; | 406 scoped_ptr<base::Value> result; |
| 407 | 407 |
| 408 GetChangelistOperation* operation = new GetChangelistOperation( | 408 GetChangelistOperation* operation = new GetChangelistOperation( |
| 409 operation_runner_.get(), | 409 operation_runner_.get(), |
| 410 request_context_getter_.get(), | 410 request_context_getter_.get(), |
| 411 *url_generator_, | 411 *url_generator_, |
| 412 true, // include deleted | 412 true, // include deleted |
| 413 100, // start changestamp | 413 100, // start changestamp |
| 414 500, // max results | 414 500, // max results |
| 415 CreateComposedCallback( | 415 CreateComposedCallback( |
| 416 base::Bind(&test_util::RunAndQuit), | 416 base::Bind(&test_util::RunAndQuit), |
| 417 test_util::CreateCopyResultCallback(&error, &result))); | 417 test_util::CreateCopyResultCallback(&error, &result))); |
| 418 operation_runner_->StartOperationWithRetry(operation); | 418 operation_runner_->StartOperationWithRetry(operation); |
| 419 MessageLoop::current()->Run(); | 419 base::MessageLoop::current()->Run(); |
| 420 | 420 |
| 421 EXPECT_EQ(HTTP_SUCCESS, error); | 421 EXPECT_EQ(HTTP_SUCCESS, error); |
| 422 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 422 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 423 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", | 423 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", |
| 424 http_request_.relative_url); | 424 http_request_.relative_url); |
| 425 EXPECT_TRUE(result); | 425 EXPECT_TRUE(result); |
| 426 } | 426 } |
| 427 | 427 |
| 428 TEST_F(DriveApiOperationsTest, GetFilelistOperation) { | 428 TEST_F(DriveApiOperationsTest, GetFilelistOperation) { |
| 429 // Set an expected data file containing valid result. | 429 // Set an expected data file containing valid result. |
| 430 expected_data_file_path_ = test_util::GetTestFilePath( | 430 expected_data_file_path_ = test_util::GetTestFilePath( |
| 431 "chromeos/drive/filelist.json"); | 431 "chromeos/drive/filelist.json"); |
| 432 | 432 |
| 433 GDataErrorCode error = GDATA_OTHER_ERROR; | 433 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 434 scoped_ptr<base::Value> result; | 434 scoped_ptr<base::Value> result; |
| 435 | 435 |
| 436 GetFilelistOperation* operation = new GetFilelistOperation( | 436 GetFilelistOperation* operation = new GetFilelistOperation( |
| 437 operation_runner_.get(), | 437 operation_runner_.get(), |
| 438 request_context_getter_.get(), | 438 request_context_getter_.get(), |
| 439 *url_generator_, | 439 *url_generator_, |
| 440 "\"abcde\" in parents", | 440 "\"abcde\" in parents", |
| 441 50, // max results | 441 50, // max results |
| 442 CreateComposedCallback( | 442 CreateComposedCallback( |
| 443 base::Bind(&test_util::RunAndQuit), | 443 base::Bind(&test_util::RunAndQuit), |
| 444 test_util::CreateCopyResultCallback(&error, &result))); | 444 test_util::CreateCopyResultCallback(&error, &result))); |
| 445 operation_runner_->StartOperationWithRetry(operation); | 445 operation_runner_->StartOperationWithRetry(operation); |
| 446 MessageLoop::current()->Run(); | 446 base::MessageLoop::current()->Run(); |
| 447 | 447 |
| 448 EXPECT_EQ(HTTP_SUCCESS, error); | 448 EXPECT_EQ(HTTP_SUCCESS, error); |
| 449 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 449 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 450 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", | 450 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", |
| 451 http_request_.relative_url); | 451 http_request_.relative_url); |
| 452 EXPECT_TRUE(result); | 452 EXPECT_TRUE(result); |
| 453 } | 453 } |
| 454 | 454 |
| 455 TEST_F(DriveApiOperationsTest, ContinueGetFileListOperation) { | 455 TEST_F(DriveApiOperationsTest, ContinueGetFileListOperation) { |
| 456 // Set an expected data file containing valid result. | 456 // Set an expected data file containing valid result. |
| 457 expected_data_file_path_ = test_util::GetTestFilePath( | 457 expected_data_file_path_ = test_util::GetTestFilePath( |
| 458 "chromeos/drive/filelist.json"); | 458 "chromeos/drive/filelist.json"); |
| 459 | 459 |
| 460 GDataErrorCode error = GDATA_OTHER_ERROR; | 460 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 461 scoped_ptr<base::Value> result; | 461 scoped_ptr<base::Value> result; |
| 462 | 462 |
| 463 drive::ContinueGetFileListOperation* operation = | 463 drive::ContinueGetFileListOperation* operation = |
| 464 new drive::ContinueGetFileListOperation( | 464 new drive::ContinueGetFileListOperation( |
| 465 operation_runner_.get(), | 465 operation_runner_.get(), |
| 466 request_context_getter_.get(), | 466 request_context_getter_.get(), |
| 467 test_server_.GetURL("/continue/get/file/list"), | 467 test_server_.GetURL("/continue/get/file/list"), |
| 468 CreateComposedCallback( | 468 CreateComposedCallback( |
| 469 base::Bind(&test_util::RunAndQuit), | 469 base::Bind(&test_util::RunAndQuit), |
| 470 test_util::CreateCopyResultCallback(&error, &result))); | 470 test_util::CreateCopyResultCallback(&error, &result))); |
| 471 operation_runner_->StartOperationWithRetry(operation); | 471 operation_runner_->StartOperationWithRetry(operation); |
| 472 MessageLoop::current()->Run(); | 472 base::MessageLoop::current()->Run(); |
| 473 | 473 |
| 474 EXPECT_EQ(HTTP_SUCCESS, error); | 474 EXPECT_EQ(HTTP_SUCCESS, error); |
| 475 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 475 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 476 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 476 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
| 477 EXPECT_TRUE(result); | 477 EXPECT_TRUE(result); |
| 478 } | 478 } |
| 479 | 479 |
| 480 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) { | 480 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) { |
| 481 // Set an expected data file containing the directory's entry data. | 481 // Set an expected data file containing the directory's entry data. |
| 482 expected_data_file_path_ = | 482 expected_data_file_path_ = |
| 483 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 483 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); |
| 484 | 484 |
| 485 GDataErrorCode error = GDATA_OTHER_ERROR; | 485 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 486 scoped_ptr<FileResource> file_resource; | 486 scoped_ptr<FileResource> file_resource; |
| 487 | 487 |
| 488 // Create "new directory" in the root directory. | 488 // Create "new directory" in the root directory. |
| 489 drive::CreateDirectoryOperation* operation = | 489 drive::CreateDirectoryOperation* operation = |
| 490 new drive::CreateDirectoryOperation( | 490 new drive::CreateDirectoryOperation( |
| 491 operation_runner_.get(), | 491 operation_runner_.get(), |
| 492 request_context_getter_.get(), | 492 request_context_getter_.get(), |
| 493 *url_generator_, | 493 *url_generator_, |
| 494 "root", | 494 "root", |
| 495 "new directory", | 495 "new directory", |
| 496 CreateComposedCallback( | 496 CreateComposedCallback( |
| 497 base::Bind(&test_util::RunAndQuit), | 497 base::Bind(&test_util::RunAndQuit), |
| 498 test_util::CreateCopyResultCallback(&error, &file_resource))); | 498 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 499 operation_runner_->StartOperationWithRetry(operation); | 499 operation_runner_->StartOperationWithRetry(operation); |
| 500 MessageLoop::current()->Run(); | 500 base::MessageLoop::current()->Run(); |
| 501 | 501 |
| 502 EXPECT_EQ(HTTP_SUCCESS, error); | 502 EXPECT_EQ(HTTP_SUCCESS, error); |
| 503 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 503 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 504 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); | 504 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); |
| 505 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 505 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 506 | 506 |
| 507 EXPECT_TRUE(http_request_.has_content); | 507 EXPECT_TRUE(http_request_.has_content); |
| 508 | 508 |
| 509 scoped_ptr<FileResource> expected( | 509 scoped_ptr<FileResource> expected( |
| 510 FileResource::CreateFrom( | 510 FileResource::CreateFrom( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 532 new drive::RenameResourceOperation( | 532 new drive::RenameResourceOperation( |
| 533 operation_runner_.get(), | 533 operation_runner_.get(), |
| 534 request_context_getter_.get(), | 534 request_context_getter_.get(), |
| 535 *url_generator_, | 535 *url_generator_, |
| 536 "resource_id", | 536 "resource_id", |
| 537 "new name", | 537 "new name", |
| 538 CreateComposedCallback( | 538 CreateComposedCallback( |
| 539 base::Bind(&test_util::RunAndQuit), | 539 base::Bind(&test_util::RunAndQuit), |
| 540 test_util::CreateCopyResultCallback(&error))); | 540 test_util::CreateCopyResultCallback(&error))); |
| 541 operation_runner_->StartOperationWithRetry(operation); | 541 operation_runner_->StartOperationWithRetry(operation); |
| 542 MessageLoop::current()->Run(); | 542 base::MessageLoop::current()->Run(); |
| 543 | 543 |
| 544 EXPECT_EQ(HTTP_SUCCESS, error); | 544 EXPECT_EQ(HTTP_SUCCESS, error); |
| 545 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); | 545 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); |
| 546 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); | 546 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); |
| 547 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 547 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 548 | 548 |
| 549 EXPECT_TRUE(http_request_.has_content); | 549 EXPECT_TRUE(http_request_.has_content); |
| 550 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 550 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
| 551 } | 551 } |
| 552 | 552 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 567 operation_runner_.get(), | 567 operation_runner_.get(), |
| 568 request_context_getter_.get(), | 568 request_context_getter_.get(), |
| 569 *url_generator_, | 569 *url_generator_, |
| 570 "resource_id", | 570 "resource_id", |
| 571 base::Time::FromUTCExploded(kModifiedDate), | 571 base::Time::FromUTCExploded(kModifiedDate), |
| 572 base::Time::FromUTCExploded(kLastViewedByMeDate), | 572 base::Time::FromUTCExploded(kLastViewedByMeDate), |
| 573 CreateComposedCallback( | 573 CreateComposedCallback( |
| 574 base::Bind(&test_util::RunAndQuit), | 574 base::Bind(&test_util::RunAndQuit), |
| 575 test_util::CreateCopyResultCallback(&error, &file_resource))); | 575 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 576 operation_runner_->StartOperationWithRetry(operation); | 576 operation_runner_->StartOperationWithRetry(operation); |
| 577 MessageLoop::current()->Run(); | 577 base::MessageLoop::current()->Run(); |
| 578 | 578 |
| 579 EXPECT_EQ(HTTP_SUCCESS, error); | 579 EXPECT_EQ(HTTP_SUCCESS, error); |
| 580 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); | 580 EXPECT_EQ(net::test_server::METHOD_PATCH, http_request_.method); |
| 581 EXPECT_EQ("/drive/v2/files/resource_id" | 581 EXPECT_EQ("/drive/v2/files/resource_id" |
| 582 "?setModifiedDate=true&updateViewedDate=false", | 582 "?setModifiedDate=true&updateViewedDate=false", |
| 583 http_request_.relative_url); | 583 http_request_.relative_url); |
| 584 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 584 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 585 | 585 |
| 586 EXPECT_TRUE(http_request_.has_content); | 586 EXPECT_TRUE(http_request_.has_content); |
| 587 EXPECT_EQ("{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\"," | 587 EXPECT_EQ("{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\"," |
| (...skipping 16 matching lines...) Expand all Loading... |
| 604 operation_runner_.get(), | 604 operation_runner_.get(), |
| 605 request_context_getter_.get(), | 605 request_context_getter_.get(), |
| 606 *url_generator_, | 606 *url_generator_, |
| 607 "resource_id", | 607 "resource_id", |
| 608 "parent_resource_id", | 608 "parent_resource_id", |
| 609 "new name", | 609 "new name", |
| 610 CreateComposedCallback( | 610 CreateComposedCallback( |
| 611 base::Bind(&test_util::RunAndQuit), | 611 base::Bind(&test_util::RunAndQuit), |
| 612 test_util::CreateCopyResultCallback(&error, &file_resource))); | 612 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 613 operation_runner_->StartOperationWithRetry(operation); | 613 operation_runner_->StartOperationWithRetry(operation); |
| 614 MessageLoop::current()->Run(); | 614 base::MessageLoop::current()->Run(); |
| 615 | 615 |
| 616 EXPECT_EQ(HTTP_SUCCESS, error); | 616 EXPECT_EQ(HTTP_SUCCESS, error); |
| 617 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 617 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 618 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); | 618 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); |
| 619 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 619 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 620 | 620 |
| 621 EXPECT_TRUE(http_request_.has_content); | 621 EXPECT_TRUE(http_request_.has_content); |
| 622 EXPECT_EQ( | 622 EXPECT_EQ( |
| 623 "{\"parents\":[{\"id\":\"parent_resource_id\"}],\"title\":\"new name\"}", | 623 "{\"parents\":[{\"id\":\"parent_resource_id\"}],\"title\":\"new name\"}", |
| 624 http_request_.content); | 624 http_request_.content); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 640 operation_runner_.get(), | 640 operation_runner_.get(), |
| 641 request_context_getter_.get(), | 641 request_context_getter_.get(), |
| 642 *url_generator_, | 642 *url_generator_, |
| 643 "resource_id", | 643 "resource_id", |
| 644 std::string(), // parent resource id. | 644 std::string(), // parent resource id. |
| 645 "new name", | 645 "new name", |
| 646 CreateComposedCallback( | 646 CreateComposedCallback( |
| 647 base::Bind(&test_util::RunAndQuit), | 647 base::Bind(&test_util::RunAndQuit), |
| 648 test_util::CreateCopyResultCallback(&error, &file_resource))); | 648 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 649 operation_runner_->StartOperationWithRetry(operation); | 649 operation_runner_->StartOperationWithRetry(operation); |
| 650 MessageLoop::current()->Run(); | 650 base::MessageLoop::current()->Run(); |
| 651 | 651 |
| 652 EXPECT_EQ(HTTP_SUCCESS, error); | 652 EXPECT_EQ(HTTP_SUCCESS, error); |
| 653 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 653 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 654 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); | 654 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); |
| 655 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 655 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 656 | 656 |
| 657 EXPECT_TRUE(http_request_.has_content); | 657 EXPECT_TRUE(http_request_.has_content); |
| 658 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 658 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
| 659 EXPECT_TRUE(file_resource); | 659 EXPECT_TRUE(file_resource); |
| 660 } | 660 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 671 drive::TrashResourceOperation* operation = | 671 drive::TrashResourceOperation* operation = |
| 672 new drive::TrashResourceOperation( | 672 new drive::TrashResourceOperation( |
| 673 operation_runner_.get(), | 673 operation_runner_.get(), |
| 674 request_context_getter_.get(), | 674 request_context_getter_.get(), |
| 675 *url_generator_, | 675 *url_generator_, |
| 676 "resource_id", | 676 "resource_id", |
| 677 CreateComposedCallback( | 677 CreateComposedCallback( |
| 678 base::Bind(&test_util::RunAndQuit), | 678 base::Bind(&test_util::RunAndQuit), |
| 679 test_util::CreateCopyResultCallback(&error))); | 679 test_util::CreateCopyResultCallback(&error))); |
| 680 operation_runner_->StartOperationWithRetry(operation); | 680 operation_runner_->StartOperationWithRetry(operation); |
| 681 MessageLoop::current()->Run(); | 681 base::MessageLoop::current()->Run(); |
| 682 | 682 |
| 683 EXPECT_EQ(HTTP_SUCCESS, error); | 683 EXPECT_EQ(HTTP_SUCCESS, error); |
| 684 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 684 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 685 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); | 685 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); |
| 686 EXPECT_TRUE(http_request_.has_content); | 686 EXPECT_TRUE(http_request_.has_content); |
| 687 EXPECT_TRUE(http_request_.content.empty()); | 687 EXPECT_TRUE(http_request_.content.empty()); |
| 688 } | 688 } |
| 689 | 689 |
| 690 TEST_F(DriveApiOperationsTest, InsertResourceOperation) { | 690 TEST_F(DriveApiOperationsTest, InsertResourceOperation) { |
| 691 // Set an expected data file containing the children entry. | 691 // Set an expected data file containing the children entry. |
| 692 expected_content_type_ = "application/json"; | 692 expected_content_type_ = "application/json"; |
| 693 expected_content_ = kTestChildrenResponse; | 693 expected_content_ = kTestChildrenResponse; |
| 694 | 694 |
| 695 GDataErrorCode error = GDATA_OTHER_ERROR; | 695 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 696 | 696 |
| 697 // Add a resource with "resource_id" to a directory with | 697 // Add a resource with "resource_id" to a directory with |
| 698 // "parent_resource_id". | 698 // "parent_resource_id". |
| 699 drive::InsertResourceOperation* operation = | 699 drive::InsertResourceOperation* operation = |
| 700 new drive::InsertResourceOperation( | 700 new drive::InsertResourceOperation( |
| 701 operation_runner_.get(), | 701 operation_runner_.get(), |
| 702 request_context_getter_.get(), | 702 request_context_getter_.get(), |
| 703 *url_generator_, | 703 *url_generator_, |
| 704 "parent_resource_id", | 704 "parent_resource_id", |
| 705 "resource_id", | 705 "resource_id", |
| 706 CreateComposedCallback( | 706 CreateComposedCallback( |
| 707 base::Bind(&test_util::RunAndQuit), | 707 base::Bind(&test_util::RunAndQuit), |
| 708 test_util::CreateCopyResultCallback(&error))); | 708 test_util::CreateCopyResultCallback(&error))); |
| 709 operation_runner_->StartOperationWithRetry(operation); | 709 operation_runner_->StartOperationWithRetry(operation); |
| 710 MessageLoop::current()->Run(); | 710 base::MessageLoop::current()->Run(); |
| 711 | 711 |
| 712 EXPECT_EQ(HTTP_SUCCESS, error); | 712 EXPECT_EQ(HTTP_SUCCESS, error); |
| 713 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 713 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 714 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", | 714 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", |
| 715 http_request_.relative_url); | 715 http_request_.relative_url); |
| 716 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 716 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 717 | 717 |
| 718 EXPECT_TRUE(http_request_.has_content); | 718 EXPECT_TRUE(http_request_.has_content); |
| 719 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); | 719 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); |
| 720 } | 720 } |
| 721 | 721 |
| 722 TEST_F(DriveApiOperationsTest, DeleteResourceOperation) { | 722 TEST_F(DriveApiOperationsTest, DeleteResourceOperation) { |
| 723 GDataErrorCode error = GDATA_OTHER_ERROR; | 723 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 724 | 724 |
| 725 // Remove a resource with "resource_id" from a directory with | 725 // Remove a resource with "resource_id" from a directory with |
| 726 // "parent_resource_id". | 726 // "parent_resource_id". |
| 727 drive::DeleteResourceOperation* operation = | 727 drive::DeleteResourceOperation* operation = |
| 728 new drive::DeleteResourceOperation( | 728 new drive::DeleteResourceOperation( |
| 729 operation_runner_.get(), | 729 operation_runner_.get(), |
| 730 request_context_getter_.get(), | 730 request_context_getter_.get(), |
| 731 *url_generator_, | 731 *url_generator_, |
| 732 "parent_resource_id", | 732 "parent_resource_id", |
| 733 "resource_id", | 733 "resource_id", |
| 734 CreateComposedCallback( | 734 CreateComposedCallback( |
| 735 base::Bind(&test_util::RunAndQuit), | 735 base::Bind(&test_util::RunAndQuit), |
| 736 test_util::CreateCopyResultCallback(&error))); | 736 test_util::CreateCopyResultCallback(&error))); |
| 737 operation_runner_->StartOperationWithRetry(operation); | 737 operation_runner_->StartOperationWithRetry(operation); |
| 738 MessageLoop::current()->Run(); | 738 base::MessageLoop::current()->Run(); |
| 739 | 739 |
| 740 EXPECT_EQ(HTTP_NO_CONTENT, error); | 740 EXPECT_EQ(HTTP_NO_CONTENT, error); |
| 741 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); | 741 EXPECT_EQ(net::test_server::METHOD_DELETE, http_request_.method); |
| 742 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", | 742 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", |
| 743 http_request_.relative_url); | 743 http_request_.relative_url); |
| 744 EXPECT_FALSE(http_request_.has_content); | 744 EXPECT_FALSE(http_request_.has_content); |
| 745 } | 745 } |
| 746 | 746 |
| 747 TEST_F(DriveApiOperationsTest, UploadNewFileOperation) { | 747 TEST_F(DriveApiOperationsTest, UploadNewFileOperation) { |
| 748 // Set an expected url for uploading. | 748 // Set an expected url for uploading. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 766 *url_generator_, | 766 *url_generator_, |
| 767 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 767 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 768 kTestContentType, | 768 kTestContentType, |
| 769 kTestContent.size(), | 769 kTestContent.size(), |
| 770 "parent_resource_id", // The resource id of the parent directory. | 770 "parent_resource_id", // The resource id of the parent directory. |
| 771 "new file title", // The title of the file being uploaded. | 771 "new file title", // The title of the file being uploaded. |
| 772 CreateComposedCallback( | 772 CreateComposedCallback( |
| 773 base::Bind(&test_util::RunAndQuit), | 773 base::Bind(&test_util::RunAndQuit), |
| 774 test_util::CreateCopyResultCallback(&error, &upload_url))); | 774 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 775 operation_runner_->StartOperationWithRetry(operation); | 775 operation_runner_->StartOperationWithRetry(operation); |
| 776 MessageLoop::current()->Run(); | 776 base::MessageLoop::current()->Run(); |
| 777 | 777 |
| 778 EXPECT_EQ(HTTP_SUCCESS, error); | 778 EXPECT_EQ(HTTP_SUCCESS, error); |
| 779 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 779 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 780 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 780 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 781 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 781 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 782 http_request_.headers["X-Upload-Content-Length"]); | 782 http_request_.headers["X-Upload-Content-Length"]); |
| 783 | 783 |
| 784 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 784 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 785 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 785 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| 786 http_request_.relative_url); | 786 http_request_.relative_url); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 806 0, // start_position | 806 0, // start_position |
| 807 kTestContent.size(), // end_position (exclusive) | 807 kTestContent.size(), // end_position (exclusive) |
| 808 kTestContent.size(), // content_length, | 808 kTestContent.size(), // content_length, |
| 809 kTestContentType, | 809 kTestContentType, |
| 810 kTestFilePath, | 810 kTestFilePath, |
| 811 CreateComposedCallback( | 811 CreateComposedCallback( |
| 812 base::Bind(&test_util::RunAndQuit), | 812 base::Bind(&test_util::RunAndQuit), |
| 813 test_util::CreateCopyResultCallback(&response, &new_entry)), | 813 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 814 ProgressCallback()); | 814 ProgressCallback()); |
| 815 operation_runner_->StartOperationWithRetry(resume_operation); | 815 operation_runner_->StartOperationWithRetry(resume_operation); |
| 816 MessageLoop::current()->Run(); | 816 base::MessageLoop::current()->Run(); |
| 817 | 817 |
| 818 // METHOD_PUT should be used to upload data. | 818 // METHOD_PUT should be used to upload data. |
| 819 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 819 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 820 // Request should go to the upload URL. | 820 // Request should go to the upload URL. |
| 821 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 821 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 822 // Content-Range header should be added. | 822 // Content-Range header should be added. |
| 823 EXPECT_EQ("bytes 0-" + | 823 EXPECT_EQ("bytes 0-" + |
| 824 base::Int64ToString(kTestContent.size() - 1) + "/" + | 824 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| 825 base::Int64ToString(kTestContent.size()), | 825 base::Int64ToString(kTestContent.size()), |
| 826 http_request_.headers["Content-Range"]); | 826 http_request_.headers["Content-Range"]); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 856 *url_generator_, | 856 *url_generator_, |
| 857 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 857 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 858 kTestContentType, | 858 kTestContentType, |
| 859 0, | 859 0, |
| 860 "parent_resource_id", // The resource id of the parent directory. | 860 "parent_resource_id", // The resource id of the parent directory. |
| 861 "new file title", // The title of the file being uploaded. | 861 "new file title", // The title of the file being uploaded. |
| 862 CreateComposedCallback( | 862 CreateComposedCallback( |
| 863 base::Bind(&test_util::RunAndQuit), | 863 base::Bind(&test_util::RunAndQuit), |
| 864 test_util::CreateCopyResultCallback(&error, &upload_url))); | 864 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 865 operation_runner_->StartOperationWithRetry(operation); | 865 operation_runner_->StartOperationWithRetry(operation); |
| 866 MessageLoop::current()->Run(); | 866 base::MessageLoop::current()->Run(); |
| 867 | 867 |
| 868 EXPECT_EQ(HTTP_SUCCESS, error); | 868 EXPECT_EQ(HTTP_SUCCESS, error); |
| 869 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 869 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 870 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 870 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 871 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); | 871 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); |
| 872 | 872 |
| 873 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 873 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 874 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 874 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| 875 http_request_.relative_url); | 875 http_request_.relative_url); |
| 876 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 876 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 895 0, // start_position | 895 0, // start_position |
| 896 0, // end_position (exclusive) | 896 0, // end_position (exclusive) |
| 897 0, // content_length, | 897 0, // content_length, |
| 898 kTestContentType, | 898 kTestContentType, |
| 899 kTestFilePath, | 899 kTestFilePath, |
| 900 CreateComposedCallback( | 900 CreateComposedCallback( |
| 901 base::Bind(&test_util::RunAndQuit), | 901 base::Bind(&test_util::RunAndQuit), |
| 902 test_util::CreateCopyResultCallback(&response, &new_entry)), | 902 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 903 ProgressCallback()); | 903 ProgressCallback()); |
| 904 operation_runner_->StartOperationWithRetry(resume_operation); | 904 operation_runner_->StartOperationWithRetry(resume_operation); |
| 905 MessageLoop::current()->Run(); | 905 base::MessageLoop::current()->Run(); |
| 906 | 906 |
| 907 // METHOD_PUT should be used to upload data. | 907 // METHOD_PUT should be used to upload data. |
| 908 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 908 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 909 // Request should go to the upload URL. | 909 // Request should go to the upload URL. |
| 910 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 910 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 911 // Content-Range header should NOT be added. | 911 // Content-Range header should NOT be added. |
| 912 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 912 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
| 913 // The upload content should be set in the HTTP request. | 913 // The upload content should be set in the HTTP request. |
| 914 EXPECT_TRUE(http_request_.has_content); | 914 EXPECT_TRUE(http_request_.has_content); |
| 915 EXPECT_EQ(kTestContent, http_request_.content); | 915 EXPECT_EQ(kTestContent, http_request_.content); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 946 *url_generator_, | 946 *url_generator_, |
| 947 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 947 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 948 kTestContentType, | 948 kTestContentType, |
| 949 kTestContent.size(), | 949 kTestContent.size(), |
| 950 "parent_resource_id", // The resource id of the parent directory. | 950 "parent_resource_id", // The resource id of the parent directory. |
| 951 "new file title", // The title of the file being uploaded. | 951 "new file title", // The title of the file being uploaded. |
| 952 CreateComposedCallback( | 952 CreateComposedCallback( |
| 953 base::Bind(&test_util::RunAndQuit), | 953 base::Bind(&test_util::RunAndQuit), |
| 954 test_util::CreateCopyResultCallback(&error, &upload_url))); | 954 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 955 operation_runner_->StartOperationWithRetry(operation); | 955 operation_runner_->StartOperationWithRetry(operation); |
| 956 MessageLoop::current()->Run(); | 956 base::MessageLoop::current()->Run(); |
| 957 | 957 |
| 958 EXPECT_EQ(HTTP_SUCCESS, error); | 958 EXPECT_EQ(HTTP_SUCCESS, error); |
| 959 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 959 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 960 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 960 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 961 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 961 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 962 http_request_.headers["X-Upload-Content-Length"]); | 962 http_request_.headers["X-Upload-Content-Length"]); |
| 963 | 963 |
| 964 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 964 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 965 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 965 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| 966 http_request_.relative_url); | 966 http_request_.relative_url); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 985 new drive::GetUploadStatusOperation( | 985 new drive::GetUploadStatusOperation( |
| 986 operation_runner_.get(), | 986 operation_runner_.get(), |
| 987 request_context_getter_.get(), | 987 request_context_getter_.get(), |
| 988 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 988 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 989 upload_url, | 989 upload_url, |
| 990 kTestContent.size(), | 990 kTestContent.size(), |
| 991 CreateComposedCallback( | 991 CreateComposedCallback( |
| 992 base::Bind(&test_util::RunAndQuit), | 992 base::Bind(&test_util::RunAndQuit), |
| 993 test_util::CreateCopyResultCallback(&response, &new_entry))); | 993 test_util::CreateCopyResultCallback(&response, &new_entry))); |
| 994 operation_runner_->StartOperationWithRetry(get_upload_status_operation); | 994 operation_runner_->StartOperationWithRetry(get_upload_status_operation); |
| 995 MessageLoop::current()->Run(); | 995 base::MessageLoop::current()->Run(); |
| 996 | 996 |
| 997 // METHOD_PUT should be used to upload data. | 997 // METHOD_PUT should be used to upload data. |
| 998 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 998 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 999 // Request should go to the upload URL. | 999 // Request should go to the upload URL. |
| 1000 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1000 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1001 // Content-Range header should be added. | 1001 // Content-Range header should be added. |
| 1002 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), | 1002 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), |
| 1003 http_request_.headers["Content-Range"]); | 1003 http_request_.headers["Content-Range"]); |
| 1004 EXPECT_TRUE(http_request_.has_content); | 1004 EXPECT_TRUE(http_request_.has_content); |
| 1005 EXPECT_TRUE(http_request_.content.empty()); | 1005 EXPECT_TRUE(http_request_.content.empty()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1031 start_position, | 1031 start_position, |
| 1032 end_position, | 1032 end_position, |
| 1033 kTestContent.size(), // content_length, | 1033 kTestContent.size(), // content_length, |
| 1034 kTestContentType, | 1034 kTestContentType, |
| 1035 kTestFilePath, | 1035 kTestFilePath, |
| 1036 CreateComposedCallback( | 1036 CreateComposedCallback( |
| 1037 base::Bind(&test_util::RunAndQuit), | 1037 base::Bind(&test_util::RunAndQuit), |
| 1038 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1038 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1039 ProgressCallback()); | 1039 ProgressCallback()); |
| 1040 operation_runner_->StartOperationWithRetry(resume_operation); | 1040 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1041 MessageLoop::current()->Run(); | 1041 base::MessageLoop::current()->Run(); |
| 1042 | 1042 |
| 1043 // METHOD_PUT should be used to upload data. | 1043 // METHOD_PUT should be used to upload data. |
| 1044 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1044 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1045 // Request should go to the upload URL. | 1045 // Request should go to the upload URL. |
| 1046 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1046 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1047 // Content-Range header should be added. | 1047 // Content-Range header should be added. |
| 1048 EXPECT_EQ("bytes " + | 1048 EXPECT_EQ("bytes " + |
| 1049 base::Int64ToString(start_position) + "-" + | 1049 base::Int64ToString(start_position) + "-" + |
| 1050 base::Int64ToString(end_position - 1) + "/" + | 1050 base::Int64ToString(end_position - 1) + "/" + |
| 1051 base::Int64ToString(kTestContent.size()), | 1051 base::Int64ToString(kTestContent.size()), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1075 new drive::GetUploadStatusOperation( | 1075 new drive::GetUploadStatusOperation( |
| 1076 operation_runner_.get(), | 1076 operation_runner_.get(), |
| 1077 request_context_getter_.get(), | 1077 request_context_getter_.get(), |
| 1078 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 1078 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 1079 upload_url, | 1079 upload_url, |
| 1080 kTestContent.size(), | 1080 kTestContent.size(), |
| 1081 CreateComposedCallback( | 1081 CreateComposedCallback( |
| 1082 base::Bind(&test_util::RunAndQuit), | 1082 base::Bind(&test_util::RunAndQuit), |
| 1083 test_util::CreateCopyResultCallback(&response, &new_entry))); | 1083 test_util::CreateCopyResultCallback(&response, &new_entry))); |
| 1084 operation_runner_->StartOperationWithRetry(get_upload_status_operation); | 1084 operation_runner_->StartOperationWithRetry(get_upload_status_operation); |
| 1085 MessageLoop::current()->Run(); | 1085 base::MessageLoop::current()->Run(); |
| 1086 | 1086 |
| 1087 // METHOD_PUT should be used to upload data. | 1087 // METHOD_PUT should be used to upload data. |
| 1088 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1088 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1089 // Request should go to the upload URL. | 1089 // Request should go to the upload URL. |
| 1090 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1090 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1091 // Content-Range header should be added. | 1091 // Content-Range header should be added. |
| 1092 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), | 1092 EXPECT_EQ("bytes */" + base::Int64ToString(kTestContent.size()), |
| 1093 http_request_.headers["Content-Range"]); | 1093 http_request_.headers["Content-Range"]); |
| 1094 EXPECT_TRUE(http_request_.has_content); | 1094 EXPECT_TRUE(http_request_.has_content); |
| 1095 EXPECT_TRUE(http_request_.content.empty()); | 1095 EXPECT_TRUE(http_request_.content.empty()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1124 *url_generator_, | 1124 *url_generator_, |
| 1125 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 1125 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 1126 kTestContentType, | 1126 kTestContentType, |
| 1127 kTestContent.size(), | 1127 kTestContent.size(), |
| 1128 "resource_id", // The resource id of the file to be overwritten. | 1128 "resource_id", // The resource id of the file to be overwritten. |
| 1129 std::string(), // No etag. | 1129 std::string(), // No etag. |
| 1130 CreateComposedCallback( | 1130 CreateComposedCallback( |
| 1131 base::Bind(&test_util::RunAndQuit), | 1131 base::Bind(&test_util::RunAndQuit), |
| 1132 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1132 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1133 operation_runner_->StartOperationWithRetry(operation); | 1133 operation_runner_->StartOperationWithRetry(operation); |
| 1134 MessageLoop::current()->Run(); | 1134 base::MessageLoop::current()->Run(); |
| 1135 | 1135 |
| 1136 EXPECT_EQ(HTTP_SUCCESS, error); | 1136 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1137 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1137 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1138 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1138 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1139 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1139 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1140 http_request_.headers["X-Upload-Content-Length"]); | 1140 http_request_.headers["X-Upload-Content-Length"]); |
| 1141 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 1141 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 1142 | 1142 |
| 1143 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1143 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1144 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1144 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1159 0, // start_position | 1159 0, // start_position |
| 1160 kTestContent.size(), // end_position (exclusive) | 1160 kTestContent.size(), // end_position (exclusive) |
| 1161 kTestContent.size(), // content_length, | 1161 kTestContent.size(), // content_length, |
| 1162 kTestContentType, | 1162 kTestContentType, |
| 1163 kTestFilePath, | 1163 kTestFilePath, |
| 1164 CreateComposedCallback( | 1164 CreateComposedCallback( |
| 1165 base::Bind(&test_util::RunAndQuit), | 1165 base::Bind(&test_util::RunAndQuit), |
| 1166 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1166 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1167 ProgressCallback()); | 1167 ProgressCallback()); |
| 1168 operation_runner_->StartOperationWithRetry(resume_operation); | 1168 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1169 MessageLoop::current()->Run(); | 1169 base::MessageLoop::current()->Run(); |
| 1170 | 1170 |
| 1171 // METHOD_PUT should be used to upload data. | 1171 // METHOD_PUT should be used to upload data. |
| 1172 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1172 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1173 // Request should go to the upload URL. | 1173 // Request should go to the upload URL. |
| 1174 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1174 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1175 // Content-Range header should be added. | 1175 // Content-Range header should be added. |
| 1176 EXPECT_EQ("bytes 0-" + | 1176 EXPECT_EQ("bytes 0-" + |
| 1177 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1177 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| 1178 base::Int64ToString(kTestContent.size()), | 1178 base::Int64ToString(kTestContent.size()), |
| 1179 http_request_.headers["Content-Range"]); | 1179 http_request_.headers["Content-Range"]); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1209 *url_generator_, | 1209 *url_generator_, |
| 1210 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 1210 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 1211 kTestContentType, | 1211 kTestContentType, |
| 1212 kTestContent.size(), | 1212 kTestContent.size(), |
| 1213 "resource_id", // The resource id of the file to be overwritten. | 1213 "resource_id", // The resource id of the file to be overwritten. |
| 1214 kTestETag, | 1214 kTestETag, |
| 1215 CreateComposedCallback( | 1215 CreateComposedCallback( |
| 1216 base::Bind(&test_util::RunAndQuit), | 1216 base::Bind(&test_util::RunAndQuit), |
| 1217 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1217 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1218 operation_runner_->StartOperationWithRetry(operation); | 1218 operation_runner_->StartOperationWithRetry(operation); |
| 1219 MessageLoop::current()->Run(); | 1219 base::MessageLoop::current()->Run(); |
| 1220 | 1220 |
| 1221 EXPECT_EQ(HTTP_SUCCESS, error); | 1221 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1222 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1222 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1223 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1223 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1224 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1224 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1225 http_request_.headers["X-Upload-Content-Length"]); | 1225 http_request_.headers["X-Upload-Content-Length"]); |
| 1226 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1226 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 1227 | 1227 |
| 1228 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1228 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1229 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1229 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1244 0, // start_position | 1244 0, // start_position |
| 1245 kTestContent.size(), // end_position (exclusive) | 1245 kTestContent.size(), // end_position (exclusive) |
| 1246 kTestContent.size(), // content_length, | 1246 kTestContent.size(), // content_length, |
| 1247 kTestContentType, | 1247 kTestContentType, |
| 1248 kTestFilePath, | 1248 kTestFilePath, |
| 1249 CreateComposedCallback( | 1249 CreateComposedCallback( |
| 1250 base::Bind(&test_util::RunAndQuit), | 1250 base::Bind(&test_util::RunAndQuit), |
| 1251 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1251 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1252 ProgressCallback()); | 1252 ProgressCallback()); |
| 1253 operation_runner_->StartOperationWithRetry(resume_operation); | 1253 operation_runner_->StartOperationWithRetry(resume_operation); |
| 1254 MessageLoop::current()->Run(); | 1254 base::MessageLoop::current()->Run(); |
| 1255 | 1255 |
| 1256 // METHOD_PUT should be used to upload data. | 1256 // METHOD_PUT should be used to upload data. |
| 1257 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1257 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1258 // Request should go to the upload URL. | 1258 // Request should go to the upload URL. |
| 1259 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1259 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1260 // Content-Range header should be added. | 1260 // Content-Range header should be added. |
| 1261 EXPECT_EQ("bytes 0-" + | 1261 EXPECT_EQ("bytes 0-" + |
| 1262 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1262 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| 1263 base::Int64ToString(kTestContent.size()), | 1263 base::Int64ToString(kTestContent.size()), |
| 1264 http_request_.headers["Content-Range"]); | 1264 http_request_.headers["Content-Range"]); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1291 *url_generator_, | 1291 *url_generator_, |
| 1292 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 1292 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 1293 kTestContentType, | 1293 kTestContentType, |
| 1294 kTestContent.size(), | 1294 kTestContent.size(), |
| 1295 "resource_id", // The resource id of the file to be overwritten. | 1295 "resource_id", // The resource id of the file to be overwritten. |
| 1296 "Conflicting-etag", | 1296 "Conflicting-etag", |
| 1297 CreateComposedCallback( | 1297 CreateComposedCallback( |
| 1298 base::Bind(&test_util::RunAndQuit), | 1298 base::Bind(&test_util::RunAndQuit), |
| 1299 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1299 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1300 operation_runner_->StartOperationWithRetry(operation); | 1300 operation_runner_->StartOperationWithRetry(operation); |
| 1301 MessageLoop::current()->Run(); | 1301 base::MessageLoop::current()->Run(); |
| 1302 | 1302 |
| 1303 EXPECT_EQ(HTTP_PRECONDITION, error); | 1303 EXPECT_EQ(HTTP_PRECONDITION, error); |
| 1304 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1304 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1305 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1305 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1306 http_request_.headers["X-Upload-Content-Length"]); | 1306 http_request_.headers["X-Upload-Content-Length"]); |
| 1307 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); | 1307 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); |
| 1308 | 1308 |
| 1309 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1309 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1310 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1310 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| 1311 http_request_.relative_url); | 1311 http_request_.relative_url); |
| 1312 EXPECT_TRUE(http_request_.has_content); | 1312 EXPECT_TRUE(http_request_.has_content); |
| 1313 EXPECT_TRUE(http_request_.content.empty()); | 1313 EXPECT_TRUE(http_request_.content.empty()); |
| 1314 } | 1314 } |
| 1315 | 1315 |
| 1316 } // namespace google_apis | 1316 } // namespace google_apis |
| OLD | NEW |