Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
03e65ebe
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,发现更多精彩内容 >>
提交
03e65ebe
编写于
10月 04, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use await/async in tests
上级
6d521405
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
100 deletion
+75
-100
extensions/vscode-api-tests/src/singlefolder-tests/commands.test.ts
.../vscode-api-tests/src/singlefolder-tests/commands.test.ts
+10
-13
extensions/vscode-api-tests/src/singlefolder-tests/languages.test.ts
...vscode-api-tests/src/singlefolder-tests/languages.test.ts
+11
-15
extensions/vscode-api-tests/src/singlefolder-tests/window.test.ts
...ns/vscode-api-tests/src/singlefolder-tests/window.test.ts
+54
-72
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/commands.test.ts
浏览文件 @
03e65ebe
...
...
@@ -39,20 +39,18 @@ suite('commands namespace tests', () => {
},
done
);
});
test
(
'
command with args
'
,
function
()
{
test
(
'
command with args
'
,
async
function
()
{
let
args
:
IArguments
;
let
registration
=
commands
.
registerCommand
(
'
t1
'
,
function
()
{
args
=
arguments
;
});
return
commands
.
executeCommand
(
'
t1
'
,
'
start
'
).
then
(()
=>
{
registration
.
dispose
();
assert
.
ok
(
args
);
assert
.
equal
(
args
.
length
,
1
);
assert
.
equal
(
args
[
0
],
'
start
'
);
});
await
commands
.
executeCommand
(
'
t1
'
,
'
start
'
);
registration
.
dispose
();
assert
.
ok
(
args
!
);
assert
.
equal
(
args
!
.
length
,
1
);
assert
.
equal
(
args
!
[
0
],
'
start
'
);
});
test
(
'
editorCommand with extra args
'
,
function
()
{
...
...
@@ -76,7 +74,7 @@ suite('commands namespace tests', () => {
});
test
(
'
api-command: vscode.previewHtml
'
,
function
()
{
test
(
'
api-command: vscode.previewHtml
'
,
async
function
()
{
let
registration
=
workspace
.
registerTextDocumentContentProvider
(
'
speciale
'
,
{
provideTextDocumentContent
(
uri
)
{
...
...
@@ -87,10 +85,9 @@ suite('commands namespace tests', () => {
let
virtualDocumentUri
=
Uri
.
parse
(
'
speciale://authority/path
'
);
let
title
=
'
A title
'
;
return
commands
.
executeCommand
(
'
vscode.previewHtml
'
,
virtualDocumentUri
,
ViewColumn
.
Three
,
title
).
then
(
success
=>
{
assert
.
ok
(
success
);
registration
.
dispose
();
});
const
success
=
await
commands
.
executeCommand
(
'
vscode.previewHtml
'
,
virtualDocumentUri
,
ViewColumn
.
Three
,
title
);
assert
.
ok
(
success
);
registration
.
dispose
();
});
...
...
extensions/vscode-api-tests/src/singlefolder-tests/languages.test.ts
浏览文件 @
03e65ebe
...
...
@@ -77,7 +77,7 @@ suite('languages namespace tests', () => {
assert
.
ok
(
found
);
});
test
(
'
diagnostics & CodeActionProvider
'
,
function
()
{
test
(
'
diagnostics & CodeActionProvider
'
,
async
function
()
{
class
D2
extends
vscode
.
Diagnostic
{
customProp
=
{
complex
()
{
}
};
...
...
@@ -117,15 +117,13 @@ suite('languages namespace tests', () => {
let
r4
=
vscode
.
languages
.
createDiagnosticCollection
();
r4
.
set
(
uri
,
[
diag2
]);
return
vscode
.
workspace
.
openTextDocument
(
uri
).
then
(
_doc
=>
{
return
vscode
.
commands
.
executeCommand
(
'
vscode.executeCodeActionProvider
'
,
uri
,
new
vscode
.
Range
(
0
,
0
,
0
,
10
));
}).
then
(
_commands
=>
{
assert
.
ok
(
ran
);
vscode
.
Disposable
.
from
(
r1
,
r2
,
r3
,
r4
).
dispose
();
});
await
vscode
.
workspace
.
openTextDocument
(
uri
);
await
vscode
.
commands
.
executeCommand
(
'
vscode.executeCodeActionProvider
'
,
uri
,
new
vscode
.
Range
(
0
,
0
,
0
,
10
));
assert
.
ok
(
ran
);
vscode
.
Disposable
.
from
(
r1
,
r2
,
r3
,
r4
).
dispose
();
});
test
(
'
completions with document filters
'
,
function
()
{
test
(
'
completions with document filters
'
,
async
function
()
{
let
ran
=
false
;
let
uri
=
vscode
.
Uri
.
file
(
join
(
vscode
.
workspace
.
rootPath
||
''
,
'
./bower.json
'
));
...
...
@@ -140,12 +138,10 @@ suite('languages namespace tests', () => {
}
});
return
vscode
.
workspace
.
openTextDocument
(
uri
).
then
(
_doc
=>
{
return
vscode
.
commands
.
executeCommand
<
vscode
.
CompletionList
>
(
'
vscode.executeCompletionItemProvider
'
,
uri
,
new
vscode
.
Position
(
1
,
0
));
}).
then
((
result
:
vscode
.
CompletionList
|
undefined
)
=>
{
r1
.
dispose
();
assert
.
ok
(
ran
);
assert
.
equal
(
result
!
.
items
[
0
].
label
,
'
foo
'
);
});
const
_doc
=
await
vscode
.
workspace
.
openTextDocument
(
uri
);
const
result
=
await
vscode
.
commands
.
executeCommand
<
vscode
.
CompletionList
>
(
'
vscode.executeCompletionItemProvider
'
,
uri
,
new
vscode
.
Position
(
1
,
0
));
r1
.
dispose
();
assert
.
ok
(
ran
);
assert
.
equal
(
result
!
.
items
[
0
].
label
,
'
foo
'
);
});
});
extensions/vscode-api-tests/src/singlefolder-tests/window.test.ts
浏览文件 @
03e65ebe
...
...
@@ -12,14 +12,12 @@ suite('window namespace tests', () => {
teardown
(
closeAllEditors
);
test
(
'
editor, active text editor
'
,
()
=>
{
return
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
||
''
,
'
./far.js
'
)).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
).
then
((
_editor
)
=>
{
const
active
=
window
.
activeTextEditor
;
assert
.
ok
(
active
);
assert
.
ok
(
pathEquals
(
active
!
.
document
.
uri
.
fsPath
,
doc
.
uri
.
fsPath
));
});
});
test
(
'
editor, active text editor
'
,
async
()
=>
{
const
doc
=
await
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
||
''
,
'
./far.js
'
));
await
window
.
showTextDocument
(
doc
);
const
active
=
window
.
activeTextEditor
;
assert
.
ok
(
active
);
assert
.
ok
(
pathEquals
(
active
!
.
document
.
uri
.
fsPath
,
doc
.
uri
.
fsPath
));
});
test
(
'
editor, opened via resource
'
,
()
=>
{
...
...
@@ -36,47 +34,37 @@ suite('window namespace tests', () => {
// assert.ok(window.activeTextEditor === undefined);
// });
test
(
'
editor, assign and check view columns
'
,
()
=>
{
return
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
||
''
,
'
./far.js
'
)).
then
(
doc
=>
{
let
p1
=
window
.
showTextDocument
(
doc
,
ViewColumn
.
One
).
then
(
editor
=>
{
assert
.
equal
(
editor
.
viewColumn
,
ViewColumn
.
One
);
});
let
p2
=
window
.
showTextDocument
(
doc
,
ViewColumn
.
Two
).
then
(
editor
=>
{
assert
.
equal
(
editor
.
viewColumn
,
ViewColumn
.
Two
);
});
let
p3
=
window
.
showTextDocument
(
doc
,
ViewColumn
.
Three
).
then
(
editor
=>
{
assert
.
equal
(
editor
.
viewColumn
,
ViewColumn
.
Three
);
});
return
Promise
.
all
([
p1
,
p2
,
p3
]);
test
(
'
editor, assign and check view columns
'
,
async
()
=>
{
const
doc
=
await
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
||
''
,
'
./far.js
'
));
let
p1
=
window
.
showTextDocument
(
doc
,
ViewColumn
.
One
).
then
(
editor
=>
{
assert
.
equal
(
editor
.
viewColumn
,
ViewColumn
.
One
);
});
let
p2
=
window
.
showTextDocument
(
doc
,
ViewColumn
.
Two
).
then
(
editor_1
=>
{
assert
.
equal
(
editor_1
.
viewColumn
,
ViewColumn
.
Two
);
});
let
p3
=
window
.
showTextDocument
(
doc
,
ViewColumn
.
Three
).
then
(
editor_2
=>
{
assert
.
equal
(
editor_2
.
viewColumn
,
ViewColumn
.
Three
);
});
return
Promise
.
all
([
p1
,
p2
,
p3
]);
});
test
(
'
editor, onDidChangeVisibleTextEditors
'
,
()
=>
{
test
(
'
editor, onDidChangeVisibleTextEditors
'
,
async
()
=>
{
let
eventCounter
=
0
;
let
reg
=
window
.
onDidChangeVisibleTextEditors
(
_editor
=>
{
eventCounter
+=
1
;
});
return
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
||
''
,
'
./far.js
'
)).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
,
ViewColumn
.
One
).
then
(
_editor
=>
{
assert
.
equal
(
eventCounter
,
1
);
return
doc
;
});
}).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
,
ViewColumn
.
Two
).
then
(
_editor
=>
{
assert
.
equal
(
eventCounter
,
2
);
return
doc
;
});
}).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
,
ViewColumn
.
Three
).
then
(
_editor
=>
{
assert
.
equal
(
eventCounter
,
3
);
return
doc
;
});
}).
then
(
_doc
=>
{
reg
.
dispose
();
});
const
doc
=
await
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
||
''
,
'
./far.js
'
));
await
window
.
showTextDocument
(
doc
,
ViewColumn
.
One
);
assert
.
equal
(
eventCounter
,
1
);
await
window
.
showTextDocument
(
doc
,
ViewColumn
.
Two
);
assert
.
equal
(
eventCounter
,
2
);
await
window
.
showTextDocument
(
doc
,
ViewColumn
.
Three
);
assert
.
equal
(
eventCounter
,
3
);
reg
.
dispose
();
});
test
(
'
editor, onDidChangeTextEditorViewColumn (close editor)
'
,
()
=>
{
...
...
@@ -92,28 +80,24 @@ suite('window namespace tests', () => {
return
Promise
.
all
([
workspace
.
openTextDocument
(
Uri
.
parse
(
'
bikes://testing/one
'
)).
then
(
doc
=>
window
.
showTextDocument
(
doc
,
ViewColumn
.
One
)),
workspace
.
openTextDocument
(
Uri
.
parse
(
'
bikes://testing/two
'
)).
then
(
doc
=>
window
.
showTextDocument
(
doc
,
ViewColumn
.
Two
))
]).
then
(
editors
=>
{
]).
then
(
async
editors
=>
{
let
[
one
,
two
]
=
editors
;
return
new
Promise
(
resolve
=>
{
await
new
Promise
(
resolve
=>
{
let
registration2
=
window
.
onDidChangeTextEditorViewColumn
(
event
=>
{
actualEvent
=
event
;
registration2
.
dispose
();
resolve
();
});
// close editor 1, wait a little for the event to bubble
one
.
hide
();
}).
then
(()
=>
{
assert
.
ok
(
actualEvent
);
assert
.
ok
(
actualEvent
.
textEditor
===
two
);
assert
.
ok
(
actualEvent
.
viewColumn
===
two
.
viewColumn
);
registration1
.
dispose
();
});
assert
.
ok
(
actualEvent
);
assert
.
ok
(
actualEvent
.
textEditor
===
two
);
assert
.
ok
(
actualEvent
.
viewColumn
===
two
.
viewColumn
);
registration1
.
dispose
();
});
});
...
...
@@ -340,22 +324,20 @@ suite('window namespace tests', () => {
source
.
dispose
();
});
test
(
'
showInputBox - undefined on cancel
'
,
function
()
{
test
(
'
showInputBox - undefined on cancel
'
,
async
function
()
{
const
source
=
new
CancellationTokenSource
();
const
p
=
window
.
showInputBox
(
undefined
,
source
.
token
);
source
.
cancel
();
return
p
.
then
(
value
=>
{
assert
.
equal
(
value
,
undefined
);
});
const
value
=
await
p
;
assert
.
equal
(
value
,
undefined
);
});
test
(
'
showInputBox - cancel early
'
,
function
()
{
test
(
'
showInputBox - cancel early
'
,
async
function
()
{
const
source
=
new
CancellationTokenSource
();
source
.
cancel
();
const
p
=
window
.
showInputBox
(
undefined
,
source
.
token
);
return
p
.
then
(
value
=>
{
assert
.
equal
(
value
,
undefined
);
});
const
value
=
await
p
;
assert
.
equal
(
value
,
undefined
);
});
test
(
'
showInputBox -
\'\'
on Enter
'
,
function
()
{
...
...
@@ -509,7 +491,7 @@ suite('window namespace tests', () => {
return
result
;
});
test
(
'
showQuickPick, native promise - #11754
'
,
function
()
{
test
(
'
showQuickPick, native promise - #11754
'
,
async
function
()
{
const
data
=
new
Promise
<
string
[]
>
(
resolve
=>
{
resolve
([
'
a
'
,
'
b
'
,
'
c
'
]);
...
...
@@ -518,9 +500,8 @@ suite('window namespace tests', () => {
const
source
=
new
CancellationTokenSource
();
const
result
=
window
.
showQuickPick
(
data
,
undefined
,
source
.
token
);
source
.
cancel
();
return
result
.
then
(
value
=>
{
assert
.
equal
(
value
,
undefined
);
});
const
value_1
=
await
result
;
assert
.
equal
(
value_1
,
undefined
);
});
test
(
'
showQuickPick, never resolve promise and cancel - #22453
'
,
function
()
{
...
...
@@ -534,16 +515,17 @@ suite('window namespace tests', () => {
return
Promise
.
all
([
a
,
b
]);
});
test
(
'
showWorkspaceFolderPick
'
,
function
()
{
test
(
'
showWorkspaceFolderPick
'
,
async
function
()
{
const
p
=
window
.
showWorkspaceFolderPick
(
undefined
);
return
commands
.
executeCommand
(
'
workbench.action.acceptSelectedQuickOpenItem
'
).
then
(()
=>
{
return
p
.
then
(
_workspace
=>
{
assert
.
ok
(
true
);
},
_error
=>
{
assert
.
ok
(
false
);
});
});
await
commands
.
executeCommand
(
'
workbench.action.acceptSelectedQuickOpenItem
'
);
try
{
await
p
;
assert
.
ok
(
true
);
}
catch
(
_error
)
{
assert
.
ok
(
false
);
}
});
test
(
'
Default value for showInput Box not accepted when it fails validateInput, reversing #33691
'
,
async
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录