• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.hardware.input.cts.tests;
18 
19 import static org.junit.Assert.assertEquals;
20 
21 import android.hardware.cts.R;
22 import android.view.KeyEvent;
23 
24 import androidx.test.ext.junit.runners.AndroidJUnit4;
25 import androidx.test.filters.SmallTest;
26 
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 
30 @SmallTest
31 @RunWith(AndroidJUnit4.class)
32 public class MicrosoftDesignerKeyboardTest extends InputHidTestCase {
33 
MicrosoftDesignerKeyboardTest()34     public MicrosoftDesignerKeyboardTest() {
35         super(R.raw.microsoft_designer_keyboard_register);
36         addDelayAfterSetup();
37     }
38 
39     @Test
testAllKeys()40     public void testAllKeys() {
41         testInputEvents(R.raw.microsoft_designer_keyboard_keyeventtests);
42     }
43 
44     /**
45      * Microsoft Designer Keyboard has meta control keys of NUM_LOCK, CAPS_LOCK and SCROLL_LOCK.
46      * Do not verify the meta key states that have global state and initially to be on.
47      */
48     @Override
assertMetaState(String testCase, int expectedMetaState, int actualMetaState)49     void assertMetaState(String testCase, int expectedMetaState, int actualMetaState) {
50         final int metaStates = KeyEvent.META_NUM_LOCK_ON | KeyEvent.META_CAPS_LOCK_ON
51                 | KeyEvent.META_SCROLL_LOCK_ON;
52         actualMetaState &= ~metaStates;
53         assertEquals(testCase + " (meta state)", expectedMetaState , actualMetaState);
54     }
55 }
56