blob: 25f24541516f2f15f280a1b28a0ced9ba83098df [file] [log] [blame]
Enrico Granatae190f572017-01-13 17:56:50 -08001/*
2 * Copyright (C) 2017 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
17package com.android.car.vehiclehal.test;
18
Enrico Granatae190f572017-01-13 17:56:50 -080019import static com.android.car.vehiclehal.test.Utils.isVhalPropertyAvailable;
20import static com.android.car.vehiclehal.test.Utils.readVhalProperty;
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070021import static org.junit.Assert.assertEquals;
22import static org.junit.Assert.assertNotNull;
23import static org.junit.Assume.assumeTrue;
Enrico Granatae190f572017-01-13 17:56:50 -080024
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070025import android.hardware.automotive.vehicle.V2_0.IVehicle;
Pavel Maltsevcfe93102017-02-02 12:38:08 -080026import android.hardware.automotive.vehicle.V2_0.StatusCode;
27import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
Pavel Maltsev99e1a752017-08-24 15:15:05 -070028import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
Enrico Granatae190f572017-01-13 17:56:50 -080029import android.os.RemoteException;
30import android.util.Log;
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070031
Enrico Granatae190f572017-01-13 17:56:50 -080032import org.junit.Before;
33import org.junit.Test;
34
35/** Test retrieving the OBD2_LIVE_FRAME property from VHAL */
36public class Obd2LiveFrameTest {
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070037 private static final String TAG = Utils.concatTag(Obd2LiveFrameTest.class);
Enrico Granatae190f572017-01-13 17:56:50 -080038
39 private IVehicle mVehicle = null;
40
41 @Before
42 public void setUp() throws Exception {
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070043 mVehicle = Utils.getVehicle();
44 assumeTrue("Live frame not available, test-case ignored.", isLiveFrameAvailable());
Enrico Granatae190f572017-01-13 17:56:50 -080045 }
46
47 @Test
48 public void testLiveFrame() throws RemoteException {
Enrico Granatae190f572017-01-13 17:56:50 -080049 readVhalProperty(
50 mVehicle,
51 VehicleProperty.OBD2_LIVE_FRAME,
52 (Integer status, VehiclePropValue value) -> {
53 assertEquals(StatusCode.OK, status.intValue());
54 assertNotNull("OBD2_LIVE_FRAME is supported; should not be null", value);
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070055 Log.i(TAG, "dump of OBD2_LIVE_FRAME:\n" + value);
Enrico Granatae190f572017-01-13 17:56:50 -080056 return true;
57 });
58 }
59
Enrico Granatae190f572017-01-13 17:56:50 -080060 private boolean isLiveFrameAvailable() throws RemoteException {
61 return isVhalPropertyAvailable(mVehicle, VehicleProperty.OBD2_LIVE_FRAME);
62 }
Enrico Granatae190f572017-01-13 17:56:50 -080063}