| 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 "components/sync/model_impl/attachments/attachment_service_impl.h" | 5 #include "components/sync/model_impl/attachments/attachment_service_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 EXPECT_TRUE(last_download_attachments().find(attachment_ids[2]) == | 420 EXPECT_TRUE(last_download_attachments().find(attachment_ids[2]) == |
| 421 last_download_attachments().end()); | 421 last_download_attachments().end()); |
| 422 EXPECT_TRUE(last_download_attachments().find(attachment_ids[3]) == | 422 EXPECT_TRUE(last_download_attachments().find(attachment_ids[3]) == |
| 423 last_download_attachments().end()); | 423 last_download_attachments().end()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 TEST_F(AttachmentServiceImplTest, GetOrDownload_NoDownloader) { | 426 TEST_F(AttachmentServiceImplTest, GetOrDownload_NoDownloader) { |
| 427 // No downloader. | 427 // No downloader. |
| 428 InitializeAttachmentService( | 428 InitializeAttachmentService( |
| 429 base::WrapUnique<MockAttachmentUploader>(new MockAttachmentUploader()), | 429 base::WrapUnique<MockAttachmentUploader>(new MockAttachmentUploader()), |
| 430 base::WrapUnique<MockAttachmentDownloader>(NULL), this); | 430 base::WrapUnique<MockAttachmentDownloader>(nullptr), this); |
| 431 | 431 |
| 432 AttachmentIdList attachment_ids; | 432 AttachmentIdList attachment_ids; |
| 433 attachment_ids.push_back(AttachmentId::Create(0, 0)); | 433 attachment_ids.push_back(AttachmentId::Create(0, 0)); |
| 434 attachment_service()->GetOrDownloadAttachments(attachment_ids, | 434 attachment_service()->GetOrDownloadAttachments(attachment_ids, |
| 435 download_callback()); | 435 download_callback()); |
| 436 RunLoop(); | 436 RunLoop(); |
| 437 EXPECT_FALSE(store()->read_ids.empty()); | 437 EXPECT_FALSE(store()->read_ids.empty()); |
| 438 | 438 |
| 439 AttachmentIdSet local_attachments; | 439 AttachmentIdSet local_attachments; |
| 440 store()->RespondToRead(local_attachments); | 440 store()->RespondToRead(local_attachments); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 for (auto iter = attachment_ids.begin(); iter != attachment_ids.end(); | 474 for (auto iter = attachment_ids.begin(); iter != attachment_ids.end(); |
| 475 ++iter) { | 475 ++iter) { |
| 476 EXPECT_THAT(on_attachment_uploaded_list(), testing::Contains(*iter)); | 476 EXPECT_THAT(on_attachment_uploaded_list(), testing::Contains(*iter)); |
| 477 } | 477 } |
| 478 EXPECT_EQ(num_attachments, store()->drop_ids.size()); | 478 EXPECT_EQ(num_attachments, store()->drop_ids.size()); |
| 479 } | 479 } |
| 480 | 480 |
| 481 TEST_F(AttachmentServiceImplTest, UploadAttachments_Success_NoDelegate) { | 481 TEST_F(AttachmentServiceImplTest, UploadAttachments_Success_NoDelegate) { |
| 482 InitializeAttachmentService(base::MakeUnique<MockAttachmentUploader>(), | 482 InitializeAttachmentService(base::MakeUnique<MockAttachmentUploader>(), |
| 483 base::MakeUnique<MockAttachmentDownloader>(), | 483 base::MakeUnique<MockAttachmentDownloader>(), |
| 484 NULL); // No delegate. | 484 nullptr); // No delegate. |
| 485 | 485 |
| 486 AttachmentIdList attachment_ids; | 486 AttachmentIdList attachment_ids; |
| 487 attachment_ids.push_back(AttachmentId::Create(0, 0)); | 487 attachment_ids.push_back(AttachmentId::Create(0, 0)); |
| 488 attachment_service()->UploadAttachments(attachment_ids); | 488 attachment_service()->UploadAttachments(attachment_ids); |
| 489 RunLoopAndFireTimer(); | 489 RunLoopAndFireTimer(); |
| 490 ASSERT_EQ(1U, store()->read_ids.size()); | 490 ASSERT_EQ(1U, store()->read_ids.size()); |
| 491 ASSERT_EQ(0U, uploader()->upload_requests.size()); | 491 ASSERT_EQ(0U, uploader()->upload_requests.size()); |
| 492 store()->RespondToRead(AttachmentIdSetFromList(attachment_ids)); | 492 store()->RespondToRead(AttachmentIdSetFromList(attachment_ids)); |
| 493 RunLoop(); | 493 RunLoop(); |
| 494 ASSERT_EQ(0U, store()->read_ids.size()); | 494 ASSERT_EQ(0U, store()->read_ids.size()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 RunLoop(); | 542 RunLoop(); |
| 543 | 543 |
| 544 // Nothing uploaded. | 544 // Nothing uploaded. |
| 545 EXPECT_EQ(0U, uploader()->upload_requests.size()); | 545 EXPECT_EQ(0U, uploader()->upload_requests.size()); |
| 546 // See that the delegate was never called. | 546 // See that the delegate was never called. |
| 547 ASSERT_EQ(0U, on_attachment_uploaded_list().size()); | 547 ASSERT_EQ(0U, on_attachment_uploaded_list().size()); |
| 548 EXPECT_EQ(num_attachments, store()->drop_ids.size()); | 548 EXPECT_EQ(num_attachments, store()->drop_ids.size()); |
| 549 } | 549 } |
| 550 | 550 |
| 551 TEST_F(AttachmentServiceImplTest, UploadAttachments_NoUploader) { | 551 TEST_F(AttachmentServiceImplTest, UploadAttachments_NoUploader) { |
| 552 InitializeAttachmentService(base::WrapUnique<MockAttachmentUploader>(NULL), | 552 InitializeAttachmentService(base::WrapUnique<MockAttachmentUploader>(nullptr), |
| 553 base::MakeUnique<MockAttachmentDownloader>(), | 553 base::MakeUnique<MockAttachmentDownloader>(), |
| 554 this); | 554 this); |
| 555 | 555 |
| 556 AttachmentIdList attachment_ids; | 556 AttachmentIdList attachment_ids; |
| 557 attachment_ids.push_back(AttachmentId::Create(0, 0)); | 557 attachment_ids.push_back(AttachmentId::Create(0, 0)); |
| 558 attachment_service()->UploadAttachments(attachment_ids); | 558 attachment_service()->UploadAttachments(attachment_ids); |
| 559 RunLoop(); | 559 RunLoop(); |
| 560 EXPECT_EQ(0U, store()->read_ids.size()); | 560 EXPECT_EQ(0U, store()->read_ids.size()); |
| 561 ASSERT_EQ(0U, on_attachment_uploaded_list().size()); | 561 ASSERT_EQ(0U, on_attachment_uploaded_list().size()); |
| 562 EXPECT_EQ(0U, store()->drop_ids.size()); | 562 EXPECT_EQ(0U, store()->drop_ids.size()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( | 628 net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests( |
| 629 net::NetworkChangeNotifier::CONNECTION_WIFI); | 629 net::NetworkChangeNotifier::CONNECTION_WIFI); |
| 630 RunLoop(); | 630 RunLoop(); |
| 631 | 631 |
| 632 // No longer in backoff. | 632 // No longer in backoff. |
| 633 ASSERT_TRUE(mock_timer()->IsRunning()); | 633 ASSERT_TRUE(mock_timer()->IsRunning()); |
| 634 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); | 634 ASSERT_EQ(base::TimeDelta(), mock_timer()->GetCurrentDelay()); |
| 635 } | 635 } |
| 636 | 636 |
| 637 } // namespace syncer | 637 } // namespace syncer |
| OLD | NEW |