/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { TestKey } from '@angular/cdk/testing'; import * as webdriver from 'selenium-webdriver'; /** * Maps the `TestKey` constants to WebDriver's `webdriver.Key` constants. * See https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/webdriver/key.js#L29 */ export const seleniumWebDriverKeyMap = { [TestKey.BACKSPACE]: webdriver.Key.BACK_SPACE, [TestKey.TAB]: webdriver.Key.TAB, [TestKey.ENTER]: webdriver.Key.ENTER, [TestKey.SHIFT]: webdriver.Key.SHIFT, [TestKey.CONTROL]: webdriver.Key.CONTROL, [TestKey.ALT]: webdriver.Key.ALT, [TestKey.ESCAPE]: webdriver.Key.ESCAPE, [TestKey.PAGE_UP]: webdriver.Key.PAGE_UP, [TestKey.PAGE_DOWN]: webdriver.Key.PAGE_DOWN, [TestKey.END]: webdriver.Key.END, [TestKey.HOME]: webdriver.Key.HOME, [TestKey.LEFT_ARROW]: webdriver.Key.ARROW_LEFT, [TestKey.UP_ARROW]: webdriver.Key.ARROW_UP, [TestKey.RIGHT_ARROW]: webdriver.Key.ARROW_RIGHT, [TestKey.DOWN_ARROW]: webdriver.Key.ARROW_DOWN, [TestKey.INSERT]: webdriver.Key.INSERT, [TestKey.DELETE]: webdriver.Key.DELETE, [TestKey.F1]: webdriver.Key.F1, [TestKey.F2]: webdriver.Key.F2, [TestKey.F3]: webdriver.Key.F3, [TestKey.F4]: webdriver.Key.F4, [TestKey.F5]: webdriver.Key.F5, [TestKey.F6]: webdriver.Key.F6, [TestKey.F7]: webdriver.Key.F7, [TestKey.F8]: webdriver.Key.F8, [TestKey.F9]: webdriver.Key.F9, [TestKey.F10]: webdriver.Key.F10, [TestKey.F11]: webdriver.Key.F11, [TestKey.F12]: webdriver.Key.F12, [TestKey.META]: webdriver.Key.META }; /** Gets a list of WebDriver `Key`s for the given `ModifierKeys`. */ export function getSeleniumWebDriverModifierKeys(modifiers) { const result = []; if (modifiers.control) { result.push(webdriver.Key.CONTROL); } if (modifiers.alt) { result.push(webdriver.Key.ALT); } if (modifiers.shift) { result.push(webdriver.Key.SHIFT); } if (modifiers.meta) { result.push(webdriver.Key.META); } return result; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZW5pdW0td2ViZHJpdmVyLWtleXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3Rlc3Rpbmcvc2VsZW5pdW0td2ViZHJpdmVyL3NlbGVuaXVtLXdlYmRyaXZlci1rZXlzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBZSxPQUFPLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssU0FBUyxNQUFNLG9CQUFvQixDQUFDO0FBRWhEOzs7R0FHRztBQUNILE1BQU0sQ0FBQyxNQUFNLHVCQUF1QixHQUFHO0lBQ3JDLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUMsVUFBVTtJQUM3QyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFBRSxTQUFTLENBQUMsR0FBRyxDQUFDLEdBQUc7SUFDaEMsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLEVBQUUsU0FBUyxDQUFDLEdBQUcsQ0FBQyxLQUFLO0lBQ3BDLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxFQUFFLFNBQVMsQ0FBQyxHQUFHLENBQUMsS0FBSztJQUNwQyxDQUFDLE9BQU8sQ0FBQyxPQUFPLENBQUMsRUFBRSxTQUFTLENBQUMsR0FBRyxDQUFDLE9BQU87SUFDeEMsQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUUsU0FBUyxDQUFDLEd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