Provide GUID in ONC for all networks in ManagedNetworkConfigurationHandler
[chromium-blink-merge.git] / sync / internal_api / attachments / fake_attachment_downloader_unittest.cc
blob1436a497eb12bd83bd2908e17c352b9cf938e4b7
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"
7 #include "base/bind.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"
13 namespace syncer {
15 class FakeAttachmentDownloaderTest : public testing::Test {
16 protected:
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();
41 private:
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();
54 downloader()->DownloadAttachment(attachment_id, download_callback());
55 RunMessageLoop();
56 EXPECT_EQ(1U, download_results().size());
57 EXPECT_EQ(AttachmentDownloader::DOWNLOAD_SUCCESS, download_results()[0]);
60 } // namespace syncer