CarInfoManagerTest.java revision 07ddbbd70e518e271f941f92df1b0e5501af0ad1
1/* 2 * Copyright (C) 2015 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 */ 16package com.android.car.test; 17 18import android.car.Car; 19import android.car.CarInfoManager; 20import android.os.Bundle; 21import android.util.Log; 22 23import com.android.car.test.MockedCarTestBase; 24import com.android.car.vehiclenetwork.VehicleNetworkConsts; 25import com.android.car.vehiclenetwork.VehiclePropConfigUtil; 26import com.android.car.vehiclenetwork.VehiclePropValueUtil; 27 28public class CarInfoManagerTest extends MockedCarTestBase { 29 30 private static final String TAG = CarInfoManagerTest.class.getSimpleName(); 31 32 private static final String MAKE_NAME = "ANDROID"; 33 34 private CarInfoManager mCarInfoManager; 35 36 @Override 37 protected void setUp() throws Exception { 38 super.setUp(); 39 getVehicleHalEmulator().addStaticProperty( 40 VehiclePropConfigUtil.createStaticStringProperty( 41 VehicleNetworkConsts.VEHICLE_PROPERTY_INFO_MAKE), 42 VehiclePropValueUtil.createStringValue( 43 VehicleNetworkConsts.VEHICLE_PROPERTY_INFO_MAKE, MAKE_NAME, 0)); 44 getVehicleHalEmulator().removeProperty(VehicleNetworkConsts.VEHICLE_PROPERTY_INFO_MODEL); 45 getVehicleHalEmulator().removeProperty( 46 VehicleNetworkConsts.VEHICLE_PROPERTY_INFO_MODEL_YEAR); 47 getVehicleHalEmulator().start(); 48 mCarInfoManager = 49 (CarInfoManager) getCar().getCarManager(Car.INFO_SERVICE); 50 } 51 52 public void testVehicleId() throws Exception { 53 assertNotNull(mCarInfoManager.getVehicleId()); 54 } 55 56 public void testManufactuter() throws Exception { 57 assertEquals(MAKE_NAME, mCarInfoManager.getManufacturer()); 58 } 59 60 public void testNullItems() throws Exception { 61 assertNull(mCarInfoManager.getModel()); 62 assertNull(mCarInfoManager.getModelYear()); 63 } 64} 65