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.apitest; 18 19 import android.car.hardware.CarPropertyValue; 20 import android.graphics.Point; 21 import android.test.suitebuilder.annotation.MediumTest; 22 23 /** 24 * Unit tests for {@link CarPropertyValue} 25 */ 26 @MediumTest 27 public class CarPropertyValueTest extends CarPropertyConfigTest { 28 29 public void testSimpleFloatValue() { 30 CarPropertyValue<Float> floatValue = 31 new CarPropertyValue<>(PROPERTY_ID, WINDOW_DRIVER, 10f); 32 33 writeToParcel(floatValue); 34 35 CarPropertyValue<Float> valueRead = readFromParcel(); 36 assertEquals(10f, valueRead.getValue()); 37 } 38 39 public void testCarAreaArbitraryParcelable() { 40 CarPropertyValue<Point> pointValue = 41 new CarPropertyValue<>(PROPERTY_ID, WINDOW_DRIVER, new Point(30, 40)); 42 43 writeToParcel(pointValue); 44 CarPropertyValue<Point> pointValueRead = readFromParcel(); 45 46 assertNotNull(pointValueRead); 47 assertEquals(30, pointValueRead.getValue().x); 48 assertEquals(40, pointValueRead.getValue().y); 49 } 50 } 51