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/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/thread_task_runner_handle.h" | |
12 #include "base/timer/mock_timer.h" | 11 #include "base/timer/mock_timer.h" |
13 #include "sync/api/attachments/attachment_store_backend.h" | |
14 #include "sync/internal_api/public/attachments/attachment_util.h" | 12 #include "sync/internal_api/public/attachments/attachment_util.h" |
15 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 13 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
16 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" | 14 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" |
17 #include "testing/gmock/include/gmock/gmock-matchers.h" | 15 #include "testing/gmock/include/gmock/gmock-matchers.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
19 | 17 |
20 namespace syncer { | 18 namespace syncer { |
21 | 19 |
22 namespace { | 20 namespace { |
23 | 21 |
24 class MockAttachmentStoreBackend | 22 class MockAttachmentStore : public AttachmentStore, |
25 : public AttachmentStoreBackend, | 23 public base::SupportsWeakPtr<MockAttachmentStore> { |
26 public base::SupportsWeakPtr<MockAttachmentStoreBackend> { | |
27 public: | 24 public: |
28 MockAttachmentStoreBackend( | 25 MockAttachmentStore() {} |
29 const scoped_refptr<base::SequencedTaskRunner>& callback_task_runner) | |
30 : AttachmentStoreBackend(callback_task_runner) {} | |
31 | 26 |
32 ~MockAttachmentStoreBackend() override {} | 27 void Init(const InitCallback& callback) override { |
33 | 28 } |
34 void Init(const AttachmentStore::InitCallback& callback) override {} | |
35 | 29 |
36 void Read(const AttachmentIdList& ids, | 30 void Read(const AttachmentIdList& ids, |
37 const AttachmentStore::ReadCallback& callback) override { | 31 const ReadCallback& callback) override { |
38 read_ids.push_back(ids); | 32 read_ids.push_back(ids); |
39 read_callbacks.push_back(callback); | 33 read_callbacks.push_back(callback); |
40 } | 34 } |
41 | 35 |
42 void Write(AttachmentStore::AttachmentReferrer referrer, | 36 void Write(const AttachmentList& attachments, |
43 const AttachmentList& attachments, | 37 const WriteCallback& callback) override { |
44 const AttachmentStore::WriteCallback& callback) override { | |
45 write_attachments.push_back(attachments); | 38 write_attachments.push_back(attachments); |
46 write_callbacks.push_back(callback); | 39 write_callbacks.push_back(callback); |
47 } | 40 } |
48 | 41 |
49 void Drop(AttachmentStore::AttachmentReferrer referrer, | 42 void Drop(const AttachmentIdList& ids, |
50 const AttachmentIdList& ids, | 43 const DropCallback& callback) override { |
51 const AttachmentStore::DropCallback& callback) override { | |
52 NOTREACHED(); | 44 NOTREACHED(); |
53 } | 45 } |
54 | 46 |
55 void ReadMetadata( | 47 void ReadMetadata(const AttachmentIdList& ids, |
56 const AttachmentIdList& ids, | 48 const ReadMetadataCallback& callback) override { |
57 const AttachmentStore::ReadMetadataCallback& callback) override { | |
58 NOTREACHED(); | 49 NOTREACHED(); |
59 } | 50 } |
60 | 51 |
61 void ReadAllMetadata( | 52 void ReadAllMetadata(const ReadMetadataCallback& callback) override { |
62 AttachmentStore::AttachmentReferrer referrer, | |
63 const AttachmentStore::ReadMetadataCallback& callback) override { | |
64 NOTREACHED(); | 53 NOTREACHED(); |
65 } | 54 } |
66 | 55 |
67 // Respond to Read request. Attachments found in local_attachments should be | 56 // Respond to Read request. Attachments found in local_attachments should be |
68 // returned, everything else should be reported unavailable. | 57 // returned, everything else should be reported unavailable. |
69 void RespondToRead(const AttachmentIdSet& local_attachments) { | 58 void RespondToRead(const AttachmentIdSet& local_attachments) { |
70 scoped_refptr<base::RefCountedString> data = new base::RefCountedString(); | 59 scoped_refptr<base::RefCountedString> data = new base::RefCountedString(); |
71 AttachmentStore::ReadCallback callback = read_callbacks.back(); | 60 ReadCallback callback = read_callbacks.back(); |
72 AttachmentIdList ids = read_ids.back(); | 61 AttachmentIdList ids = read_ids.back(); |
73 read_callbacks.pop_back(); | 62 read_callbacks.pop_back(); |
74 read_ids.pop_back(); | 63 read_ids.pop_back(); |
75 | 64 |
76 scoped_ptr<AttachmentMap> attachments(new AttachmentMap()); | 65 scoped_ptr<AttachmentMap> attachments(new AttachmentMap()); |
77 scoped_ptr<AttachmentIdList> unavailable_attachments( | 66 scoped_ptr<AttachmentIdList> unavailable_attachments( |
78 new AttachmentIdList()); | 67 new AttachmentIdList()); |
79 for (AttachmentIdList::const_iterator iter = ids.begin(); iter != ids.end(); | 68 for (AttachmentIdList::const_iterator iter = ids.begin(); iter != ids.end(); |
80 ++iter) { | 69 ++iter) { |
81 if (local_attachments.find(*iter) != local_attachments.end()) { | 70 if (local_attachments.find(*iter) != local_attachments.end()) { |
82 uint32_t crc32c = ComputeCrc32c(data); | 71 uint32_t crc32c = ComputeCrc32c(data); |
83 Attachment attachment = | 72 Attachment attachment = |
84 Attachment::CreateFromParts(*iter, data, crc32c); | 73 Attachment::CreateFromParts(*iter, data, crc32c); |
85 attachments->insert(std::make_pair(*iter, attachment)); | 74 attachments->insert(std::make_pair(*iter, attachment)); |
86 } else { | 75 } else { |
87 unavailable_attachments->push_back(*iter); | 76 unavailable_attachments->push_back(*iter); |
88 } | 77 } |
89 } | 78 } |
90 AttachmentStore::Result result = unavailable_attachments->empty() | 79 Result result = |
91 ? AttachmentStore::SUCCESS | 80 unavailable_attachments->empty() ? SUCCESS : UNSPECIFIED_ERROR; |
92 : AttachmentStore::UNSPECIFIED_ERROR; | |
93 | 81 |
94 base::MessageLoop::current()->PostTask( | 82 base::MessageLoop::current()->PostTask( |
95 FROM_HERE, | 83 FROM_HERE, |
96 base::Bind(callback, | 84 base::Bind(callback, |
97 result, | 85 result, |
98 base::Passed(&attachments), | 86 base::Passed(&attachments), |
99 base::Passed(&unavailable_attachments))); | 87 base::Passed(&unavailable_attachments))); |
100 } | 88 } |
101 | 89 |
102 // Respond to Write request with |result|. | 90 // Respond to Write request with |result|. |
103 void RespondToWrite(const AttachmentStore::Result& result) { | 91 void RespondToWrite(const Result& result) { |
104 AttachmentStore::WriteCallback callback = write_callbacks.back(); | 92 WriteCallback callback = write_callbacks.back(); |
105 AttachmentList attachments = write_attachments.back(); | 93 AttachmentList attachments = write_attachments.back(); |
106 write_callbacks.pop_back(); | 94 write_callbacks.pop_back(); |
107 write_attachments.pop_back(); | 95 write_attachments.pop_back(); |
108 base::MessageLoop::current()->PostTask(FROM_HERE, | 96 base::MessageLoop::current()->PostTask(FROM_HERE, |
109 base::Bind(callback, result)); | 97 base::Bind(callback, result)); |
110 } | 98 } |
111 | 99 |
112 std::vector<AttachmentIdList> read_ids; | 100 std::vector<AttachmentIdList> read_ids; |
113 std::vector<AttachmentStore::ReadCallback> read_callbacks; | 101 std::vector<ReadCallback> read_callbacks; |
114 std::vector<AttachmentList> write_attachments; | 102 std::vector<AttachmentList> write_attachments; |
115 std::vector<AttachmentStore::WriteCallback> write_callbacks; | 103 std::vector<WriteCallback> write_callbacks; |
116 | 104 |
117 private: | 105 private: |
118 DISALLOW_COPY_AND_ASSIGN(MockAttachmentStoreBackend); | 106 ~MockAttachmentStore() override {} |
| 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(MockAttachmentStore); |
119 }; | 109 }; |
120 | 110 |
121 class MockAttachmentDownloader | 111 class MockAttachmentDownloader |
122 : public AttachmentDownloader, | 112 : public AttachmentDownloader, |
123 public base::SupportsWeakPtr<MockAttachmentDownloader> { | 113 public base::SupportsWeakPtr<MockAttachmentDownloader> { |
124 public: | 114 public: |
125 MockAttachmentDownloader() {} | 115 MockAttachmentDownloader() {} |
126 | 116 |
127 void DownloadAttachment(const AttachmentId& id, | 117 void DownloadAttachment(const AttachmentId& id, |
128 const DownloadCallback& callback) override { | 118 const DownloadCallback& callback) override { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 178 |
189 void SetUp() override { | 179 void SetUp() override { |
190 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); | 180 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); |
191 InitializeAttachmentService(make_scoped_ptr(new MockAttachmentUploader()), | 181 InitializeAttachmentService(make_scoped_ptr(new MockAttachmentUploader()), |
192 make_scoped_ptr(new MockAttachmentDownloader()), | 182 make_scoped_ptr(new MockAttachmentDownloader()), |
193 this); | 183 this); |
194 } | 184 } |
195 | 185 |
196 void TearDown() override { | 186 void TearDown() override { |
197 attachment_service_.reset(); | 187 attachment_service_.reset(); |
198 RunLoop(); | 188 ASSERT_FALSE(attachment_store_); |
199 ASSERT_FALSE(attachment_store_backend_); | |
200 ASSERT_FALSE(attachment_uploader_); | 189 ASSERT_FALSE(attachment_uploader_); |
201 ASSERT_FALSE(attachment_downloader_); | 190 ASSERT_FALSE(attachment_downloader_); |
202 } | 191 } |
203 | 192 |
204 // AttachmentService::Delegate implementation. | 193 // AttachmentService::Delegate implementation. |
205 void OnAttachmentUploaded(const AttachmentId& attachment_id) override { | 194 void OnAttachmentUploaded(const AttachmentId& attachment_id) override { |
206 on_attachment_uploaded_list_.push_back(attachment_id); | 195 on_attachment_uploaded_list_.push_back(attachment_id); |
207 } | 196 } |
208 | 197 |
209 void InitializeAttachmentService( | 198 void InitializeAttachmentService( |
210 scoped_ptr<MockAttachmentUploader> uploader, | 199 scoped_ptr<MockAttachmentUploader> uploader, |
211 scoped_ptr<MockAttachmentDownloader> downloader, | 200 scoped_ptr<MockAttachmentDownloader> downloader, |
212 AttachmentService::Delegate* delegate) { | 201 AttachmentService::Delegate* delegate) { |
213 // Initialize mock attachment store | 202 scoped_refptr<MockAttachmentStore> attachment_store( |
214 scoped_refptr<base::SingleThreadTaskRunner> runner = | 203 new MockAttachmentStore()); |
215 base::ThreadTaskRunnerHandle::Get(); | 204 attachment_store_ = attachment_store->AsWeakPtr(); |
216 scoped_ptr<MockAttachmentStoreBackend> attachment_store_backend( | |
217 new MockAttachmentStoreBackend(runner)); | |
218 attachment_store_backend_ = attachment_store_backend->AsWeakPtr(); | |
219 scoped_ptr<AttachmentStore> attachment_store = | |
220 AttachmentStore::CreateMockStoreForTest( | |
221 attachment_store_backend.Pass()); | |
222 | 205 |
223 if (uploader.get()) { | 206 if (uploader.get()) { |
224 attachment_uploader_ = uploader->AsWeakPtr(); | 207 attachment_uploader_ = uploader->AsWeakPtr(); |
225 } | 208 } |
226 if (downloader.get()) { | 209 if (downloader.get()) { |
227 attachment_downloader_ = downloader->AsWeakPtr(); | 210 attachment_downloader_ = downloader->AsWeakPtr(); |
228 } | 211 } |
229 attachment_service_.reset(new AttachmentServiceImpl( | 212 attachment_service_.reset( |
230 attachment_store.Pass(), uploader.Pass(), downloader.Pass(), delegate, | 213 new AttachmentServiceImpl(attachment_store, |
231 base::TimeDelta::FromMinutes(1), base::TimeDelta::FromMinutes(8))); | 214 uploader.Pass(), |
| 215 downloader.Pass(), |
| 216 delegate, |
| 217 base::TimeDelta::FromMinutes(1), |
| 218 base::TimeDelta::FromMinutes(8))); |
232 | 219 |
233 scoped_ptr<base::MockTimer> timer_to_pass( | 220 scoped_ptr<base::MockTimer> timer_to_pass( |
234 new base::MockTimer(false, false)); | 221 new base::MockTimer(false, false)); |
235 mock_timer_ = timer_to_pass.get(); | 222 mock_timer_ = timer_to_pass.get(); |
236 attachment_service_->SetTimerForTest(timer_to_pass.Pass()); | 223 attachment_service_->SetTimerForTest(timer_to_pass.Pass()); |
237 } | 224 } |
238 | 225 |
239 AttachmentService* attachment_service() { return attachment_service_.get(); } | 226 AttachmentService* attachment_service() { return attachment_service_.get(); } |
240 | 227 |
241 base::MockTimer* mock_timer() { return mock_timer_; } | 228 base::MockTimer* mock_timer() { return mock_timer_; } |
(...skipping 11 matching lines...) Expand all Loading... |
253 | 240 |
254 void RunLoop() { | 241 void RunLoop() { |
255 base::RunLoop run_loop; | 242 base::RunLoop run_loop; |
256 run_loop.RunUntilIdle(); | 243 run_loop.RunUntilIdle(); |
257 } | 244 } |
258 | 245 |
259 void RunLoopAndFireTimer() { | 246 void RunLoopAndFireTimer() { |
260 RunLoop(); | 247 RunLoop(); |
261 if (mock_timer()->IsRunning()) { | 248 if (mock_timer()->IsRunning()) { |
262 mock_timer()->Fire(); | 249 mock_timer()->Fire(); |
263 RunLoop(); | |
264 } | 250 } |
| 251 RunLoop(); |
265 } | 252 } |
266 | 253 |
267 const std::vector<AttachmentService::GetOrDownloadResult>& | 254 const std::vector<AttachmentService::GetOrDownloadResult>& |
268 download_results() const { | 255 download_results() const { |
269 return download_results_; | 256 return download_results_; |
270 } | 257 } |
271 | 258 |
272 const AttachmentMap& last_download_attachments() const { | 259 const AttachmentMap& last_download_attachments() const { |
273 return *last_download_attachments_.get(); | 260 return *last_download_attachments_.get(); |
274 } | 261 } |
275 | 262 |
276 net::NetworkChangeNotifier* network_change_notifier() { | 263 net::NetworkChangeNotifier* network_change_notifier() { |
277 return network_change_notifier_.get(); | 264 return network_change_notifier_.get(); |
278 } | 265 } |
279 | 266 |
280 MockAttachmentStoreBackend* store() { | 267 MockAttachmentStore* store() { return attachment_store_.get(); } |
281 return attachment_store_backend_.get(); | |
282 } | |
283 | 268 |
284 MockAttachmentDownloader* downloader() { | 269 MockAttachmentDownloader* downloader() { |
285 return attachment_downloader_.get(); | 270 return attachment_downloader_.get(); |
286 } | 271 } |
287 | 272 |
288 MockAttachmentUploader* uploader() { | 273 MockAttachmentUploader* uploader() { |
289 return attachment_uploader_.get(); | 274 return attachment_uploader_.get(); |
290 } | 275 } |
291 | 276 |
292 const std::vector<AttachmentId>& on_attachment_uploaded_list() const { | 277 const std::vector<AttachmentId>& on_attachment_uploaded_list() const { |
293 return on_attachment_uploaded_list_; | 278 return on_attachment_uploaded_list_; |
294 } | 279 } |
295 | 280 |
296 private: | 281 private: |
297 base::MessageLoop message_loop_; | 282 base::MessageLoop message_loop_; |
298 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 283 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
299 base::WeakPtr<MockAttachmentStoreBackend> attachment_store_backend_; | 284 base::WeakPtr<MockAttachmentStore> attachment_store_; |
300 base::WeakPtr<MockAttachmentDownloader> attachment_downloader_; | 285 base::WeakPtr<MockAttachmentDownloader> attachment_downloader_; |
301 base::WeakPtr<MockAttachmentUploader> attachment_uploader_; | 286 base::WeakPtr<MockAttachmentUploader> attachment_uploader_; |
302 scoped_ptr<AttachmentServiceImpl> attachment_service_; | 287 scoped_ptr<AttachmentServiceImpl> attachment_service_; |
303 base::MockTimer* mock_timer_; // not owned | 288 base::MockTimer* mock_timer_; // not owned |
304 | 289 |
305 std::vector<AttachmentService::GetOrDownloadResult> download_results_; | 290 std::vector<AttachmentService::GetOrDownloadResult> download_results_; |
306 scoped_ptr<AttachmentMap> last_download_attachments_; | 291 scoped_ptr<AttachmentMap> last_download_attachments_; |
307 std::vector<AttachmentId> on_attachment_uploaded_list_; | 292 std::vector<AttachmentId> on_attachment_uploaded_list_; |
308 }; | 293 }; |
309 | 294 |
| 295 TEST_F(AttachmentServiceImplTest, GetStore) { |
| 296 EXPECT_EQ(store(), attachment_service()->GetStore()); |
| 297 } |
| 298 |
310 TEST_F(AttachmentServiceImplTest, GetOrDownload_EmptyAttachmentList) { | 299 TEST_F(AttachmentServiceImplTest, GetOrDownload_EmptyAttachmentList) { |
311 AttachmentIdList attachment_ids; | 300 AttachmentIdList attachment_ids; |
312 attachment_service()->GetOrDownloadAttachments(attachment_ids, | 301 attachment_service()->GetOrDownloadAttachments(attachment_ids, |
313 download_callback()); | 302 download_callback()); |
314 RunLoop(); | |
315 store()->RespondToRead(AttachmentIdSet()); | 303 store()->RespondToRead(AttachmentIdSet()); |
316 | 304 |
317 RunLoop(); | 305 RunLoop(); |
318 EXPECT_EQ(1U, download_results().size()); | 306 EXPECT_EQ(1U, download_results().size()); |
319 EXPECT_EQ(0U, last_download_attachments().size()); | 307 EXPECT_EQ(0U, last_download_attachments().size()); |
320 } | 308 } |
321 | 309 |
322 TEST_F(AttachmentServiceImplTest, GetOrDownload_Local) { | 310 TEST_F(AttachmentServiceImplTest, GetOrDownload_Local) { |
323 AttachmentIdList attachment_ids; | 311 AttachmentIdList attachment_ids; |
324 attachment_ids.push_back(AttachmentId::Create()); | 312 attachment_ids.push_back(AttachmentId::Create()); |
325 attachment_service()->GetOrDownloadAttachments(attachment_ids, | 313 attachment_service()->GetOrDownloadAttachments(attachment_ids, |
326 download_callback()); | 314 download_callback()); |
327 AttachmentIdSet local_attachments; | 315 AttachmentIdSet local_attachments; |
328 local_attachments.insert(attachment_ids[0]); | 316 local_attachments.insert(attachment_ids[0]); |
329 RunLoop(); | |
330 store()->RespondToRead(local_attachments); | 317 store()->RespondToRead(local_attachments); |
331 | 318 |
332 RunLoop(); | 319 RunLoop(); |
333 EXPECT_EQ(1U, download_results().size()); | 320 EXPECT_EQ(1U, download_results().size()); |
334 EXPECT_EQ(1U, last_download_attachments().size()); | 321 EXPECT_EQ(1U, last_download_attachments().size()); |
335 EXPECT_TRUE(last_download_attachments().find(attachment_ids[0]) != | 322 EXPECT_TRUE(last_download_attachments().find(attachment_ids[0]) != |
336 last_download_attachments().end()); | 323 last_download_attachments().end()); |
337 } | 324 } |
338 | 325 |
339 TEST_F(AttachmentServiceImplTest, GetOrDownload_LocalRemoteUnavailable) { | 326 TEST_F(AttachmentServiceImplTest, GetOrDownload_LocalRemoteUnavailable) { |
340 // Create attachment list with 4 ids. | 327 // Create attachment list with 4 ids. |
341 AttachmentIdList attachment_ids; | 328 AttachmentIdList attachment_ids; |
342 attachment_ids.push_back(AttachmentId::Create()); | 329 attachment_ids.push_back(AttachmentId::Create()); |
343 attachment_ids.push_back(AttachmentId::Create()); | 330 attachment_ids.push_back(AttachmentId::Create()); |
344 attachment_ids.push_back(AttachmentId::Create()); | 331 attachment_ids.push_back(AttachmentId::Create()); |
345 attachment_ids.push_back(AttachmentId::Create()); | 332 attachment_ids.push_back(AttachmentId::Create()); |
346 // Call attachment service. | 333 // Call attachment service. |
347 attachment_service()->GetOrDownloadAttachments(attachment_ids, | 334 attachment_service()->GetOrDownloadAttachments(attachment_ids, |
348 download_callback()); | 335 download_callback()); |
349 RunLoop(); | |
350 // Ensure AttachmentStore is called. | 336 // Ensure AttachmentStore is called. |
351 EXPECT_FALSE(store()->read_ids.empty()); | 337 EXPECT_FALSE(store()->read_ids.empty()); |
352 | 338 |
353 // Make AttachmentStore return only attachment 0. | 339 // Make AttachmentStore return only attachment 0. |
354 AttachmentIdSet local_attachments; | 340 AttachmentIdSet local_attachments; |
355 local_attachments.insert(attachment_ids[0]); | 341 local_attachments.insert(attachment_ids[0]); |
356 store()->RespondToRead(local_attachments); | 342 store()->RespondToRead(local_attachments); |
357 RunLoop(); | 343 RunLoop(); |
358 // Ensure Downloader called with right attachment ids | 344 // Ensure Downloader called with right attachment ids |
359 EXPECT_EQ(3U, downloader()->download_requests.size()); | 345 EXPECT_EQ(3U, downloader()->download_requests.size()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // No downloader. | 391 // No downloader. |
406 InitializeAttachmentService( | 392 InitializeAttachmentService( |
407 make_scoped_ptr<MockAttachmentUploader>(new MockAttachmentUploader()), | 393 make_scoped_ptr<MockAttachmentUploader>(new MockAttachmentUploader()), |
408 make_scoped_ptr<MockAttachmentDownloader>(NULL), | 394 make_scoped_ptr<MockAttachmentDownloader>(NULL), |
409 this); | 395 this); |
410 | 396 |
411 AttachmentIdList attachment_ids; | 397 AttachmentIdList attachment_ids; |
412 attachment_ids.push_back(AttachmentId::Create()); | 398 attachment_ids.push_back(AttachmentId::Create()); |
413 attachment_service()->GetOrDownloadAttachments(attachment_ids, | 399 attachment_service()->GetOrDownloadAttachments(attachment_ids, |
414 download_callback()); | 400 download_callback()); |
415 RunLoop(); | |
416 EXPECT_FALSE(store()->read_ids.empty()); | 401 EXPECT_FALSE(store()->read_ids.empty()); |
417 | 402 |
418 AttachmentIdSet local_attachments; | 403 AttachmentIdSet local_attachments; |
419 store()->RespondToRead(local_attachments); | 404 store()->RespondToRead(local_attachments); |
420 RunLoop(); | 405 RunLoop(); |
421 ASSERT_EQ(1U, download_results().size()); | 406 ASSERT_EQ(1U, download_results().size()); |
422 EXPECT_EQ(AttachmentService::GET_UNSPECIFIED_ERROR, download_results()[0]); | 407 EXPECT_EQ(AttachmentService::GET_UNSPECIFIED_ERROR, download_results()[0]); |
423 EXPECT_TRUE(last_download_attachments().empty()); | 408 EXPECT_TRUE(last_download_attachments().empty()); |
424 } | 409 } |
425 | 410 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( | 586 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( |
602 net::NetworkChangeNotifier::CONNECTION_WIFI); | 587 net::NetworkChangeNotifier::CONNECTION_WIFI); |
603 RunLoop(); | 588 RunLoop(); |
604 | 589 |
605 // No longer in backoff. | 590 // No longer in backoff. |
606 ASSERT_TRUE(mock_timer()->IsRunning()); | 591 ASSERT_TRUE(mock_timer()->IsRunning()); |
607 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); | 592 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); |
608 } | 593 } |
609 | 594 |
610 } // namespace syncer | 595 } // namespace syncer |
OLD | NEW |