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

Side by Side Diff: chrome/browser/chromeos/drive/drive_scheduler_unittest.cc

Issue 12500008: Eliminate CopyResultsFromDownloadActionCallback(AndQuit). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_operations_server_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/drive_scheduler.h" 5 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 const GURL kContentUrl("https://file_content_url/"); 398 const GURL kContentUrl("https://file_content_url/");
399 const base::FilePath kOutputFilePath = 399 const base::FilePath kOutputFilePath =
400 temp_dir.path().AppendASCII("whatever.txt"); 400 temp_dir.path().AppendASCII("whatever.txt");
401 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR; 401 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR;
402 base::FilePath output_file_path; 402 base::FilePath output_file_path;
403 scheduler_->DownloadFile( 403 scheduler_->DownloadFile(
404 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 404 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
405 kOutputFilePath, 405 kOutputFilePath,
406 kContentUrl, 406 kContentUrl,
407 DriveClientContext(BACKGROUND), 407 DriveClientContext(BACKGROUND),
408 base::Bind(&google_apis::test_util::CopyResultsFromDownloadActionCallback, 408 google_apis::test_util::CreateCopyResultCallback(
409 &download_error, 409 &download_error, &output_file_path),
410 &output_file_path),
411 google_apis::GetContentCallback()); 410 google_apis::GetContentCallback());
412 // Metadata should still work 411 // Metadata should still work
413 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR; 412 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR;
414 scoped_ptr<google_apis::AccountMetadata> account_metadata; 413 scoped_ptr<google_apis::AccountMetadata> account_metadata;
415 414
416 // Try to get the metadata 415 // Try to get the metadata
417 scheduler_->GetAccountMetadata( 416 scheduler_->GetAccountMetadata(
418 google_apis::test_util::CreateCopyResultCallback( 417 google_apis::test_util::CreateCopyResultCallback(
419 &metadata_error, &account_metadata)); 418 &metadata_error, &account_metadata));
420 google_apis::test_util::RunBlockingPoolTask(); 419 google_apis::test_util::RunBlockingPoolTask();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 const GURL kContentUrl("https://file_content_url/"); 452 const GURL kContentUrl("https://file_content_url/");
454 const base::FilePath kOutputFilePath = 453 const base::FilePath kOutputFilePath =
455 temp_dir.path().AppendASCII("whatever.txt"); 454 temp_dir.path().AppendASCII("whatever.txt");
456 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR; 455 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR;
457 base::FilePath output_file_path; 456 base::FilePath output_file_path;
458 scheduler_->DownloadFile( 457 scheduler_->DownloadFile(
459 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 458 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
460 kOutputFilePath, 459 kOutputFilePath,
461 kContentUrl, 460 kContentUrl,
462 DriveClientContext(BACKGROUND), 461 DriveClientContext(BACKGROUND),
463 base::Bind(&google_apis::test_util::CopyResultsFromDownloadActionCallback, 462 google_apis::test_util::CreateCopyResultCallback(
464 &download_error, 463 &download_error, &output_file_path),
465 &output_file_path),
466 google_apis::GetContentCallback()); 464 google_apis::GetContentCallback());
467 // Metadata should still work 465 // Metadata should still work
468 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR; 466 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR;
469 scoped_ptr<google_apis::AccountMetadata> account_metadata; 467 scoped_ptr<google_apis::AccountMetadata> account_metadata;
470 468
471 // Try to get the metadata 469 // Try to get the metadata
472 scheduler_->GetAccountMetadata( 470 scheduler_->GetAccountMetadata(
473 google_apis::test_util::CreateCopyResultCallback( 471 google_apis::test_util::CreateCopyResultCallback(
474 &metadata_error, &account_metadata)); 472 &metadata_error, &account_metadata));
475 google_apis::test_util::RunBlockingPoolTask(); 473 google_apis::test_util::RunBlockingPoolTask();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 const GURL kContentUrl("https://file_content_url/"); 506 const GURL kContentUrl("https://file_content_url/");
509 const base::FilePath kOutputFilePath = 507 const base::FilePath kOutputFilePath =
510 temp_dir.path().AppendASCII("whatever.txt"); 508 temp_dir.path().AppendASCII("whatever.txt");
511 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR; 509 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR;
512 base::FilePath output_file_path; 510 base::FilePath output_file_path;
513 scheduler_->DownloadFile( 511 scheduler_->DownloadFile(
514 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 512 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
515 kOutputFilePath, 513 kOutputFilePath,
516 kContentUrl, 514 kContentUrl,
517 DriveClientContext(BACKGROUND), 515 DriveClientContext(BACKGROUND),
518 base::Bind(&google_apis::test_util::CopyResultsFromDownloadActionCallback, 516 google_apis::test_util::CreateCopyResultCallback(
519 &download_error, 517 &download_error, &output_file_path),
520 &output_file_path),
521 google_apis::GetContentCallback()); 518 google_apis::GetContentCallback());
522 // Metadata should still work 519 // Metadata should still work
523 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR; 520 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR;
524 scoped_ptr<google_apis::AccountMetadata> account_metadata; 521 scoped_ptr<google_apis::AccountMetadata> account_metadata;
525 522
526 // Try to get the metadata 523 // Try to get the metadata
527 scheduler_->GetAccountMetadata( 524 scheduler_->GetAccountMetadata(
528 google_apis::test_util::CreateCopyResultCallback( 525 google_apis::test_util::CreateCopyResultCallback(
529 &metadata_error, &account_metadata)); 526 &metadata_error, &account_metadata));
530 google_apis::test_util::RunBlockingPoolTask(); 527 google_apis::test_util::RunBlockingPoolTask();
(...skipping 24 matching lines...) Expand all
555 const GURL kContentUrl("https://file_content_url/"); 552 const GURL kContentUrl("https://file_content_url/");
556 const base::FilePath kOutputFilePath = 553 const base::FilePath kOutputFilePath =
557 temp_dir.path().AppendASCII("whatever.txt"); 554 temp_dir.path().AppendASCII("whatever.txt");
558 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR; 555 google_apis::GDataErrorCode download_error = google_apis::GDATA_OTHER_ERROR;
559 base::FilePath output_file_path; 556 base::FilePath output_file_path;
560 scheduler_->DownloadFile( 557 scheduler_->DownloadFile(
561 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path 558 base::FilePath::FromUTF8Unsafe("/drive/whatever.txt"), // virtual path
562 kOutputFilePath, 559 kOutputFilePath,
563 kContentUrl, 560 kContentUrl,
564 DriveClientContext(BACKGROUND), 561 DriveClientContext(BACKGROUND),
565 base::Bind(&google_apis::test_util::CopyResultsFromDownloadActionCallback, 562 google_apis::test_util::CreateCopyResultCallback(
566 &download_error, 563 &download_error, &output_file_path),
567 &output_file_path),
568 google_apis::GetContentCallback()); 564 google_apis::GetContentCallback());
569 // Metadata should still work 565 // Metadata should still work
570 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR; 566 google_apis::GDataErrorCode metadata_error = google_apis::GDATA_OTHER_ERROR;
571 scoped_ptr<google_apis::AccountMetadata> account_metadata; 567 scoped_ptr<google_apis::AccountMetadata> account_metadata;
572 568
573 // Try to get the metadata 569 // Try to get the metadata
574 scheduler_->GetAccountMetadata( 570 scheduler_->GetAccountMetadata(
575 google_apis::test_util::CreateCopyResultCallback( 571 google_apis::test_util::CreateCopyResultCallback(
576 &metadata_error, &account_metadata)); 572 &metadata_error, &account_metadata));
577 google_apis::test_util::RunBlockingPoolTask(); 573 google_apis::test_util::RunBlockingPoolTask();
578 574
579 // Check the metadata 575 // Check the metadata
580 ASSERT_EQ(google_apis::HTTP_SUCCESS, metadata_error); 576 ASSERT_EQ(google_apis::HTTP_SUCCESS, metadata_error);
581 ASSERT_TRUE(account_metadata); 577 ASSERT_TRUE(account_metadata);
582 578
583 // Check the download 579 // Check the download
584 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error); 580 EXPECT_EQ(google_apis::HTTP_SUCCESS, download_error);
585 std::string content; 581 std::string content;
586 EXPECT_EQ(output_file_path, kOutputFilePath); 582 EXPECT_EQ(output_file_path, kOutputFilePath);
587 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content)); 583 ASSERT_TRUE(file_util::ReadFileToString(output_file_path, &content));
588 // The content is "x"s of the file size specified in root_feed.json. 584 // The content is "x"s of the file size specified in root_feed.json.
589 EXPECT_EQ("xxxxxxxxxx", content); 585 EXPECT_EQ("xxxxxxxxxx", content);
590 } 586 }
591 587
592 } // namespace drive 588 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google_apis/base_operations_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698