1 /* 2 * Copyright 2020 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 android.hardware.cts.R; 20 import android.server.wm.WindowManagerStateHelper; 21 import android.view.KeyEvent; 22 23 import androidx.test.ext.junit.runners.AndroidJUnit4; 24 import androidx.test.filters.SmallTest; 25 26 import org.junit.Test; 27 import org.junit.runner.RunWith; 28 29 @SmallTest 30 @RunWith(AndroidJUnit4.class) 31 public class RazerRaijuMobileBluetoothTest extends InputHidTestCase { 32 33 // Simulates the behavior of Razer Raiju Mobile gamepad. RazerRaijuMobileBluetoothTest()34 public RazerRaijuMobileBluetoothTest() { 35 super(R.raw.razer_raiju_mobile_bluetooth_register); 36 addDelayAfterSetup(); 37 } 38 39 @Test testAllKeys()40 public void testAllKeys() { 41 testInputEvents(R.raw.razer_raiju_mobile_bluetooth_keyeventtests); 42 } 43 44 @Test testAllMotions()45 public void testAllMotions() { 46 testInputEvents(R.raw.razer_raiju_mobile_bluetooth_motioneventtests); 47 } 48 49 /** 50 * Add BUTTON_MODE to the activity's unhandled keys list to allow the fallback 51 * of HOME. Do home button behavior check with wm utils. 52 */ 53 @Test testHomeKey()54 public void testHomeKey() throws Exception { 55 mTestActivity.addUnhandleKeyCode(KeyEvent.KEYCODE_BUTTON_MODE); 56 testInputEvents(R.raw.razer_raiju_mobile_bluetooth_homekey); 57 58 WindowManagerStateHelper wmStateHelper = new WindowManagerStateHelper(); 59 60 wmStateHelper.waitForHomeActivityVisible(); 61 wmStateHelper.assertHomeActivityVisible(true); 62 } 63 } 64