Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
78d76cb1
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,发现更多精彩内容 >>
提交
78d76cb1
编写于
9月 06, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
smoke test: adopt terminal tests
上级
8ce75db7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
106 addition
and
60 deletion
+106
-60
test/smoke/src/areas/git/git.test.ts
test/smoke/src/areas/git/git.test.ts
+2
-5
test/smoke/src/areas/integrated-terminal.ts
test/smoke/src/areas/integrated-terminal.ts
+0
-54
test/smoke/src/areas/statusbar/statusbar.ts
test/smoke/src/areas/statusbar/statusbar.ts
+0
-1
test/smoke/src/areas/terminal/terminal.test.ts
test/smoke/src/areas/terminal/terminal.test.ts
+24
-0
test/smoke/src/areas/terminal/terminal.ts
test/smoke/src/areas/terminal/terminal.ts
+75
-0
test/smoke/src/areas/workbench/workbench.ts
test/smoke/src/areas/workbench/workbench.ts
+3
-0
test/smoke/src/main.ts
test/smoke/src/main.ts
+2
-0
未找到文件。
test/smoke/src/areas/git/git.test.ts
浏览文件 @
78d76cb1
...
...
@@ -10,11 +10,8 @@ const DIFF_EDITOR_LINE_INSERT = '.monaco-diff-editor .editor.modified .line-inse
const
SYNC_STATUSBAR
=
'
div[id="workbench.parts.statusbar"] .statusbar-entry a[title$="Synchronize Changes"]
'
;
describe
(
'
Git
'
,
()
=>
{
let
app
:
SpectronApplication
;
before
(()
=>
{
app
=
new
SpectronApplication
(
LATEST_PATH
,
''
,
0
,
[
WORKSPACE_PATH
]);
return
app
.
start
();
});
let
app
:
SpectronApplication
=
new
SpectronApplication
(
LATEST_PATH
,
''
,
0
,
[
WORKSPACE_PATH
]);
before
(()
=>
app
.
start
());
after
(()
=>
app
.
stop
());
it
(
'
reflects working tree changes
'
,
async
function
()
{
...
...
test/smoke/src/areas/integrated-terminal.ts
已删除
100644 → 0
浏览文件 @
8ce75db7
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
SpectronApplication
}
from
'
../spectron/application
'
;
import
{
CommonActions
}
from
'
./common
'
;
export
class
IntegratedTerminal
{
public
static
terminalSelector
=
'
div[id="workbench.panel.terminal"]
'
;
public
static
terminalRowsSelector
=
'
div[id="workbench.panel.terminal"] .xterm-rows
'
;
constructor
(
private
spectron
:
SpectronApplication
)
{
// noop
}
public
async
openTerminal
(
commonActions
:
CommonActions
):
Promise
<
any
>
{
// Backquote dispatching does not work in OS X
if
(
process
.
platform
===
'
darwin
'
)
{
await
commonActions
.
showCommands
();
await
commonActions
.
type
(
'
Toggle Integrated Terminal
'
);
return
commonActions
.
enter
();
}
await
this
.
spectron
.
command
(
'
workbench.action.terminal.toggleTerminal
'
);
// If no terminal panel was opened, try triggering terminal from quick open
try
{
await
this
.
spectron
.
client
.
waitForHTML
(
IntegratedTerminal
.
terminalSelector
);
}
catch
(
e
)
{
await
commonActions
.
openQuickOpen
();
await
this
.
spectron
.
client
.
keys
(
'
>Toggle Integrated Terminal
'
);
await
this
.
spectron
.
client
.
keys
([
'
Enter
'
,
'
NULL
'
]);
}
}
public
async
commandOutputHas
(
result
:
string
):
Promise
<
boolean
>
{
const
rows
=
await
this
.
spectron
.
client
.
waitForElements
(
`
${
IntegratedTerminal
.
terminalRowsSelector
}
div`
);
for
(
let
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
let
rowText
;
try
{
rowText
=
await
this
.
spectron
.
client
.
getText
(
`
${
IntegratedTerminal
.
terminalRowsSelector
}
>:nth-child(
${
i
+
1
}
)`
);
}
catch
(
e
)
{
return
Promise
.
reject
(
`Failed to obtain text from line
${
i
+
1
}
from the terminal.`
);
}
if
(
rowText
.
trim
()
===
result
)
{
return
true
;
}
}
return
false
;
}
}
\ No newline at end of file
test/smoke/src/areas/statusbar/statusbar.ts
浏览文件 @
78d76cb1
...
...
@@ -19,7 +19,6 @@ export enum StatusBarElement {
export
class
StatusBar
{
// private selectorsMap: Map<StatusBarElement, string>;
private
readonly
mainSelector
=
'
div[id="workbench.parts.statusbar"]
'
;
constructor
(
private
spectron
:
SpectronApplication
)
{
...
...
test/smoke/src/
tests/integrated-terminal
.ts
→
test/smoke/src/
areas/terminal/terminal.test
.ts
浏览文件 @
78d76cb1
...
...
@@ -4,37 +4,21 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
SpectronApplication
,
LATEST_PATH
,
WORKSPACE_PATH
}
from
'
../../spectron/application
'
;
import
{
SpectronApplication
,
LATEST_PATH
,
WORKSPACE_PATH
}
from
'
../spectron/application
'
;
import
{
CommonActions
}
from
'
../areas/common
'
;
import
{
IntegratedTerminal
}
from
'
../areas/integrated-terminal
'
;
describe
(
'
Terminal
'
,
()
=>
{
let
app
:
SpectronApplication
=
new
SpectronApplication
(
LATEST_PATH
,
''
,
0
,
[
WORKSPACE_PATH
]);
before
(()
=>
app
.
start
());
after
(()
=>
app
.
stop
());
let
app
:
SpectronApplication
;
let
common
:
CommonActions
;
it
(
`opens terminal, runs 'echo' and verifies the output`
,
async
function
()
{
const
expected
=
new
Date
().
getTime
().
toString
();
await
app
.
workbench
.
terminal
.
showTerminal
();
export
function
testIntegratedTerminal
()
{
describe
(
'
Integrated Terminal
'
,
()
=>
{
let
terminal
:
IntegratedTerminal
;
const
currentLine
=
await
app
.
workbench
.
terminal
.
getCurrentLineNumber
();
await
app
.
workbench
.
terminal
.
runCommand
(
`echo
${
expected
}
`
);
beforeEach
(
async
function
()
{
app
=
new
SpectronApplication
(
LATEST_PATH
,
this
.
currentTest
.
fullTitle
(),
(
this
.
currentTest
as
any
).
currentRetry
(),
[
WORKSPACE_PATH
]);
common
=
new
CommonActions
(
app
);
terminal
=
new
IntegratedTerminal
(
app
);
return
await
app
.
start
();
});
afterEach
(
async
function
()
{
return
await
app
.
stop
();
});
it
(
`opens terminal, runs 'echo' and verifies the output`
,
async
function
()
{
const
command
=
'
echo test
'
;
await
terminal
.
openTerminal
(
common
);
await
app
.
wait
();
await
common
.
type
(
command
);
await
common
.
enter
();
await
app
.
wait
();
assert
.
ok
(
await
terminal
.
commandOutputHas
(
'
test
'
),
'
Terminal output does not contain echo.
'
);
});
const
actual
=
await
app
.
workbench
.
terminal
.
waitForText
(
currentLine
+
1
,
text
=>
!!
text
.
trim
());
assert
.
equal
(
actual
.
trim
(),
expected
);
});
}
\ No newline at end of file
});
\ No newline at end of file
test/smoke/src/areas/terminal/terminal.ts
0 → 100644
浏览文件 @
78d76cb1
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
SpectronApplication
}
from
'
../../spectron/application
'
;
export
class
Terminal
{
static
TERMINAL_SELECTOR
=
'
.panel.integrated-terminal
'
;
static
TERMINAL_ROWS_SELECTOR
=
`
${
Terminal
.
TERMINAL_SELECTOR
}
.xterm-rows > div`
;
constructor
(
private
spectron
:
SpectronApplication
)
{
}
public
async
showTerminal
():
Promise
<
void
>
{
if
(
!
await
this
.
isVisible
())
{
await
this
.
spectron
.
workbench
.
commandPallette
.
runCommand
(
'
Toggle Integrated Terminal
'
);
await
this
.
spectron
.
client
.
waitForElement
(
Terminal
.
TERMINAL_SELECTOR
);
await
this
.
waitForText
(
1
,
text
=>
text
.
trim
().
indexOf
(
'
vscode-smoketest-express git:(master)
'
)
!==
-
1
);
}
}
public
async
isVisible
():
Promise
<
boolean
>
{
const
element
=
await
this
.
spectron
.
client
.
element
(
Terminal
.
TERMINAL_SELECTOR
);
return
!!
element
;
}
public
async
runCommand
(
commandText
:
string
):
Promise
<
void
>
{
await
this
.
spectron
.
type
(
commandText
);
await
this
.
spectron
.
client
.
keys
([
'
Enter
'
,
'
NULL
'
]);
}
public
async
waitForText
(
line
:
number
,
fn
:
(
text
:
string
)
=>
boolean
):
Promise
<
string
>
{
return
this
.
spectron
.
client
.
waitFor
(
async
()
=>
{
const
terminalText
=
await
this
.
getTerminalText
();
if
(
fn
(
terminalText
[
line
-
1
]))
{
return
terminalText
[
line
-
1
];
}
return
undefined
;
});
}
public
getCurrentLineNumber
():
Promise
<
number
>
{
return
this
.
getTerminalText
().
then
(
text
=>
text
.
length
);
}
private
async
getTerminalText
():
Promise
<
string
[]
>
{
const
linesText
:
string
[]
=
await
this
.
spectron
.
webclient
.
selectorExecute
<
string
[]
>
(
Terminal
.
TERMINAL_ROWS_SELECTOR
,
div
=>
(
Array
.
isArray
(
div
)
?
div
:
[
div
])
.
map
(
element
=>
{
function
getTextFromAll
(
spanElements
:
NodeList
):
string
{
let
text
=
''
;
for
(
let
i
=
0
;
i
<
spanElements
.
length
;
i
++
)
{
text
+=
getText
(
spanElements
.
item
(
i
)
as
HTMLElement
);
}
return
text
;
}
function
getText
(
spanElement
:
HTMLElement
):
string
{
if
(
spanElement
.
hasChildNodes
())
{
return
getTextFromAll
(
spanElement
.
childNodes
);
}
return
spanElement
.
textContent
||
''
;
}
return
getTextFromAll
(
element
.
querySelectorAll
(
'
span
'
));
}));
let
lastLineIndex
=
0
;
for
(
let
index
=
0
;
index
<
linesText
.
length
;
index
++
)
{
if
(
linesText
[
index
].
trim
())
{
lastLineIndex
=
index
;
}
}
return
linesText
.
slice
(
0
,
lastLineIndex
+
1
);
}
}
\ No newline at end of file
test/smoke/src/areas/workbench/workbench.ts
浏览文件 @
78d76cb1
...
...
@@ -18,6 +18,7 @@ import { StatusBar } from '../statusbar/statusbar';
import
{
Problems
}
from
'
../problems/problems
'
;
import
{
SettingsEditor
}
from
'
../preferences/settings
'
;
import
{
KeybindingsEditor
}
from
'
../preferences/keybindings
'
;
import
{
Terminal
}
from
'
../terminal/terminal
'
;
export
class
Workbench
{
...
...
@@ -34,6 +35,7 @@ export class Workbench {
readonly
problems
:
Problems
;
readonly
settingsEditor
:
SettingsEditor
;
readonly
keybindingsEditor
:
KeybindingsEditor
;
readonly
terminal
:
Terminal
;
constructor
(
private
spectron
:
SpectronApplication
)
{
this
.
explorer
=
new
Explorer
(
spectron
);
...
...
@@ -49,6 +51,7 @@ export class Workbench {
this
.
problems
=
new
Problems
(
spectron
);
this
.
settingsEditor
=
new
SettingsEditor
(
spectron
);
this
.
keybindingsEditor
=
new
KeybindingsEditor
(
spectron
);
this
.
terminal
=
new
Terminal
(
spectron
);
}
public
async
saveOpenedFile
():
Promise
<
any
>
{
...
...
test/smoke/src/main.ts
浏览文件 @
78d76cb1
...
...
@@ -176,4 +176,6 @@ import './areas/workbench/data-loss.test';
import
'
./areas/git/git.test
'
;
import
'
./areas/statusbar/statusbar.test
'
;
import
'
./areas/debug/debug.test
'
;
import
'
./areas/workbench/localization.test
'
;
import
'
./areas/terminal/terminal.test
'
;
// import './areas/workbench/data-migration.test';
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录