1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
10 #include "sync/api/attachments/attachment.h"
11 #include "testing/gtest/include/gtest/gtest.h"
15 class FakeAttachmentDownloaderTest
: public testing::Test
{
17 FakeAttachmentDownloaderTest() {}
19 void SetUp() override
{}
21 void TearDown() override
{}
23 AttachmentDownloader
* downloader() {
24 return &attachment_downloader_
;
27 AttachmentDownloader::DownloadCallback
download_callback() {
28 return base::Bind(&FakeAttachmentDownloaderTest::DownloadDone
,
29 base::Unretained(this));
32 const std::vector
<AttachmentDownloader::DownloadResult
>& download_results() {
33 return download_results_
;
36 void RunMessageLoop() {
37 base::RunLoop run_loop
;
38 run_loop
.RunUntilIdle();
42 void DownloadDone(const AttachmentDownloader::DownloadResult
& result
,
43 scoped_ptr
<Attachment
> attachment
) {
44 download_results_
.push_back(result
);
47 base::MessageLoop message_loop_
;
48 FakeAttachmentDownloader attachment_downloader_
;
49 std::vector
<AttachmentDownloader::DownloadResult
> download_results_
;
52 TEST_F(FakeAttachmentDownloaderTest
, DownloadAttachment
) {
53 AttachmentId attachment_id
= AttachmentId::Create(0, 0);
54 downloader()->DownloadAttachment(attachment_id
, download_callback());
56 EXPECT_EQ(1U, download_results().size());
57 EXPECT_EQ(AttachmentDownloader::DOWNLOAD_SUCCESS
, download_results()[0]);