blob: 8ae0f69d5381a5a63601c22ec258c33114c27d3a [file] [log] [blame]
Logan Hanks5cde0842018-10-05 15:56:10 -07001<!DOCTYPE html>
2<!--
3@license
4Copyright (C) 2018 The Android Open Source Project
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing, software
13distributed under the License is distributed on an "AS IS" BASIS,
14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15See the License for the specific language governing permissions and
16limitations under the License.
17-->
18<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
Tao Zhoud90e7f42020-04-29 17:07:14 +020019<meta charset="utf-8">
Logan Hanks5cde0842018-10-05 15:56:10 -070020<title>gr-key-binding-display</title>
Tao Zhou8ef16f72019-11-18 14:14:36 -080021
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010022<script src="/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
Logan Hanks5cde0842018-10-05 15:56:10 -070023
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010024<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
25<script src="/components/wct-browser-legacy/browser.js"></script>
Logan Hanks5cde0842018-10-05 15:56:10 -070026
27<test-fixture id="basic">
28 <template>
29 <gr-key-binding-display></gr-key-binding-display>
30 </template>
31</test-fixture>
32
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010033<script type="module">
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010034import '../../../test/common-test-setup.js';
35import './gr-key-binding-display.js';
36suite('gr-key-binding-display tests', () => {
37 let element;
Logan Hanks5cde0842018-10-05 15:56:10 -070038
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010039 setup(() => {
40 element = fixture('basic');
41 });
42
43 suite('_computeKey', () => {
44 test('unmodified key', () => {
45 assert.strictEqual(element._computeKey(['x']), 'x');
Logan Hanks5cde0842018-10-05 15:56:10 -070046 });
47
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010048 test('key with modifiers', () => {
49 assert.strictEqual(element._computeKey(['Ctrl', 'x']), 'x');
50 assert.strictEqual(element._computeKey(['Shift', 'Meta', 'x']), 'x');
Logan Hanks5cde0842018-10-05 15:56:10 -070051 });
52 });
Dmitrii Filippovdaf0ec92020-03-17 11:27:28 +010053
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 Hanks5cde0842018-10-05 15:56:10 -070067</script>