You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/05/08 06:48:38 UTC
[echarts] branch enhance-visual-regression-test updated:
test(visual): proper error handling in action replay
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch enhance-visual-regression-test
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/enhance-visual-regression-test by this push:
new b5d46d7 test(visual): proper error handling in action replay
b5d46d7 is described below
commit b5d46d79a6a2a3a8fd0b15d8b134bdfee6963e52
Author: pissang <bm...@gmail.com>
AuthorDate: Sat May 8 11:59:56 2021 +0800
test(visual): proper error handling in action replay
---
test/runTest/cli.js | 34 ++++++++++++-------------
test/runTest/runtime/ActionPlayback.js | 23 ++++++++++++++---
test/runTest/runtime/main.js | 1 +
test/runTest/runtime/timeline.js | 2 +-
test/runTest/server.js | 4 +--
test/sample-compare.html | 46 +++++++++++++++-------------------
6 files changed, 60 insertions(+), 50 deletions(-)
diff --git a/test/runTest/cli.js b/test/runTest/cli.js
index e1c7f97..bd5af5f 100644
--- a/test/runTest/cli.js
+++ b/test/runTest/cli.js
@@ -122,22 +122,6 @@ async function takeScreenshot(page, fullPage, fileUrl, desc, isExpected, minor)
};
}
-async function runActions(page, testOpt) {
- let actions;
- try {
- let actContent = fs.readFileSync(path.join(__dirname, 'actions', testOpt.name + '.json'));
- actions = JSON.parse(actContent);
- }
- catch (e) {
- // Can't find actions
- return;
- }
- if (actions.length > 0) {
- await page.evaluate(async (actions) => {
- await __VST_RUN_ACTIONS__(actions);
- }, actions);
- }
-}
async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
const fileUrl = testOpt.fileUrl;
@@ -239,7 +223,23 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
]);
clearTimeout(autoScreenshotTimeout);
- await runActions(page, testOpt, isExpected, screenshots);
+ // Run actions
+ let actions = [];
+ try {
+ let actContent = fs.readFileSync(path.join(__dirname, 'actions', testOpt.name + '.json'));
+ actions = JSON.parse(actContent);
+ }
+ catch (e) {}
+ if (actions.length > 0) {
+ try {
+ await page.evaluate(async (actions) => {
+ await __VST_RUN_ACTIONS__(actions);
+ }, actions);
+ }
+ catch (e) {
+ errors.push(e.toString());
+ }
+ }
}
catch(e) {
console.error(e);
diff --git a/test/runTest/runtime/ActionPlayback.js b/test/runTest/runtime/ActionPlayback.js
index 690c184..270f16c 100644
--- a/test/runTest/runtime/ActionPlayback.js
+++ b/test/runTest/runtime/ActionPlayback.js
@@ -75,7 +75,7 @@ export class ActionPlayback {
timeline.resume();
}
- return new Promise(resolve => {
+ return new Promise((resolve, reject) => {
async function tick() {
// Date has multiplied playbackSpeed
let current = Date.now();
@@ -83,7 +83,15 @@ export class ActionPlayback {
self._elapsedTime += dTime;
self._current = current;
- await self._update(takeScreenshot, playbackSpeed);
+ try {
+ await self._update(takeScreenshot, playbackSpeed);
+ }
+ catch (e) {
+ // Stop running and throw error.
+ reject(e);
+ return;
+ }
+
if (self._currentOpIndex >= self._ops.length) {
// Finished
resolve();
@@ -115,15 +123,22 @@ export class ActionPlayback {
let screenshotTaken = false;
switch (op.type) {
case 'mousedown':
+ // Pause timeline to avoid frame not sync.
+ timeline.pause();
await __VST_MOUSE_MOVE__(op.x, op.y);
await __VST_MOUSE_DOWN__();
+ timeline.resume();
break;
case 'mouseup':
+ timeline.pause();
await __VST_MOUSE_MOVE__(op.x, op.y);
await __VST_MOUSE_UP__();
+ timeline.resume();
break;
case 'mousemove':
+ timeline.pause();
await __VST_MOUSE_MOVE__(op.x, op.y);
+ timeline.resume();
break;
case 'mousewheel':
let element = document.elementFromPoint(op.x, op.y);
@@ -132,8 +147,8 @@ export class ActionPlayback {
let event = new WheelEvent('mousewheel', {
// PENDING
// Needs inverse delta?
- deltaY,
- clientX: x, clientY: y,
+ deltaY: op.deltaY,
+ clientX: op.x, clientY: op.y,
// Needs bubble to parent container
bubbles: true
});
diff --git a/test/runTest/runtime/main.js b/test/runTest/runtime/main.js
index 9d1233d..9643402 100644
--- a/test/runTest/runtime/main.js
+++ b/test/runTest/runtime/main.js
@@ -57,6 +57,7 @@ window.__VST_RUN_ACTIONS__ = async function (actions) {
timeline.resume();
const actionPlayback = new ActionPlayback();
for (let action of actions) {
+ window.scrollTo(action.scrollX, action.scrollY);
await actionPlayback.runAction(action, __VST_PLAYBACK_SPEED__);
}
actionPlayback.stop();
diff --git a/test/runTest/runtime/timeline.js b/test/runTest/runtime/timeline.js
index aee6117..fb2fa04 100644
--- a/test/runTest/runtime/timeline.js
+++ b/test/runTest/runtime/timeline.js
@@ -131,7 +131,7 @@ function flushIntervalHandlers() {
const NativeDate = window.Date;
const mockNow = function () {
- // speed up
+ // Use same time in one frame.
return TIMELINE_START + timelineTime * window.__VST_PLAYBACK_SPEED__;
};
function MockDate(...args) {
diff --git a/test/runTest/server.js b/test/runTest/server.js
index 0f7711e..d053aae 100644
--- a/test/runTest/server.js
+++ b/test/runTest/server.js
@@ -203,7 +203,7 @@ function checkPuppeteer() {
try {
const packageConfig = require('puppeteer/package.json');
console.log(`puppeteer version: ${packageConfig.version}`);
- return semver.satisfies(packageConfig.version, '>=1.19.0');
+ return semver.satisfies(packageConfig.version, '>=5.5.0');
}
catch (e) {
return false;
@@ -214,7 +214,7 @@ function checkPuppeteer() {
async function start() {
if (!checkPuppeteer()) {
// TODO Check version.
- console.error(`Can't find puppeteer >= 1.19.0, use 'npm install puppeteer --no-save' to install or update`);
+ console.error(`Can't find puppeteer >= 5.5.0, use 'npm install puppeteer --no-save' to install or update`);
return;
}
diff --git a/test/sample-compare.html b/test/sample-compare.html
index 6018475..3aac394 100644
--- a/test/sample-compare.html
+++ b/test/sample-compare.html
@@ -38,8 +38,9 @@ under the License.
<script src='lib/config.js'></script>
<script>
require([
- 'echarts'
- ], function (echarts) {
+ 'echarts',
+ 'data/large-data.json'
+ ], function (echarts, packedData) {
function round2(val) {
return Math.round(val * 100) / 100;
}
@@ -164,36 +165,29 @@ under the License.
}
}]
};
- const startTime = performance.now();
+ const startTime = Date.now();
myChart.setOption(opts, {
notMerge: true
});
- const endTime = performance.now();
+ const endTime = Date.now();
titleDom.innerHTML = `${title}(${data.length / 4 * 3}) ${(endTime - startTime).toFixed(0)} ms`;
}
let status = document.getElementById('status');
- status.textContent = 'Fetching data.json (2.07MB)....';
-
- fetch('data/large-data.json')
- .then(r => r.json())
- .then(packed => {
- status.textContent = 'Warming up';
- let data = prepData(packed);
-
- setTimeout(function () {
- for (let i = 0; i < 5; i++) {
- makeChart(data, 'warmup');
- makeChart(data, 'warmup', 'lttb');
- makeChart(data, 'warmup', 'average');
- makeChart(data, 'warmup', 'max');
- }
- status.textContent = 'Running';
- setTimeout(() => makeChart(data, 'No Sampling', null), 500);
- setTimeout(() => makeChart(data, 'LTTB Sampling', 'lttb'), 1000);
- setTimeout(() => makeChart(data, 'Max Sampling', 'max'), 1500);
- setTimeout(() => makeChart(data, 'Average Sampling', 'average'), 1500);
- });
- });
+
+ status.textContent = 'Warming up';
+ let data = prepData(packedData);
+
+ for (let i = 0; i < 5; i++) {
+ makeChart(data, 'warmup');
+ makeChart(data, 'warmup', 'lttb');
+ makeChart(data, 'warmup', 'average');
+ makeChart(data, 'warmup', 'max');
+ }
+ status.textContent = 'Running';
+ makeChart(data, 'No Sampling', null);
+ setTimeout(() => makeChart(data, 'LTTB Sampling', 'lttb'), 200);
+ setTimeout(() => makeChart(data, 'Max Sampling', 'max'), 400);
+ setTimeout(() => makeChart(data, 'Average Sampling', 'average'), 600);
});
</script>
</body>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org