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/shared_change_processor.h" | 5 #include "components/sync_driver/shared_change_processor.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 class SyncSharedChangeProcessorTest : | 35 class SyncSharedChangeProcessorTest : |
36 public testing::Test, | 36 public testing::Test, |
37 public SyncApiComponentFactory { | 37 public SyncApiComponentFactory { |
38 public: | 38 public: |
39 SyncSharedChangeProcessorTest() | 39 SyncSharedChangeProcessorTest() |
40 : backend_thread_("dbthread"), | 40 : backend_thread_("dbthread"), |
41 did_connect_(false), | 41 did_connect_(false), |
42 has_attachment_service_(false) {} | 42 has_attachment_service_(false) {} |
43 | 43 |
44 virtual ~SyncSharedChangeProcessorTest() { | 44 ~SyncSharedChangeProcessorTest() override { |
45 EXPECT_FALSE(db_syncable_service_.get()); | 45 EXPECT_FALSE(db_syncable_service_.get()); |
46 } | 46 } |
47 | 47 |
48 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( | 48 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( |
49 syncer::ModelType type) override { | 49 syncer::ModelType type) override { |
50 return db_syncable_service_->AsWeakPtr(); | 50 return db_syncable_service_->AsWeakPtr(); |
51 } | 51 } |
52 | 52 |
53 virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService( | 53 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( |
54 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, | 54 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, |
55 const syncer::UserShare& user_share, | 55 const syncer::UserShare& user_share, |
56 const std::string& store_birthday, | 56 const std::string& store_birthday, |
57 syncer::ModelType model_type, | 57 syncer::ModelType model_type, |
58 syncer::AttachmentService::Delegate* delegate) override { | 58 syncer::AttachmentService::Delegate* delegate) override { |
59 return syncer::AttachmentServiceImpl::CreateForTest(); | 59 return syncer::AttachmentServiceImpl::CreateForTest(); |
60 } | 60 } |
61 | 61 |
62 protected: | 62 protected: |
63 virtual void SetUp() override { | 63 void SetUp() override { |
64 test_user_share_.SetUp(); | 64 test_user_share_.SetUp(); |
65 shared_change_processor_ = new SharedChangeProcessor(); | 65 shared_change_processor_ = new SharedChangeProcessor(); |
66 ASSERT_TRUE(backend_thread_.Start()); | 66 ASSERT_TRUE(backend_thread_.Start()); |
67 ASSERT_TRUE(backend_thread_.message_loop_proxy()->PostTask( | 67 ASSERT_TRUE(backend_thread_.message_loop_proxy()->PostTask( |
68 FROM_HERE, | 68 FROM_HERE, |
69 base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService, | 69 base::Bind(&SyncSharedChangeProcessorTest::SetUpDBSyncableService, |
70 base::Unretained(this)))); | 70 base::Unretained(this)))); |
71 } | 71 } |
72 | 72 |
73 virtual void TearDown() override { | 73 void TearDown() override { |
74 EXPECT_TRUE(backend_thread_.message_loop_proxy()->PostTask( | 74 EXPECT_TRUE(backend_thread_.message_loop_proxy()->PostTask( |
75 FROM_HERE, | 75 FROM_HERE, |
76 base::Bind(&SyncSharedChangeProcessorTest::TearDownDBSyncableService, | 76 base::Bind(&SyncSharedChangeProcessorTest::TearDownDBSyncableService, |
77 base::Unretained(this)))); | 77 base::Unretained(this)))); |
78 // This must happen before the DB thread is stopped since | 78 // This must happen before the DB thread is stopped since |
79 // |shared_change_processor_| may post tasks to delete its members | 79 // |shared_change_processor_| may post tasks to delete its members |
80 // on the correct thread. | 80 // on the correct thread. |
81 // | 81 // |
82 // TODO(akalin): Write deterministic tests for the destruction of | 82 // TODO(akalin): Write deterministic tests for the destruction of |
83 // |shared_change_processor_| on the UI and DB threads. | 83 // |shared_change_processor_| on the UI and DB threads. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // creates AttachmentService and passes it back to the syncable service. | 187 // creates AttachmentService and passes it back to the syncable service. |
188 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { | 188 TEST_F(SyncSharedChangeProcessorTest, ConnectWithAttachmentStore) { |
189 SetAttachmentStore(); | 189 SetAttachmentStore(); |
190 Connect(); | 190 Connect(); |
191 EXPECT_TRUE(HasAttachmentService()); | 191 EXPECT_TRUE(HasAttachmentService()); |
192 } | 192 } |
193 | 193 |
194 } // namespace | 194 } // namespace |
195 | 195 |
196 } // namespace sync_driver | 196 } // namespace sync_driver |
OLD | NEW |