Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
1a95439a
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
1a95439a
编写于
9月 06, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more textfileservice tests
上级
56b19635
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
120 addition
and
11 deletion
+120
-11
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+4
-4
src/vs/workbench/parts/files/test/browser/textFileServices.test.ts
...rkbench/parts/files/test/browser/textFileServices.test.ts
+111
-7
src/vs/workbench/test/common/editor/untitledEditor.test.ts
src/vs/workbench/test/common/editor/untitledEditor.test.ts
+5
-0
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
1a95439a
...
...
@@ -20,7 +20,7 @@ import {IConfigurationService, getConfigurationValue, IConfigurationValue} from
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
IEditorInput
,
IEditorModel
,
Position
,
Direction
,
IEditor
,
IResourceInput
,
ITextEditorModel
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditor
Options
,
IEditor
Model
,
Position
,
Direction
,
IEditor
,
IResourceInput
,
ITextEditorModel
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IMessageService
,
IConfirmation
}
from
'
vs/platform/message/common/message
'
;
...
...
@@ -413,9 +413,9 @@ export class TestEditorGroupService implements IEditorGroupService {
export
class
TestEditorService
implements
IWorkbenchEditorService
{
public
_serviceBrand
:
any
;
public
activeEditorInput
;
public
activeEditorOptions
;
public
activeEditorPosition
;
public
activeEditorInput
:
IEditorInput
;
public
activeEditorOptions
:
IEditorOptions
;
public
activeEditorPosition
:
Position
;
private
callback
:
(
method
:
string
)
=>
void
;
...
...
src/vs/workbench/parts/files/test/browser/textFileServices.test.ts
浏览文件 @
1a95439a
...
...
@@ -14,6 +14,8 @@ import {TestInstantiationService} from 'vs/test/utils/instantiationTestUtils';
import
{
TextFileEditorModel
,
CACHE
}
from
'
vs/workbench/parts/files/common/editors/textFileEditorModel
'
;
import
{
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
UntitledEditorModel
}
from
'
vs/workbench/common/editor/untitledEditorModel
'
;
function
toResource
(
path
)
{
return
URI
.
file
(
paths
.
join
(
'
C:
\\
'
,
path
));
...
...
@@ -22,7 +24,8 @@ function toResource(path) {
class
ServiceAccessor
{
constructor
(
@
ILifecycleService
public
lifecycleService
:
TestLifecycleService
,
@
ITextFileService
public
textFileService
:
TestTextFileService
@
ITextFileService
public
textFileService
:
TestTextFileService
,
@
IUntitledEditorService
public
untitledEditorService
:
IUntitledEditorService
)
{
}
}
...
...
@@ -52,6 +55,7 @@ suite('Files - TextFileServices', () => {
teardown
(()
=>
{
model
.
dispose
();
CACHE
.
clear
();
accessor
.
untitledEditorService
.
revertAll
();
});
test
(
'
confirm onWillShutdown - no veto
'
,
function
()
{
...
...
@@ -62,12 +66,13 @@ suite('Files - TextFileServices', () => {
});
test
(
'
confirm onWillShutdown - veto if user cancels
'
,
function
(
done
)
{
accessor
.
textFileService
.
setConfirmResult
(
ConfirmResult
.
CANCEL
);
const
service
=
accessor
.
textFileService
;
service
.
setConfirmResult
(
ConfirmResult
.
CANCEL
);
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
equal
(
accessor
.
textFileS
ervice
.
getDirty
().
length
,
1
);
assert
.
equal
(
s
ervice
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
...
...
@@ -79,12 +84,13 @@ suite('Files - TextFileServices', () => {
});
test
(
'
confirm onWillShutdown - no veto if user does not want to save
'
,
function
(
done
)
{
accessor
.
textFileService
.
setConfirmResult
(
ConfirmResult
.
DONT_SAVE
);
const
service
=
accessor
.
textFileService
;
service
.
setConfirmResult
(
ConfirmResult
.
DONT_SAVE
);
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
equal
(
accessor
.
textFileS
ervice
.
getDirty
().
length
,
1
);
assert
.
equal
(
s
ervice
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
...
...
@@ -96,12 +102,13 @@ suite('Files - TextFileServices', () => {
});
test
(
'
confirm onWillShutdown - save
'
,
function
(
done
)
{
accessor
.
textFileService
.
setConfirmResult
(
ConfirmResult
.
SAVE
);
const
service
=
accessor
.
textFileService
;
service
.
setConfirmResult
(
ConfirmResult
.
SAVE
);
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
equal
(
accessor
.
textFileS
ervice
.
getDirty
().
length
,
1
);
assert
.
equal
(
s
ervice
.
getDirty
().
length
,
1
);
const
event
=
new
ShutdownEventImpl
();
accessor
.
lifecycleService
.
fireWillShutdown
(
event
);
...
...
@@ -114,4 +121,101 @@ suite('Files - TextFileServices', () => {
});
});
});
test
(
'
isDirty/getDirty - files and untitled
'
,
function
(
done
)
{
const
service
=
accessor
.
textFileService
;
model
.
load
().
then
(()
=>
{
assert
.
ok
(
!
service
.
isDirty
(
model
.
getResource
()));
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
ok
(
service
.
isDirty
(
model
.
getResource
()));
assert
.
equal
(
service
.
getDirty
().
length
,
1
);
assert
.
equal
(
service
.
getDirty
([
model
.
getResource
()])[
0
].
toString
(),
model
.
getResource
().
toString
());
const
untitled
=
accessor
.
untitledEditorService
.
createOrGet
();
return
untitled
.
resolve
().
then
((
model
:
UntitledEditorModel
)
=>
{
assert
.
ok
(
!
service
.
isDirty
(
untitled
.
getResource
()));
assert
.
equal
(
service
.
getDirty
().
length
,
1
);
model
.
setValue
(
'
changed
'
);
assert
.
ok
(
service
.
isDirty
(
untitled
.
getResource
()));
assert
.
equal
(
service
.
getDirty
().
length
,
2
);
assert
.
equal
(
service
.
getDirty
([
untitled
.
getResource
()])[
0
].
toString
(),
untitled
.
getResource
().
toString
());
done
();
});
});
});
test
(
'
save - file
'
,
function
(
done
)
{
const
service
=
accessor
.
textFileService
;
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
ok
(
service
.
isDirty
(
model
.
getResource
()));
return
service
.
save
(
model
.
getResource
()).
then
(
res
=>
{
assert
.
ok
(
res
);
assert
.
ok
(
!
service
.
isDirty
(
model
.
getResource
()));
done
();
});
});
});
test
(
'
saveAll - file
'
,
function
(
done
)
{
const
service
=
accessor
.
textFileService
;
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
ok
(
service
.
isDirty
(
model
.
getResource
()));
return
service
.
saveAll
([
model
.
getResource
()]).
then
(
res
=>
{
assert
.
ok
(
res
);
assert
.
ok
(
!
service
.
isDirty
(
model
.
getResource
()));
assert
.
equal
(
res
.
results
.
length
,
1
);
assert
.
equal
(
res
.
results
[
0
].
source
.
toString
(),
model
.
getResource
().
toString
());
done
();
});
});
});
test
(
'
saveAs - file
'
,
function
(
done
)
{
const
service
=
accessor
.
textFileService
;
service
.
setPromptPath
(
model
.
getResource
().
fsPath
);
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
ok
(
service
.
isDirty
(
model
.
getResource
()));
return
service
.
saveAs
(
model
.
getResource
()).
then
(
res
=>
{
assert
.
equal
(
res
.
toString
(),
model
.
getResource
().
toString
());
assert
.
ok
(
!
service
.
isDirty
(
model
.
getResource
()));
done
();
});
});
});
test
(
'
revert - file
'
,
function
(
done
)
{
const
service
=
accessor
.
textFileService
;
service
.
setPromptPath
(
model
.
getResource
().
fsPath
);
model
.
load
().
then
(()
=>
{
model
.
textEditorModel
.
setValue
(
'
foo
'
);
assert
.
ok
(
service
.
isDirty
(
model
.
getResource
()));
return
service
.
revert
(
model
.
getResource
()).
then
(
res
=>
{
assert
.
ok
(
res
);
assert
.
ok
(
!
service
.
isDirty
(
model
.
getResource
()));
done
();
});
});
});
});
\ No newline at end of file
src/vs/workbench/test/common/editor/untitledEditor.test.ts
浏览文件 @
1a95439a
...
...
@@ -25,6 +25,9 @@ suite('Workbench - Untitled Editor', () => {
setup
(()
=>
{
instantiationService
=
workbenchInstantiationService
();
accessor
=
instantiationService
.
createInstance
(
ServiceAccessor
);
});
teardown
(()
=>
{
accessor
.
untitledEditorService
.
revertAll
();
});
...
...
@@ -33,6 +36,8 @@ suite('Workbench - Untitled Editor', () => {
assert
.
equal
(
service
.
getAll
().
length
,
0
);
const
input1
=
service
.
createOrGet
();
assert
.
equal
(
input1
,
service
.
createOrGet
(
input1
.
getResource
()));
const
input2
=
service
.
createOrGet
();
// get() / getAll()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录