OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 5 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return download_results_; | 35 return download_results_; |
36 } | 36 } |
37 | 37 |
38 void RunMessageLoop() { | 38 void RunMessageLoop() { |
39 base::RunLoop run_loop; | 39 base::RunLoop run_loop; |
40 run_loop.RunUntilIdle(); | 40 run_loop.RunUntilIdle(); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 void DownloadDone(const AttachmentDownloader::DownloadResult& result, | 44 void DownloadDone(const AttachmentDownloader::DownloadResult& result, |
45 scoped_ptr<Attachment> attachment) { | 45 std::unique_ptr<Attachment> attachment) { |
46 download_results_.push_back(result); | 46 download_results_.push_back(result); |
47 } | 47 } |
48 | 48 |
49 base::MessageLoop message_loop_; | 49 base::MessageLoop message_loop_; |
50 FakeAttachmentDownloader attachment_downloader_; | 50 FakeAttachmentDownloader attachment_downloader_; |
51 std::vector<AttachmentDownloader::DownloadResult> download_results_; | 51 std::vector<AttachmentDownloader::DownloadResult> download_results_; |
52 }; | 52 }; |
53 | 53 |
54 TEST_F(FakeAttachmentDownloaderTest, DownloadAttachment) { | 54 TEST_F(FakeAttachmentDownloaderTest, DownloadAttachment) { |
55 AttachmentId attachment_id = AttachmentId::Create(0, 0); | 55 AttachmentId attachment_id = AttachmentId::Create(0, 0); |
56 downloader()->DownloadAttachment(attachment_id, download_callback()); | 56 downloader()->DownloadAttachment(attachment_id, download_callback()); |
57 RunMessageLoop(); | 57 RunMessageLoop(); |
58 EXPECT_EQ(1U, download_results().size()); | 58 EXPECT_EQ(1U, download_results().size()); |
59 EXPECT_EQ(AttachmentDownloader::DOWNLOAD_SUCCESS, download_results()[0]); | 59 EXPECT_EQ(AttachmentDownloader::DOWNLOAD_SUCCESS, download_results()[0]); |
60 } | 60 } |
61 | 61 |
62 } // namespace syncer | 62 } // namespace syncer |
OLD | NEW |