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

Side by Side Diff: sync/internal_api/attachments/fake_attachment_downloader_unittest.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
OLDNEW
(Empty)
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.
4
5 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h"
12 #include "sync/api/attachments/attachment.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace syncer {
16
17 class FakeAttachmentDownloaderTest : public testing::Test {
18 protected:
19 FakeAttachmentDownloaderTest() {}
20
21 void SetUp() override {}
22
23 void TearDown() override {}
24
25 AttachmentDownloader* downloader() {
26 return &attachment_downloader_;
27 }
28
29 AttachmentDownloader::DownloadCallback download_callback() {
30 return base::Bind(&FakeAttachmentDownloaderTest::DownloadDone,
31 base::Unretained(this));
32 }
33
34 const std::vector<AttachmentDownloader::DownloadResult>& download_results() {
35 return download_results_;
36 }
37
38 void RunMessageLoop() {
39 base::RunLoop run_loop;
40 run_loop.RunUntilIdle();
41 }
42
43 private:
44 void DownloadDone(const AttachmentDownloader::DownloadResult& result,
45 std::unique_ptr<Attachment> attachment) {
46 download_results_.push_back(result);
47 }
48
49 base::MessageLoop message_loop_;
50 FakeAttachmentDownloader attachment_downloader_;
51 std::vector<AttachmentDownloader::DownloadResult> download_results_;
52 };
53
54 TEST_F(FakeAttachmentDownloaderTest, DownloadAttachment) {
55 AttachmentId attachment_id = AttachmentId::Create(0, 0);
56 downloader()->DownloadAttachment(attachment_id, download_callback());
57 RunMessageLoop();
58 EXPECT_EQ(1U, download_results().size());
59 EXPECT_EQ(AttachmentDownloader::DOWNLOAD_SUCCESS, download_results()[0]);
60 }
61
62 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/fake_attachment_downloader.cc ('k') | sync/internal_api/attachments/fake_attachment_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698