Enrico Granata | 517a1e0 | 2017-09-20 16:15:50 -0700 | [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; |
| 18 | |
| 19 | import android.car.Car; |
| 20 | import android.car.storagemonitoring.CarStorageMonitoringManager; |
Enrico Granata | 1172f88 | 2017-09-21 14:51:30 -0700 | [diff] [blame^] | 21 | import android.car.storagemonitoring.WearEstimate; |
Enrico Granata | 517a1e0 | 2017-09-20 16:15:50 -0700 | [diff] [blame] | 22 | import android.test.suitebuilder.annotation.MediumTest; |
| 23 | import com.android.car.storagemonitoring.WearInformation; |
| 24 | |
| 25 | /** Test the public entry points for the CarStorageMonitoringManager */ |
| 26 | @MediumTest |
| 27 | public class CarStorageMonitoringTest extends MockedCarTestBase { |
| 28 | private static final String TAG = CarStorageMonitoringTest.class.getSimpleName(); |
| 29 | |
Enrico Granata | 1172f88 | 2017-09-21 14:51:30 -0700 | [diff] [blame^] | 30 | private static final WearInformation DEFAULT_WEAR_INFORMATION = |
| 31 | new WearInformation(10, 0, WearInformation.PRE_EOL_INFO_NORMAL); |
| 32 | |
Enrico Granata | 517a1e0 | 2017-09-20 16:15:50 -0700 | [diff] [blame] | 33 | private CarStorageMonitoringManager mCarStorageMonitoringManager; |
| 34 | |
| 35 | @Override |
| 36 | protected synchronized void configureFakeSystemInterface() { |
Enrico Granata | 1172f88 | 2017-09-21 14:51:30 -0700 | [diff] [blame^] | 37 | setFlashWearInformation(DEFAULT_WEAR_INFORMATION); |
Enrico Granata | 517a1e0 | 2017-09-20 16:15:50 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | @Override |
| 41 | protected void setUp() throws Exception { |
| 42 | super.setUp(); |
| 43 | |
| 44 | mCarStorageMonitoringManager = |
| 45 | (CarStorageMonitoringManager) getCar().getCarManager(Car.STORAGE_MONITORING_SERVICE); |
| 46 | } |
| 47 | |
| 48 | public void testReadPreEolInformation() throws Exception { |
Enrico Granata | 1172f88 | 2017-09-21 14:51:30 -0700 | [diff] [blame^] | 49 | assertEquals(DEFAULT_WEAR_INFORMATION.preEolInfo, |
Enrico Granata | 517a1e0 | 2017-09-20 16:15:50 -0700 | [diff] [blame] | 50 | mCarStorageMonitoringManager.getPreEolIndicatorStatus()); |
| 51 | } |
Enrico Granata | 1172f88 | 2017-09-21 14:51:30 -0700 | [diff] [blame^] | 52 | |
| 53 | public void testReadWearEstimate() throws Exception { |
| 54 | final WearEstimate wearEstimate = mCarStorageMonitoringManager.getWearEstimate(); |
| 55 | |
| 56 | assertNotNull(wearEstimate); |
| 57 | assertEquals(DEFAULT_WEAR_INFORMATION.lifetimeEstimateA, wearEstimate.typeA); |
| 58 | assertEquals(DEFAULT_WEAR_INFORMATION.lifetimeEstimateB, wearEstimate.typeB); |
| 59 | } |
Enrico Granata | 517a1e0 | 2017-09-20 16:15:50 -0700 | [diff] [blame] | 60 | } |