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
17package android.car.apitest;
18
19import android.car.hardware.CarPropertyConfig;
20import android.car.hardware.CarPropertyValue;
21import android.os.Parcel;
22import android.os.Parcelable;
23import android.test.AndroidTestCase;
24
25/**
26 * Base class to test {@link CarPropertyConfig} and {@link CarPropertyValue}.
27 */
28public class CarPropertyTestBase extends AndroidTestCase {
29
30    protected final static int PROPERTY_ID      = 0xBEEFBEEF;
31    protected final static int CAR_AREA_TYPE    = 0xDEADBEEF;
32    protected final static int WINDOW_DRIVER    = 0x00000001;
33    protected final static int WINDOW_PASSENGER = 0x00000002;
34
35    private Parcel mParcel;
36
37    @Override
38    protected void setUp() throws Exception {
39        super.setUp();
40        mParcel = Parcel.obtain();
41    }
42
43    @Override
44    protected void tearDown() throws Exception {
45        mParcel.recycle();
46        super.tearDown();
47    }
48
49    protected  <T extends Parcelable> T readFromParcel() {
50        mParcel.setDataPosition(0);
51        return mParcel.readParcelable(null);
52    }
53
54    protected void writeToParcel(Parcelable value) {
55        mParcel.writeParcelable(value, 0);
56    }
57}
58