| Index: sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
|
| diff --git a/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc b/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
|
| index 1d026eb56a5f6de7e01c241b1e18dd332c30057a..a0f4f98bbb6fd2ee5fc50dc0999b8a1cb226d55a 100644
|
| --- a/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
|
| +++ b/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
|
| @@ -152,7 +152,12 @@ class AttachmentDownloaderImplTest : public testing::Test {
|
| HASH_HEADER_INVALID
|
| };
|
|
|
| - AttachmentDownloaderImplTest() : num_completed_downloads_(0) {}
|
| + AttachmentDownloaderImplTest()
|
| + : num_completed_downloads_(0),
|
| + attachment_id_(
|
| + Attachment::Create(new base::RefCountedStaticMemory(
|
| + kAttachmentContent,
|
| + strlen(kAttachmentContent))).GetId()) {}
|
|
|
| void SetUp() override;
|
| void TearDown() override;
|
| @@ -163,6 +168,8 @@ class AttachmentDownloaderImplTest : public testing::Test {
|
|
|
| int num_completed_downloads() { return num_completed_downloads_; }
|
|
|
| + const AttachmentId attachment_id() const { return attachment_id_; }
|
| +
|
| AttachmentDownloader::DownloadCallback download_callback(
|
| const AttachmentId& id) {
|
| return base::Bind(&AttachmentDownloaderImplTest::DownloadDone,
|
| @@ -193,6 +200,7 @@ class AttachmentDownloaderImplTest : public testing::Test {
|
| scoped_ptr<AttachmentDownloader> attachment_downloader_;
|
| ResultsMap download_results_;
|
| int num_completed_downloads_;
|
| + const AttachmentId attachment_id_;
|
| };
|
|
|
| void AttachmentDownloaderImplTest::SetUp() {
|
| @@ -294,7 +302,7 @@ void AttachmentDownloaderImplTest::AddHashHeader(
|
| }
|
|
|
| TEST_F(AttachmentDownloaderImplTest, HappyCase) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| // DownloadAttachment should trigger RequestAccessToken.
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| RunMessageLoop();
|
| @@ -314,7 +322,7 @@ TEST_F(AttachmentDownloaderImplTest, HappyCase) {
|
| }
|
|
|
| TEST_F(AttachmentDownloaderImplTest, SameIdMultipleDownloads) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| base::HistogramTester histogram_tester;
|
| // Call DownloadAttachment two times for the same id.
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| @@ -351,8 +359,8 @@ TEST_F(AttachmentDownloaderImplTest, SameIdMultipleDownloads) {
|
| }
|
|
|
| TEST_F(AttachmentDownloaderImplTest, RequestAccessTokenFails) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| - AttachmentId id2 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| + AttachmentId id2 = AttachmentId::Create(id1.GetSize(), id1.GetCrc32c());
|
| // Trigger first RequestAccessToken.
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| RunMessageLoop();
|
| @@ -375,7 +383,7 @@ TEST_F(AttachmentDownloaderImplTest, RequestAccessTokenFails) {
|
| }
|
|
|
| TEST_F(AttachmentDownloaderImplTest, URLFetcher_BadToken) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| RunMessageLoop();
|
| // Return valid access token.
|
| @@ -393,7 +401,7 @@ TEST_F(AttachmentDownloaderImplTest, URLFetcher_BadToken) {
|
| }
|
|
|
| TEST_F(AttachmentDownloaderImplTest, URLFetcher_ServiceUnavailable) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| RunMessageLoop();
|
| // Return valid access token.
|
| @@ -413,7 +421,7 @@ TEST_F(AttachmentDownloaderImplTest, URLFetcher_ServiceUnavailable) {
|
| // Verify that if no hash is present on the response the downloader accepts the
|
| // received attachment.
|
| TEST_F(AttachmentDownloaderImplTest, NoHash) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| RunMessageLoop();
|
| token_service()->RespondToAccessTokenRequest(
|
| @@ -426,7 +434,7 @@ TEST_F(AttachmentDownloaderImplTest, NoHash) {
|
| // Verify that if an invalid hash is present on the response the downloader
|
| // treats it as a transient error.
|
| TEST_F(AttachmentDownloaderImplTest, InvalidHash) {
|
| - AttachmentId id1 = AttachmentId::Create();
|
| + AttachmentId id1 = attachment_id();
|
| downloader()->DownloadAttachment(id1, download_callback(id1));
|
| RunMessageLoop();
|
| token_service()->RespondToAccessTokenRequest(
|
|
|