CarInfoManagerTest.java revision 0d07c76bbc788fba8c77d8e932330ab22ec6ba27
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.hardware.vehicle.V2_0.VehicleProperty;
21
22import com.android.car.vehiclehal.VehiclePropValueBuilder;
23
24public class CarInfoManagerTest extends MockedCarTestBase {
25    private static final String MAKE_NAME = "ANDROID";
26
27    private CarInfoManager mCarInfoManager;
28
29    @Override
30    protected synchronized void configureMockedHal() {
31        addStaticProperty(VehicleProperty.INFO_MAKE,
32                VehiclePropValueBuilder.newBuilder(VehicleProperty.INFO_MAKE)
33                        .setStringValue(MAKE_NAME)
34                        .build());
35
36    }
37
38    @Override
39    protected void setUp() throws Exception {
40        super.setUp();
41        mCarInfoManager = (CarInfoManager) getCar().getCarManager(Car.INFO_SERVICE);
42    }
43
44    public void testVehicleId() throws Exception {
45        assertNotNull(mCarInfoManager.getVehicleId());
46    }
47
48    public void testManufacturer() throws Exception {
49        assertEquals(MAKE_NAME, mCarInfoManager.getManufacturer());
50    }
51
52    public void testNullItems() throws Exception {
53        assertNull(mCarInfoManager.getModel());
54        assertNull(mCarInfoManager.getModelYear());
55    }
56}
57