1 /* 2 * Copyright (C) 2016 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; 18 19 import android.car.test.AbstractExpectableTestCase; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 import org.junit.After; 24 25 /** 26 * Base class to test {@link CarPropertyConfig} and {@link CarPropertyValue}. 27 */ 28 abstract class CarPropertyTestBase extends AbstractExpectableTestCase { 29 30 protected static final int FLOAT_PROPERTY_ID = 0x1160BEEF; 31 protected static final int INT_ARRAY_PROPERTY_ID = 0x0041BEEF; 32 protected static final int INT_PROPERTY_ID = 0x0040BEEF; 33 protected static final int LONG_PROPERTY_ID = 0x0050BEEF; 34 protected static final int MIXED_TYPE_PROPERTY_ID = 0x01e0BEEF; 35 36 protected static final int CAR_AREA_TYPE = 0xDEADBEEF; 37 protected static final int WINDOW_DRIVER = 0x00000001; 38 protected static final int WINDOW_PASSENGER = 0x00000002; 39 40 private final Parcel mParcel = Parcel.obtain(); 41 42 @After recycleParcel()43 public void recycleParcel() throws Exception { 44 mParcel.recycle(); 45 } 46 readFromParcel()47 protected <T extends Parcelable> T readFromParcel() { 48 mParcel.setDataPosition(0); 49 return mParcel.readParcelable(null); 50 } 51 writeToParcel(Parcelable value)52 protected void writeToParcel(Parcelable value) { 53 mParcel.writeParcelable(value, 0); 54 } 55 } 56