diff options
| author | 2024-12-05 20:26:33 +0000 | |
|---|---|---|
| committer | 2024-12-10 01:14:25 +0000 | |
| commit | 7b494d2aad9239d0c8bf49f04816004054dc01dd (patch) | |
| tree | 9e1e39ee2efc51cd1b5a18db085fef93067f0ad6 | |
| parent | 6136c48d52d939976331243051972f41a0e02e60 (diff) | |
Add KeyCharacterMapTest unit test
Adds unit test for KeyCharacterMapTest, primarily focusing on test
cases not covered in existing CTS tests.
Bug: None
Test: atest com.android.test.input.KeyCharacterMapTest
Flag: TEST_ONLY
Change-Id: Ie36f8ad505b26a2a1c2741804fcfd31d56649bc2
| -rw-r--r-- | tests/Input/src/com/android/test/input/KeyCharacterMapTest.kt | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/Input/src/com/android/test/input/KeyCharacterMapTest.kt b/tests/Input/src/com/android/test/input/KeyCharacterMapTest.kt new file mode 100644 index 000000000000..281837920548 --- /dev/null +++ b/tests/Input/src/com/android/test/input/KeyCharacterMapTest.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.input + +import android.view.KeyCharacterMap +import android.view.KeyEvent + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Tests for {@link KeyCharacterMap}. + * + * <p>Build/Install/Run: + * atest KeyCharacterMapTest + * + */ +class KeyCharacterMapTest { + @Test + fun testGetFallback() { + // Based off of VIRTUAL kcm fallbacks. + val keyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD) + + // One modifier fallback. + assertEquals( + keyCharacterMap.getFallbackAction(KeyEvent.KEYCODE_SPACE, + KeyEvent.META_CTRL_ON).keyCode, + KeyEvent.KEYCODE_LANGUAGE_SWITCH) + + // Multiple modifier fallback. + assertEquals( + keyCharacterMap.getFallbackAction(KeyEvent.KEYCODE_DEL, + KeyEvent.META_CTRL_ON or KeyEvent.META_ALT_ON).keyCode, + KeyEvent.KEYCODE_BACK) + + // No default button, fallback only. + assertEquals( + keyCharacterMap.getFallbackAction(KeyEvent.KEYCODE_BUTTON_A, 0).keyCode, + KeyEvent.KEYCODE_DPAD_CENTER) + } +} |