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_driver/generic_change_processor.h" | 5 #include "components/sync_driver/generic_change_processor.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace sync_driver { | 33 namespace sync_driver { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // A mock that keeps track of attachments passed to UploadAttachments. | 37 // A mock that keeps track of attachments passed to UploadAttachments. |
38 class MockAttachmentService : public syncer::AttachmentServiceImpl { | 38 class MockAttachmentService : public syncer::AttachmentServiceImpl { |
39 public: | 39 public: |
40 MockAttachmentService( | 40 MockAttachmentService( |
41 const scoped_refptr<syncer::AttachmentStore>& attachment_store); | 41 const scoped_refptr<syncer::AttachmentStore>& attachment_store); |
42 virtual ~MockAttachmentService(); | 42 ~MockAttachmentService() override; |
43 virtual void UploadAttachments( | 43 void UploadAttachments( |
44 const syncer::AttachmentIdSet& attachment_ids) override; | 44 const syncer::AttachmentIdSet& attachment_ids) override; |
45 std::vector<syncer::AttachmentIdSet>* attachment_id_sets(); | 45 std::vector<syncer::AttachmentIdSet>* attachment_id_sets(); |
46 | 46 |
47 private: | 47 private: |
48 std::vector<syncer::AttachmentIdSet> attachment_id_sets_; | 48 std::vector<syncer::AttachmentIdSet> attachment_id_sets_; |
49 }; | 49 }; |
50 | 50 |
51 MockAttachmentService::MockAttachmentService( | 51 MockAttachmentService::MockAttachmentService( |
52 const scoped_refptr<syncer::AttachmentStore>& attachment_store) | 52 const scoped_refptr<syncer::AttachmentStore>& attachment_store) |
53 : AttachmentServiceImpl(attachment_store, | 53 : AttachmentServiceImpl(attachment_store, |
(...skipping 21 matching lines...) Expand all Loading... |
75 } | 75 } |
76 | 76 |
77 // MockSyncApiComponentFactory needed to initialize GenericChangeProcessor and | 77 // MockSyncApiComponentFactory needed to initialize GenericChangeProcessor and |
78 // pass MockAttachmentService to it. | 78 // pass MockAttachmentService to it. |
79 class MockSyncApiComponentFactory : public SyncApiComponentFactory { | 79 class MockSyncApiComponentFactory : public SyncApiComponentFactory { |
80 public: | 80 public: |
81 MockSyncApiComponentFactory( | 81 MockSyncApiComponentFactory( |
82 scoped_ptr<syncer::AttachmentService> attachment_service) | 82 scoped_ptr<syncer::AttachmentService> attachment_service) |
83 : attachment_service_(attachment_service.Pass()) {} | 83 : attachment_service_(attachment_service.Pass()) {} |
84 | 84 |
85 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( | 85 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( |
86 syncer::ModelType type) override { | 86 syncer::ModelType type) override { |
87 // Shouldn't be called for this test. | 87 // Shouldn't be called for this test. |
88 NOTREACHED(); | 88 NOTREACHED(); |
89 return base::WeakPtr<syncer::SyncableService>(); | 89 return base::WeakPtr<syncer::SyncableService>(); |
90 } | 90 } |
91 | 91 |
92 virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService( | 92 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( |
93 const scoped_refptr<syncer::AttachmentStore>& attachment_store, | 93 const scoped_refptr<syncer::AttachmentStore>& attachment_store, |
94 const syncer::UserShare& user_share, | 94 const syncer::UserShare& user_share, |
95 syncer::AttachmentService::Delegate* delegate) override { | 95 syncer::AttachmentService::Delegate* delegate) override { |
96 EXPECT_TRUE(attachment_service_ != NULL); | 96 EXPECT_TRUE(attachment_service_ != NULL); |
97 return attachment_service_.Pass(); | 97 return attachment_service_.Pass(); |
98 } | 98 } |
99 | 99 |
100 private: | 100 private: |
101 scoped_ptr<syncer::AttachmentService> attachment_service_; | 101 scoped_ptr<syncer::AttachmentService> attachment_service_; |
102 }; | 102 }; |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // AttachmentService to upload id1 only. | 476 // AttachmentService to upload id1 only. |
477 ConstructGenericChangeProcessor(kType); | 477 ConstructGenericChangeProcessor(kType); |
478 ASSERT_EQ(1U, mock_attachment_service()->attachment_id_sets()->size()); | 478 ASSERT_EQ(1U, mock_attachment_service()->attachment_id_sets()->size()); |
479 ASSERT_THAT(mock_attachment_service()->attachment_id_sets()->front(), | 479 ASSERT_THAT(mock_attachment_service()->attachment_id_sets()->front(), |
480 testing::UnorderedElementsAre(id1)); | 480 testing::UnorderedElementsAre(id1)); |
481 } | 481 } |
482 | 482 |
483 } // namespace | 483 } // namespace |
484 | 484 |
485 } // namespace sync_driver | 485 } // namespace sync_driver |
OLD | NEW |