added modifier tests

This commit is contained in:
Jörg Breitbart
2019-07-22 15:22:14 +02:00
parent 986bdac191
commit 25ed7f7a7f
+844 -43
View File
@@ -134,6 +134,8 @@ function parseReport(encoding: string, msg: number[]): {state: any; row: number;
row: report.charCodeAt(5) - 32 row: report.charCodeAt(5) - 32
}; };
case 'UTF8': case 'UTF8':
// TODO: once the binary patch is in place,
// use UTF8 byte check here
return { return {
state: evalButtonCode(report.charCodeAt(3) - 32), state: evalButtonCode(report.charCodeAt(3) - 32),
col: report.charCodeAt(4) - 32, col: report.charCodeAt(4) - 32,
@@ -199,9 +201,9 @@ describe('Mouse Tracking Tests', function(): void {
/** /**
* X10 protocol: * X10 protocol:
* - only press events * - only press events
* - no wheel? (TBD) * - no wheel
* - no move * - no move
* - no modifiers? (TDB) * - no modifiers
*/ */
it('default encoding', async () => { it('default encoding', async () => {
const encoding = 'DEFAULT'; const encoding = 'DEFAULT';
@@ -266,7 +268,57 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), []); assert.deepEqual(await getReports(encoding), []);
// modifiers // modifiers
// TODO // CTRL
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// ALT
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// SHIFT
// note: caught by selection manager
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), []);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
*/
}); });
it('UTF8 encoding', async () => { it('UTF8 encoding', async () => {
const encoding = 'UTF8'; const encoding = 'UTF8';
@@ -329,7 +381,57 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), []); assert.deepEqual(await getReports(encoding), []);
// modifiers // modifiers
// TODO // CTRL
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// ALT
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// SHIFT
// note: caught by selection manager
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), []);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
*/
}); });
it('SGR encoding', async () => { it('SGR encoding', async () => {
const encoding = 'SGR'; const encoding = 'SGR';
@@ -392,7 +494,57 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), []); assert.deepEqual(await getReports(encoding), []);
// modifiers // modifiers
// TODO // CTRL
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// ALT
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// SHIFT
// note: caught by selection manager
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), []);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
*/
}); });
it('URXVT encoding', async () => { it('URXVT encoding', async () => {
// bug: always reports +1 for row/col (temp. fixed in parseReport to pass tests) // bug: always reports +1 for row/col (temp. fixed in parseReport to pass tests)
@@ -456,7 +608,57 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), []); assert.deepEqual(await getReports(encoding), []);
// modifiers // modifiers
// TODO // CTRL
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// ALT
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
// SHIFT
// note: caught by selection manager
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), []);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}}]);
*/
}); });
}); });
describe('DECSET 1000 (VT200 mouse)', () => { describe('DECSET 1000 (VT200 mouse)', () => {
@@ -465,7 +667,7 @@ describe('Mouse Tracking Tests', function(): void {
* - press and release events * - press and release events
* - wheel up/down * - wheel up/down
* - no move * - no move
* - modifiers? (TBD) * - all modifiers
*/ */
it('default encoding', async () => { it('default encoding', async () => {
const encoding = 'DEFAULT'; const encoding = 'DEFAULT';
@@ -548,38 +750,84 @@ describe('Mouse Tracking Tests', function(): void {
await wheelDown(); await wheelDown();
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers (commented out - none working) // modifiers
// ctrl // CTRL
// await mouseMove(43, 24); // bug: totally broken - reports no modifier, reports wrong button and action, reports wrong coords for release
// await getReports(encoding); // clear reports // after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control'); // await page.keyboard.down('Control');
// await mouseDown('left'); await mouseDown('left');
// await mouseMove(44, 24); await mouseMove(44, 24);
// await mouseUp('left'); await mouseUp('left');
await wheelDown();
// await page.keyboard.up('Control'); // await page.keyboard.up('Control');
// bug: not working - reports wheel instead assert.deepEqual(await getReports(encoding), [
// assert.deepEqual(await getReports(encoding), [ {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, {col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: false, shift: false, meta: false}}},
// {col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: false, meta: false}}}, {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// ]); // expected
// await getReports(encoding); // clear reports // {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}},
// alt // {col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: false, meta: false}}},
// await mouseMove(43, 24); // {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
// await getReports(encoding); // clear reports ]);
// await page.keyboard.down('Alt');
// await mouseDown('left'); // ALT
// await mouseMove(44, 24); // bug: no modifier reported, release with wrong coords
// await mouseUp('left'); await mouseMove(43, 24);
// await page.keyboard.up('Alt'); await getReports(encoding); // clear reports
// bug: not working - reports wheel instead await page.keyboard.down('Alt');
// assert.deepEqual(await getReports(encoding), [ await mouseDown('left');
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, await mouseMove(44, 24);
// {col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: false, meta: false}}}, await mouseUp('left');
// ]); await wheelDown();
// await getReports(encoding); // clear reports await page.keyboard.up('Alt');
// shift assert.deepEqual(await getReports(encoding), [
// seems shift pressed alone would supress any mouse event - limitation of chrome? {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', 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 caught by selection manager
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
it('UTF8 encoding', async () => { it('UTF8 encoding', async () => {
const encoding = 'UTF8'; const encoding = 'UTF8';
@@ -661,7 +909,83 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action, reports wrong coords for release
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
]);
// ALT
// bug: no modifier reported, release with wrong coords
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', 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 caught by selection manager
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
it('SGR encoding', async () => { it('SGR encoding', async () => {
const encoding = 'SGR'; const encoding = 'SGR';
@@ -744,7 +1068,83 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action, reports wrong coords for release
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
]);
// ALT
// bug: no modifier reported, release with wrong coords
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', 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 caught by selection manager
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
it('URXVT encoding', async () => { it('URXVT encoding', async () => {
const encoding = 'URXVT'; const encoding = 'URXVT';
@@ -826,7 +1226,83 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action, reports wrong coords for release
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
]);
// ALT
// bug: no modifier reported, release with wrong coords
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: 'press', button: 'left', modifier: {control: false, shift: false, meta: false}}},
{col: 44, row: 25, state: {action: 'release', button: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: false, shift: false, meta: true}}},
// {col: 45, row: 25, state: {action: 'release', button: '<none>', 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 caught by selection manager
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
}); });
describe('DECSET 1002 (xterm with drag)', () => { describe('DECSET 1002 (xterm with drag)', () => {
@@ -919,7 +1395,88 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: '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: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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: '<none>', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
]);
// ALT
// bug: no modifier reported
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: '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: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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: '<none>', 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
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
it('UTF8 encoding', async () => { it('UTF8 encoding', async () => {
const encoding = 'UTF8'; const encoding = 'UTF8';
@@ -1002,7 +1559,88 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: '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: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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: '<none>', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
]);
// ALT
// bug: no modifier reported
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: '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: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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: '<none>', 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
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
it('SGR encoding', async () => { it('SGR encoding', async () => {
const encoding = 'SGR'; const encoding = 'SGR';
@@ -1085,7 +1723,88 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: '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}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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
// bug: no modifier reported
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: '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}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
it('URXVT encoding', async () => { it('URXVT encoding', async () => {
const encoding = 'URXVT'; const encoding = 'URXVT';
@@ -1167,7 +1886,88 @@ describe('Mouse Tracking Tests', function(): void {
assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]);
// modifiers // modifiers
// TODO // CTRL
// bug: totally broken - reports no modifier, reports wrong button and action
// after fix: removed faulty reports below and uncomment lines
await mouseMove(43, 24);
await getReports(encoding); // clear reports
// await page.keyboard.down('Control');
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: '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: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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: '<none>', modifier: {control: true, shift: false, meta: false}}},
// {col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: false, meta: false}}}
]);
// ALT
// bug: no modifier reported
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Alt');
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: '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: '<none>', modifier: {control: false, shift: false, meta: false}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
// expected
// {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: '<none>', 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
// bug: modifier not reported for passed events
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Shift'); // defaults to ShiftLeft
await mouseDown('left');
await mouseMove(44, 24);
await mouseUp('left');
await wheelDown();
await page.keyboard.up('Shift');
assert.deepEqual(await getReports(encoding), [
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}
]);
/*
// all modifiers
// bug: this is totally broken with wrong coords and messed up modifiers
await mouseMove(43, 24);
await getReports(encoding); // clear reports
await page.keyboard.down('Control');
await page.keyboard.down('Alt');
await page.keyboard.down('Shift');
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: 'press', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'move', button: 'left', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'release', button: '<none>', modifier: {control: true, shift: true, meta: true}}},
{col: 45, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: true, shift: true, meta: true}}}
]);
*/
}); });
}); });
describe('DECSET 1003 (xterm any event)', () => { describe('DECSET 1003 (xterm any event)', () => {
@@ -1178,4 +1978,5 @@ describe('Mouse Tracking Tests', function(): void {
*/ */
// bug: currently same reports as 1002, FIXME: implement tests once fixed // bug: currently same reports as 1002, FIXME: implement tests once fixed
}); });
// TODO: move tests with several buttons pressed
}); });