• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
16 package com.android.car;
17 
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21 
22 import android.car.Car;
23 import android.car.CarInfoManager;
24 import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
25 import android.support.test.filters.MediumTest;
26 import android.support.test.runner.AndroidJUnit4;
27 
28 import com.android.car.vehiclehal.VehiclePropValueBuilder;
29 
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 
33 @RunWith(AndroidJUnit4.class)
34 @MediumTest
35 public class CarInfoManagerTest extends MockedCarTestBase {
36     private static final String MAKE_NAME = "ANDROID";
37 
38     private CarInfoManager mCarInfoManager;
39 
40     @Override
configureMockedHal()41     protected synchronized void configureMockedHal() {
42         addStaticProperty(VehicleProperty.INFO_MAKE,
43                 VehiclePropValueBuilder.newBuilder(VehicleProperty.INFO_MAKE)
44                         .setStringValue(MAKE_NAME)
45                         .build());
46 
47     }
48 
49     @Override
setUp()50     public void setUp() throws Exception {
51         super.setUp();
52         mCarInfoManager = (CarInfoManager) getCar().getCarManager(Car.INFO_SERVICE);
53     }
54 
55     @Test
testVehicleId()56     public void testVehicleId() throws Exception {
57         assertNotNull(mCarInfoManager.getVehicleId());
58     }
59 
60     @Test
testManufacturer()61     public void testManufacturer() throws Exception {
62         assertEquals(MAKE_NAME, mCarInfoManager.getManufacturer());
63     }
64 
65     @Test
testNullItems()66     public void testNullItems() throws Exception {
67         assertNull(mCarInfoManager.getModel());
68         assertNull(mCarInfoManager.getModelYear());
69     }
70 }
71