Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fe6e7b51
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fe6e7b51
编写于
2月 18, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#90076 add more tests
上级
c77f8a80
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
133 addition
and
21 deletion
+133
-21
src/vs/platform/userDataSync/common/userDataSyncService.ts
src/vs/platform/userDataSync/common/userDataSyncService.ts
+20
-20
src/vs/platform/userDataSync/test/common/userDataSyncService.test.ts
...form/userDataSync/test/common/userDataSyncService.test.ts
+113
-1
未找到文件。
src/vs/platform/userDataSync/common/userDataSyncService.ts
浏览文件 @
fe6e7b51
...
...
@@ -140,26 +140,6 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
return
synchroniser
.
accept
(
content
);
}
private
async
hasPreviouslySynced
():
Promise
<
boolean
>
{
await
this
.
checkEnablement
();
for
(
const
synchroniser
of
this
.
synchronisers
)
{
if
(
await
synchroniser
.
hasPreviouslySynced
())
{
return
true
;
}
}
return
false
;
}
private
async
hasLocalData
():
Promise
<
boolean
>
{
await
this
.
checkEnablement
();
for
(
const
synchroniser
of
this
.
synchronisers
)
{
if
(
await
synchroniser
.
hasLocalData
())
{
return
true
;
}
}
return
false
;
}
async
getRemoteContent
(
source
:
SyncSource
,
preview
:
boolean
):
Promise
<
string
|
null
>
{
await
this
.
checkEnablement
();
for
(
const
synchroniser
of
this
.
synchronisers
)
{
...
...
@@ -199,6 +179,26 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
}
}
private
async
hasPreviouslySynced
():
Promise
<
boolean
>
{
await
this
.
checkEnablement
();
for
(
const
synchroniser
of
this
.
synchronisers
)
{
if
(
await
synchroniser
.
hasPreviouslySynced
())
{
return
true
;
}
}
return
false
;
}
private
async
hasLocalData
():
Promise
<
boolean
>
{
await
this
.
checkEnablement
();
for
(
const
synchroniser
of
this
.
synchronisers
)
{
if
(
await
synchroniser
.
hasLocalData
())
{
return
true
;
}
}
return
false
;
}
private
async
resetRemote
():
Promise
<
void
>
{
await
this
.
checkEnablement
();
try
{
...
...
src/vs/platform/userDataSync/test/common/userDataSyncService.test.ts
浏览文件 @
fe6e7b51
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
IUserDataSyncService
,
UserDataSyncError
,
UserDataSyncErrorCode
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IUserDataSyncService
,
UserDataSyncError
,
UserDataSyncErrorCode
,
SyncStatus
,
SyncSource
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
UserDataSyncClient
,
UserDataSyncTestServer
}
from
'
vs/platform/userDataSync/test/common/userDataSyncClient
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -371,4 +371,116 @@ suite('UserDataSyncService', () => {
throw
assert
.
fail
(
'
Should fail with turned off error
'
);
});
test
(
'
test sync status
'
,
async
()
=>
{
const
target
=
new
UserDataSyncTestServer
();
// Setup the client
const
client
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
client
.
setUp
();
const
testObject
=
client
.
instantiationService
.
get
(
IUserDataSyncService
);
// sync from the client
const
actualStatuses
:
SyncStatus
[]
=
[];
const
disposable
=
testObject
.
onDidChangeStatus
(
status
=>
actualStatuses
.
push
(
status
));
await
testObject
.
sync
();
disposable
.
dispose
();
assert
.
deepEqual
(
actualStatuses
,
[
SyncStatus
.
Syncing
,
SyncStatus
.
Idle
,
SyncStatus
.
Syncing
,
SyncStatus
.
Idle
,
SyncStatus
.
Syncing
,
SyncStatus
.
Idle
,
SyncStatus
.
Syncing
,
SyncStatus
.
Idle
]);
});
test
(
'
test sync conflicts status
'
,
async
()
=>
{
const
target
=
new
UserDataSyncTestServer
();
// Setup and sync from the first client
const
client
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
client
.
setUp
();
let
fileService
=
client
.
instantiationService
.
get
(
IFileService
);
let
environmentService
=
client
.
instantiationService
.
get
(
IEnvironmentService
);
await
fileService
.
writeFile
(
environmentService
.
settingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
({
'
editor.fontSize
'
:
14
})));
await
client
.
instantiationService
.
get
(
IUserDataSyncService
).
sync
();
// Setup the test client
const
testClient
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
testClient
.
setUp
();
fileService
=
testClient
.
instantiationService
.
get
(
IFileService
);
environmentService
=
testClient
.
instantiationService
.
get
(
IEnvironmentService
);
await
fileService
.
writeFile
(
environmentService
.
settingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
({
'
editor.fontSize
'
:
16
})));
const
testObject
=
testClient
.
instantiationService
.
get
(
IUserDataSyncService
);
// sync from the client
await
testObject
.
sync
();
assert
.
deepEqual
(
testObject
.
status
,
SyncStatus
.
HasConflicts
);
assert
.
deepEqual
(
testObject
.
conflictsSources
,
[
SyncSource
.
Settings
]);
});
test
(
'
test sync will sync other non conflicted areas
'
,
async
()
=>
{
const
target
=
new
UserDataSyncTestServer
();
// Setup and sync from the first client
const
client
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
client
.
setUp
();
let
fileService
=
client
.
instantiationService
.
get
(
IFileService
);
let
environmentService
=
client
.
instantiationService
.
get
(
IEnvironmentService
);
await
fileService
.
writeFile
(
environmentService
.
settingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
({
'
editor.fontSize
'
:
14
})));
await
client
.
instantiationService
.
get
(
IUserDataSyncService
).
sync
();
// Setup the test client and get conflicts in settings
const
testClient
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
testClient
.
setUp
();
let
testFileService
=
testClient
.
instantiationService
.
get
(
IFileService
);
let
testEnvironmentService
=
testClient
.
instantiationService
.
get
(
IEnvironmentService
);
await
testFileService
.
writeFile
(
testEnvironmentService
.
settingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
({
'
editor.fontSize
'
:
16
})));
const
testObject
=
testClient
.
instantiationService
.
get
(
IUserDataSyncService
);
await
testObject
.
sync
();
// sync from the first client with changes in keybindings
await
fileService
.
writeFile
(
environmentService
.
keybindingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
([{
'
command
'
:
'
abcd
'
,
'
key
'
:
'
cmd+c
'
}])));
await
client
.
instantiationService
.
get
(
IUserDataSyncService
).
sync
();
// sync from the test client
target
.
reset
();
const
actualStatuses
:
SyncStatus
[]
=
[];
const
disposable
=
testObject
.
onDidChangeStatus
(
status
=>
actualStatuses
.
push
(
status
));
await
testObject
.
sync
();
disposable
.
dispose
();
assert
.
deepEqual
(
actualStatuses
,
[]);
assert
.
deepEqual
(
testObject
.
status
,
SyncStatus
.
HasConflicts
);
assert
.
deepEqual
(
target
.
requests
,
[
// Manifest
{
type
:
'
GET
'
,
url
:
`
${
target
.
url
}
/v1/manifest`
,
headers
:
{}
},
// Keybindings
{
type
:
'
GET
'
,
url
:
`
${
target
.
url
}
/v1/resource/keybindings/latest`
,
headers
:
{
'
If-None-Match
'
:
'
1
'
}
},
]);
});
test
(
'
test stop sync reset status
'
,
async
()
=>
{
const
target
=
new
UserDataSyncTestServer
();
// Setup and sync from the first client
const
client
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
client
.
setUp
();
let
fileService
=
client
.
instantiationService
.
get
(
IFileService
);
let
environmentService
=
client
.
instantiationService
.
get
(
IEnvironmentService
);
await
fileService
.
writeFile
(
environmentService
.
settingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
({
'
editor.fontSize
'
:
14
})));
await
client
.
instantiationService
.
get
(
IUserDataSyncService
).
sync
();
// Setup the test client
const
testClient
=
disposableStore
.
add
(
new
UserDataSyncClient
(
target
));
await
testClient
.
setUp
();
fileService
=
testClient
.
instantiationService
.
get
(
IFileService
);
environmentService
=
testClient
.
instantiationService
.
get
(
IEnvironmentService
);
await
fileService
.
writeFile
(
environmentService
.
settingsResource
,
VSBuffer
.
fromString
(
JSON
.
stringify
({
'
editor.fontSize
'
:
16
})));
const
testObject
=
testClient
.
instantiationService
.
get
(
IUserDataSyncService
);
await
testObject
.
sync
();
// sync from the client
await
testObject
.
stop
();
assert
.
deepEqual
(
testObject
.
status
,
SyncStatus
.
Idle
);
assert
.
deepEqual
(
testObject
.
conflictsSources
,
[]);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录