1 package org.robolectric.shadows; 2 3 import static android.os.Build.VERSION_CODES.KITKAT; 4 5 import android.view.InputDevice; 6 import org.robolectric.annotation.Implementation; 7 import org.robolectric.annotation.Implements; 8 import org.robolectric.shadow.api.Shadow; 9 10 @Implements(InputDevice.class) 11 public class ShadowInputDevice { 12 private String deviceName; 13 private int productId; 14 private int vendorId; 15 makeInputDeviceNamed(String deviceName)16 public static InputDevice makeInputDeviceNamed(String deviceName) { 17 InputDevice inputDevice = Shadow.newInstanceOf(InputDevice.class); 18 ShadowInputDevice shadowInputDevice = Shadow.extract(inputDevice); 19 shadowInputDevice.setDeviceName(deviceName); 20 return inputDevice; 21 } 22 23 @Implementation getName()24 protected String getName() { 25 return deviceName; 26 } 27 28 @Implementation(minSdk = KITKAT) getProductId()29 protected int getProductId() { 30 return productId; 31 } 32 33 @Implementation(minSdk = KITKAT) getVendorId()34 protected int getVendorId() { 35 return vendorId; 36 } 37 setDeviceName(String deviceName)38 public void setDeviceName(String deviceName) { 39 this.deviceName = deviceName; 40 } 41 setProductId(int productId)42 public void setProductId(int productId) { 43 this.productId = productId; 44 } 45 setVendorId(int vendorId)46 public void setVendorId(int vendorId) { 47 this.vendorId = vendorId; 48 } 49 } 50