OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ |
6 #define COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | 6 #define COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/test/test_message_loop.h" | 16 #include "base/test/test_message_loop.h" |
17 #include "components/browser_sync/profile_sync_test_util.h" | 17 #include "components/browser_sync/profile_sync_test_util.h" |
18 #include "components/sync/base/model_type.h" | 18 #include "components/sync/base/model_type.h" |
19 #include "components/sync/core/change_record.h" | 19 #include "components/sync/core/change_record.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 class TestProfileSyncService; | |
23 | |
24 namespace syncer { | 22 namespace syncer { |
25 struct UserShare; | 23 struct UserShare; |
26 } // namespace syncer | 24 } // namespace syncer |
27 | 25 |
26 namespace browser_sync { | |
27 | |
skym
2016/09/22 17:25:59
Is it right to have a newline here?
maxbogue
2016/09/22 19:41:15
I think having it makes it clearer that the namesp
| |
28 class TestProfileSyncService; | |
29 | |
28 class ProfileSyncServiceTestHelper { | 30 class ProfileSyncServiceTestHelper { |
29 public: | 31 public: |
30 static syncer::ImmutableChangeRecordList MakeSingletonChangeRecordList( | 32 static syncer::ImmutableChangeRecordList MakeSingletonChangeRecordList( |
31 int64_t node_id, | 33 int64_t node_id, |
32 syncer::ChangeRecord::Action action); | 34 syncer::ChangeRecord::Action action); |
33 | 35 |
34 // Deletions must provide an EntitySpecifics for the deleted data. | 36 // Deletions must provide an EntitySpecifics for the deleted data. |
35 static syncer::ImmutableChangeRecordList | 37 static syncer::ImmutableChangeRecordList |
36 MakeSingletonDeletionChangeRecordList( | 38 MakeSingletonDeletionChangeRecordList( |
37 int64_t node_id, | 39 int64_t node_id, |
38 const sync_pb::EntitySpecifics& specifics); | 40 const sync_pb::EntitySpecifics& specifics); |
39 | 41 |
40 private: | 42 private: |
41 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTestHelper); | 43 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTestHelper); |
42 }; | 44 }; |
43 | 45 |
44 class AbstractProfileSyncServiceTest : public testing::Test { | 46 class AbstractProfileSyncServiceTest : public testing::Test { |
45 public: | 47 public: |
46 AbstractProfileSyncServiceTest(); | 48 AbstractProfileSyncServiceTest(); |
47 ~AbstractProfileSyncServiceTest() override; | 49 ~AbstractProfileSyncServiceTest() override; |
48 | 50 |
49 bool CreateRoot(syncer::ModelType model_type); | 51 bool CreateRoot(syncer::ModelType model_type); |
50 | 52 |
51 protected: | 53 protected: |
52 // Creates a TestProfileSyncService instance based on | 54 // Creates a TestProfileSyncService instance based on |
53 // |profile_sync_service_bundle_|, with start behavior | 55 // |profile_sync_service_bundle_|, with start behavior |
54 // browser_sync::AUTO_START. Passes |callback| down to | 56 // AUTO_START. Passes |callback| down to |
skym
2016/09/22 17:25:59
Why'd you strip off the namespace here?
maxbogue
2016/09/22 19:41:15
I literally did s/browser_sync::// in this directo
| |
55 // SyncManagerForProfileSyncTest to be used by NotifyInitializationSuccess. | 57 // SyncManagerForProfileSyncTest to be used by NotifyInitializationSuccess. |
56 // |sync_client| is passed to the service. The created service is stored in | 58 // |sync_client| is passed to the service. The created service is stored in |
57 // |sync_service_|. | 59 // |sync_service_|. |
58 void CreateSyncService(std::unique_ptr<sync_driver::SyncClient> sync_client, | 60 void CreateSyncService(std::unique_ptr<sync_driver::SyncClient> sync_client, |
59 const base::Closure& initialization_success_callback); | 61 const base::Closure& initialization_success_callback); |
60 | 62 |
61 base::Thread* data_type_thread() { return &data_type_thread_; } | 63 base::Thread* data_type_thread() { return &data_type_thread_; } |
62 | 64 |
63 TestProfileSyncService* sync_service() { return sync_service_.get(); } | 65 TestProfileSyncService* sync_service() { return sync_service_.get(); } |
64 | 66 |
65 // Returns the callback for the FakeSyncClient builder. It is not possible to | 67 // Returns the callback for the FakeSyncClient builder. It is not possible to |
66 // just Bind() sync_service(), because of Callback not understanding the | 68 // just Bind() sync_service(), because of Callback not understanding the |
67 // inheritance of its template arguments. | 69 // inheritance of its template arguments. |
68 base::Callback<sync_driver::SyncService*(void)> GetSyncServiceCallback(); | 70 base::Callback<sync_driver::SyncService*(void)> GetSyncServiceCallback(); |
69 | 71 |
70 browser_sync::ProfileSyncServiceBundle* profile_sync_service_bundle() { | 72 ProfileSyncServiceBundle* profile_sync_service_bundle() { |
71 return &profile_sync_service_bundle_; | 73 return &profile_sync_service_bundle_; |
72 } | 74 } |
73 | 75 |
74 private: | 76 private: |
75 // Use |data_type_thread_| for code disallowed on the UI thread. | 77 // Use |data_type_thread_| for code disallowed on the UI thread. |
76 base::Thread data_type_thread_; | 78 base::Thread data_type_thread_; |
77 | 79 |
78 base::TestMessageLoop message_loop_; | 80 base::TestMessageLoop message_loop_; |
79 browser_sync::ProfileSyncServiceBundle profile_sync_service_bundle_; | 81 ProfileSyncServiceBundle profile_sync_service_bundle_; |
80 std::unique_ptr<TestProfileSyncService> sync_service_; | 82 std::unique_ptr<TestProfileSyncService> sync_service_; |
81 | 83 |
82 base::ScopedTempDir temp_dir_; // To pass to the backend host. | 84 base::ScopedTempDir temp_dir_; // To pass to the backend host. |
83 | 85 |
84 DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest); | 86 DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest); |
85 }; | 87 }; |
86 | 88 |
87 class CreateRootHelper { | 89 class CreateRootHelper { |
88 public: | 90 public: |
89 CreateRootHelper(AbstractProfileSyncServiceTest* test, | 91 CreateRootHelper(AbstractProfileSyncServiceTest* test, |
90 syncer::ModelType model_type); | 92 syncer::ModelType model_type); |
91 virtual ~CreateRootHelper(); | 93 virtual ~CreateRootHelper(); |
92 | 94 |
93 const base::Closure& callback() const; | 95 const base::Closure& callback() const; |
94 bool success(); | 96 bool success(); |
95 | 97 |
96 private: | 98 private: |
97 void CreateRootCallback(); | 99 void CreateRootCallback(); |
98 | 100 |
99 base::Closure callback_; | 101 base::Closure callback_; |
100 AbstractProfileSyncServiceTest* test_; | 102 AbstractProfileSyncServiceTest* test_; |
101 syncer::ModelType model_type_; | 103 syncer::ModelType model_type_; |
102 bool success_; | 104 bool success_; |
103 | 105 |
104 DISALLOW_COPY_AND_ASSIGN(CreateRootHelper); | 106 DISALLOW_COPY_AND_ASSIGN(CreateRootHelper); |
105 }; | 107 }; |
106 | 108 |
109 } // namespace browser_sync | |
110 | |
107 #endif // COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | 111 #endif // COMPONENTS_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ |
OLD | NEW |