CarInfoManagerTest.java revision 6745635909d050c57f5a08bfc28580feb0f2cfe0
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().start();
45        mCarInfoManager =
46                (CarInfoManager) getCar().getCarManager(Car.INFO_SERVICE);
47    }
48
49    public void testManufactuter() throws Exception {
50        Bundle info = mCarInfoManager.getBasicInfo();
51        assertEquals(MAKE_NAME, info.getCharSequence(CarInfoManager.BASIC_INFO_KEY_MANUFACTURER));
52    }
53
54    public void testNoSuchInfo() throws Exception {
55        final String NO_SUCH_NAME = "no-such-information-available";
56        Bundle info = mCarInfoManager.getBasicInfo();
57        assertNotNull(info);
58        assertNull(info.getCharSequence(NO_SUCH_NAME));
59    }
60}
61