53
54
constructor(readonly testServer: UserDataSyncTestServer = new UserDataSyncTestServer()) {
56
>
this.instantiationService = this._register(new TestInstantiationService());
57
>
}
58
59
async setUp(empty: boolean = false): Promise<void> {
61
>
62
>
const logService = this.instantiationService.stub(ILogService, new NullLogService());
63
>
64
>
const userRoamingDataHome = URI.file('userdata').with({ scheme: Schemas.inMemory });
65
>
const userDataSyncHome = joinPath(userRoamingDataHome, '.sync');
66
>
const environmentService = this.instantiationService.stub(IEnvironmentService, {
67
>
userDataSyncHome,
68
>
userRoamingDataHome,
69
>
cacheHome: joinPath(userRoamingDataHome, 'cache'),
70
>
argvResource: joinPath(userRoamingDataHome, 'argv.json'),
71
>
sync: 'on'
72
>
});
73
>
74
>
this.instantiationService.stub(IProductService, {
75
>
_serviceBrand: undefined, ...product, ...{
76
>
'configurationSync.store': {
77
>
url: this.testServer.url,
78
>
stableUrl: this.testServer.url,
79
>
insidersUrl: this.testServer.url,
80
>
canSwitch: false,
81
>
authenticationProviders: { 'test': { scopes: [] } }
82
>
}
83
>
}
84
>
});
85
>
86
>
const fileService = this._register(new FileService(logService));
87
>
this._register(fileService.registerProvider(Schemas.inMemory, this._register(new InMemoryFileSystemProvider())));
88
>
this._register(fileService.registerProvider(USER_DATA_SYNC_SCHEME, this._register(new InMemoryFileSystemProvider())));
89
>
this.instantiationService.stub(IFileService, fileService);
90
>
91
>
const uriIdentityService = this._register(this.instantiationService.createInstance(UriIdentityService));
92
>
this.instantiationService.stub(IUriIdentityService, uriIdentityService);
93
>
94
>
const userDataProfilesService = this._register(new InMemoryUserDataProfilesService(environmentService, fileService, uriIdentityService, logService));
95
>
this.instantiationService.stub(IUserDataProfilesService, userDataProfilesService);
96
>
97
>
const storageService = this._register(new TestStorageService(userDataProfilesService.defaultProfile));
98
>
this.instantiationService.stub(IStorageService, this._register(storageService));
99
>
this.instantiationService.stub(IUserDataProfileStorageService, this._register(new TestUserDataProfileStorageService(false, storageService)));
100
>
101
>
const configurationService = this._register(new ConfigurationService(userDataProfilesService.defaultProfile.settingsResource, fileService, new NullPolicyService(), logService));
102
>
await configurationService.initialize();
103
>
this.instantiationService.stub(IConfigurationService, configurationService);
104
>
105
>
this.instantiationService.stub(IMeteredConnectionService, { isConnectionMetered: false, onDidChangeIsConnectionMetered: new Emitter<boolean>().event });
106
>
107
>
this.instantiationService.stub(IRequestService, this.testServer);
108
>
109
>
this.instantiationService.stub(IUserDataSyncLogService, logService);
110
>
this.instantiationService.stub(ITelemetryService, NullTelemetryService);
111
>
this.instantiationService.stub(IUserDataSyncStoreManagementService, this._register(this.instantiationService.createInstance(UserDataSyncStoreManagementService)));
112
>
this.instantiationService.stub(IUserDataSyncStoreService, this._register(this.instantiationService.createInstance(UserDataSyncStoreService)));
113
>
114
>
const userDataSyncAccountService: IUserDataSyncAccountService = this._register(this.instantiationService.createInstance(UserDataSyncAccountService));
115
>
await userDataSyncAccountService.updateAccount({ authenticationProviderId: 'authenticationProviderId', token: 'token' });
116
>
this.instantiationService.stub(IUserDataSyncAccountService, userDataSyncAccountService);
117
>
118
>
this.instantiationService.stub(IUserDataSyncMachinesService, this._register(this.instantiationService.createInstance(UserDataSyncMachinesService)));
119
>
this.instantiationService.stub(IUserDataSyncLocalStoreService, this._register(this.instantiationService.createInstance(UserDataSyncLocalStoreService)));
120
>
this.instantiationService.stub(IUserDataSyncUtilService, new TestUserDataSyncUtilService());
121
>
this.instantiationService.stub(IUserDataSyncEnablementService, this._register(this.instantiationService.createInstance(UserDataSyncEnablementService)));
122
>
123
>
this.instantiationService.stub(IExtensionManagementService, {
124
>
async getInstalled() { return []; },
125
>
onDidInstallExtensions: new Emitter<readonly InstallExtensionResult[]>().event,
126
>
onDidUninstallExtension: new Emitter<DidUninstallExtensionEvent>().event,
127
>
});
128
>
this.instantiationService.stub(IGlobalExtensionEnablementService, this._register(this.instantiationService.createInstance(GlobalExtensionEnablementService)));
129
>
this.instantiationService.stub(IExtensionStorageService, this._register(this.instantiationService.createInstance(ExtensionStorageService)));
130
>
this.instantiationService.stub(IIgnoredExtensionsManagementService, this.instantiationService.createInstance(IgnoredExtensionsManagementService));
131
>
this.instantiationService.stub(IExtensionGalleryService, {
132
>
isEnabled() { return true; },
133
>
async getCompatibleExtension() { return null; }
134
>
});
135
>
136
>
this.instantiationService.stub(IUserDataSyncService, this._register(this.instantiationService.createInstance(UserDataSyncService)));
137
>
138
>
if (!empty) {
139
await fileService.writeFile(userDataProfilesService.defaultProfile.settingsResource, VSBuffer.fromString(JSON.stringify({})));
140
await fileService.writeFile(userDataProfilesService.defaultProfile.keybindingsResource, VSBuffer.fromString(JSON.stringify([])));