Add a method to calculate battery usage diff results from history
Bug: 184807417 Test: make SettingsRoboTests Test: make SettingsGoogleRoboTests Change-Id: If613c5cfd7e00e1883107385d3d8552774378cd7
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public final class BatteryDiffEntryTest {
|
||||
|
||||
@Test
|
||||
public void testSetTotalConsumePower_returnExpectedResult() {
|
||||
final BatteryDiffEntry entry =
|
||||
new BatteryDiffEntry(
|
||||
/*foregroundUsageTimeInMs=*/ 10001L,
|
||||
/*backgroundUsageTimeInMs=*/ 20002L,
|
||||
/*consumePower=*/ 22.0,
|
||||
/*batteryHistEntry=*/ null);
|
||||
entry.setTotalConsumePower(100.0);
|
||||
|
||||
assertThat(entry.getPercentOfTotal()).isEqualTo(22.0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user