From bf2cc23eb0eb6362649da12ca2c13289f19e9313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 1 Aug 2019 16:15:55 +0200 Subject: [PATCH] tests for DECSET 1003 --- test/api/MouseTracking.api.ts | 661 +++++++++++++++++++++++++++++++++- 1 file changed, 651 insertions(+), 10 deletions(-) diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 745c5c06..3637a428 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -375,7 +375,7 @@ describe('Mouse Tracking Tests', function(): void { // await page.keyboard.up('Shift'); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); }); - it('UTF8 encoding', async () => { + it.skip('UTF8 encoding', async () => { const encoding = 'UTF8'; await resetMouseModes(); await mouseMove(0, 0); @@ -611,7 +611,7 @@ describe('Mouse Tracking Tests', function(): void { // await page.keyboard.up('Shift'); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]); }); - it('URXVT encoding', async () => { + it.skip('URXVT encoding', async () => { // bug: always reports +1 for row/col (temp. fixed in parseReport to pass tests) const encoding = 'URXVT'; await resetMouseModes(); @@ -891,7 +891,7 @@ describe('Mouse Tracking Tests', function(): void { {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} ]); }); - it('UTF8 encoding', async () => { + it.skip('UTF8 encoding', async () => { const encoding = 'UTF8'; await resetMouseModes(); await mouseMove(0, 0); @@ -1189,7 +1189,7 @@ describe('Mouse Tracking Tests', function(): void { {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} ]); }); - it('URXVT encoding', async () => { + it.skip('URXVT encoding', async () => { const encoding = 'URXVT'; await resetMouseModes(); await mouseMove(0, 0); @@ -1341,7 +1341,6 @@ describe('Mouse Tracking Tests', function(): void { }); describe('DECSET 1002 (xterm with drag)', () => { /** - * VT200 protocol: * - press and release events * - wheel up/down * - move only on press (drag) @@ -1505,7 +1504,7 @@ describe('Mouse Tracking Tests', function(): void { {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} ]); }); - it('UTF8 encoding', async () => { + it.skip('UTF8 encoding', async () => { const encoding = 'UTF8'; await resetMouseModes(); await mouseMove(0, 0); @@ -1819,7 +1818,7 @@ describe('Mouse Tracking Tests', function(): void { {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} ]); }); - it('URXVT encoding', async () => { + it.skip('URXVT encoding', async () => { const encoding = 'URXVT'; await resetMouseModes(); await mouseMove(0, 0); @@ -1978,11 +1977,653 @@ describe('Mouse Tracking Tests', function(): void { }); describe('DECSET 1003 (xterm any event)', () => { /** - * VT200 protocol: * - all events (press, release, wheel, move) * - all modifiers */ - // bug: currently same reports as 1002, FIXME: implement tests once fixed + it('default encoding', async () => { + const encoding = 'DEFAULT'; + await resetMouseModes(); + await mouseMove(0, 0); + await page.evaluate(`window.term.write('\x1b[?1003h');`); + + // test at 0,0 + await mouseDown('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mouseup should report, encoding cannot report released button + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mousemove should report + await mouseMove(50, 10); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 51, row: 11, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // test at max rows/cols + // bug: we are capped at col 95 currently + // fix: allow values up to 223, any bigger should drop to 0 + await mouseMove(cols - 1, rows - 1); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 95, row: rows, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 95, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 95, row: rows, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // button press/move/release tests + // left button + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + // middle button + // bug: default action not cancelled (adds data to getReports from clipboard under X11) + // await mouseMove(43, 24); + // await getReports(encoding); // clear reports + // await mouseDown('middle'); + // await mouseMove(44, 24); + // await mouseUp('middle'); + // assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'middle', modifier: {control: false, shift: false, meta: false}}}]); + // right button + // bug: default action not cancelled (popup shown) + await mouseMove(43, 24); + await mouseDown('right'); + await mouseMove(44, 24); + await mouseUp('right'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // wheel + await mouseMove(43, 24); + await getReports(encoding); // clear reports + await wheelUp(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await wheelDown(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + + // modifiers + // CTRL + await page.keyboard.down('Control'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + ]); + + // ALT + await page.keyboard.down('Alt'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Alt'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + ]); + + // SHIFT + // note: press/release/drag caught by selection manager + await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Shift'); + if (noShift) { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } else { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } + + // all modifiers + // bug: Shift not working + await page.keyboard.down('Control'); + await page.keyboard.down('Alt'); + // await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + await page.keyboard.up('Alt'); + // await page.keyboard.up('Shift'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + ]); + }); + it.skip('UTF8 encoding', async () => { + const encoding = 'UTF8'; + await resetMouseModes(); + await mouseMove(0, 0); + await page.evaluate(`window.term.write('\x1b[?1003h\x1b[?1005h');`); + + // test at 0,0 + await mouseDown('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mouseup should report, encoding cannot report released button + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mousemove should report + await mouseMove(50, 10); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 51, row: 11, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // test at max rows/cols + // bug: we are capped at col 95 currently + // fix: allow values up to 223, any bigger should drop to 0 + await mouseMove(cols - 1, rows - 1); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: cols, row: rows, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: cols, row: rows, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // button press/move/release tests + // left button + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + // middle button + // bug: default action not cancelled (adds data to getReports from clipboard under X11) + // await mouseMove(43, 24); + // await getReports(encoding); // clear reports + // await mouseDown('middle'); + // await mouseMove(44, 24); + // await mouseUp('middle'); + // assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'middle', modifier: {control: false, shift: false, meta: false}}}]); + // right button + // bug: default action not cancelled (popup shown) + await mouseMove(43, 24); + await mouseDown('right'); + await mouseMove(44, 24); + await mouseUp('right'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // wheel + await mouseMove(43, 24); + await getReports(encoding); // clear reports + await wheelUp(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await wheelDown(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + + // modifiers + // CTRL + await page.keyboard.down('Control'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + ]); + + // ALT + await page.keyboard.down('Alt'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Alt'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + ]); + + // SHIFT + // note: press/release/drag caught by selection manager + await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Shift'); + if (noShift) { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } else { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } + + // all modifiers + // bug: Shift not working + await page.keyboard.down('Control'); + await page.keyboard.down('Alt'); + // await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + await page.keyboard.up('Alt'); + // await page.keyboard.up('Shift'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + ]); + }); + it('SGR encoding', async () => { + const encoding = 'SGR'; + await resetMouseModes(); + await mouseMove(0, 0); + await page.evaluate(`window.term.write('\x1b[?1003h\x1b[?1006h');`); + + // test at 0,0 + await mouseDown('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mouseup should report, encoding cannot report released button + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mousemove should report + await mouseMove(50, 10); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 51, row: 11, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // test at max rows/cols + // bug: we are capped at col 95 currently + // fix: allow values up to 223, any bigger should drop to 0 + await mouseMove(cols - 1, rows - 1); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: cols, row: rows, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: cols, row: rows, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // button press/move/release tests + // left button + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + // middle button + // bug: default action not cancelled (adds data to getReports from clipboard under X11) + // await mouseMove(43, 24); + // await getReports(encoding); // clear reports + // await mouseDown('middle'); + // await mouseMove(44, 24); + // await mouseUp('middle'); + // assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'middle', modifier: {control: false, shift: false, meta: false}}}]); + // right button + // bug: default action not cancelled (popup shown) + await mouseMove(43, 24); + await mouseDown('right'); + await mouseMove(44, 24); + await mouseUp('right'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: 'right', modifier: {control: false, shift: false, meta: false}}} + ]); + + // wheel + await mouseMove(43, 24); + await getReports(encoding); // clear reports + await wheelUp(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await wheelDown(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + + // modifiers + // CTRL + await page.keyboard.down('Control'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + ]); + + // ALT + await page.keyboard.down('Alt'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Alt'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + ]); + + // SHIFT + // note: press/release/drag caught by selection manager + await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Shift'); + if (noShift) { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } else { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } + + // all modifiers + // bug: Shift not working + await page.keyboard.down('Control'); + await page.keyboard.down('Alt'); + // await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + await page.keyboard.up('Alt'); + // await page.keyboard.up('Shift'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + ]); + }); + it.skip('URXVT encoding', async () => { + const encoding = 'URXVT'; + await resetMouseModes(); + await mouseMove(0, 0); + await page.evaluate(`window.term.write('\x1b[?1003h\x1b[?1015h');`); + + // test at 0,0 + await mouseDown('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mouseup should report, encoding cannot report released button + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 1, row: 1, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // mousemove should report + await mouseMove(50, 10); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 51, row: 11, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 51, row: 11, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // test at max rows/cols + // bug: we are capped at col 95 currently + // fix: allow values up to 223, any bigger should drop to 0 + await mouseMove(cols - 1, rows - 1); + await mouseDown('left'); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: cols, row: rows, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: cols, row: rows, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: cols, row: rows, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // button press/move/release tests + // left button + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + // middle button + // bug: default action not cancelled (adds data to getReports from clipboard under X11) + // await mouseMove(43, 24); + // await getReports(encoding); // clear reports + // await mouseDown('middle'); + // await mouseMove(44, 24); + // await mouseUp('middle'); + // assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'press', button: 'middle', modifier: {control: false, shift: false, meta: false}}}]); + // right button + // bug: default action not cancelled (popup shown) + await mouseMove(43, 24); + await mouseDown('right'); + await mouseMove(44, 24); + await mouseUp('right'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'right', modifier: {control: false, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: false}}} + ]); + + // wheel + await mouseMove(43, 24); + await getReports(encoding); // clear reports + await wheelUp(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'up', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + await wheelDown(); + assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); + + // modifiers + // CTRL + await page.keyboard.down('Control'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}} + ]); + + // ALT + await page.keyboard.down('Alt'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Alt'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: true}}} + ]); + + // SHIFT + // note: press/release/drag caught by selection manager + await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Shift'); + if (noShift) { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } else { + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: false, shift: true, meta: false}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: true, meta: false}}} + ]); + } + + // all modifiers + // bug: Shift not working + await page.keyboard.down('Control'); + await page.keyboard.down('Alt'); + // await page.keyboard.down('Shift'); + await mouseMove(43, 24); + await mouseDown('left'); + await mouseMove(44, 24); + await mouseUp('left'); + await wheelDown(); + await page.keyboard.up('Control'); + await page.keyboard.up('Alt'); + // await page.keyboard.up('Shift'); + assert.deepEqual(await getReports(encoding), [ + {col: 44, row: 25, state: {action: 'move', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: true}}}, + {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: true}}} + ]); + }); }); - // TODO: move tests with several buttons pressed + // TODO: tests with multiple buttons pressed });