This is an automated email from the ASF dual-hosted git repository. shenyi pushed a commit to branch feature/clip in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/feature/clip by this push: new 2bbb297 test: add recorded action for clip test. not save result when replay in recorder page. 2bbb297 is described below commit 2bbb2975f3ae743b4f708c3d42c878e889dba4a5 Author: pissang <bm2736...@gmail.com> AuthorDate: Thu Sep 19 17:33:00 2019 +0800 test: add recorded action for clip test. not save result when replay in recorder page. --- test/clip.html | 11 +++- test/runTest/actions/__meta__.json | 3 +- test/runTest/actions/clip.json | 1 + test/runTest/cli.js | 113 +++++++++++++++++++++---------------- test/runTest/server.js | 32 ++++++----- 5 files changed, 94 insertions(+), 66 deletions(-) diff --git a/test/clip.html b/test/clip.html index ecfca8c..ad7dd3d 100644 --- a/test/clip.html +++ b/test/clip.html @@ -315,12 +315,16 @@ under the License. dataZoom: [{ type: 'inside', xAxisIndex: 0, - filterMode: 'filter' + filterMode: 'filter', + start: 30, + end: 70 }, { type: 'inside', yAxisIndex: 0, - filterMode: 'weakFilter' + filterMode: 'weakFilter', + start: 30, + end: 70 } ], series: [{ @@ -349,7 +353,8 @@ under the License. buttons: makeToggleChartButtons(function (clip) { chart.setOption({ series: [{ - clip: clip + clip: clip, + data: lineData }] }) }) diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 839a201..b4e3080 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -129,5 +129,6 @@ "treemap-option2": 1, "visualMap-categories": 1, "axes": 0, - "stackBar-dataZoom": 7 + "stackBar-dataZoom": 7, + "clip": 9 } \ No newline at end of file diff --git a/test/runTest/actions/clip.json b/test/runTest/actions/clip.json new file mode 100644 index 0000000..53e9f6e --- /dev/null +++ b/test/runTest/actions/clip.json @@ -0,0 +1 @@ +[{"name":"Action 1","ops":[{"type":"mousedown","time":447,"x":92,"y":75},{"type":"mouseup","time":559,"x":92,"y":75},{"time":560,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":749,"x":90,"y":75},{"type":"mousemove","time":949,"x":43,"y":75},{"type":"mousemove","time":1157,"x":34,"y":75},{"type":"mousedown","time":1225,"x":34,"y":75},{"type":"mouseup","time":1322,"x":34,"y":75},{"time":1323,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":156888 [...] \ No newline at end of file diff --git a/test/runTest/cli.js b/test/runTest/cli.js index 39f85b9..2076710 100644 --- a/test/runTest/cli.js +++ b/test/runTest/cli.js @@ -35,7 +35,8 @@ program .option('-s, --speed <speed>', 'Playback speed') .option('--expected <expected>', 'Expected version') .option('--actual <actual>', 'Actual version') - .option('--renderer <renderer>', 'svg/canvas renderer'); + .option('--renderer <renderer>', 'svg/canvas renderer') + .option('--no-save', 'Don\'t save result'); program.parse(process.argv); @@ -115,6 +116,9 @@ async function runActions(page, testOpt, isExpected, screenshots) { let count = 0; async function _innerTakeScreenshot() { + if (!program.save) { + return; + } const desc = action.desc || action.name; const {screenshotName, screenshotPath} = await takeScreenshot(page, false, testOpt.fileUrl, desc, isExpected, count++); screenshots.push({screenshotName, desc, screenshotPath}); @@ -165,9 +169,11 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) { await waitTime(500); // Wait for animation or something else. Pending // Final shot. await page.mouse.move(0, 0); - let desc = 'Full Shot'; - const {screenshotName, screenshotPath} = await takeScreenshot(page, true, fileUrl, desc, isExpected); - screenshots.push({screenshotName, desc, screenshotPath}); + if (program.save) { + let desc = 'Full Shot'; + const {screenshotName, screenshotPath} = await takeScreenshot(page, true, fileUrl, desc, isExpected); + screenshots.push({screenshotName, desc, screenshotPath}); + } await runActions(page, testOpt, isExpected, screenshots); } @@ -198,54 +204,61 @@ async function runTest(browser, testOpt, runtimeCode, expectedVersion, actualVer return; } - testOpt.status === 'running'; - const expectedResult = await runTestPage(browser, testOpt, expectedVersion, runtimeCode, true); - const actualResult = await runTestPage(browser, testOpt, actualVersion, runtimeCode, false); + if (program.save) { + testOpt.status === 'running'; + + const expectedResult = await runTestPage(browser, testOpt, expectedVersion, runtimeCode, true); + const actualResult = await runTestPage(browser, testOpt, actualVersion, runtimeCode, false); + + // sortScreenshots(expectedResult.screenshots); + // sortScreenshots(actualResult.screenshots); + + const screenshots = []; + let idx = 0; + for (let shot of expectedResult.screenshots) { + let expected = shot; + let actual = actualResult.screenshots[idx++]; + let result = { + actual: getClientRelativePath(actual.screenshotPath), + expected: getClientRelativePath(expected.screenshotPath), + name: actual.screenshotName, + desc: actual.desc + }; + try { + let {diffRatio, diffPNG} = await compareScreenshot( + expected.screenshotPath, + actual.screenshotPath + ); - // sortScreenshots(expectedResult.screenshots); - // sortScreenshots(actualResult.screenshots); + let diffPath = `${path.resolve(__dirname, getScreenshotDir())}/${shot.screenshotName}-diff.png`; + await writePNG(diffPNG, diffPath); - const screenshots = []; - let idx = 0; - for (let shot of expectedResult.screenshots) { - let expected = shot; - let actual = actualResult.screenshots[idx++]; - let result = { - actual: getClientRelativePath(actual.screenshotPath), - expected: getClientRelativePath(expected.screenshotPath), - name: actual.screenshotName, - desc: actual.desc - }; - try { - let {diffRatio, diffPNG} = await compareScreenshot( - expected.screenshotPath, - actual.screenshotPath - ); - - let diffPath = `${path.resolve(__dirname, getScreenshotDir())}/${shot.screenshotName}-diff.png`; - await writePNG(diffPNG, diffPath); - - result.diff = getClientRelativePath(diffPath); - result.diffRatio = diffRatio; - } - catch(e) { - result.diff = ''; - result.diffRatio = 1; - console.log(e); + result.diff = getClientRelativePath(diffPath); + result.diffRatio = diffRatio; + } + catch(e) { + result.diff = ''; + result.diffRatio = 1; + console.log(e); + } + screenshots.push(result); } - screenshots.push(result); - } - testOpt.results = screenshots; - testOpt.status = 'finished'; - testOpt.actualLogs = actualResult.logs; - testOpt.expectedLogs = expectedResult.logs; - testOpt.actualErrors = actualResult.errors; - testOpt.expectedErrors = expectedResult.errors; - testOpt.actualVersion = actualVersion; - testOpt.expectedVersion = expectedVersion; - testOpt.useSVG = program.renderer === 'svg'; - testOpt.lastRun = Date.now(); + testOpt.results = screenshots; + testOpt.status = 'finished'; + testOpt.actualLogs = actualResult.logs; + testOpt.expectedLogs = expectedResult.logs; + testOpt.actualErrors = actualResult.errors; + testOpt.expectedErrors = expectedResult.errors; + testOpt.actualVersion = actualVersion; + testOpt.expectedVersion = expectedVersion; + testOpt.useSVG = program.renderer === 'svg'; + testOpt.lastRun = Date.now(); + } + else { + // Only run once + await runTestPage(browser, testOpt, 'local', runtimeCode, true); + } } async function runTests(pendingTests) { @@ -270,7 +283,9 @@ async function runTests(pendingTests) { console.log(e); } - process.send(testOpt); + if (program.save) { + process.send(testOpt); + } } } catch(e) { diff --git a/test/runTest/server.js b/test/runTest/server.js index 565cb21..04ba560 100644 --- a/test/runTest/server.js +++ b/test/runTest/server.js @@ -111,7 +111,8 @@ function startTests(testsNameList, socket, { replaySpeed, actualVersion, expectedVersion, - renderer + renderer, + noSave }) { console.log('Received: ', testsNameList.join(',')); @@ -122,16 +123,18 @@ function startTests(testsNameList, socket, { pendingTests = getTestsList().filter(testOpt => { return testsNameList.includes(testOpt.name); }); - pendingTests.forEach(testOpt => { - // Reset all tests results - testOpt.status = 'pending'; - testOpt.results = []; - }); - if (!aborted) { - socket.emit('update', {tests: getTestsList(), running: true}); - } + if (!noSave) { + pendingTests.forEach(testOpt => { + // Reset all tests results + testOpt.status = 'pending'; + testOpt.results = []; + }); + if (!aborted) { + socket.emit('update', {tests: getTestsList(), running: true}); + } + } let runningCount = 0; function onExit() { runningCount--; @@ -142,7 +145,7 @@ function startTests(testsNameList, socket, { } function onUpdate() { // Merge tests. - if (!aborted) { + if (!aborted && !noSave) { socket.emit('update', {tests: getTestsList(), running: true}); } } @@ -160,7 +163,8 @@ function startTests(testsNameList, socket, { '--actual', actualVersion, '--expected', expectedVersion, '--renderer', renderer, - ...(noHeadless ? ['--no-headless'] : []) + ...(noHeadless ? ['--no-headless'] : []), + ...(noSave ? ['--no-save'] : []) ]); runningCount++; } @@ -230,7 +234,8 @@ async function start() { replaySpeed: data.replaySpeed, actualVersion: data.actualVersion, expectedVersion: data.expectedVersion, - renderer: data.renderer + renderer: data.renderer, + noSave: false } ); } @@ -292,7 +297,8 @@ async function start() { replaySpeed: 2, actualVersion: data.actualVersion, expectedVersion: data.expectedVersion, - renderer: data.renderer + renderer: data.renderer, + noSave: true }); } catch (e) { console.error(e); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org