Add summary for items in App Usage List in Battery page
This summary shows the active time of the app. For example "Used for 27m". Bug: 34467139 Test: RunSettingsRoboTests & Take screenshots Change-Id: I0ef48427ad21be4dacd290fffb2c5d519ef58506
This commit is contained in:
@@ -6,6 +6,7 @@ import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.text.format.DateUtils;
|
||||
import java.net.InetAddress;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -71,4 +72,29 @@ public class UtilsTest {
|
||||
// Should not crash here
|
||||
assertThat(Utils.assignDefaultPhoto(null, 0)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatElapsedTime_WithSeconds_ShowSeconds() {
|
||||
final double testMillis = 5 * DateUtils.MINUTE_IN_MILLIS;
|
||||
final String expectedTime = "5m 0s";
|
||||
|
||||
assertThat(Utils.formatElapsedTime(mContext, testMillis, true)).isEqualTo(expectedTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatElapsedTime_NoSeconds_DoNotShowSeconds() {
|
||||
final double testMillis = 5 * DateUtils.MINUTE_IN_MILLIS;
|
||||
final String expectedTime = "5m";
|
||||
|
||||
assertThat(Utils.formatElapsedTime(mContext, testMillis, false)).isEqualTo(expectedTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatElapsedTime_TimeMoreThanOneDay_ShowCorrectly() {
|
||||
final double testMillis = 2 * DateUtils.DAY_IN_MILLIS
|
||||
+ 4 * DateUtils.HOUR_IN_MILLIS + 15 * DateUtils.MINUTE_IN_MILLIS;
|
||||
final String expectedTime = "2d 4h 15m";
|
||||
|
||||
assertThat(Utils.formatElapsedTime(mContext, testMillis, false)).isEqualTo(expectedTime);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user