Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: components/browser_sync/browser/abstract_profile_sync_service_test.h

Issue 2345843003: [Sync] Merge //components/browser_sync into one directory. (Closed)
Patch Set: Address comment + rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
6 #define COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <string>
12
13 #include "base/callback.h"
14 #include "base/files/scoped_temp_dir.h"
15 #include "base/macros.h"
16 #include "base/test/test_message_loop.h"
17 #include "components/browser_sync/browser/profile_sync_test_util.h"
18 #include "components/sync/base/model_type.h"
19 #include "components/sync/core/change_record.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21
22 class TestProfileSyncService;
23
24 namespace syncer {
25 struct UserShare;
26 } // namespace syncer
27
28 class ProfileSyncServiceTestHelper {
29 public:
30 static syncer::ImmutableChangeRecordList MakeSingletonChangeRecordList(
31 int64_t node_id,
32 syncer::ChangeRecord::Action action);
33
34 // Deletions must provide an EntitySpecifics for the deleted data.
35 static syncer::ImmutableChangeRecordList
36 MakeSingletonDeletionChangeRecordList(
37 int64_t node_id,
38 const sync_pb::EntitySpecifics& specifics);
39
40 private:
41 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceTestHelper);
42 };
43
44 class AbstractProfileSyncServiceTest : public testing::Test {
45 public:
46 AbstractProfileSyncServiceTest();
47 ~AbstractProfileSyncServiceTest() override;
48
49 bool CreateRoot(syncer::ModelType model_type);
50
51 protected:
52 // Creates a TestProfileSyncService instance based on
53 // |profile_sync_service_bundle_|, with start behavior
54 // browser_sync::AUTO_START. Passes |callback| down to
55 // SyncManagerForProfileSyncTest to be used by NotifyInitializationSuccess.
56 // |sync_client| is passed to the service. The created service is stored in
57 // |sync_service_|.
58 void CreateSyncService(std::unique_ptr<sync_driver::SyncClient> sync_client,
59 const base::Closure& initialization_success_callback);
60
61 base::Thread* data_type_thread() { return &data_type_thread_; }
62
63 TestProfileSyncService* sync_service() { return sync_service_.get(); }
64
65 // Returns the callback for the FakeSyncClient builder. It is not possible to
66 // just Bind() sync_service(), because of Callback not understanding the
67 // inheritance of its template arguments.
68 base::Callback<sync_driver::SyncService*(void)> GetSyncServiceCallback();
69
70 browser_sync::ProfileSyncServiceBundle* profile_sync_service_bundle() {
71 return &profile_sync_service_bundle_;
72 }
73
74 private:
75 // Use |data_type_thread_| for code disallowed on the UI thread.
76 base::Thread data_type_thread_;
77
78 base::TestMessageLoop message_loop_;
79 browser_sync::ProfileSyncServiceBundle profile_sync_service_bundle_;
80 std::unique_ptr<TestProfileSyncService> sync_service_;
81
82 base::ScopedTempDir temp_dir_; // To pass to the backend host.
83
84 DISALLOW_COPY_AND_ASSIGN(AbstractProfileSyncServiceTest);
85 };
86
87 class CreateRootHelper {
88 public:
89 CreateRootHelper(AbstractProfileSyncServiceTest* test,
90 syncer::ModelType model_type);
91 virtual ~CreateRootHelper();
92
93 const base::Closure& callback() const;
94 bool success();
95
96 private:
97 void CreateRootCallback();
98
99 base::Closure callback_;
100 AbstractProfileSyncServiceTest* test_;
101 syncer::ModelType model_type_;
102 bool success_;
103
104 DISALLOW_COPY_AND_ASSIGN(CreateRootHelper);
105 };
106
107 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_ABSTRACT_PROFILE_SYNC_SERVICE_TEST_H_
OLDNEW
« no previous file with comments | « components/browser_sync/browser/DEPS ('k') | components/browser_sync/browser/abstract_profile_sync_service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698