summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
diff options
context:
space:
mode:
authorpavely@chromium.org <pavely@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 13:10:32 +0000
committerpavely@chromium.org <pavely@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 13:10:32 +0000
commiteffb2428965667514179fa5ca234959bfc95a19d (patch)
tree0299625b8adb6a730fcfc9fd72ac07b0fcc27a7d /sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
parent66613bc0c8f94a325bacad2c2f65e50ebcbf6637 (diff)
downloadchromium_src-effb2428965667514179fa5ca234959bfc95a19d.zip
chromium_src-effb2428965667514179fa5ca234959bfc95a19d.tar.gz
chromium_src-effb2428965667514179fa5ca234959bfc95a19d.tar.bz2
AttachmentDownloader implementation.
This is rudimentary implemenatation of AttachmentDownloader along with fake for tests. BUG=376073 R=maniscalco@chromium.org Review URL: https://codereview.chromium.org/296153014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/attachments/attachment_downloader_impl_unittest.cc')
-rw-r--r--sync/internal_api/attachments/attachment_downloader_impl_unittest.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc b/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
new file mode 100644
index 0000000..240aae17
--- /dev/null
+++ b/sync/internal_api/attachments/attachment_downloader_impl_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/attachments/attachment_downloader_impl.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "sync/api/attachments/attachment.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace syncer {
+
+class AttachmentDownloaderImplTest : public testing::Test {
+ protected:
+ AttachmentDownloaderImplTest() {}
+
+ virtual void SetUp() OVERRIDE {}
+
+ virtual void TearDown() OVERRIDE {}
+
+ AttachmentDownloader* downloader() {
+ return &attachment_downloader_;
+ }
+
+ AttachmentDownloader::DownloadCallback download_callback() {
+ return base::Bind(&AttachmentDownloaderImplTest::DownloadDone,
+ base::Unretained(this));
+ }
+
+ const std::vector<AttachmentDownloader::DownloadResult>& download_results() {
+ return download_results_;
+ }
+
+ void RunMessageLoop() {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+
+ private:
+ void DownloadDone(const AttachmentDownloader::DownloadResult& result,
+ scoped_ptr<Attachment> attachment) {
+ download_results_.push_back(result);
+ }
+
+ base::MessageLoop message_loop_;
+ AttachmentDownloaderImpl attachment_downloader_;
+ std::vector<AttachmentDownloader::DownloadResult> download_results_;
+};
+
+TEST_F(AttachmentDownloaderImplTest, DownloadAttachment_Fail) {
+ AttachmentId attachment_id = AttachmentId::Create();
+ downloader()->DownloadAttachment(attachment_id, download_callback());
+ RunMessageLoop();
+ EXPECT_EQ(1U, download_results().size());
+ EXPECT_EQ(AttachmentDownloader::DOWNLOAD_UNSPECIFIED_ERROR,
+ download_results()[0]);
+}
+
+} // namespace syncer