Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
62446d3b
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,发现更多精彩内容 >>
提交
62446d3b
编写于
4月 23, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gridview: first tests
上级
bb0892f0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
122 addition
and
1 deletion
+122
-1
src/vs/base/browser/ui/grid/gridview.ts
src/vs/base/browser/ui/grid/gridview.ts
+26
-1
src/vs/base/test/browser/ui/grid/gridview.test.ts
src/vs/base/test/browser/ui/grid/gridview.test.ts
+96
-0
未找到文件。
src/vs/base/browser/ui/grid/gridview.ts
浏览文件 @
62446d3b
...
...
@@ -38,7 +38,11 @@ export interface IGrid<T extends IView> {
}
function
tail
<
T
>
(
arr
:
T
[]):
[
T
[],
T
]
{
return
[
arr
.
slice
(
0
,
arr
.
length
-
1
),
arr
[
length
-
1
]];
if
(
arr
.
length
===
0
)
{
throw
new
Error
(
'
Invalid tail call
'
);
}
return
[
arr
.
slice
(
0
,
arr
.
length
-
1
),
arr
[
arr
.
length
-
1
]];
}
abstract
class
AbstractNode
implements
IView
{
...
...
@@ -130,12 +134,20 @@ class BranchNode<T extends IView> extends AbstractNode {
}
addChild
(
node
:
Node
<
T
>
,
size
:
number
,
index
:
number
):
void
{
if
(
index
<
0
||
index
>=
this
.
children
.
length
)
{
throw
new
Error
(
'
Invalid index
'
);
}
this
.
splitview
.
addView
(
node
,
size
,
index
);
this
.
children
.
splice
(
index
,
0
,
node
);
this
.
onDidChildrenChange
();
}
removeChild
(
index
:
number
):
Node
<
T
>
{
if
(
index
<
0
||
index
>=
this
.
children
.
length
)
{
throw
new
Error
(
'
Invalid index
'
);
}
const
child
=
this
.
children
[
index
];
this
.
splitview
.
removeView
(
index
);
this
.
children
.
splice
(
index
,
1
);
...
...
@@ -144,10 +156,18 @@ class BranchNode<T extends IView> extends AbstractNode {
}
resizeChild
(
index
:
number
,
size
:
number
):
void
{
if
(
index
<
0
||
index
>=
this
.
children
.
length
)
{
throw
new
Error
(
'
Invalid index
'
);
}
this
.
splitview
.
resizeView
(
index
,
size
);
}
getChildSize
(
index
:
number
):
number
{
if
(
index
<
0
||
index
>=
this
.
children
.
length
)
{
throw
new
Error
(
'
Invalid index
'
);
}
return
this
.
splitview
.
getViewSize
(
index
);
}
...
...
@@ -296,6 +316,11 @@ export class GridView<T extends IView> implements IGrid<T>, IDisposable {
}
const
[
index
,
...
rest
]
=
location
;
if
(
index
<
0
||
index
>=
node
.
children
.
length
)
{
throw
new
Error
(
'
Invalid location
'
);
}
const
child
=
node
.
children
[
index
];
path
.
push
(
node
);
...
...
src/vs/base/test/browser/ui/grid/gridview.test.ts
0 → 100644
浏览文件 @
62446d3b
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
GridView
,
IView
,
Orientation
}
from
'
vs/base/browser/ui/grid/gridview
'
;
class
TestView
implements
IView
{
private
_onDidChange
=
new
Emitter
<
number
|
undefined
>
();
readonly
onDidChange
=
this
.
_onDidChange
.
event
;
get
minimumSize
():
number
{
return
this
.
_minimumSize
;
}
set
minimumSize
(
size
:
number
)
{
this
.
_minimumSize
=
size
;
this
.
_onDidChange
.
fire
();
}
get
maximumSize
():
number
{
return
this
.
_maximumSize
;
}
set
maximumSize
(
size
:
number
)
{
this
.
_maximumSize
=
size
;
this
.
_onDidChange
.
fire
();
}
private
_onDidRender
=
new
Emitter
<
{
container
:
HTMLElement
;
orientation
:
Orientation
}
>
();
readonly
onDidRender
=
this
.
_onDidRender
.
event
;
private
_size
=
0
;
get
size
():
number
{
return
this
.
_size
;
}
private
_onDidLayout
=
new
Emitter
<
{
size
:
number
;
orientation
:
Orientation
}
>
();
readonly
onDidLayout
=
this
.
_onDidLayout
.
event
;
private
_onDidFocus
=
new
Emitter
<
void
>
();
readonly
onDidFocus
=
this
.
_onDidFocus
.
event
;
constructor
(
private
_minimumSize
:
number
,
private
_maximumSize
:
number
)
{
assert
(
_minimumSize
<=
_maximumSize
,
'
splitview view minimum size must be <= maximum size
'
);
}
render
(
container
:
HTMLElement
,
orientation
:
Orientation
):
void
{
this
.
_onDidRender
.
fire
({
container
,
orientation
});
}
layout
(
size
:
number
,
orientation
:
Orientation
):
void
{
this
.
_size
=
size
;
this
.
_onDidLayout
.
fire
({
size
,
orientation
});
}
focus
():
void
{
this
.
_onDidFocus
.
fire
();
}
dispose
():
void
{
this
.
_onDidChange
.
dispose
();
this
.
_onDidRender
.
dispose
();
this
.
_onDidLayout
.
dispose
();
this
.
_onDidFocus
.
dispose
();
}
}
// function getSashes(splitview: SplitView): Sash[] {
// return (splitview as any).sashItems.map(i => i.sash) as Sash[];
// }
suite
(
'
GridView
'
,
function
()
{
let
container
:
HTMLElement
;
setup
(
function
()
{
container
=
document
.
createElement
(
'
div
'
);
container
.
style
.
position
=
'
absolute
'
;
container
.
style
.
width
=
`
${
200
}
px`
;
container
.
style
.
height
=
`
${
200
}
px`
;
});
teardown
(
function
()
{
container
=
null
;
});
test
(
'
empty gridview is empty
'
,
function
()
{
const
gridview
=
new
GridView
(
container
);
assert
.
deepEqual
(
gridview
.
getViews
(),
{
children
:
[]
});
gridview
.
dispose
();
});
test
(
'
gridview addView
'
,
function
()
{
const
gridview
=
new
GridView
(
container
);
const
view
=
new
TestView
(
20
,
20
);
assert
.
throws
(()
=>
gridview
.
addView
(
view
,
200
,
[]),
'
empty location
'
);
assert
.
throws
(()
=>
gridview
.
addView
(
view
,
200
,
[
1
]),
'
index overflow
'
);
assert
.
throws
(()
=>
gridview
.
addView
(
view
,
200
,
[
0
,
0
]),
'
hierarchy overflow
'
);
gridview
.
dispose
();
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录