| 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/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/google_apis/drive_api_operations.h" | 10 #include "chrome/browser/google_apis/drive_api_operations.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 received_bytes_ = 0; | 84 received_bytes_ = 0; |
| 85 content_length_ = 0; | 85 content_length_ = 0; |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void TearDown() OVERRIDE { | 88 virtual void TearDown() OVERRIDE { |
| 89 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 89 EXPECT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
| 90 request_context_getter_ = NULL; | 90 request_context_getter_ = NULL; |
| 91 ResetExpectedResponse(); | 91 ResetExpectedResponse(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 MessageLoopForUI message_loop_; | 94 base::MessageLoopForUI message_loop_; |
| 95 content::TestBrowserThread ui_thread_; | 95 content::TestBrowserThread ui_thread_; |
| 96 content::TestBrowserThread file_thread_; | 96 content::TestBrowserThread file_thread_; |
| 97 content::TestBrowserThread io_thread_; | 97 content::TestBrowserThread io_thread_; |
| 98 test_server::HttpServer test_server_; | 98 test_server::HttpServer test_server_; |
| 99 OperationRegistry operation_registry_; | 99 OperationRegistry operation_registry_; |
| 100 scoped_ptr<DriveApiUrlGenerator> url_generator_; | 100 scoped_ptr<DriveApiUrlGenerator> url_generator_; |
| 101 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 101 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
| 102 | 102 |
| 103 // This is a path to the file which contains expected response from | 103 // This is a path to the file which contains expected response from |
| 104 // the server. See also HandleDataFileRequest below. | 104 // the server. See also HandleDataFileRequest below. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 GetAboutOperation* operation = new GetAboutOperation( | 311 GetAboutOperation* operation = new GetAboutOperation( |
| 312 &operation_registry_, | 312 &operation_registry_, |
| 313 request_context_getter_.get(), | 313 request_context_getter_.get(), |
| 314 *url_generator_, | 314 *url_generator_, |
| 315 CreateComposedCallback( | 315 CreateComposedCallback( |
| 316 base::Bind(&test_util::RunAndQuit), | 316 base::Bind(&test_util::RunAndQuit), |
| 317 test_util::CreateCopyResultCallback(&error, &about_resource))); | 317 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 318 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 318 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 319 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 319 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 320 MessageLoop::current()->Run(); | 320 base::MessageLoop::current()->Run(); |
| 321 | 321 |
| 322 EXPECT_EQ(HTTP_SUCCESS, error); | 322 EXPECT_EQ(HTTP_SUCCESS, error); |
| 323 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 323 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 324 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 324 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 325 | 325 |
| 326 scoped_ptr<AboutResource> expected( | 326 scoped_ptr<AboutResource> expected( |
| 327 AboutResource::CreateFrom( | 327 AboutResource::CreateFrom( |
| 328 *test_util::LoadJSONFile("chromeos/drive/about.json"))); | 328 *test_util::LoadJSONFile("chromeos/drive/about.json"))); |
| 329 ASSERT_TRUE(about_resource.get()); | 329 ASSERT_TRUE(about_resource.get()); |
| 330 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); | 330 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 343 | 343 |
| 344 GetAboutOperation* operation = new GetAboutOperation( | 344 GetAboutOperation* operation = new GetAboutOperation( |
| 345 &operation_registry_, | 345 &operation_registry_, |
| 346 request_context_getter_.get(), | 346 request_context_getter_.get(), |
| 347 *url_generator_, | 347 *url_generator_, |
| 348 CreateComposedCallback( | 348 CreateComposedCallback( |
| 349 base::Bind(&test_util::RunAndQuit), | 349 base::Bind(&test_util::RunAndQuit), |
| 350 test_util::CreateCopyResultCallback(&error, &about_resource))); | 350 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 351 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 351 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 352 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 352 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 353 MessageLoop::current()->Run(); | 353 base::MessageLoop::current()->Run(); |
| 354 | 354 |
| 355 // "parse error" should be returned, and the about resource should be NULL. | 355 // "parse error" should be returned, and the about resource should be NULL. |
| 356 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 356 EXPECT_EQ(GDATA_PARSE_ERROR, error); |
| 357 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 357 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 358 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 358 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 359 EXPECT_FALSE(about_resource.get()); | 359 EXPECT_FALSE(about_resource.get()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 TEST_F(DriveApiOperationsTest, GetApplistOperation) { | 362 TEST_F(DriveApiOperationsTest, GetApplistOperation) { |
| 363 // Set an expected data file containing valid result. | 363 // Set an expected data file containing valid result. |
| 364 expected_data_file_path_ = test_util::GetTestFilePath( | 364 expected_data_file_path_ = test_util::GetTestFilePath( |
| 365 "chromeos/drive/applist.json"); | 365 "chromeos/drive/applist.json"); |
| 366 | 366 |
| 367 GDataErrorCode error = GDATA_OTHER_ERROR; | 367 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 368 scoped_ptr<base::Value> result; | 368 scoped_ptr<base::Value> result; |
| 369 | 369 |
| 370 GetApplistOperation* operation = new GetApplistOperation( | 370 GetApplistOperation* operation = new GetApplistOperation( |
| 371 &operation_registry_, | 371 &operation_registry_, |
| 372 request_context_getter_.get(), | 372 request_context_getter_.get(), |
| 373 *url_generator_, | 373 *url_generator_, |
| 374 CreateComposedCallback( | 374 CreateComposedCallback( |
| 375 base::Bind(&test_util::RunAndQuit), | 375 base::Bind(&test_util::RunAndQuit), |
| 376 test_util::CreateCopyResultCallback(&error, &result))); | 376 test_util::CreateCopyResultCallback(&error, &result))); |
| 377 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 377 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 378 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 378 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 379 MessageLoop::current()->Run(); | 379 base::MessageLoop::current()->Run(); |
| 380 | 380 |
| 381 EXPECT_EQ(HTTP_SUCCESS, error); | 381 EXPECT_EQ(HTTP_SUCCESS, error); |
| 382 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 382 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 383 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 383 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
| 384 EXPECT_TRUE(result); | 384 EXPECT_TRUE(result); |
| 385 } | 385 } |
| 386 | 386 |
| 387 TEST_F(DriveApiOperationsTest, GetChangelistOperation) { | 387 TEST_F(DriveApiOperationsTest, GetChangelistOperation) { |
| 388 // Set an expected data file containing valid result. | 388 // Set an expected data file containing valid result. |
| 389 expected_data_file_path_ = test_util::GetTestFilePath( | 389 expected_data_file_path_ = test_util::GetTestFilePath( |
| 390 "chromeos/drive/changelist.json"); | 390 "chromeos/drive/changelist.json"); |
| 391 | 391 |
| 392 GDataErrorCode error = GDATA_OTHER_ERROR; | 392 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 393 scoped_ptr<base::Value> result; | 393 scoped_ptr<base::Value> result; |
| 394 | 394 |
| 395 GetChangelistOperation* operation = new GetChangelistOperation( | 395 GetChangelistOperation* operation = new GetChangelistOperation( |
| 396 &operation_registry_, | 396 &operation_registry_, |
| 397 request_context_getter_.get(), | 397 request_context_getter_.get(), |
| 398 *url_generator_, | 398 *url_generator_, |
| 399 true, // include deleted | 399 true, // include deleted |
| 400 100, // start changestamp | 400 100, // start changestamp |
| 401 500, // max results | 401 500, // max results |
| 402 CreateComposedCallback( | 402 CreateComposedCallback( |
| 403 base::Bind(&test_util::RunAndQuit), | 403 base::Bind(&test_util::RunAndQuit), |
| 404 test_util::CreateCopyResultCallback(&error, &result))); | 404 test_util::CreateCopyResultCallback(&error, &result))); |
| 405 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 405 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 406 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 406 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 407 MessageLoop::current()->Run(); | 407 base::MessageLoop::current()->Run(); |
| 408 | 408 |
| 409 EXPECT_EQ(HTTP_SUCCESS, error); | 409 EXPECT_EQ(HTTP_SUCCESS, error); |
| 410 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 410 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 411 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", | 411 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", |
| 412 http_request_.relative_url); | 412 http_request_.relative_url); |
| 413 EXPECT_TRUE(result); | 413 EXPECT_TRUE(result); |
| 414 } | 414 } |
| 415 | 415 |
| 416 TEST_F(DriveApiOperationsTest, GetFilelistOperation) { | 416 TEST_F(DriveApiOperationsTest, GetFilelistOperation) { |
| 417 // Set an expected data file containing valid result. | 417 // Set an expected data file containing valid result. |
| 418 expected_data_file_path_ = test_util::GetTestFilePath( | 418 expected_data_file_path_ = test_util::GetTestFilePath( |
| 419 "chromeos/drive/filelist.json"); | 419 "chromeos/drive/filelist.json"); |
| 420 | 420 |
| 421 GDataErrorCode error = GDATA_OTHER_ERROR; | 421 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 422 scoped_ptr<base::Value> result; | 422 scoped_ptr<base::Value> result; |
| 423 | 423 |
| 424 GetFilelistOperation* operation = new GetFilelistOperation( | 424 GetFilelistOperation* operation = new GetFilelistOperation( |
| 425 &operation_registry_, | 425 &operation_registry_, |
| 426 request_context_getter_.get(), | 426 request_context_getter_.get(), |
| 427 *url_generator_, | 427 *url_generator_, |
| 428 "\"abcde\" in parents", | 428 "\"abcde\" in parents", |
| 429 50, // max results | 429 50, // max results |
| 430 CreateComposedCallback( | 430 CreateComposedCallback( |
| 431 base::Bind(&test_util::RunAndQuit), | 431 base::Bind(&test_util::RunAndQuit), |
| 432 test_util::CreateCopyResultCallback(&error, &result))); | 432 test_util::CreateCopyResultCallback(&error, &result))); |
| 433 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 433 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 434 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 434 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 435 MessageLoop::current()->Run(); | 435 base::MessageLoop::current()->Run(); |
| 436 | 436 |
| 437 EXPECT_EQ(HTTP_SUCCESS, error); | 437 EXPECT_EQ(HTTP_SUCCESS, error); |
| 438 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 438 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 439 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", | 439 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", |
| 440 http_request_.relative_url); | 440 http_request_.relative_url); |
| 441 EXPECT_TRUE(result); | 441 EXPECT_TRUE(result); |
| 442 } | 442 } |
| 443 | 443 |
| 444 TEST_F(DriveApiOperationsTest, ContinueGetFileListOperation) { | 444 TEST_F(DriveApiOperationsTest, ContinueGetFileListOperation) { |
| 445 // Set an expected data file containing valid result. | 445 // Set an expected data file containing valid result. |
| 446 expected_data_file_path_ = test_util::GetTestFilePath( | 446 expected_data_file_path_ = test_util::GetTestFilePath( |
| 447 "chromeos/drive/filelist.json"); | 447 "chromeos/drive/filelist.json"); |
| 448 | 448 |
| 449 GDataErrorCode error = GDATA_OTHER_ERROR; | 449 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 450 scoped_ptr<base::Value> result; | 450 scoped_ptr<base::Value> result; |
| 451 | 451 |
| 452 drive::ContinueGetFileListOperation* operation = | 452 drive::ContinueGetFileListOperation* operation = |
| 453 new drive::ContinueGetFileListOperation( | 453 new drive::ContinueGetFileListOperation( |
| 454 &operation_registry_, | 454 &operation_registry_, |
| 455 request_context_getter_.get(), | 455 request_context_getter_.get(), |
| 456 test_server_.GetURL("/continue/get/file/list"), | 456 test_server_.GetURL("/continue/get/file/list"), |
| 457 CreateComposedCallback( | 457 CreateComposedCallback( |
| 458 base::Bind(&test_util::RunAndQuit), | 458 base::Bind(&test_util::RunAndQuit), |
| 459 test_util::CreateCopyResultCallback(&error, &result))); | 459 test_util::CreateCopyResultCallback(&error, &result))); |
| 460 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 460 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 461 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 461 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 462 MessageLoop::current()->Run(); | 462 base::MessageLoop::current()->Run(); |
| 463 | 463 |
| 464 EXPECT_EQ(HTTP_SUCCESS, error); | 464 EXPECT_EQ(HTTP_SUCCESS, error); |
| 465 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); | 465 EXPECT_EQ(test_server::METHOD_GET, http_request_.method); |
| 466 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 466 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
| 467 EXPECT_TRUE(result); | 467 EXPECT_TRUE(result); |
| 468 } | 468 } |
| 469 | 469 |
| 470 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) { | 470 TEST_F(DriveApiOperationsTest, CreateDirectoryOperation) { |
| 471 // Set an expected data file containing the directory's entry data. | 471 // Set an expected data file containing the directory's entry data. |
| 472 expected_data_file_path_ = | 472 expected_data_file_path_ = |
| 473 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 473 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); |
| 474 | 474 |
| 475 GDataErrorCode error = GDATA_OTHER_ERROR; | 475 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 476 scoped_ptr<FileResource> file_resource; | 476 scoped_ptr<FileResource> file_resource; |
| 477 | 477 |
| 478 // Create "new directory" in the root directory. | 478 // Create "new directory" in the root directory. |
| 479 drive::CreateDirectoryOperation* operation = | 479 drive::CreateDirectoryOperation* operation = |
| 480 new drive::CreateDirectoryOperation( | 480 new drive::CreateDirectoryOperation( |
| 481 &operation_registry_, | 481 &operation_registry_, |
| 482 request_context_getter_.get(), | 482 request_context_getter_.get(), |
| 483 *url_generator_, | 483 *url_generator_, |
| 484 "root", | 484 "root", |
| 485 "new directory", | 485 "new directory", |
| 486 CreateComposedCallback( | 486 CreateComposedCallback( |
| 487 base::Bind(&test_util::RunAndQuit), | 487 base::Bind(&test_util::RunAndQuit), |
| 488 test_util::CreateCopyResultCallback(&error, &file_resource))); | 488 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 489 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 489 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 490 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 490 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 491 MessageLoop::current()->Run(); | 491 base::MessageLoop::current()->Run(); |
| 492 | 492 |
| 493 EXPECT_EQ(HTTP_SUCCESS, error); | 493 EXPECT_EQ(HTTP_SUCCESS, error); |
| 494 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 494 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 495 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); | 495 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); |
| 496 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 496 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 497 | 497 |
| 498 EXPECT_TRUE(http_request_.has_content); | 498 EXPECT_TRUE(http_request_.has_content); |
| 499 | 499 |
| 500 scoped_ptr<FileResource> expected( | 500 scoped_ptr<FileResource> expected( |
| 501 FileResource::CreateFrom( | 501 FileResource::CreateFrom( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 524 &operation_registry_, | 524 &operation_registry_, |
| 525 request_context_getter_.get(), | 525 request_context_getter_.get(), |
| 526 *url_generator_, | 526 *url_generator_, |
| 527 "resource_id", | 527 "resource_id", |
| 528 "new name", | 528 "new name", |
| 529 CreateComposedCallback( | 529 CreateComposedCallback( |
| 530 base::Bind(&test_util::RunAndQuit), | 530 base::Bind(&test_util::RunAndQuit), |
| 531 test_util::CreateCopyResultCallback(&error))); | 531 test_util::CreateCopyResultCallback(&error))); |
| 532 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 532 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 533 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 533 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 534 MessageLoop::current()->Run(); | 534 base::MessageLoop::current()->Run(); |
| 535 | 535 |
| 536 EXPECT_EQ(HTTP_SUCCESS, error); | 536 EXPECT_EQ(HTTP_SUCCESS, error); |
| 537 EXPECT_EQ(test_server::METHOD_PATCH, http_request_.method); | 537 EXPECT_EQ(test_server::METHOD_PATCH, http_request_.method); |
| 538 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); | 538 EXPECT_EQ("/drive/v2/files/resource_id", http_request_.relative_url); |
| 539 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 539 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 540 | 540 |
| 541 EXPECT_TRUE(http_request_.has_content); | 541 EXPECT_TRUE(http_request_.has_content); |
| 542 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 542 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
| 543 } | 543 } |
| 544 | 544 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 557 &operation_registry_, | 557 &operation_registry_, |
| 558 request_context_getter_.get(), | 558 request_context_getter_.get(), |
| 559 *url_generator_, | 559 *url_generator_, |
| 560 "resource_id", | 560 "resource_id", |
| 561 "new name", | 561 "new name", |
| 562 CreateComposedCallback( | 562 CreateComposedCallback( |
| 563 base::Bind(&test_util::RunAndQuit), | 563 base::Bind(&test_util::RunAndQuit), |
| 564 test_util::CreateCopyResultCallback(&error, &file_resource))); | 564 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 565 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 565 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 566 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 566 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 567 MessageLoop::current()->Run(); | 567 base::MessageLoop::current()->Run(); |
| 568 | 568 |
| 569 EXPECT_EQ(HTTP_SUCCESS, error); | 569 EXPECT_EQ(HTTP_SUCCESS, error); |
| 570 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 570 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 571 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); | 571 EXPECT_EQ("/drive/v2/files/resource_id/copy", http_request_.relative_url); |
| 572 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 572 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 573 | 573 |
| 574 EXPECT_TRUE(http_request_.has_content); | 574 EXPECT_TRUE(http_request_.has_content); |
| 575 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 575 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
| 576 EXPECT_TRUE(file_resource); | 576 EXPECT_TRUE(file_resource); |
| 577 } | 577 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 589 new drive::TrashResourceOperation( | 589 new drive::TrashResourceOperation( |
| 590 &operation_registry_, | 590 &operation_registry_, |
| 591 request_context_getter_.get(), | 591 request_context_getter_.get(), |
| 592 *url_generator_, | 592 *url_generator_, |
| 593 "resource_id", | 593 "resource_id", |
| 594 CreateComposedCallback( | 594 CreateComposedCallback( |
| 595 base::Bind(&test_util::RunAndQuit), | 595 base::Bind(&test_util::RunAndQuit), |
| 596 test_util::CreateCopyResultCallback(&error))); | 596 test_util::CreateCopyResultCallback(&error))); |
| 597 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 597 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 598 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 598 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 599 MessageLoop::current()->Run(); | 599 base::MessageLoop::current()->Run(); |
| 600 | 600 |
| 601 EXPECT_EQ(HTTP_SUCCESS, error); | 601 EXPECT_EQ(HTTP_SUCCESS, error); |
| 602 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 602 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 603 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); | 603 EXPECT_EQ("/drive/v2/files/resource_id/trash", http_request_.relative_url); |
| 604 EXPECT_TRUE(http_request_.has_content); | 604 EXPECT_TRUE(http_request_.has_content); |
| 605 EXPECT_TRUE(http_request_.content.empty()); | 605 EXPECT_TRUE(http_request_.content.empty()); |
| 606 } | 606 } |
| 607 | 607 |
| 608 TEST_F(DriveApiOperationsTest, InsertResourceOperation) { | 608 TEST_F(DriveApiOperationsTest, InsertResourceOperation) { |
| 609 // Set an expected data file containing the children entry. | 609 // Set an expected data file containing the children entry. |
| 610 expected_content_type_ = "application/json"; | 610 expected_content_type_ = "application/json"; |
| 611 expected_content_ = kTestChildrenResponse; | 611 expected_content_ = kTestChildrenResponse; |
| 612 | 612 |
| 613 GDataErrorCode error = GDATA_OTHER_ERROR; | 613 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 614 | 614 |
| 615 // Add a resource with "resource_id" to a directory with | 615 // Add a resource with "resource_id" to a directory with |
| 616 // "parent_resource_id". | 616 // "parent_resource_id". |
| 617 drive::InsertResourceOperation* operation = | 617 drive::InsertResourceOperation* operation = |
| 618 new drive::InsertResourceOperation( | 618 new drive::InsertResourceOperation( |
| 619 &operation_registry_, | 619 &operation_registry_, |
| 620 request_context_getter_.get(), | 620 request_context_getter_.get(), |
| 621 *url_generator_, | 621 *url_generator_, |
| 622 "parent_resource_id", | 622 "parent_resource_id", |
| 623 "resource_id", | 623 "resource_id", |
| 624 CreateComposedCallback( | 624 CreateComposedCallback( |
| 625 base::Bind(&test_util::RunAndQuit), | 625 base::Bind(&test_util::RunAndQuit), |
| 626 test_util::CreateCopyResultCallback(&error))); | 626 test_util::CreateCopyResultCallback(&error))); |
| 627 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 627 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 628 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 628 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 629 MessageLoop::current()->Run(); | 629 base::MessageLoop::current()->Run(); |
| 630 | 630 |
| 631 EXPECT_EQ(HTTP_SUCCESS, error); | 631 EXPECT_EQ(HTTP_SUCCESS, error); |
| 632 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 632 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 633 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", | 633 EXPECT_EQ("/drive/v2/files/parent_resource_id/children", |
| 634 http_request_.relative_url); | 634 http_request_.relative_url); |
| 635 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 635 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 636 | 636 |
| 637 EXPECT_TRUE(http_request_.has_content); | 637 EXPECT_TRUE(http_request_.has_content); |
| 638 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); | 638 EXPECT_EQ("{\"id\":\"resource_id\"}", http_request_.content); |
| 639 } | 639 } |
| 640 | 640 |
| 641 TEST_F(DriveApiOperationsTest, DeleteResourceOperation) { | 641 TEST_F(DriveApiOperationsTest, DeleteResourceOperation) { |
| 642 GDataErrorCode error = GDATA_OTHER_ERROR; | 642 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 643 | 643 |
| 644 // Remove a resource with "resource_id" from a directory with | 644 // Remove a resource with "resource_id" from a directory with |
| 645 // "parent_resource_id". | 645 // "parent_resource_id". |
| 646 drive::DeleteResourceOperation* operation = | 646 drive::DeleteResourceOperation* operation = |
| 647 new drive::DeleteResourceOperation( | 647 new drive::DeleteResourceOperation( |
| 648 &operation_registry_, | 648 &operation_registry_, |
| 649 request_context_getter_.get(), | 649 request_context_getter_.get(), |
| 650 *url_generator_, | 650 *url_generator_, |
| 651 "parent_resource_id", | 651 "parent_resource_id", |
| 652 "resource_id", | 652 "resource_id", |
| 653 CreateComposedCallback( | 653 CreateComposedCallback( |
| 654 base::Bind(&test_util::RunAndQuit), | 654 base::Bind(&test_util::RunAndQuit), |
| 655 test_util::CreateCopyResultCallback(&error))); | 655 test_util::CreateCopyResultCallback(&error))); |
| 656 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 656 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 657 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 657 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 658 MessageLoop::current()->Run(); | 658 base::MessageLoop::current()->Run(); |
| 659 | 659 |
| 660 EXPECT_EQ(HTTP_NO_CONTENT, error); | 660 EXPECT_EQ(HTTP_NO_CONTENT, error); |
| 661 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); | 661 EXPECT_EQ(test_server::METHOD_DELETE, http_request_.method); |
| 662 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", | 662 EXPECT_EQ("/drive/v2/files/parent_resource_id/children/resource_id", |
| 663 http_request_.relative_url); | 663 http_request_.relative_url); |
| 664 EXPECT_FALSE(http_request_.has_content); | 664 EXPECT_FALSE(http_request_.has_content); |
| 665 } | 665 } |
| 666 | 666 |
| 667 TEST_F(DriveApiOperationsTest, UploadNewFileOperation) { | 667 TEST_F(DriveApiOperationsTest, UploadNewFileOperation) { |
| 668 // Set an expected url for uploading. | 668 // Set an expected url for uploading. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 684 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 684 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 685 kTestContentType, | 685 kTestContentType, |
| 686 kTestContent.size(), | 686 kTestContent.size(), |
| 687 "parent_resource_id", // The resource id of the parent directory. | 687 "parent_resource_id", // The resource id of the parent directory. |
| 688 "new file title", // The title of the file being uploaded. | 688 "new file title", // The title of the file being uploaded. |
| 689 CreateComposedCallback( | 689 CreateComposedCallback( |
| 690 base::Bind(&test_util::RunAndQuit), | 690 base::Bind(&test_util::RunAndQuit), |
| 691 test_util::CreateCopyResultCallback(&error, &upload_url))); | 691 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 692 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 692 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 693 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 693 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 694 MessageLoop::current()->Run(); | 694 base::MessageLoop::current()->Run(); |
| 695 | 695 |
| 696 EXPECT_EQ(HTTP_SUCCESS, error); | 696 EXPECT_EQ(HTTP_SUCCESS, error); |
| 697 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 697 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 698 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 698 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 699 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 699 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 700 http_request_.headers["X-Upload-Content-Length"]); | 700 http_request_.headers["X-Upload-Content-Length"]); |
| 701 | 701 |
| 702 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 702 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 703 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 703 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| 704 http_request_.relative_url); | 704 http_request_.relative_url); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 729 kTestContent.size(), // content_length, | 729 kTestContent.size(), // content_length, |
| 730 kTestContentType, | 730 kTestContentType, |
| 731 buffer, | 731 buffer, |
| 732 CreateComposedCallback( | 732 CreateComposedCallback( |
| 733 base::Bind(&test_util::RunAndQuit), | 733 base::Bind(&test_util::RunAndQuit), |
| 734 test_util::CreateCopyResultCallback(&response, &new_entry)), | 734 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 735 ProgressCallback()); | 735 ProgressCallback()); |
| 736 resume_operation->Start( | 736 resume_operation->Start( |
| 737 kTestDriveApiAuthToken, kTestUserAgent, | 737 kTestDriveApiAuthToken, kTestUserAgent, |
| 738 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 738 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 739 MessageLoop::current()->Run(); | 739 base::MessageLoop::current()->Run(); |
| 740 | 740 |
| 741 // METHOD_PUT should be used to upload data. | 741 // METHOD_PUT should be used to upload data. |
| 742 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 742 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 743 // Request should go to the upload URL. | 743 // Request should go to the upload URL. |
| 744 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 744 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 745 // Content-Range header should be added. | 745 // Content-Range header should be added. |
| 746 EXPECT_EQ("bytes 0-" + | 746 EXPECT_EQ("bytes 0-" + |
| 747 base::Int64ToString(kTestContent.size() - 1) + "/" + | 747 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| 748 base::Int64ToString(kTestContent.size()), | 748 base::Int64ToString(kTestContent.size()), |
| 749 http_request_.headers["Content-Range"]); | 749 http_request_.headers["Content-Range"]); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 778 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 778 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 779 kTestContentType, | 779 kTestContentType, |
| 780 0, | 780 0, |
| 781 "parent_resource_id", // The resource id of the parent directory. | 781 "parent_resource_id", // The resource id of the parent directory. |
| 782 "new file title", // The title of the file being uploaded. | 782 "new file title", // The title of the file being uploaded. |
| 783 CreateComposedCallback( | 783 CreateComposedCallback( |
| 784 base::Bind(&test_util::RunAndQuit), | 784 base::Bind(&test_util::RunAndQuit), |
| 785 test_util::CreateCopyResultCallback(&error, &upload_url))); | 785 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 786 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 786 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 787 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 787 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 788 MessageLoop::current()->Run(); | 788 base::MessageLoop::current()->Run(); |
| 789 | 789 |
| 790 EXPECT_EQ(HTTP_SUCCESS, error); | 790 EXPECT_EQ(HTTP_SUCCESS, error); |
| 791 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 791 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 792 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 792 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 793 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); | 793 EXPECT_EQ("0", http_request_.headers["X-Upload-Content-Length"]); |
| 794 | 794 |
| 795 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 795 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 796 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 796 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| 797 http_request_.relative_url); | 797 http_request_.relative_url); |
| 798 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 798 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 822 0, // content_length, | 822 0, // content_length, |
| 823 kTestContentType, | 823 kTestContentType, |
| 824 buffer, | 824 buffer, |
| 825 CreateComposedCallback( | 825 CreateComposedCallback( |
| 826 base::Bind(&test_util::RunAndQuit), | 826 base::Bind(&test_util::RunAndQuit), |
| 827 test_util::CreateCopyResultCallback(&response, &new_entry)), | 827 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 828 ProgressCallback()); | 828 ProgressCallback()); |
| 829 resume_operation->Start( | 829 resume_operation->Start( |
| 830 kTestDriveApiAuthToken, kTestUserAgent, | 830 kTestDriveApiAuthToken, kTestUserAgent, |
| 831 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 831 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 832 MessageLoop::current()->Run(); | 832 base::MessageLoop::current()->Run(); |
| 833 | 833 |
| 834 // METHOD_PUT should be used to upload data. | 834 // METHOD_PUT should be used to upload data. |
| 835 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 835 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 836 // Request should go to the upload URL. | 836 // Request should go to the upload URL. |
| 837 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 837 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 838 // Content-Range header should NOT be added. | 838 // Content-Range header should NOT be added. |
| 839 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); | 839 EXPECT_EQ(0U, http_request_.headers.count("Content-Range")); |
| 840 // The upload content should be set in the HTTP request. | 840 // The upload content should be set in the HTTP request. |
| 841 EXPECT_TRUE(http_request_.has_content); | 841 EXPECT_TRUE(http_request_.has_content); |
| 842 EXPECT_EQ(kTestContent, http_request_.content); | 842 EXPECT_EQ(kTestContent, http_request_.content); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 869 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 869 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 870 kTestContentType, | 870 kTestContentType, |
| 871 kTestContent.size(), | 871 kTestContent.size(), |
| 872 "parent_resource_id", // The resource id of the parent directory. | 872 "parent_resource_id", // The resource id of the parent directory. |
| 873 "new file title", // The title of the file being uploaded. | 873 "new file title", // The title of the file being uploaded. |
| 874 CreateComposedCallback( | 874 CreateComposedCallback( |
| 875 base::Bind(&test_util::RunAndQuit), | 875 base::Bind(&test_util::RunAndQuit), |
| 876 test_util::CreateCopyResultCallback(&error, &upload_url))); | 876 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 877 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 877 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 878 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 878 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 879 MessageLoop::current()->Run(); | 879 base::MessageLoop::current()->Run(); |
| 880 | 880 |
| 881 EXPECT_EQ(HTTP_SUCCESS, error); | 881 EXPECT_EQ(HTTP_SUCCESS, error); |
| 882 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); | 882 EXPECT_EQ(kTestUploadNewFilePath, upload_url.path()); |
| 883 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 883 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 884 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 884 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 885 http_request_.headers["X-Upload-Content-Length"]); | 885 http_request_.headers["X-Upload-Content-Length"]); |
| 886 | 886 |
| 887 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); | 887 EXPECT_EQ(test_server::METHOD_POST, http_request_.method); |
| 888 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", | 888 EXPECT_EQ("/upload/drive/v2/files?uploadType=resumable", |
| 889 http_request_.relative_url); | 889 http_request_.relative_url); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 920 kTestContent.size(), // content_length, | 920 kTestContent.size(), // content_length, |
| 921 kTestContentType, | 921 kTestContentType, |
| 922 buffer, | 922 buffer, |
| 923 CreateComposedCallback( | 923 CreateComposedCallback( |
| 924 base::Bind(&test_util::RunAndQuit), | 924 base::Bind(&test_util::RunAndQuit), |
| 925 test_util::CreateCopyResultCallback(&response, &new_entry)), | 925 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 926 ProgressCallback()); | 926 ProgressCallback()); |
| 927 resume_operation->Start( | 927 resume_operation->Start( |
| 928 kTestDriveApiAuthToken, kTestUserAgent, | 928 kTestDriveApiAuthToken, kTestUserAgent, |
| 929 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 929 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 930 MessageLoop::current()->Run(); | 930 base::MessageLoop::current()->Run(); |
| 931 | 931 |
| 932 // METHOD_PUT should be used to upload data. | 932 // METHOD_PUT should be used to upload data. |
| 933 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 933 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 934 // Request should go to the upload URL. | 934 // Request should go to the upload URL. |
| 935 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 935 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 936 // Content-Range header should be added. | 936 // Content-Range header should be added. |
| 937 EXPECT_EQ("bytes " + | 937 EXPECT_EQ("bytes " + |
| 938 base::Int64ToString(start_position) + "-" + | 938 base::Int64ToString(start_position) + "-" + |
| 939 base::Int64ToString(end_position - 1) + "/" + | 939 base::Int64ToString(end_position - 1) + "/" + |
| 940 base::Int64ToString(kTestContent.size()), | 940 base::Int64ToString(kTestContent.size()), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 979 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 980 kTestContentType, | 980 kTestContentType, |
| 981 kTestContent.size(), | 981 kTestContent.size(), |
| 982 "resource_id", // The resource id of the file to be overwritten. | 982 "resource_id", // The resource id of the file to be overwritten. |
| 983 std::string(), // No etag. | 983 std::string(), // No etag. |
| 984 CreateComposedCallback( | 984 CreateComposedCallback( |
| 985 base::Bind(&test_util::RunAndQuit), | 985 base::Bind(&test_util::RunAndQuit), |
| 986 test_util::CreateCopyResultCallback(&error, &upload_url))); | 986 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 987 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 987 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 988 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 988 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 989 MessageLoop::current()->Run(); | 989 base::MessageLoop::current()->Run(); |
| 990 | 990 |
| 991 EXPECT_EQ(HTTP_SUCCESS, error); | 991 EXPECT_EQ(HTTP_SUCCESS, error); |
| 992 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 992 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 993 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 993 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 994 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 994 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 995 http_request_.headers["X-Upload-Content-Length"]); | 995 http_request_.headers["X-Upload-Content-Length"]); |
| 996 EXPECT_EQ("*", http_request_.headers["If-Match"]); | 996 EXPECT_EQ("*", http_request_.headers["If-Match"]); |
| 997 | 997 |
| 998 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 998 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 999 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 999 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1019 kTestContent.size(), // content_length, | 1019 kTestContent.size(), // content_length, |
| 1020 kTestContentType, | 1020 kTestContentType, |
| 1021 buffer, | 1021 buffer, |
| 1022 CreateComposedCallback( | 1022 CreateComposedCallback( |
| 1023 base::Bind(&test_util::RunAndQuit), | 1023 base::Bind(&test_util::RunAndQuit), |
| 1024 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1024 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1025 ProgressCallback()); | 1025 ProgressCallback()); |
| 1026 resume_operation->Start( | 1026 resume_operation->Start( |
| 1027 kTestDriveApiAuthToken, kTestUserAgent, | 1027 kTestDriveApiAuthToken, kTestUserAgent, |
| 1028 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1028 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1029 MessageLoop::current()->Run(); | 1029 base::MessageLoop::current()->Run(); |
| 1030 | 1030 |
| 1031 // METHOD_PUT should be used to upload data. | 1031 // METHOD_PUT should be used to upload data. |
| 1032 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1032 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1033 // Request should go to the upload URL. | 1033 // Request should go to the upload URL. |
| 1034 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1034 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1035 // Content-Range header should be added. | 1035 // Content-Range header should be added. |
| 1036 EXPECT_EQ("bytes 0-" + | 1036 EXPECT_EQ("bytes 0-" + |
| 1037 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1037 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| 1038 base::Int64ToString(kTestContent.size()), | 1038 base::Int64ToString(kTestContent.size()), |
| 1039 http_request_.headers["Content-Range"]); | 1039 http_request_.headers["Content-Range"]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1067 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 1067 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 1068 kTestContentType, | 1068 kTestContentType, |
| 1069 kTestContent.size(), | 1069 kTestContent.size(), |
| 1070 "resource_id", // The resource id of the file to be overwritten. | 1070 "resource_id", // The resource id of the file to be overwritten. |
| 1071 kTestETag, | 1071 kTestETag, |
| 1072 CreateComposedCallback( | 1072 CreateComposedCallback( |
| 1073 base::Bind(&test_util::RunAndQuit), | 1073 base::Bind(&test_util::RunAndQuit), |
| 1074 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1074 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1075 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 1075 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 1076 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1076 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1077 MessageLoop::current()->Run(); | 1077 base::MessageLoop::current()->Run(); |
| 1078 | 1078 |
| 1079 EXPECT_EQ(HTTP_SUCCESS, error); | 1079 EXPECT_EQ(HTTP_SUCCESS, error); |
| 1080 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); | 1080 EXPECT_EQ(kTestUploadExistingFilePath, upload_url.path()); |
| 1081 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1081 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1082 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1082 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1083 http_request_.headers["X-Upload-Content-Length"]); | 1083 http_request_.headers["X-Upload-Content-Length"]); |
| 1084 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); | 1084 EXPECT_EQ(kTestETag, http_request_.headers["If-Match"]); |
| 1085 | 1085 |
| 1086 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1086 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1087 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1087 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1107 kTestContent.size(), // content_length, | 1107 kTestContent.size(), // content_length, |
| 1108 kTestContentType, | 1108 kTestContentType, |
| 1109 buffer, | 1109 buffer, |
| 1110 CreateComposedCallback( | 1110 CreateComposedCallback( |
| 1111 base::Bind(&test_util::RunAndQuit), | 1111 base::Bind(&test_util::RunAndQuit), |
| 1112 test_util::CreateCopyResultCallback(&response, &new_entry)), | 1112 test_util::CreateCopyResultCallback(&response, &new_entry)), |
| 1113 ProgressCallback()); | 1113 ProgressCallback()); |
| 1114 resume_operation->Start( | 1114 resume_operation->Start( |
| 1115 kTestDriveApiAuthToken, kTestUserAgent, | 1115 kTestDriveApiAuthToken, kTestUserAgent, |
| 1116 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1116 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1117 MessageLoop::current()->Run(); | 1117 base::MessageLoop::current()->Run(); |
| 1118 | 1118 |
| 1119 // METHOD_PUT should be used to upload data. | 1119 // METHOD_PUT should be used to upload data. |
| 1120 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1120 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1121 // Request should go to the upload URL. | 1121 // Request should go to the upload URL. |
| 1122 EXPECT_EQ(upload_url.path(), http_request_.relative_url); | 1122 EXPECT_EQ(upload_url.path(), http_request_.relative_url); |
| 1123 // Content-Range header should be added. | 1123 // Content-Range header should be added. |
| 1124 EXPECT_EQ("bytes 0-" + | 1124 EXPECT_EQ("bytes 0-" + |
| 1125 base::Int64ToString(kTestContent.size() - 1) + "/" + | 1125 base::Int64ToString(kTestContent.size() - 1) + "/" + |
| 1126 base::Int64ToString(kTestContent.size()), | 1126 base::Int64ToString(kTestContent.size()), |
| 1127 http_request_.headers["Content-Range"]); | 1127 http_request_.headers["Content-Range"]); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1155 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), | 1155 base::FilePath(FILE_PATH_LITERAL("drive/file/path")), |
| 1156 kTestContentType, | 1156 kTestContentType, |
| 1157 kTestContent.size(), | 1157 kTestContent.size(), |
| 1158 "resource_id", // The resource id of the file to be overwritten. | 1158 "resource_id", // The resource id of the file to be overwritten. |
| 1159 "Conflicting-etag", | 1159 "Conflicting-etag", |
| 1160 CreateComposedCallback( | 1160 CreateComposedCallback( |
| 1161 base::Bind(&test_util::RunAndQuit), | 1161 base::Bind(&test_util::RunAndQuit), |
| 1162 test_util::CreateCopyResultCallback(&error, &upload_url))); | 1162 test_util::CreateCopyResultCallback(&error, &upload_url))); |
| 1163 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, | 1163 operation->Start(kTestDriveApiAuthToken, kTestUserAgent, |
| 1164 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); | 1164 base::Bind(&test_util::DoNothingForReAuthenticateCallback)); |
| 1165 MessageLoop::current()->Run(); | 1165 base::MessageLoop::current()->Run(); |
| 1166 | 1166 |
| 1167 EXPECT_EQ(HTTP_PRECONDITION, error); | 1167 EXPECT_EQ(HTTP_PRECONDITION, error); |
| 1168 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); | 1168 EXPECT_EQ(kTestContentType, http_request_.headers["X-Upload-Content-Type"]); |
| 1169 EXPECT_EQ(base::Int64ToString(kTestContent.size()), | 1169 EXPECT_EQ(base::Int64ToString(kTestContent.size()), |
| 1170 http_request_.headers["X-Upload-Content-Length"]); | 1170 http_request_.headers["X-Upload-Content-Length"]); |
| 1171 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); | 1171 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); |
| 1172 | 1172 |
| 1173 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); | 1173 EXPECT_EQ(test_server::METHOD_PUT, http_request_.method); |
| 1174 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1174 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| 1175 http_request_.relative_url); | 1175 http_request_.relative_url); |
| 1176 EXPECT_TRUE(http_request_.has_content); | 1176 EXPECT_TRUE(http_request_.has_content); |
| 1177 EXPECT_TRUE(http_request_.content.empty()); | 1177 EXPECT_TRUE(http_request_.content.empty()); |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 } // namespace google_apis | 1180 } // namespace google_apis |
| OLD | NEW |