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

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

Issue 601553004: Refactor FakeAttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes after feedback. Handle unittest. Created 6 years, 2 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
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/attachment_service_impl.h" 5 #include "sync/internal_api/public/attachments/attachment_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/timer/mock_timer.h" 11 #include "base/timer/mock_timer.h"
12 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" 12 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h"
13 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" 13 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h"
14 #include "testing/gmock/include/gmock/gmock-matchers.h" 14 #include "testing/gmock/include/gmock/gmock-matchers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace syncer { 17 namespace syncer {
18 18
19 namespace {
20
19 class MockAttachmentStore : public AttachmentStore, 21 class MockAttachmentStore : public AttachmentStore,
20 public base::SupportsWeakPtr<MockAttachmentStore> { 22 public base::SupportsWeakPtr<MockAttachmentStore> {
21 public: 23 public:
22 MockAttachmentStore() {} 24 MockAttachmentStore() {}
23 25
24 virtual void Read(const AttachmentIdList& ids, 26 virtual void Read(const AttachmentIdList& ids,
25 const ReadCallback& callback) OVERRIDE { 27 const ReadCallback& callback) OVERRIDE {
26 read_ids.push_back(ids); 28 read_ids.push_back(ids);
27 read_callbacks.push_back(callback); 29 read_callbacks.push_back(callback);
28 } 30 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 base::MessageLoop::current()->PostTask( 145 base::MessageLoop::current()->PostTask(
144 FROM_HERE, base::Bind(upload_requests[id], result, id)); 146 FROM_HERE, base::Bind(upload_requests[id], result, id));
145 upload_requests.erase(id); 147 upload_requests.erase(id);
146 } 148 }
147 149
148 std::map<AttachmentId, UploadCallback> upload_requests; 150 std::map<AttachmentId, UploadCallback> upload_requests;
149 151
150 DISALLOW_COPY_AND_ASSIGN(MockAttachmentUploader); 152 DISALLOW_COPY_AND_ASSIGN(MockAttachmentUploader);
151 }; 153 };
152 154
155 } // namespace
153 class AttachmentServiceImplTest : public testing::Test, 156 class AttachmentServiceImplTest : public testing::Test,
maniscalco 2014/09/30 00:26:13 nit: new line above?
pavely 2014/09/30 00:30:38 Done.
154 public AttachmentService::Delegate { 157 public AttachmentService::Delegate {
155 protected: 158 protected:
156 AttachmentServiceImplTest() {} 159 AttachmentServiceImplTest() {}
157 160
158 virtual void SetUp() OVERRIDE { 161 virtual void SetUp() OVERRIDE {
159 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); 162 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
160 InitializeAttachmentService(make_scoped_ptr(new MockAttachmentUploader()), 163 InitializeAttachmentService(make_scoped_ptr(new MockAttachmentUploader()),
161 make_scoped_ptr(new MockAttachmentDownloader()), 164 make_scoped_ptr(new MockAttachmentDownloader()),
162 this); 165 this);
163 } 166 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( 548 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests(
546 net::NetworkChangeNotifier::CONNECTION_WIFI); 549 net::NetworkChangeNotifier::CONNECTION_WIFI);
547 RunLoop(); 550 RunLoop();
548 551
549 // No longer in backoff. 552 // No longer in backoff.
550 ASSERT_TRUE(mock_timer()->IsRunning()); 553 ASSERT_TRUE(mock_timer()->IsRunning());
551 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); 554 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay());
552 } 555 }
553 556
554 } // namespace syncer 557 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/attachment_service_impl.cc ('k') | sync/internal_api/attachments/attachment_store_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698