提交 b1657f3f 编写于 作者: P pissang

test: reduce screenshots when mousewheel in replay

上级 6a127535
...@@ -31,12 +31,15 @@ module.exports = class Timeline { ...@@ -31,12 +31,15 @@ module.exports = class Timeline {
this._currentOpIndex = 0; this._currentOpIndex = 0;
this._client; this._client;
this._isLastOpMousewheel = false;
} }
_reset() { _reset() {
this._currentOpIndex = 0; this._currentOpIndex = 0;
this._current = Date.now(); this._current = Date.now();
this._elapsedTime = 0; this._elapsedTime = 0;
this._isLastOpMousewheel = false;
} }
...@@ -102,6 +105,7 @@ module.exports = class Timeline { ...@@ -102,6 +105,7 @@ module.exports = class Timeline {
} }
let page = this._page; let page = this._page;
let takenScreenshot = false;
switch (op.type) { switch (op.type) {
case 'mousedown': case 'mousedown':
await page.mouse.move(op.x, op.y); await page.mouse.move(op.x, op.y);
...@@ -130,7 +134,7 @@ module.exports = class Timeline { ...@@ -130,7 +134,7 @@ module.exports = class Timeline {
element.dispatchEvent(event); element.dispatchEvent(event);
}, op.x, op.y, op.deltaX || 0, op.deltaY); }, op.x, op.y, op.deltaX || 0, op.deltaY);
this._isLastOpMousewheel = true;
// console.log('mousewheel', op.x, op.y, op.deltaX, op.deltaY); // console.log('mousewheel', op.x, op.y, op.deltaX, op.deltaY);
// await this._client.send('Input.dispatchMouseEvent', { // await this._client.send('Input.dispatchMouseEvent', {
// type: 'mouseWheel', // type: 'mouseWheel',
...@@ -139,9 +143,10 @@ module.exports = class Timeline { ...@@ -139,9 +143,10 @@ module.exports = class Timeline {
// deltaX: op.deltaX, // deltaX: op.deltaX,
// deltaY: op.deltaY // deltaY: op.deltaY
// }); // });
// break; break;
case 'screenshot': case 'screenshot':
await takeScreenshot(); await takeScreenshot();
takenScreenshot = true;
break; break;
case 'valuechange': case 'valuechange':
if (op.target === 'select') { if (op.target === 'select') {
...@@ -159,7 +164,16 @@ module.exports = class Timeline { ...@@ -159,7 +164,16 @@ module.exports = class Timeline {
// TODO Configuration time // TODO Configuration time
await waitTime(delay / playbackSpeed); await waitTime(delay / playbackSpeed);
await takeScreenshot(); await takeScreenshot();
takenScreenshot = true;
this._currentOpIndex++; this._currentOpIndex++;
} }
if (this._isLastOpMousewheel && op.type !== 'mousewheel') {
// Only take screenshot after mousewheel finished
if (!takenScreenshot) {
takeScreenshot();
}
this._isLastOpMousewheel = false;
}
} }
}; };
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册