1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
#define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
#include <string>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync_driver/data_type_manager_impl.h"
#include "components/sync_driver/glue/sync_backend_host_impl.h"
#include "components/sync_driver/sync_client.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/browser_context.h"
#include "sync/test/engine/test_id_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
class Profile;
class ProfileOAuth2TokenService;
class SyncApiComponentFactoryMock;
ACTION(ReturnNewDataTypeManager) {
return new sync_driver::DataTypeManagerImpl(arg0, arg1, arg2, arg3, arg4);
}
namespace browser_sync {
class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl {
public:
SyncBackendHostForProfileSyncTest(
Profile* profile,
sync_driver::SyncClient* sync_client,
const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
invalidation::InvalidationService* invalidator,
const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
base::Closure callback);
~SyncBackendHostForProfileSyncTest() override;
void RequestConfigureSyncer(
syncer::ConfigureReason reason,
syncer::ModelTypeSet to_download,
syncer::ModelTypeSet to_purge,
syncer::ModelTypeSet to_journal,
syncer::ModelTypeSet to_unapply,
syncer::ModelTypeSet to_ignore,
const syncer::ModelSafeRoutingInfo& routing_info,
const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
ready_task,
const base::Closure& retry_callback) override;
protected:
void InitCore(scoped_ptr<DoInitializeOptions> options) override;
private:
// Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop.
// Allows extra initialization work to be performed before the backend comes
// up.
base::Closure callback_;
};
} // namespace browser_sync
class TestProfileSyncService : public ProfileSyncService {
public:
// TODO(tim): Add ability to inject TokenService alongside SigninManager.
// TODO(rogerta): what does above comment mean?
TestProfileSyncService(
Profile* profile,
SigninManagerBase* signin,
ProfileOAuth2TokenService* oauth2_token_service,
browser_sync::ProfileSyncServiceStartBehavior behavior);
~TestProfileSyncService() override;
void OnConfigureDone(
const sync_driver::DataTypeManager::ConfigureResult& result) override;
// We implement our own version to avoid some DCHECKs.
syncer::UserShare* GetUserShare() const override;
static TestProfileSyncService* BuildAutoStartAsyncInit(
Profile* profile, base::Closure callback);
SyncApiComponentFactoryMock* GetSyncApiComponentFactoryMock();
syncer::TestIdFactory* id_factory();
// Raise visibility to ease testing.
using ProfileSyncService::NotifyObservers;
protected:
static scoped_ptr<KeyedService> TestFactoryFunction(
content::BrowserContext* profile);
// Return NULL handle to use in backend initialization to avoid receiving
// js messages on UI loop when it's being destroyed, which are not deleted
// and cause memory leak in test.
syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler() override;
bool NeedBackup() const override;
private:
syncer::TestIdFactory id_factory_;
};
#endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_
|