Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.car.vehiclehal.test; |
| 18 | |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 19 | import static com.android.car.vehiclehal.test.Utils.isVhalPropertyAvailable; |
| 20 | import static com.android.car.vehiclehal.test.Utils.readVhalProperty; |
Kai | bbbd0d6 | 2019-03-25 15:47:27 -0700 | [diff] [blame] | 21 | |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 22 | import static org.junit.Assert.assertEquals; |
| 23 | import static org.junit.Assert.assertNotNull; |
| 24 | import static org.junit.Assume.assumeTrue; |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 25 | |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 26 | import android.hardware.automotive.vehicle.V2_0.IVehicle; |
Pavel Maltsev | cfe9310 | 2017-02-02 12:38:08 -0800 | [diff] [blame] | 27 | import android.hardware.automotive.vehicle.V2_0.StatusCode; |
| 28 | import android.hardware.automotive.vehicle.V2_0.VehiclePropValue; |
Pavel Maltsev | 99e1a75 | 2017-08-24 15:15:05 -0700 | [diff] [blame] | 29 | import android.hardware.automotive.vehicle.V2_0.VehicleProperty; |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 30 | import android.os.RemoteException; |
| 31 | import android.util.Log; |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 32 | |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 33 | import org.junit.Before; |
| 34 | import org.junit.Test; |
| 35 | |
| 36 | /** Test retrieving the OBD2_LIVE_FRAME property from VHAL */ |
| 37 | public class Obd2LiveFrameTest { |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 38 | private static final String TAG = Utils.concatTag(Obd2LiveFrameTest.class); |
Kai | bbbd0d6 | 2019-03-25 15:47:27 -0700 | [diff] [blame] | 39 | private static final int DEFAULT_WAIT_TIMEOUT_MS = 5000; |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 40 | private IVehicle mVehicle = null; |
| 41 | |
| 42 | @Before |
| 43 | public void setUp() throws Exception { |
Kai | bbbd0d6 | 2019-03-25 15:47:27 -0700 | [diff] [blame] | 44 | mVehicle = Utils.getVehicleWithTimeout(DEFAULT_WAIT_TIMEOUT_MS); |
Pavel Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 45 | assumeTrue("Live frame not available, test-case ignored.", isLiveFrameAvailable()); |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | @Test |
| 49 | public void testLiveFrame() throws RemoteException { |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 50 | 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 Maltsev | 82c20cd | 2017-04-11 12:38:17 -0700 | [diff] [blame] | 56 | Log.i(TAG, "dump of OBD2_LIVE_FRAME:\n" + value); |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 57 | return true; |
| 58 | }); |
| 59 | } |
| 60 | |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 61 | private boolean isLiveFrameAvailable() throws RemoteException { |
| 62 | return isVhalPropertyAvailable(mVehicle, VehicleProperty.OBD2_LIVE_FRAME); |
| 63 | } |
Enrico Granata | e190f57 | 2017-01-13 17:56:50 -0800 | [diff] [blame] | 64 | } |