Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
713e5c13
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,发现更多精彩内容 >>
提交
713e5c13
编写于
4月 18, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
screenshot support
上级
66581ee3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
2 deletion
+53
-2
src/vs/platform/driver/common/driver.ts
src/vs/platform/driver/common/driver.ts
+7
-0
src/vs/platform/driver/electron-main/driver.ts
src/vs/platform/driver/electron-main/driver.ts
+12
-0
test/smoke/src/application.ts
test/smoke/src/application.ts
+4
-0
test/smoke/src/main.ts
test/smoke/src/main.ts
+25
-2
test/smoke/src/vscode/code.ts
test/smoke/src/vscode/code.ts
+5
-0
未找到文件。
src/vs/platform/driver/common/driver.ts
浏览文件 @
713e5c13
...
...
@@ -27,6 +27,7 @@ export interface IDriver {
_serviceBrand
:
any
;
getWindowIds
():
TPromise
<
number
[]
>
;
capturePage
(
windowId
:
number
):
TPromise
<
string
>
;
reloadWindow
(
windowId
:
number
):
TPromise
<
void
>
;
dispatchKeybinding
(
windowId
:
number
,
keybinding
:
string
):
TPromise
<
void
>
;
click
(
windowId
:
number
,
selector
:
string
,
xoffset
?:
number
|
undefined
,
yoffset
?:
number
|
undefined
):
TPromise
<
void
>
;
...
...
@@ -43,6 +44,7 @@ export interface IDriver {
export
interface
IDriverChannel
extends
IChannel
{
call
(
command
:
'
getWindowIds
'
):
TPromise
<
number
[]
>
;
call
(
command
:
'
capturePage
'
):
TPromise
<
string
>
;
call
(
command
:
'
reloadWindow
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
dispatchKeybinding
'
,
arg
:
[
number
,
string
]):
TPromise
<
void
>
;
call
(
command
:
'
click
'
,
arg
:
[
number
,
string
,
number
|
undefined
,
number
|
undefined
]):
TPromise
<
void
>
;
...
...
@@ -64,6 +66,7 @@ export class DriverChannel implements IDriverChannel {
call
(
command
:
string
,
arg
?:
any
):
TPromise
<
any
>
{
switch
(
command
)
{
case
'
getWindowIds
'
:
return
this
.
driver
.
getWindowIds
();
case
'
capturePage
'
:
return
this
.
driver
.
capturePage
(
arg
);
case
'
reloadWindow
'
:
return
this
.
driver
.
reloadWindow
(
arg
);
case
'
dispatchKeybinding
'
:
return
this
.
driver
.
dispatchKeybinding
(
arg
[
0
],
arg
[
1
]);
case
'
click
'
:
return
this
.
driver
.
click
(
arg
[
0
],
arg
[
1
],
arg
[
2
],
arg
[
3
]);
...
...
@@ -91,6 +94,10 @@ export class DriverChannelClient implements IDriver {
return
this
.
channel
.
call
(
'
getWindowIds
'
);
}
capturePage
(
windowId
:
number
):
TPromise
<
string
>
{
return
this
.
channel
.
call
(
'
capturePage
'
,
windowId
);
}
reloadWindow
(
windowId
:
number
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
reloadWindow
'
,
windowId
);
}
...
...
src/vs/platform/driver/electron-main/driver.ts
浏览文件 @
713e5c13
...
...
@@ -20,6 +20,7 @@ import { Emitter, toPromise } from 'vs/base/common/event';
// TODO@joao: bad layering!
import
{
KeybindingIO
}
from
'
vs/workbench/services/keybinding/common/keybindingIO
'
;
import
{
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
NativeImage
}
from
'
electron
'
;
class
WindowRouter
implements
IClientRouter
{
...
...
@@ -63,6 +64,17 @@ export class Driver implements IDriver, IWindowDriverRegistry {
.
filter
(
id
=>
this
.
registeredWindowIds
.
has
(
id
)
&&
!
this
.
reloadingWindowIds
.
has
(
id
));
}
async
capturePage
(
windowId
:
number
):
TPromise
<
string
>
{
await
this
.
whenUnfrozen
(
windowId
);
const
window
=
this
.
windowsService
.
getWindowById
(
windowId
);
const
webContents
=
window
.
win
.
webContents
;
const
image
=
await
new
Promise
<
NativeImage
>
(
c
=>
webContents
.
capturePage
(
c
));
const
buffer
=
image
.
toPNG
();
return
buffer
.
toString
(
'
base64
'
);
}
async
reloadWindow
(
windowId
:
number
):
TPromise
<
void
>
{
await
this
.
whenUnfrozen
(
windowId
);
...
...
test/smoke/src/application.ts
浏览文件 @
713e5c13
...
...
@@ -93,6 +93,10 @@ export class Application {
}
}
async
capturePage
():
Promise
<
string
>
{
return
this
.
code
.
capturePage
();
}
private
async
startApplication
(
workspaceOrFolder
:
string
,
extraArgs
:
string
[]
=
[]):
Promise
<
any
>
{
this
.
_code
=
await
spawn
({
codePath
:
this
.
options
.
codePath
,
...
...
test/smoke/src/main.ts
浏览文件 @
713e5c13
...
...
@@ -38,7 +38,8 @@ const opts = minimist(args, {
'
stable-build
'
,
'
wait-time
'
,
'
test-repo
'
,
'
keybindings
'
'
keybindings
'
,
'
screenshots
'
],
boolean
:
[
'
verbose
'
...
...
@@ -55,6 +56,12 @@ const keybindingsPath = path.join(testDataPath, 'keybindings.json');
const
extensionsPath
=
path
.
join
(
testDataPath
,
'
extensions-dir
'
);
mkdirp
.
sync
(
extensionsPath
);
const
screenshotsPath
=
opts
.
screenshots
?
path
.
resolve
(
opts
.
screenshots
)
:
null
;
if
(
screenshotsPath
)
{
mkdirp
.
sync
(
screenshotsPath
);
}
function
fail
(
errorMessage
):
void
{
console
.
error
(
errorMessage
);
process
.
exit
(
1
);
...
...
@@ -256,7 +263,7 @@ describe('Data Migration', () => {
setupDataMigrationTests
(
userDataDir
,
createApp
);
});
describe
(
'
Everything Else
'
,
()
=>
{
describe
(
'
Test
'
,
()
=>
{
before
(
async
function
()
{
const
app
=
createApp
(
quality
);
await
app
!
.
start
();
...
...
@@ -267,6 +274,22 @@ describe('Everything Else', () => {
await
this
.
app
.
stop
();
});
if
(
screenshotsPath
)
{
afterEach
(
async
function
()
{
if
(
this
.
currentTest
.
state
!==
'
failed
'
)
{
return
;
}
const
app
=
this
.
app
as
Application
;
const
raw
=
await
app
.
capturePage
();
const
buffer
=
new
Buffer
(
raw
,
'
base64
'
);
const
name
=
this
.
currentTest
.
fullTitle
().
replace
(
/
[^
a-z0-9
\-]
/ig
,
'
_
'
);
const
screenshotPath
=
path
.
join
(
screenshotsPath
,
`
${
name
}
.png`
);
fs
.
writeFileSync
(
screenshotPath
,
buffer
);
});
}
setupDataLossTests
();
setupDataExplorerTests
();
setupDataPreferencesTests
();
...
...
test/smoke/src/vscode/code.ts
浏览文件 @
713e5c13
...
...
@@ -202,6 +202,11 @@ export class Code {
}
}
async
capturePage
():
Promise
<
string
>
{
const
windowId
=
await
this
.
getActiveWindowId
();
return
await
this
.
driver
.
capturePage
(
windowId
);
}
async
waitForWindowIds
(
fn
:
(
windowIds
:
number
[])
=>
boolean
):
Promise
<
void
>
{
await
poll
(()
=>
this
.
driver
.
getWindowIds
(),
fn
,
`get window ids`
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录