1 /* 2 * Copyright (C) 2022 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.car.hardware.property; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import android.car.VehicleUnit; 22 23 import androidx.test.filters.SmallTest; 24 25 import com.android.compatibility.common.util.ApiTest; 26 27 import org.junit.Test; 28 import org.junit.runner.RunWith; 29 import org.junit.runners.Parameterized; 30 31 import java.util.Arrays; 32 import java.util.Collection; 33 34 @SmallTest 35 @RunWith(Parameterized.class) 36 public final class VehicleUnitTest { 37 private final int mJavaConstantValue; 38 private final int mHalConstantValue; 39 VehicleUnitTest(int javaConstantValue, int halConstantValue)40 public VehicleUnitTest(int javaConstantValue, int halConstantValue) { 41 mJavaConstantValue = javaConstantValue; 42 mHalConstantValue = halConstantValue; 43 } 44 45 @Parameterized.Parameters constantValues()46 public static Collection constantValues() { 47 return Arrays.asList(new Object[][]{ 48 {VehicleUnit.SHOULD_NOT_USE, 49 android.hardware.automotive.vehicle.VehicleUnit.SHOULD_NOT_USE}, 50 {VehicleUnit.METER_PER_SEC, 51 android.hardware.automotive.vehicle.VehicleUnit.METER_PER_SEC}, 52 {VehicleUnit.RPM, android.hardware.automotive.vehicle.VehicleUnit.RPM}, 53 {VehicleUnit.HERTZ, android.hardware.automotive.vehicle.VehicleUnit.HERTZ}, 54 {VehicleUnit.PERCENTILE, 55 android.hardware.automotive.vehicle.VehicleUnit.PERCENTILE}, 56 {VehicleUnit.MILLIMETER, 57 android.hardware.automotive.vehicle.VehicleUnit.MILLIMETER}, 58 {VehicleUnit.METER, android.hardware.automotive.vehicle.VehicleUnit.METER}, 59 {VehicleUnit.KILOMETER, android.hardware.automotive.vehicle.VehicleUnit.KILOMETER}, 60 {VehicleUnit.MILE, android.hardware.automotive.vehicle.VehicleUnit.MILE}, 61 {VehicleUnit.CELSIUS, android.hardware.automotive.vehicle.VehicleUnit.CELSIUS}, 62 {VehicleUnit.FAHRENHEIT, 63 android.hardware.automotive.vehicle.VehicleUnit.FAHRENHEIT}, 64 {VehicleUnit.KELVIN, android.hardware.automotive.vehicle.VehicleUnit.KELVIN}, 65 {VehicleUnit.MILLILITER, 66 android.hardware.automotive.vehicle.VehicleUnit.MILLILITER}, 67 {VehicleUnit.LITER, android.hardware.automotive.vehicle.VehicleUnit.LITER}, 68 {VehicleUnit.US_GALLON, android.hardware.automotive.vehicle.VehicleUnit.US_GALLON}, 69 {VehicleUnit.IMPERIAL_GALLON, 70 android.hardware.automotive.vehicle.VehicleUnit.IMPERIAL_GALLON}, 71 {VehicleUnit.NANO_SECS, android.hardware.automotive.vehicle.VehicleUnit.NANO_SECS}, 72 {VehicleUnit.MILLI_SECS, 73 android.hardware.automotive.vehicle.VehicleUnit.MILLI_SECS}, 74 {VehicleUnit.SECS, android.hardware.automotive.vehicle.VehicleUnit.SECS}, 75 {VehicleUnit.YEAR, android.hardware.automotive.vehicle.VehicleUnit.YEAR}, 76 {VehicleUnit.WATT_HOUR, android.hardware.automotive.vehicle.VehicleUnit.WATT_HOUR}, 77 {VehicleUnit.MILLIAMPERE, 78 android.hardware.automotive.vehicle.VehicleUnit.MILLIAMPERE}, 79 {VehicleUnit.MILLIVOLT, android.hardware.automotive.vehicle.VehicleUnit.MILLIVOLT}, 80 {VehicleUnit.MILLIWATTS, 81 android.hardware.automotive.vehicle.VehicleUnit.MILLIWATTS}, 82 {VehicleUnit.AMPERE_HOURS, 83 android.hardware.automotive.vehicle.VehicleUnit.AMPERE_HOURS}, 84 {VehicleUnit.KILOWATT_HOUR, 85 android.hardware.automotive.vehicle.VehicleUnit.KILOWATT_HOUR}, 86 {VehicleUnit.KILOPASCAL, 87 android.hardware.automotive.vehicle.VehicleUnit.KILOPASCAL}, 88 {VehicleUnit.PSI, android.hardware.automotive.vehicle.VehicleUnit.PSI}, 89 {VehicleUnit.BAR, android.hardware.automotive.vehicle.VehicleUnit.BAR}, 90 {VehicleUnit.DEGREES, android.hardware.automotive.vehicle.VehicleUnit.DEGREES}, 91 {VehicleUnit.MILES_PER_HOUR, 92 android.hardware.automotive.vehicle.VehicleUnit.MILES_PER_HOUR}, 93 {VehicleUnit.KILOMETERS_PER_HOUR, 94 android.hardware.automotive.vehicle.VehicleUnit.KILOMETERS_PER_HOUR}, 95 }); 96 } 97 98 @Test 99 @ApiTest(apis = {"android.car.VehicleUnit#SHOULD_NOT_USE", 100 "android.car.VehicleUnit#METER_PER_SEC", "android.car.VehicleUnit#RPM", 101 "android.car.VehicleUnit#HERTZ", "android.car.VehicleUnit#PERCENTILE", 102 "android.car.VehicleUnit#MILLIMETER", "android.car.VehicleUnit#METER", 103 "android.car.VehicleUnit#KILOMETER", "android.car.VehicleUnit#MILE", 104 "android.car.VehicleUnit#CELSIUS", "android.car.VehicleUnit#FAHRENHEIT", 105 "android.car.VehicleUnit#KELVIN", "android.car.VehicleUnit#LITER", 106 "android.car.VehicleUnit#US_GALLON", "android.car.VehicleUnit#IMPERIAL_GALLON", 107 "android.car.VehicleUnit#NANO_SECS", "android.car.VehicleUnit#MILLI_SECS", 108 "android.car.VehicleUnit#SECS", "android.car.VehicleUnit#YEAR", 109 "android.car.VehicleUnit#WATT_HOUR", "android.car.VehicleUnit#MILLIAMPERE", 110 "android.car.VehicleUnit#MILLIVOLT", "android.car.VehicleUnit#MILLIWATTS", 111 "android.car.VehicleUnit#AMPERE_HOURS", "android.car.VehicleUnit#KILOWATT_HOUR", 112 "android.car.VehicleUnit#KILOPASCAL", "android.car.VehicleUnit#PSI", 113 "android.car.VehicleUnit#BAR", "android.car.VehicleUnit#DEGREES", 114 "android.car.VehicleUnit#MILES_PER_HOUR", 115 "android.car.VehicleUnit#KILOMETERS_PER_HOUR"}) testMatchWithVehicleHal()116 public void testMatchWithVehicleHal() { 117 assertThat(mJavaConstantValue).isEqualTo(mHalConstantValue); 118 } 119 } 120