• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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.Assume.assumeTrue;
20 
21 import android.hardware.cts.R;
22 import android.view.InputDevice;
23 
24 import androidx.test.ext.junit.runners.AndroidJUnit4;
25 import androidx.test.filters.SmallTest;
26 
27 import com.android.cts.kernelinfo.KernelInfo;
28 
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 
32 @SmallTest
33 @RunWith(AndroidJUnit4.class)
34 public class SonyDualSenseUsbTest extends InputHidTestCase {
35 
36     // Simulates the behavior of PlayStation DualSense gamepad
SonyDualSenseUsbTest()37     public SonyDualSenseUsbTest() {
38         super(R.raw.sony_dualsense_usb_register);
39     }
40 
41     @Override
getAdditionalSources()42     protected int getAdditionalSources() {
43         if (KernelInfo.hasConfig("CONFIG_HID_PLAYSTATION")) {
44             return InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_SENSOR;
45         }
46         return 0;
47     }
48 
49     @Test
testAllKeys()50     public void testAllKeys() {
51         testInputEvents(R.raw.sony_dualsense_usb_keyeventtests);
52     }
53 
54     @Test
testAllMotions()55     public void testAllMotions() {
56         testInputEvents(R.raw.sony_dualsense_usb_motioneventtests);
57     }
58 
59     @Test
testVibrator()60     public void testVibrator() throws Exception {
61         assumeTrue(KernelInfo.hasConfig("CONFIG_HID_PLAYSTATION"));
62         testInputVibratorEvents(R.raw.sony_dualsense_usb_vibratortests);
63         // hid-generic does not support vibration for this device
64     }
65 }
66