Cleaned up VehiclePropertyIdsTest file. #codehealth
Test: atest VehiclePropertyIdsTest
Bug: 192514521
Change-Id: Ia9b7ea356c8023e1f5d54c0ebe2aa6c296ae69e8
diff --git a/tests/tests/car/src/android/car/cts/VehiclePropertyIdsTest.java b/tests/tests/car/src/android/car/cts/VehiclePropertyIdsTest.java
index 49fa9dd..4d00ea9 100644
--- a/tests/tests/car/src/android/car/cts/VehiclePropertyIdsTest.java
+++ b/tests/tests/car/src/android/car/cts/VehiclePropertyIdsTest.java
@@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
-import android.car.VehicleGear;
import android.car.VehiclePropertyIds;
import android.platform.test.annotations.RequiresDevice;
import android.test.suitebuilder.annotation.SmallTest;
@@ -39,6 +38,22 @@
public class VehiclePropertyIdsTest {
private static final String TAG = "VehiclePropertyIdsTest";
+ // Get all enums from the class.
+ private static List<Integer> getIntegersFromDataEnums() {
+ Field[] fields = VehiclePropertyIds.class.getDeclaredFields();
+ List<Integer> integerList = new ArrayList<>(5);
+ for (Field f : fields) {
+ if (f.getType() == int.class) {
+ try {
+ integerList.add(f.getInt(VehiclePropertyIds.class));
+ } catch (IllegalAccessException | RuntimeException e) {
+ Log.w(TAG, "Failed to get value");
+ }
+ }
+ }
+ return integerList;
+ }
+
/**
* Test for {@link VehiclePropertyIds#toString()}
*/
@@ -316,26 +331,10 @@
*/
@Test
public void testAllPropertiesAreMappedInToString() {
- List<Integer> systemProperties = getIntegersFromDataEnums(
- new VehiclePropertyIds().getClass());
+ List<Integer> systemProperties = getIntegersFromDataEnums();
for (int propertyId : systemProperties) {
String propertyString = VehiclePropertyIds.toString(propertyId);
assertThat(propertyString.startsWith("0x")).isFalse();
}
}
- // Get all enums from the class.
- private static List<Integer> getIntegersFromDataEnums(Class clazz) {
- Field[] fields = clazz.getDeclaredFields();
- List<Integer> integerList = new ArrayList<>(5);
- for (Field f : fields) {
- if (f.getType() == int.class) {
- try {
- integerList.add(f.getInt(clazz));
- } catch (IllegalAccessException | RuntimeException e) {
- Log.w(TAG, "Failed to get value");
- }
- }
- }
- return integerList;
- }
}