From 8fb6ded5066b0fd765cc96b1a00a4870607aa4b0 Mon Sep 17 00:00:00 2001 From: Jon Bockhorst Date: Tue, 11 Feb 2020 13:13:03 -0600 Subject: [PATCH] Fix mouse tests for chromium --- test/api/MouseTracking.api.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/test/api/MouseTracking.api.ts b/test/api/MouseTracking.api.ts index 74e6aade..98b65b2a 100644 --- a/test/api/MouseTracking.api.ts +++ b/test/api/MouseTracking.api.ts @@ -90,7 +90,7 @@ async function wheelUp(): Promise { y: self._y, deltaX: 0, deltaY: -10, - modifiers: self._keyboard._modifiers + modifiers: toModifiersMask(page.keyboard._modifiers()) }); } async function wheelDown(): Promise { @@ -101,10 +101,27 @@ async function wheelDown(): Promise { y: self._y, deltaX: 0, deltaY: 10, - modifiers: self._keyboard._modifiers + modifiers: toModifiersMask(page.keyboard._modifiers()) }); } +function toModifiersMask(modifiers: Set): number { + let mask = 0; + if (modifiers.has('Alt')) { + mask |= 1; + } + if (modifiers.has('Control')) { + mask |= 2; + } + if (modifiers.has('Meta')) { + mask |= 4; + } + if (modifiers.has('Shift')) { + mask |= 8; + } + return mask; +} + // button definitions const buttons: { [key: string]: number } = { '': -1, @@ -199,7 +216,7 @@ function parseReport(encoding: string, msg: number[]): { state: any; row: number * Mouse tracking tests. */ describe('Mouse Tracking Tests', () => { - before(async function (): Promise { + before(async function(): Promise { browser = await getBrowserType().launch({ headless: process.argv.indexOf('--headless') !== -1, args: [`--window-size=${width},${height}`, `--no-sandbox`]