Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
56e3ca96
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,发现更多精彩内容 >>
提交
56e3ca96
编写于
5月 06, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first test for persisting model
上级
d9fd9aa9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
111 addition
and
9 deletion
+111
-9
src/vs/workbench/common/editor/editorStacksModel.ts
src/vs/workbench/common/editor/editorStacksModel.ts
+2
-2
src/vs/workbench/test/common/editor/editorStacksModel.test.ts
...vs/workbench/test/common/editor/editorStacksModel.test.ts
+84
-6
src/vs/workbench/test/common/servicesTestUtils.ts
src/vs/workbench/test/common/servicesTestUtils.ts
+25
-1
未找到文件。
src/vs/workbench/common/editor/editorStacksModel.ts
浏览文件 @
56e3ca96
...
@@ -95,12 +95,12 @@ export function setOpenEditorDirection(dir: Direction): void {
...
@@ -95,12 +95,12 @@ export function setOpenEditorDirection(dir: Direction): void {
DEFAULT_OPEN_EDITOR_DIRECTION
=
dir
;
DEFAULT_OPEN_EDITOR_DIRECTION
=
dir
;
}
}
interface
ISerializedEditorInput
{
export
interface
ISerializedEditorInput
{
id
:
string
;
id
:
string
;
value
:
string
;
value
:
string
;
}
}
interface
ISerializedEditorGroup
{
export
interface
ISerializedEditorGroup
{
label
:
string
;
label
:
string
;
editors
:
ISerializedEditorInput
[];
editors
:
ISerializedEditorInput
[];
mru
:
number
[];
mru
:
number
[];
...
...
src/vs/workbench/test/common/editor/editorStacksModel.test.ts
浏览文件 @
56e3ca96
...
@@ -8,16 +8,19 @@
...
@@ -8,16 +8,19 @@
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
EditorStacksModel
,
IEditorStacksModel
,
IEditorGroup
,
setOpenEditorDirection
,
Direction
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
EditorStacksModel
,
IEditorStacksModel
,
IEditorGroup
,
setOpenEditorDirection
,
Direction
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
TestStorageService
}
from
'
vs/workbench/test/common/servicesTestUtils
'
;
import
{
TestStorageService
,
TestLifecycleService
}
from
'
vs/workbench/test/common/servicesTestUtils
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ILifecycleService
,
NullLifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
,
IEditorInputFactory
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
function
create
():
IEditorStacksModel
{
function
create
():
IEditorStacksModel
{
let
services
=
new
ServiceCollection
();
let
services
=
new
ServiceCollection
();
services
.
set
(
IStorageService
,
new
TestStorageService
());
services
.
set
(
IStorageService
,
new
TestStorageService
());
services
.
set
(
ILifecycleService
,
NullLifecycleService
);
services
.
set
(
ILifecycleService
,
new
TestLifecycleService
()
);
let
inst
=
new
InstantiationService
(
services
);
let
inst
=
new
InstantiationService
(
services
);
...
@@ -75,14 +78,52 @@ class TestEditorInput extends EditorInput {
...
@@ -75,14 +78,52 @@ class TestEditorInput extends EditorInput {
constructor
(
public
id
:
string
)
{
constructor
(
public
id
:
string
)
{
super
();
super
();
}
}
public
getId
()
{
return
'
id
'
;
}
public
getId
()
{
return
'
testEditorInput
'
;
}
public
resolve
()
{
return
null
;
}
public
resolve
()
{
return
null
;
}
public
matches
(
other
:
TestEditorInput
):
boolean
{
return
this
.
id
===
other
.
id
;
}
}
class
NonSerializableTestEditorInput
extends
EditorInput
{
constructor
(
public
id
:
string
)
{
super
();
}
public
getId
()
{
return
'
testEditorInput-nonSerializable
'
;
}
public
resolve
()
{
return
null
;
}
}
function
input
(
id
=
String
(
index
++
),
nonSerializable
?:
boolean
):
EditorInput
{
return
nonSerializable
?
new
NonSerializableTestEditorInput
(
id
)
:
new
TestEditorInput
(
id
);
}
}
function
input
(
id
=
String
(
index
++
)):
Editor
Input
{
interface
ISerializedTest
Input
{
return
new
TestEditorInput
(
id
)
;
id
:
string
;
}
}
class
TestEditorInputFactory
implements
IEditorInputFactory
{
constructor
()
{
}
public
serialize
(
editorInput
:
EditorInput
):
string
{
let
testEditorInput
=
<
TestEditorInput
>
editorInput
;
let
testInput
:
ISerializedTestInput
=
{
id
:
testEditorInput
.
id
};
return
JSON
.
stringify
(
testInput
);
}
public
deserialize
(
instantiationService
:
IInstantiationService
,
serializedEditorInput
:
string
):
EditorInput
{
let
testInput
:
ISerializedTestInput
=
JSON
.
parse
(
serializedEditorInput
);
return
new
TestEditorInput
(
testInput
.
id
);
}
}
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
registerEditorInputFactory
(
'
testEditorInput
'
,
TestEditorInputFactory
);
suite
(
'
Editor Stacks Model
'
,
()
=>
{
suite
(
'
Editor Stacks Model
'
,
()
=>
{
teardown
(()
=>
{
teardown
(()
=>
{
...
@@ -642,4 +683,41 @@ suite('Editor Stacks Model', () => {
...
@@ -642,4 +683,41 @@ suite('Editor Stacks Model', () => {
assert
.
equal
(
group
.
activeEditor
,
null
);
assert
.
equal
(
group
.
activeEditor
,
null
);
assert
.
equal
(
group
.
previewEditor
,
null
);
assert
.
equal
(
group
.
previewEditor
,
null
);
});
});
test
(
'
Stack - Single Group, Single Editor - persist
'
,
function
()
{
let
services
=
new
ServiceCollection
();
services
.
set
(
IStorageService
,
new
TestStorageService
());
const
lifecycle
=
new
TestLifecycleService
();
services
.
set
(
ILifecycleService
,
lifecycle
);
let
inst
=
new
InstantiationService
(
services
);
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
setInstantiationService
(
inst
);
let
model
:
IEditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
const
group
=
model
.
openGroup
(
'
group
'
);
const
input1
=
input
();
group
.
openEditor
(
input1
);
assert
.
equal
(
model
.
groups
.
length
,
1
);
assert
.
equal
(
group
.
count
,
1
);
assert
.
equal
(
group
.
activeEditor
.
matches
(
input1
),
true
);
assert
.
equal
(
group
.
previewEditor
.
matches
(
input1
),
true
);
assert
.
equal
(
group
.
label
,
'
group
'
);
assert
.
equal
(
group
.
isActive
(
input1
),
true
);
lifecycle
.
fireShutdown
();
// Create model again - should load from storage
model
=
inst
.
createInstance
(
EditorStacksModel
);
assert
.
equal
(
model
.
groups
.
length
,
1
);
assert
.
equal
(
group
.
count
,
1
);
assert
.
equal
(
group
.
activeEditor
.
matches
(
input1
),
true
);
assert
.
equal
(
group
.
previewEditor
.
matches
(
input1
),
true
);
assert
.
equal
(
group
.
label
,
'
group
'
);
assert
.
equal
(
group
.
isActive
(
input1
),
true
);
});
});
});
\ No newline at end of file
src/vs/workbench/test/common/servicesTestUtils.ts
浏览文件 @
56e3ca96
...
@@ -12,7 +12,7 @@ import URI from 'vs/base/common/uri';
...
@@ -12,7 +12,7 @@ import URI from 'vs/base/common/uri';
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
Storage
=
require
(
'
vs/workbench/common/storage
'
);
import
Storage
=
require
(
'
vs/workbench/common/storage
'
);
import
WorkbenchEditorCommon
=
require
(
'
vs/workbench/common/editor
'
);
import
WorkbenchEditorCommon
=
require
(
'
vs/workbench/common/editor
'
);
import
Event
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Types
=
require
(
'
vs/base/common/types
'
);
import
Types
=
require
(
'
vs/base/common/types
'
);
import
Severity
from
'
vs/base/common/severity
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
http
=
require
(
'
vs/base/common/http
'
);
import
http
=
require
(
'
vs/base/common/http
'
);
...
@@ -28,6 +28,7 @@ import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/unti
...
@@ -28,6 +28,7 @@ import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/unti
import
{
IMessageService
,
IConfirmation
}
from
'
vs/platform/message/common/message
'
;
import
{
IMessageService
,
IConfirmation
}
from
'
vs/platform/message/common/message
'
;
import
{
BaseRequestService
}
from
'
vs/platform/request/common/baseRequestService
'
;
import
{
BaseRequestService
}
from
'
vs/platform/request/common/baseRequestService
'
;
import
{
IWorkspace
,
IConfiguration
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspace
,
IConfiguration
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILifecycleService
,
ShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
export
const
TestWorkspace
:
IWorkspace
=
{
export
const
TestWorkspace
:
IWorkspace
=
{
resource
:
URI
.
file
(
'
C:
\\
testWorkspace
'
),
resource
:
URI
.
file
(
'
C:
\\
testWorkspace
'
),
...
@@ -460,4 +461,27 @@ export class TestConfigurationService extends EventEmitter.EventEmitter implemen
...
@@ -460,4 +461,27 @@ export class TestConfigurationService extends EventEmitter.EventEmitter implemen
public
onDidUpdateConfiguration
()
{
public
onDidUpdateConfiguration
()
{
return
{
dispose
()
{
}
};
return
{
dispose
()
{
}
};
}
}
}
export
class
TestLifecycleService
implements
ILifecycleService
{
public
serviceId
=
ILifecycleService
;
private
_onWillShutdown
=
new
Emitter
<
ShutdownEvent
>
();
private
_onShutdown
=
new
Emitter
<
void
>
();
constructor
()
{
}
public
fireShutdown
():
void
{
this
.
_onShutdown
.
fire
();
}
public
get
onWillShutdown
():
Event
<
ShutdownEvent
>
{
return
this
.
_onWillShutdown
.
event
;
}
public
get
onShutdown
():
Event
<
void
>
{
return
this
.
_onShutdown
.
event
;
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录