Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
4ea2714d
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ea2714d
编写于
11月 25, 2015
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more meaningful api tests
上级
8a0f53ba
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
156 addition
and
19 deletion
+156
-19
extensions/vscode-api-tests/src/editor.test.ts
extensions/vscode-api-tests/src/editor.test.ts
+39
-0
extensions/vscode-api-tests/src/index.ts
extensions/vscode-api-tests/src/index.ts
+2
-1
extensions/vscode-api-tests/src/utils.ts
extensions/vscode-api-tests/src/utils.ts
+40
-0
extensions/vscode-api-tests/src/window.test.ts
extensions/vscode-api-tests/src/window.test.ts
+12
-6
extensions/vscode-api-tests/src/workspace.test.ts
extensions/vscode-api-tests/src/workspace.test.ts
+54
-12
src/vs/workbench/electron-main/main.ts
src/vs/workbench/electron-main/main.ts
+9
-0
未找到文件。
extensions/vscode-api-tests/src/editor.test.ts
0 → 100644
浏览文件 @
4ea2714d
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
os
from
'
os
'
;
import
{
workspace
,
window
,
Position
}
from
'
vscode
'
;
import
{
createRandomFile
,
deleteFile
}
from
'
./utils
'
;
import
{
join
}
from
'
path
'
;
suite
(
"
editor tests
"
,
()
=>
{
test
(
'
make edit
'
,
(
done
)
=>
{
createRandomFile
().
then
(
file
=>
{
return
workspace
.
openTextDocument
(
file
).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
).
then
((
editor
)
=>
{
return
editor
.
edit
((
builder
)
=>
{
builder
.
insert
(
new
Position
(
0
,
0
),
'
Hello World
'
);
}).
then
(
applied
=>
{
assert
.
ok
(
applied
);
assert
.
equal
(
doc
.
getText
(),
'
Hello World
'
);
assert
.
ok
(
doc
.
isDirty
);
return
doc
.
save
().
then
(
saved
=>
{
assert
.
ok
(
saved
);
assert
.
ok
(
!
doc
.
isDirty
);
return
deleteFile
(
file
);
});
});
});
});
}).
then
(()
=>
done
(),
(
error
)
=>
done
(
error
));
});
});
\ No newline at end of file
extensions/vscode-api-tests/src/index.ts
浏览文件 @
4ea2714d
...
...
@@ -21,7 +21,8 @@ const testRunner = require('vscode/lib/testrunner');
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
testRunner
.
configure
({
ui
:
'
tdd
'
,
// the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors
:
true
// colored output from test results
useColors
:
true
,
// colored output from test results
timeout
:
10000
});
export
=
testRunner
;
\ No newline at end of file
extensions/vscode-api-tests/src/utils.ts
0 → 100644
浏览文件 @
4ea2714d
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
os
from
'
os
'
;
import
{
join
}
from
'
path
'
;
function
rndName
()
{
return
Math
.
random
().
toString
(
36
).
replace
(
/
[^
a-z
]
+/g
,
''
).
substr
(
0
,
10
);
}
export
function
createRandomFile
(
contents
=
''
):
Thenable
<
vscode
.
Uri
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
tmpFile
=
join
(
os
.
tmpdir
(),
rndName
());
fs
.
writeFile
(
tmpFile
,
contents
,
(
error
)
=>
{
if
(
error
)
{
return
reject
(
error
);
}
resolve
(
vscode
.
Uri
.
file
(
tmpFile
));
});
});
}
export
function
deleteFile
(
file
:
vscode
.
Uri
):
Thenable
<
boolean
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
unlink
(
file
.
fsPath
,
(
err
)
=>
{
if
(
err
)
{
reject
(
err
);
}
else
{
resolve
(
true
);
}
});
});
}
\ No newline at end of file
extensions/vscode-api-tests/src/window.test.ts
浏览文件 @
4ea2714d
...
...
@@ -6,12 +6,18 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
window
,
workspace
}
from
'
vscode
'
;
import
{
workspace
,
window
}
from
'
vscode
'
;
import
{
join
}
from
'
path
'
;
suite
(
"
window namespace texts
"
,
()
=>
{
// test('open document fires event', (done) => {
// });
suite
(
"
window namespace tests
"
,
()
=>
{
test
(
'
active text editor
'
,
(
done
)
=>
{
workspace
.
openTextDocument
(
join
(
workspace
.
rootPath
,
'
./far.js
'
)).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
).
then
((
editor
)
=>
{
const
active
=
window
.
activeTextEditor
;
assert
.
ok
(
active
);
assert
.
equal
(
active
.
document
.
uri
.
fsPath
,
doc
.
uri
.
fsPath
);
});
}).
then
(()
=>
done
(),
(
error
)
=>
done
(
error
));
});
});
\ No newline at end of file
extensions/vscode-api-tests/src/workspace.test.ts
浏览文件 @
4ea2714d
...
...
@@ -6,8 +6,15 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
workspace
,
TextDocument
}
from
'
vscode
'
;
import
{
workspace
,
TextDocument
,
window
,
Position
}
from
'
vscode
'
;
import
{
createRandomFile
,
deleteFile
}
from
'
./utils
'
;
import
{
join
}
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
os
from
'
os
'
;
function
rndName
()
{
return
Math
.
random
().
toString
(
36
).
replace
(
/
[^
a-z
]
+/g
,
''
).
substr
(
0
,
10
);
}
suite
(
'
workspace-namespace
'
,
()
=>
{
...
...
@@ -38,17 +45,52 @@ suite('workspace-namespace', () => {
});
});
// test('createTextDocument', done => {
test
(
'
events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument
'
,
(
done
)
=>
{
createRandomFile
().
then
(
file
=>
{
let
onDidOpenTextDocument
=
false
;
workspace
.
onDidOpenTextDocument
(
e
=>
{
assert
.
equal
(
e
.
uri
.
fsPath
,
file
.
fsPath
);
onDidOpenTextDocument
=
true
;
});
let
onDidChangeTextDocument
=
false
;
workspace
.
onDidChangeTextDocument
(
e
=>
{
assert
.
equal
(
e
.
document
.
uri
.
fsPath
,
file
.
fsPath
);
onDidChangeTextDocument
=
true
;
});
let
onDidSaveTextDocument
=
false
;
workspace
.
onDidSaveTextDocument
(
e
=>
{
assert
.
equal
(
e
.
uri
.
fsPath
,
file
.
fsPath
);
onDidSaveTextDocument
=
true
;
});
return
workspace
.
openTextDocument
(
file
).
then
(
doc
=>
{
return
window
.
showTextDocument
(
doc
).
then
((
editor
)
=>
{
return
editor
.
edit
((
builder
)
=>
{
builder
.
insert
(
new
Position
(
0
,
0
),
'
Hello World
'
);
}).
then
(
applied
=>
{
return
doc
.
save
().
then
(
saved
=>
{
assert
.
ok
(
onDidOpenTextDocument
);
assert
.
ok
(
onDidChangeTextDocument
);
assert
.
ok
(
onDidSaveTextDocument
);
return
deleteFile
(
file
);
});
});
});
});
}).
then
(()
=>
done
(),
(
error
)
=>
done
(
error
));
});
// let text = 'Das Pferd isst keinen Reis.'
test
(
'
findFiles
'
,
done
=>
{
workspace
.
findFiles
(
'
*.js
'
,
null
).
then
((
res
)
=>
{
assert
.
equal
(
res
.
length
,
1
);
assert
.
equal
(
workspace
.
asRelativePath
(
res
[
0
]),
'
/far.js
'
);
// workspace.createTextDocument(text).then(doc => {
// assert.equal(doc.getText(), text);
// assert.equal(doc.uri.scheme, 'untitled');
// assert.equal(doc.languageId, 'plaintext');
// done();
// }, err => {
// done(err);
// });
// });
done
();
},
err
=>
{
done
(
err
);
});
});
});
\ No newline at end of file
src/vs/workbench/electron-main/main.ts
浏览文件 @
4ea2714d
...
...
@@ -190,6 +190,15 @@ function setupIPC(): TPromise<Server> {
// there's a running instance, let's connect to it
return
connect
(
env
.
mainIPCHandle
).
then
(
client
=>
{
// Tests from CLI require to be the only instance currently (TODO@Ben support multiple instances and output)
if
(
env
.
isTestingFromCli
)
{
const
errorMsg
=
'
Running tests from the command line is currently only supported if no other instance of Code is running.
'
;
console
.
error
(
errorMsg
);
return
Promise
.
wrapError
(
errorMsg
);
}
env
.
log
(
'
Sending env to running instance...
'
);
const
service
=
client
.
getService
<
LaunchService
>
(
'
LaunchService
'
,
LaunchService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录