blob: 627e032a16fdc0235f8479518e67804ec05c1645 [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;
Kaibbbd0d62019-03-25 15:47:27 -070021
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070022import static org.junit.Assert.assertEquals;
23import static org.junit.Assert.assertNotNull;
24import static org.junit.Assume.assumeTrue;
Enrico Granatae190f572017-01-13 17:56:50 -080025
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070026import android.hardware.automotive.vehicle.V2_0.IVehicle;
Pavel Maltsevcfe93102017-02-02 12:38:08 -080027import android.hardware.automotive.vehicle.V2_0.StatusCode;
28import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
Pavel Maltsev99e1a752017-08-24 15:15:05 -070029import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
Enrico Granatae190f572017-01-13 17:56:50 -080030import android.os.RemoteException;
31import android.util.Log;
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070032
Enrico Granatae190f572017-01-13 17:56:50 -080033import org.junit.Before;
34import org.junit.Test;
35
36/** Test retrieving the OBD2_LIVE_FRAME property from VHAL */
37public class Obd2LiveFrameTest {
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070038 private static final String TAG = Utils.concatTag(Obd2LiveFrameTest.class);
Kaibbbd0d62019-03-25 15:47:27 -070039 private static final int DEFAULT_WAIT_TIMEOUT_MS = 5000;
Enrico Granatae190f572017-01-13 17:56:50 -080040 private IVehicle mVehicle = null;
41
42 @Before
43 public void setUp() throws Exception {
Kaibbbd0d62019-03-25 15:47:27 -070044 mVehicle = Utils.getVehicleWithTimeout(DEFAULT_WAIT_TIMEOUT_MS);
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070045 assumeTrue("Live frame not available, test-case ignored.", isLiveFrameAvailable());
Enrico Granatae190f572017-01-13 17:56:50 -080046 }
47
48 @Test
49 public void testLiveFrame() throws RemoteException {
Enrico Granatae190f572017-01-13 17:56:50 -080050 readVhalProperty(
51 mVehicle,
52 VehicleProperty.OBD2_LIVE_FRAME,
53 (Integer status, VehiclePropValue value) -> {
54 assertEquals(StatusCode.OK, status.intValue());
55 assertNotNull("OBD2_LIVE_FRAME is supported; should not be null", value);
Pavel Maltsev82c20cd2017-04-11 12:38:17 -070056 Log.i(TAG, "dump of OBD2_LIVE_FRAME:\n" + value);
Enrico Granatae190f572017-01-13 17:56:50 -080057 return true;
58 });
59 }
60
Enrico Granatae190f572017-01-13 17:56:50 -080061 private boolean isLiveFrameAvailable() throws RemoteException {
62 return isVhalPropertyAvailable(mVehicle, VehicleProperty.OBD2_LIVE_FRAME);
63 }
Enrico Granatae190f572017-01-13 17:56:50 -080064}