Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
525b1c84
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
525b1c84
编写于
5月 07, 2021
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(visual): fix actions manager. fix some runtime issue
上级
05a0c7d1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
40 deletion
+33
-40
test/runTest/cli.js
test/runTest/cli.js
+10
-10
test/runTest/runtime/ActionPlayback.js
test/runTest/runtime/ActionPlayback.js
+17
-18
test/runTest/runtime/main.js
test/runTest/runtime/main.js
+1
-1
test/runTest/server.js
test/runTest/server.js
+1
-1
test/runTest/store.js
test/runTest/store.js
+4
-10
未找到文件。
test/runTest/cli.js
浏览文件 @
525b1c84
...
...
@@ -122,7 +122,7 @@ async function takeScreenshot(page, fullPage, fileUrl, desc, isExpected, minor)
};
}
async
function
runActions
(
page
,
testOpt
,
isExpected
,
screenshots
)
{
async
function
runActions
(
page
,
testOpt
)
{
let
actions
;
try
{
let
actContent
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
actions
'
,
testOpt
.
name
+
'
.json
'
));
...
...
@@ -132,10 +132,11 @@ async function runActions(page, testOpt, isExpected, screenshots) {
// Can't find actions
return
;
}
await
page
.
evaluate
(
async
(
actions
)
=>
{
await
__VST_RUN_ACTIONS__
(
actions
);
},
actions
);
if
(
actions
.
length
>
0
)
{
await
page
.
evaluate
(
async
(
actions
)
=>
{
await
__VST_RUN_ACTIONS__
(
actions
);
},
actions
);
}
}
async
function
runTestPage
(
browser
,
testOpt
,
version
,
runtimeCode
,
isExpected
)
{
...
...
@@ -148,7 +149,6 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
page
.
setRequestInterception
(
true
);
page
.
on
(
'
request
'
,
request
=>
replaceEChartsVersion
(
request
,
version
));
async
function
pageScreenshot
()
{
if
(
!
program
.
save
)
{
return
;
...
...
@@ -226,18 +226,18 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
timeout
:
10000
});
let
auto
s
creenshotTimeout
;
let
auto
S
creenshotTimeout
;
// TODO Use waitForFunction?
await
Promise
.
race
([
waitClientScreenshot
,
new
Promise
(
resolve
=>
{
auto
s
creenshotTimeout
=
setTimeout
(()
=>
{
auto
S
creenshotTimeout
=
setTimeout
(()
=>
{
console
.
log
(
`Automatically screenshot in
${
testNameFromFile
(
fileUrl
)}
`
);
pageScreenshot
().
then
(
resolve
)
},
1000
)
})
]);
clearTimeout
(
auto
s
creenshotTimeout
);
clearTimeout
(
auto
S
creenshotTimeout
);
await
runActions
(
page
,
testOpt
,
isExpected
,
screenshots
);
}
...
...
test/runTest/runtime/ActionPlayback.js
浏览文件 @
525b1c84
...
...
@@ -68,22 +68,22 @@ export class ActionPlayback {
let
self
=
this
;
async
function
takeScreenshot
()
{
// Pause timeline when doing screenshot to avoid screenshot needs taking a while.
timeline
.
pause
();
await
__VST_ACTION_SCREENSHOT__
(
action
);
timeline
.
resume
();
}
return
new
Promise
(
resolve
=>
{
async
function
tick
()
{
// Date has multiplied playbackSpeed
let
current
=
Date
.
now
();
let
dTime
=
current
-
self
.
_current
;
self
.
_elapsedTime
+=
dTime
*
playbackSpeed
;
self
.
_elapsedTime
+=
dTime
;
self
.
_current
=
current
;
await
self
.
_update
(
async
()
=>
{
// Pause timeline when doing screenshot to avoid screenshot needs taking a while.
timeline
.
pause
();
await
__VST_ACTION_SCREENSHOT__
(
action
);
timeline
.
resume
();
},
playbackSpeed
);
await
self
.
_update
(
takeScreenshot
,
playbackSpeed
);
if
(
self
.
_currentOpIndex
>=
self
.
_ops
.
length
)
{
// Finished
resolve
();
...
...
@@ -104,7 +104,7 @@ export class ActionPlayback {
}
}
async
_update
(
playbackSpeed
)
{
async
_update
(
takeScreenshot
,
playbackSpeed
)
{
let
op
=
this
.
_ops
[
this
.
_currentOpIndex
];
if
(
op
.
time
>
this
.
_elapsedTime
)
{
...
...
@@ -112,8 +112,7 @@ export class ActionPlayback {
return
;
}
let
page
=
this
.
_page
;
let
takenScreenshot
=
false
;
let
screenshotTaken
=
false
;
switch
(
op
.
type
)
{
case
'
mousedown
'
:
await
__VST_MOUSE_MOVE__
(
op
.
x
,
op
.
y
);
...
...
@@ -121,7 +120,7 @@ export class ActionPlayback {
break
;
case
'
mouseup
'
:
await
__VST_MOUSE_MOVE__
(
op
.
x
,
op
.
y
);
await
page
.
mouse
.
up
();
await
__VST_MOUSE_UP__
();
break
;
case
'
mousemove
'
:
await
__VST_MOUSE_MOVE__
(
op
.
x
,
op
.
y
);
...
...
@@ -143,7 +142,7 @@ export class ActionPlayback {
break
;
case
'
screenshot
'
:
await
takeScreenshot
();
takenScreenshot
=
true
;
screenshotTaken
=
true
;
break
;
case
'
valuechange
'
:
document
.
querySelector
(
op
.
selector
).
value
=
op
.
value
;
...
...
@@ -159,14 +158,14 @@ export class ActionPlayback {
// TODO Configuration time
await
waitTime
(
delay
/
playbackSpeed
);
await
takeScreenshot
();
takenScreenshot
=
true
;
screenshotTaken
=
true
;
this
.
_currentOpIndex
++
;
}
if
(
this
.
_isLastOpMousewheel
&&
op
.
type
!==
'
mousewheel
'
)
{
// Only take screenshot after mousewheel finished
if
(
!
takenScreenshot
)
{
takeScreenshot
();
if
(
!
screenshotTaken
)
{
await
takeScreenshot
();
}
this
.
_isLastOpMousewheel
=
false
;
}
...
...
test/runTest/runtime/main.js
浏览文件 @
525b1c84
...
...
@@ -57,7 +57,7 @@ window.__VST_RUN_ACTIONS__ = async function (actions) {
timeline
.
resume
();
const
actionPlayback
=
new
ActionPlayback
();
for
(
let
action
of
actions
)
{
await
actionPlayback
.
runAction
(
action
);
await
actionPlayback
.
runAction
(
action
,
__VST_PLAYBACK_SPEED__
);
}
actionPlayback
.
stop
();
}
...
...
test/runTest/server.js
浏览文件 @
525b1c84
...
...
@@ -361,7 +361,6 @@ async function start() {
});
io
.
of
(
'
/recorder
'
).
on
(
'
connect
'
,
async
socket
=>
{
await
updateTestsList
();
socket
.
on
(
'
saveActions
'
,
data
=>
{
if
(
data
.
testName
)
{
fse
.
outputFile
(
...
...
@@ -403,6 +402,7 @@ async function start() {
});
socket
.
emit
(
'
getTests
'
,
{
// TODO updateTestsList.
tests
:
getTestsList
().
map
(
test
=>
{
return
{
name
:
test
.
name
,
...
...
test/runTest/store.js
浏览文件 @
525b1c84
...
...
@@ -181,12 +181,14 @@ module.exports.updateTestsList = async function (
_tests
.
push
(
_testsMap
[
key
]);
});
cons
t
actionsMetaData
=
{};
le
t
actionsMetaData
=
{};
const
metaPath
=
path
.
join
(
__dirname
,
'
actions/__meta__.json
'
);
try
{
actionsMetaData
=
JSON
.
parse
(
fs
.
readFileSync
(
metaPath
,
'
utf-8
'
));
}
catch
(
e
)
{}
catch
(
e
)
{
console
.
log
(
e
);
}
_tests
.
forEach
(
testOpt
=>
{
testOpt
.
actions
=
actionsMetaData
[
testOpt
.
name
]
||
0
;
...
...
@@ -233,14 +235,6 @@ async function getFolderSize(dir) {
size
+=
fs
.
statSync
(
file
).
size
;
}
return
size
;
// const statAsync = promisify(fs.stat);
// return Promise.all(
// files.map(file => statAsync(file))
// ).then(sizes => {
// return sizes.reduce((total, current) => {
// return total + current.size;
// }, 0)
// });
}
/**
* Get results of all runs
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录