OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | |
6 #define CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/callback.h" | |
13 #include "base/files/scoped_temp_dir.h" | |
14 #include "base/macros.h" | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "components/browser_sync/browser/profile_sync_test_util.h" | |
17 #include "sync/internal_api/public/base/model_type.h" | |
18 #include "sync/internal_api/public/change_record.h" | |
19 #include "testing/gtest/include/gtest/gtest.h" | |
20 | |
21 class TestProfileSyncService; | |
22 | |
23 namespace syncer { | |
24 struct UserShare; | |
25 } // namespace syncer | |
26 | |
27 class ProfileSyncServiceTestHelper { | |
28 public: | |
29 static syncer::ImmutableChangeRecordList MakeSingletonChangeRecordList( | |
30 int64_t node_id, | |
31 syncer::ChangeRecord::Action action); | |
32 | |
33 // Deletions must provide an EntitySpecifics for the deleted data. | |
34 static syncer::ImmutableChangeRecordList | |
35 MakeSingletonDeletionChangeRecordList( | |
36 int64_t node_id, | |
37 const sync_pb::EntitySpecifics& specifics); | |
38 | |
39 private: | |
40 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTestHelper); | |
41 }; | |
42 | |
43 class AbstractProfileSyncServiceTest : public testing::Test { | |
44 public: | |
45 AbstractProfileSyncServiceTest(); | |
46 ~AbstractProfileSyncServiceTest() override; | |
47 | |
48 bool CreateRoot(syncer::ModelType model_type); | |
49 | |
50 protected: | |
51 // Creates a TestProfileSyncService instance based on | |
52 // |profile_sync_service_bundle_|, with start behavior | |
53 // browser_sync::AUTO_START. Passes |callback| down to | |
54 // SyncManagerForProfileSyncTest to be used by NotifyInitializationSuccess. | |
55 // |sync_client| is passed to the service. | |
56 scoped_ptr<TestProfileSyncService> CreateSyncService( | |
57 scoped_ptr<sync_driver::SyncClient> sync_client, | |
58 const base::Closure& initialization_success_callback); | |
59 | |
60 // Use |data_type_thread_| for code disallowed on the UI thread. | |
61 base::Thread data_type_thread_; | |
62 | |
63 base::MessageLoop message_loop_; | |
64 browser_sync::ProfileSyncServiceBundle profile_sync_service_bundle_; | |
65 scoped_ptr<TestProfileSyncService> sync_service_; | |
66 | |
67 private: | |
68 base::ScopedTempDir temp_dir_; // To pass to the backend host. | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest); | |
71 }; | |
72 | |
73 class CreateRootHelper { | |
74 public: | |
75 CreateRootHelper(AbstractProfileSyncServiceTest* test, | |
76 syncer::ModelType model_type); | |
77 virtual ~CreateRootHelper(); | |
78 | |
79 const base::Closure& callback() const; | |
80 bool success(); | |
81 | |
82 private: | |
83 void CreateRootCallback(); | |
84 | |
85 base::Closure callback_; | |
86 AbstractProfileSyncServiceTest* test_; | |
87 syncer::ModelType model_type_; | |
88 bool success_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(CreateRootHelper); | |
91 }; | |
92 | |
93 #endif // CHROME_BROWSER_SYNC_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_ | |
OLD | NEW |