Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | @license |
| 4 | Copyright (C) 2018 The Android Open Source Project |
| 5 | |
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | you may not use this file except in compliance with the License. |
| 8 | You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, software |
| 13 | distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | See the License for the specific language governing permissions and |
| 16 | limitations under the License. |
| 17 | --> |
| 18 | <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
Tao Zhou | d90e7f4 | 2020-04-29 17:07:14 +0200 | [diff] [blame] | 19 | <meta charset="utf-8"> |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 20 | <title>gr-key-binding-display</title> |
Tao Zhou | 8ef16f7 | 2019-11-18 14:14:36 -0800 | [diff] [blame] | 21 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 22 | <script src="/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script> |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 23 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 24 | <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script> |
| 25 | <script src="/components/wct-browser-legacy/browser.js"></script> |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 26 | |
| 27 | <test-fixture id="basic"> |
| 28 | <template> |
| 29 | <gr-key-binding-display></gr-key-binding-display> |
| 30 | </template> |
| 31 | </test-fixture> |
| 32 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 33 | <script type="module"> |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 34 | import '../../../test/common-test-setup.js'; |
| 35 | import './gr-key-binding-display.js'; |
| 36 | suite('gr-key-binding-display tests', () => { |
| 37 | let element; |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 38 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 39 | setup(() => { |
| 40 | element = fixture('basic'); |
| 41 | }); |
| 42 | |
| 43 | suite('_computeKey', () => { |
| 44 | test('unmodified key', () => { |
| 45 | assert.strictEqual(element._computeKey(['x']), 'x'); |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 46 | }); |
| 47 | |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 48 | test('key with modifiers', () => { |
| 49 | assert.strictEqual(element._computeKey(['Ctrl', 'x']), 'x'); |
| 50 | assert.strictEqual(element._computeKey(['Shift', 'Meta', 'x']), 'x'); |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 51 | }); |
| 52 | }); |
Dmitrii Filippov | daf0ec9 | 2020-03-17 11:27:28 +0100 | [diff] [blame] | 53 | |
| 54 | suite('_computeModifiers', () => { |
| 55 | test('single unmodified key', () => { |
| 56 | assert.deepEqual(element._computeModifiers(['x']), []); |
| 57 | }); |
| 58 | |
| 59 | test('key with modifiers', () => { |
| 60 | assert.deepEqual(element._computeModifiers(['Ctrl', 'x']), ['Ctrl']); |
| 61 | assert.deepEqual( |
| 62 | element._computeModifiers(['Shift', 'Meta', 'x']), |
| 63 | ['Shift', 'Meta']); |
| 64 | }); |
| 65 | }); |
| 66 | }); |
Logan Hanks | 5cde084 | 2018-10-05 15:56:10 -0700 | [diff] [blame] | 67 | </script> |