Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/google_apis/drive_api_operations_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698