Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
aa70d314
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,发现更多精彩内容 >>
提交
aa70d314
编写于
4月 23, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gridview: addView tests
上级
62446d3b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
33 addition
and
19 deletion
+33
-19
src/vs/base/browser/ui/grid/gridview.ts
src/vs/base/browser/ui/grid/gridview.ts
+12
-12
src/vs/base/test/browser/ui/grid/gridview.test.ts
src/vs/base/test/browser/ui/grid/gridview.test.ts
+21
-7
未找到文件。
src/vs/base/browser/ui/grid/gridview.ts
浏览文件 @
aa70d314
...
...
@@ -17,15 +17,15 @@ function orthogonal(orientation: Orientation): Orientation {
return
orientation
===
Orientation
.
VERTICAL
?
Orientation
.
HORIZONTAL
:
Orientation
.
VERTICAL
;
}
export
interface
I
LeafNode
<
T
extends
IView
>
{
view
:
T
;
export
class
Grid
LeafNode
<
T
extends
IView
>
{
constructor
(
readonly
view
:
T
)
{
}
}
export
interface
I
BranchNode
<
T
extends
IView
>
{
c
hildren
:
IGridNode
<
T
>
[];
export
class
Grid
BranchNode
<
T
extends
IView
>
{
c
onstructor
(
readonly
children
:
GridNode
<
T
>
[])
{
}
}
export
type
IGridNode
<
T
extends
IView
>
=
ILeafNode
<
T
>
|
I
BranchNode
<
T
>
;
export
type
GridNode
<
T
extends
IView
>
=
GridLeafNode
<
T
>
|
Grid
BranchNode
<
T
>
;
export
interface
IGrid
<
T
extends
IView
>
{
layout
(
width
:
number
,
height
:
number
):
void
;
...
...
@@ -34,7 +34,7 @@ export interface IGrid<T extends IView> {
moveView
(
from
:
number
[],
to
:
number
[]):
void
;
resizeView
(
location
:
number
[],
size
:
number
):
void
;
getViewSize
(
location
:
number
[]):
number
;
getViews
():
I
BranchNode
<
T
>
;
getViews
():
Grid
BranchNode
<
T
>
;
}
function
tail
<
T
>
(
arr
:
T
[]):
[
T
[],
T
]
{
...
...
@@ -134,7 +134,7 @@ class BranchNode<T extends IView> extends AbstractNode {
}
addChild
(
node
:
Node
<
T
>
,
size
:
number
,
index
:
number
):
void
{
if
(
index
<
0
||
index
>
=
this
.
children
.
length
)
{
if
(
index
<
0
||
index
>
this
.
children
.
length
)
{
throw
new
Error
(
'
Invalid index
'
);
}
...
...
@@ -294,15 +294,15 @@ export class GridView<T extends IView> implements IGrid<T>, IDisposable {
return
parent
.
getChildSize
(
index
);
}
getViews
():
I
BranchNode
<
T
>
{
return
this
.
_getViews
(
this
.
root
)
as
I
BranchNode
<
T
>
;
getViews
():
Grid
BranchNode
<
T
>
{
return
this
.
_getViews
(
this
.
root
)
as
Grid
BranchNode
<
T
>
;
}
private
_getViews
(
node
:
Node
<
T
>
):
I
GridNode
<
T
>
{
private
_getViews
(
node
:
Node
<
T
>
):
GridNode
<
T
>
{
if
(
node
instanceof
BranchNode
)
{
return
{
children
:
node
.
children
.
map
(
c
=>
this
.
_getViews
(
c
))
}
;
return
new
GridBranchNode
(
node
.
children
.
map
(
c
=>
this
.
_getViews
(
c
)))
;
}
else
{
return
{
view
:
node
.
view
}
;
return
new
GridLeafNode
(
node
.
view
)
;
}
}
...
...
src/vs/base/test/browser/ui/grid/gridview.test.ts
浏览文件 @
aa70d314
...
...
@@ -5,7 +5,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
GridView
,
IView
,
Orientation
}
from
'
vs/base/browser/ui/grid/gridview
'
;
import
{
GridView
,
IView
,
Orientation
,
GridNode
,
GridBranchNode
}
from
'
vs/base/browser/ui/grid/gridview
'
;
class
TestView
implements
IView
{
...
...
@@ -33,7 +33,7 @@ class TestView implements IView {
private
_minimumSize
:
number
,
private
_maximumSize
:
number
)
{
assert
(
_minimumSize
<=
_maximumSize
,
'
split
view view minimum size must be <= maximum size
'
);
assert
(
_minimumSize
<=
_maximumSize
,
'
grid
view view minimum size must be <= maximum size
'
);
}
render
(
container
:
HTMLElement
,
orientation
:
Orientation
):
void
{
...
...
@@ -57,10 +57,13 @@ class TestView implements IView {
}
}
// function getSashes(splitview: SplitView): Sash[] {
// return (splitview as any).sashItems.map(i => i.sash) as Sash[];
// }
function
nodesToArrays
(
node
:
GridNode
<
any
>
):
any
{
if
(
node
instanceof
GridBranchNode
)
{
return
node
.
children
.
map
(
nodesToArrays
);
}
else
{
return
node
.
view
;
}
}
suite
(
'
GridView
'
,
function
()
{
let
container
:
HTMLElement
;
...
...
@@ -86,11 +89,22 @@ suite('GridView', 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
'
);
const
views
=
[
new
TestView
(
20
,
20
),
new
TestView
(
20
,
20
),
new
TestView
(
20
,
20
)
];
gridview
.
addView
(
views
[
0
],
200
,
[
0
]);
gridview
.
addView
(
views
[
1
],
200
,
[
1
]);
gridview
.
addView
(
views
[
2
],
200
,
[
2
]);
assert
.
deepEqual
(
nodesToArrays
(
gridview
.
getViews
()),
views
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录