From ee3cbae35a2ed95eeb663efd38ee677001435250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 18 Jul 2019 00:00:41 +0200 Subject: [PATCH] modifier test examples --- test/api/MouseTracking.api.ts | 48 +++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 0476d41a..0bf24f97 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -67,18 +67,18 @@ async function cellPos(col: number, row: number): Promise { * - allow modifiers to be set * - fake wheel events */ -async function mouseMove(col: number, row: number, modifier?: number): Promise { +async function mouseMove(col: number, row: number): Promise { const [xPixels, yPixels] = await cellPos(col, row); return await page.mouse.move(xPixels, yPixels); } -async function mouseClick(col: number, row: number, modifier?: number): Promise { +async function mouseClick(col: number, row: number): Promise { const [xPixels, yPixels] = await cellPos(col, row); return await page.mouse.click(xPixels, yPixels); } -async function mouseDown(button: "left" | "right" | "middle" | undefined, modifier?: number): Promise { +async function mouseDown(button: "left" | "right" | "middle" | undefined): Promise { return await page.mouse.down({button}); } -async function mouseUp(button: "left" | "right" | "middle" | undefined, modifier?: number): Promise { +async function mouseUp(button: "left" | "right" | "middle" | undefined): Promise { return await page.mouse.up({button}); } async function wheelUp(): Promise { @@ -88,7 +88,8 @@ async function wheelUp(): Promise { x: self._x, y: self._y, deltaX: 0, - deltaY: -10 + deltaY: -10, + modifiers: self._keyboard._modifiers }); } async function wheelDown(): Promise { @@ -98,7 +99,8 @@ async function wheelDown(): Promise { x: self._x, y: self._y, deltaX: 0, - deltaY: 10 + deltaY: 10, + modifiers: self._keyboard._modifiers }); } @@ -556,8 +558,38 @@ describe('Mouse Tracking Tests', function(): void { await wheelDown(); assert.deepEqual(await getReports(encoding), [{col: 44, row: 25, state: {action: 'down', button: 'wheel', modifier: {control: false, shift: false, meta: false}}}]); - // modifiers - // TODO + // modifiers (commented out - none working) + // 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 page.keyboard.up('Control'); + // bug: not working - reports wheel instead + // assert.deepEqual(await getReports(encoding), [ + // {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + // {col: 44, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, + // ]); + // await getReports(encoding); // clear reports + // 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 page.keyboard.up('Alt'); + // bug: not working - reports wheel instead + // assert.deepEqual(await getReports(encoding), [ + // {col: 44, row: 25, state: {action: 'press', button: 'left', modifier: {control: true, shift: false, meta: false}}}, + // {col: 44, row: 25, state: {action: 'release', button: '', modifier: {control: true, shift: false, meta: false}}}, + // ]); + // await getReports(encoding); // clear reports + // shift + // seems shift pressed alone would supress any mouse event - limitation of chrome? + }); it('UTF8 encoding', async () => { const encoding = 'UTF8';