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 08:46:59 UTC

[echarts] 02/02: test(visual): start vst without simpleRequire. optimize cases

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

commit 9ce0d35ddb1c41bd297d2b138cb1ac4d5290dedd
Author: pissang <bm...@gmail.com>
AuthorDate: Sat May 8 16:45:11 2021 +0800

    test(visual): start vst without simpleRequire. optimize cases
---
 test/bar-t.html                |  2 +-
 test/check-build.html          | 14 +++++++-------
 test/dataZoom-axes.html        |  4 ++--
 test/graphicOption.html        |  4 ++--
 test/lib/simpleRequire.js      |  4 ++++
 test/runTest/cli.js            | 36 +++++++++++++++++++-----------------
 test/runTest/client/index.html |  2 +-
 test/runTest/runtime/main.js   |  4 ++--
 test/tooltip-touch.html        |  4 ++--
 9 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/test/bar-t.html b/test/bar-t.html
index 01926c1..7c44f70 100644
--- a/test/bar-t.html
+++ b/test/bar-t.html
@@ -142,7 +142,7 @@ under the License.
                     // //         myTool2: {
                     // //             show: true,
                     // //             title: '自定义扩展方法2',
-                    // //             icon: 'image://https://echarts.apache.org/zh/images/favicon.png',
+                    // //             icon: 'image://asset/echarts-logo.png',
                     // //             onclick: function (){
                     // //                 alert('myToolHandler2')
                     // //             }
diff --git a/test/check-build.html b/test/check-build.html
index e4dcfc7..d81585d 100644
--- a/test/check-build.html
+++ b/test/check-build.html
@@ -589,25 +589,25 @@ under the License.
 
             setTimeout(function () {
                 makeLine();
-            }, 200);
+            }, 50);
             setTimeout(function () {
                 makeBar();
-            }, 400);
+            }, 100);
             setTimeout(function () {
                 makePie();
-            }, 800);
+            }, 150);
             setTimeout(function () {
                 makeScatter();
-            }, 1000);
+            }, 200);
             setTimeout(function () {
                 makeFunnel();
-            }, 1200);
+            }, 250);
             setTimeout(function () {
                 makeDataZoom();
-            }, 1400);
+            }, 300);
             setTimeout(function () {
                 makeGraph();
-            }, 1600);
+            }, 350);
         </script>
     </body>
 </html>
\ No newline at end of file
diff --git a/test/dataZoom-axes.html b/test/dataZoom-axes.html
index d4b3925..d97f362 100644
--- a/test/dataZoom-axes.html
+++ b/test/dataZoom-axes.html
@@ -285,7 +285,7 @@ under the License.
                             id: 'xSlider',
                             name: 'xSlider',
                             show: true,
-                            handleIcon: 'image://https://echarts.apache.org/zh/images/favicon.png',
+                            handleIcon: 'image://asset/echarts-logo.png',
                             filterMode: args.xFilterMode,
                             xAxisIndex: [0],
                             start: args.xStart,
@@ -294,7 +294,7 @@ under the License.
                         {
                             name: 'ySlider',
                             show: true,
-                            handleIcon: 'image://https://echarts.apache.org/zh/images/favicon.png',
+                            handleIcon: 'image://asset/echarts-logo.png',
                             filterMode: args.yFitlerMode,
                             yAxisIndex: [0],
                             start: args.yStart,
diff --git a/test/graphicOption.html b/test/graphicOption.html
index 1bbb88a..b9b46e3 100644
--- a/test/graphicOption.html
+++ b/test/graphicOption.html
@@ -98,7 +98,7 @@ under the License.
         right: 20,
         top: 'center',
         style: {
-            image: 'https://echarts.apache.org/zh/images/favicon.png',
+            image: 'asset/echarts-logo.png',
             width: 50,
             height: 50,
             opacity: 0.5
@@ -386,7 +386,7 @@ under the License.
         origin: [75, 75],
         style: {
             fill: '#000',
-            image: 'https://echarts.apache.org/zh/images/favicon.png',
+            image: 'asset/echarts-logo.png',
             width: 150,
             height: 150,
             opacity: 0.4
diff --git a/test/lib/simpleRequire.js b/test/lib/simpleRequire.js
index fd65fe4..69441ee 100644
--- a/test/lib/simpleRequire.js
+++ b/test/lib/simpleRequire.js
@@ -28,6 +28,10 @@
 //  2. Only `paths` can be configured
 (function (global) {
 
+    if (typeof __VST_INIT__ !== 'undefined') {
+        __VST_INIT__();
+    }
+
     var requireCfg = { paths: {} }
 
     var currentDefinedFactory;
diff --git a/test/runTest/cli.js b/test/runTest/cli.js
index 99070a2..12f9d92 100644
--- a/test/runTest/cli.js
+++ b/test/runTest/cli.js
@@ -24,7 +24,7 @@ const fs = require('fs');
 const path = require('path');
 const program = require('commander');
 const compareScreenshot = require('./compareScreenshot');
-const {testNameFromFile, fileNameFromTest, getVersionDir, buildRuntimeCode, getEChartsTestFileName} = require('./util');
+const {testNameFromFile, fileNameFromTest, getVersionDir, buildRuntimeCode, getEChartsTestFileName, waitTime} = require('./util');
 const {origin} = require('./config');
 const cwebpBin = require('cwebp-bin');
 const { execFile } = require('child_process');
@@ -153,6 +153,11 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
         });
     }
 
+    let vstInited = false;
+
+    await page.exposeFunction('__VST_INIT__', () => {
+        vstInited = true;
+    });
     await page.exposeFunction('__VST_MOUSE_MOVE__', async (x, y) =>  {
         await page.mouse.move(x, y);
     });
@@ -163,10 +168,11 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
         await page.mouse.up();
     });
 
-    let waitClientScreenshot = new Promise((resolve) => {
-        // TODO wait for this function exposed?
-        page.exposeFunction('__VST_FULL_SCREENSHOT__', () =>  {
-            pageScreenshot().then(resolve);
+    // TODO should await exposeFunction here
+    const waitForScreenshot = new Promise((resolve) => {
+        page.exposeFunction('__VST_FULL_SCREENSHOT__', async () =>  {
+            await pageScreenshot();
+            resolve();
         });
     });
 
@@ -210,18 +216,14 @@ async function runTestPage(browser, testOpt, version, runtimeCode, isExpected) {
             timeout: 10000
         });
 
-        let autoScreenshotTimeout;
-        // TODO Use waitForFunction?
-        await Promise.race([
-            waitClientScreenshot,
-            new Promise(resolve => {
-                autoScreenshotTimeout = setTimeout(() => {
-                    console.log(`Automatically screenshot in ${testNameFromFile(fileUrl)}`);
-                    pageScreenshot().then(resolve)
-                }, 1000)
-            })
-        ]);
-        clearTimeout(autoScreenshotTimeout);
+        if (!vstInited) {    // Not using simpleRequire in the test
+            console.log(`Automatically started in ${testNameFromFile(fileUrl)}`);
+            await page.evaluate(() => {
+                __VST_START__();
+            });
+        }
+        // Wait do screenshot after inited
+        await waitForScreenshot;
 
         // Run actions
         let actions = [];
diff --git a/test/runTest/client/index.html b/test/runTest/client/index.html
index 23bdddc..f466e1a 100644
--- a/test/runTest/client/index.html
+++ b/test/runTest/client/index.html
@@ -24,7 +24,7 @@ under the License.
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
-    <link rel="shortcut icon" href="https://echarts.apache.org/zh/images/favicon.png">
+    <link rel="shortcut icon" href="asset/echarts-logo.png">
     <title>Visual Regression Testing Tool</title>
 </head>
 <body>
diff --git a/test/runTest/runtime/main.js b/test/runTest/runtime/main.js
index 9643402..ef076b3 100644
--- a/test/runTest/runtime/main.js
+++ b/test/runTest/runtime/main.js
@@ -46,10 +46,10 @@ window.__VST_START__ = function () {
     vstStarted = true;
     timeline.start();
     // Screenshot after 500ms
-    setTimeout(function () {
+    setTimeout(async () => {
         // Pause timeline until run actions.
         timeline.pause();
-        __VST_FULL_SCREENSHOT__();
+        await __VST_FULL_SCREENSHOT__();
     }, 500);
 }
 
diff --git a/test/tooltip-touch.html b/test/tooltip-touch.html
index 0346e09..34d1478 100644
--- a/test/tooltip-touch.html
+++ b/test/tooltip-touch.html
@@ -200,7 +200,7 @@ under the License.
                         axisPointer: {
                             handle: {
                                 show: true,
-                                icon: 'image://https://echarts.apache.org/zh/images/favicon.png'
+                                icon: 'image://asset/echarts-logo.png'
                             },
                             snap: true,
                             value: 600 // init value
@@ -215,7 +215,7 @@ under the License.
                         axisPointer: {
                             handle: {
                                 show: true,
-                                icon: 'image://https://echarts.apache.org/zh/images/favicon.png',
+                                icon: 'image://asset/echarts-logo.png',
                                 margin: 70
                             }
                         }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org