| Index: components/sync_driver/generic_change_processor_unittest.cc
|
| diff --git a/components/sync_driver/generic_change_processor_unittest.cc b/components/sync_driver/generic_change_processor_unittest.cc
|
| index f1b35e6afc5e11657ab66a6f41c5ec89198547de..bdd72662473f2e6e6591fa809c7a73f8fafe39e5 100644
|
| --- a/components/sync_driver/generic_change_processor_unittest.cc
|
| +++ b/components/sync_driver/generic_change_processor_unittest.cc
|
| @@ -7,7 +7,6 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| -#include "base/run_loop.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "components/sync_driver/data_type_error_handler_mock.h"
|
| #include "components/sync_driver/sync_api_component_factory.h"
|
| @@ -26,7 +25,6 @@
|
| #include "sync/internal_api/public/user_share.h"
|
| #include "sync/internal_api/public/write_node.h"
|
| #include "sync/internal_api/public/write_transaction.h"
|
| -#include "testing/gmock/include/gmock/gmock-matchers.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace sync_driver {
|
| @@ -35,17 +33,17 @@
|
|
|
| const char kTestData[] = "some data";
|
|
|
| -// A mock that keeps track of attachments passed to UploadAttachments.
|
| +// A mock that keeps track of attachments passed to StoreAttachments.
|
| class MockAttachmentService : public syncer::AttachmentServiceImpl {
|
| public:
|
| MockAttachmentService();
|
| virtual ~MockAttachmentService();
|
| - virtual void UploadAttachments(
|
| - const syncer::AttachmentIdSet& attachment_ids) OVERRIDE;
|
| - std::vector<syncer::AttachmentIdSet>* attachment_id_sets();
|
| + virtual void StoreAttachments(const syncer::AttachmentList& attachments,
|
| + const StoreCallback& callback) OVERRIDE;
|
| + std::vector<syncer::AttachmentList>* attachment_lists();
|
|
|
| private:
|
| - std::vector<syncer::AttachmentIdSet> attachment_id_sets_;
|
| + std::vector<syncer::AttachmentList> attachment_lists_;
|
| };
|
|
|
| MockAttachmentService::MockAttachmentService()
|
| @@ -62,15 +60,15 @@
|
| MockAttachmentService::~MockAttachmentService() {
|
| }
|
|
|
| -void MockAttachmentService::UploadAttachments(
|
| - const syncer::AttachmentIdSet& attachment_ids) {
|
| - attachment_id_sets_.push_back(attachment_ids);
|
| - AttachmentServiceImpl::UploadAttachments(attachment_ids);
|
| -}
|
| -
|
| -std::vector<syncer::AttachmentIdSet>*
|
| -MockAttachmentService::attachment_id_sets() {
|
| - return &attachment_id_sets_;
|
| +void MockAttachmentService::StoreAttachments(
|
| + const syncer::AttachmentList& attachments,
|
| + const StoreCallback& callback) {
|
| + attachment_lists_.push_back(attachments);
|
| + AttachmentServiceImpl::StoreAttachments(attachments, callback);
|
| +}
|
| +
|
| +std::vector<syncer::AttachmentList>* MockAttachmentService::attachment_lists() {
|
| + return &attachment_lists_;
|
| }
|
|
|
| // MockSyncApiComponentFactory needed to initialize GenericChangeProcessor and
|
| @@ -161,11 +159,6 @@
|
|
|
| MockAttachmentService* mock_attachment_service() {
|
| return mock_attachment_service_;
|
| - }
|
| -
|
| - void RunLoop() {
|
| - base::RunLoop run_loop;
|
| - run_loop.RunUntilIdle();
|
| }
|
|
|
| private:
|
| @@ -356,20 +349,19 @@
|
| tag, title, specifics, attachments)));
|
| ASSERT_FALSE(
|
| change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet());
|
| - RunLoop();
|
|
|
| // Check that the AttachmentService received the new attachments.
|
| - ASSERT_EQ(mock_attachment_service()->attachment_id_sets()->size(), 1U);
|
| - const syncer::AttachmentIdSet& attachments_added =
|
| - mock_attachment_service()->attachment_id_sets()->front();
|
| - ASSERT_THAT(attachments_added,
|
| - testing::UnorderedElementsAre(attachments[0].GetId(),
|
| - attachments[1].GetId()));
|
| + ASSERT_EQ(mock_attachment_service()->attachment_lists()->size(), 1U);
|
| + const syncer::AttachmentList& attachments_added =
|
| + mock_attachment_service()->attachment_lists()->front();
|
| + ASSERT_EQ(attachments_added.size(), 2U);
|
| + ASSERT_EQ(attachments_added[0].GetId(), attachments[0].GetId());
|
| + ASSERT_EQ(attachments_added[1].GetId(), attachments[1].GetId());
|
|
|
| // Update the SyncData, replacing its two attachments with one new attachment.
|
| syncer::AttachmentList new_attachments;
|
| new_attachments.push_back(syncer::Attachment::Create(attachment_data));
|
| - mock_attachment_service()->attachment_id_sets()->clear();
|
| + mock_attachment_service()->attachment_lists()->clear();
|
| change_list.clear();
|
| change_list.push_back(
|
| syncer::SyncChange(FROM_HERE,
|
| @@ -378,14 +370,13 @@
|
| tag, title, specifics, new_attachments)));
|
| ASSERT_FALSE(
|
| change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet());
|
| - RunLoop();
|
|
|
| // Check that the AttachmentService received it.
|
| - ASSERT_EQ(mock_attachment_service()->attachment_id_sets()->size(), 1U);
|
| - const syncer::AttachmentIdSet& new_attachments_added =
|
| - mock_attachment_service()->attachment_id_sets()->front();
|
| - ASSERT_THAT(new_attachments_added,
|
| - testing::UnorderedElementsAre(new_attachments[0].GetId()));
|
| + ASSERT_EQ(mock_attachment_service()->attachment_lists()->size(), 1U);
|
| + const syncer::AttachmentList& new_attachments_added =
|
| + mock_attachment_service()->attachment_lists()->front();
|
| + ASSERT_EQ(new_attachments_added.size(), 1U);
|
| + ASSERT_EQ(new_attachments_added[0].GetId(), new_attachments[0].GetId());
|
| }
|
|
|
| // Verify that after attachment is uploaded GenericChangeProcessor updates
|
|
|