Reland "Don't use framework strings for formatting file sizes"
Reland http://ag/2529020 because the over-translation issue should be resolved now. Modify various formatters to avoid using framework strings for formatting file sizes. Also update README instructions for running unit tests. Bug: 36994779 Bug: 71580745 Bug: 217592956 Test: no new test failures from RunSettingsRoboTests Test: manual opening the settings page. Change-Id: Ic4689ab1b76622028004d05e69858228bdc441cf
This commit is contained in:
committed by
Victor Chang
parent
1143a4e8dc
commit
ad389346c8
@@ -18,9 +18,11 @@ package com.android.settings.utils;
|
||||
|
||||
import static com.android.settings.utils.FileSizeFormatter.GIGABYTE_IN_BYTES;
|
||||
import static com.android.settings.utils.FileSizeFormatter.MEGABYTE_IN_BYTES;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.icu.util.MeasureUnit;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.filters.SmallTest;
|
||||
@@ -46,7 +48,7 @@ public class FileSizeFormatterTest {
|
||||
FileSizeFormatter.formatFileSize(
|
||||
mContext,
|
||||
0 /* size */,
|
||||
com.android.internal.R.string.gigabyteShort,
|
||||
MeasureUnit.GIGABYTE,
|
||||
GIGABYTE_IN_BYTES))
|
||||
.isEqualTo("0.00 GB");
|
||||
}
|
||||
@@ -57,7 +59,7 @@ public class FileSizeFormatterTest {
|
||||
FileSizeFormatter.formatFileSize(
|
||||
mContext,
|
||||
MEGABYTE_IN_BYTES * 11 /* size */,
|
||||
com.android.internal.R.string.gigabyteShort,
|
||||
MeasureUnit.GIGABYTE,
|
||||
GIGABYTE_IN_BYTES))
|
||||
.isEqualTo("0.01 GB");
|
||||
}
|
||||
@@ -68,7 +70,7 @@ public class FileSizeFormatterTest {
|
||||
FileSizeFormatter.formatFileSize(
|
||||
mContext,
|
||||
MEGABYTE_IN_BYTES * 155 /* size */,
|
||||
com.android.internal.R.string.gigabyteShort,
|
||||
MeasureUnit.GIGABYTE,
|
||||
GIGABYTE_IN_BYTES))
|
||||
.isEqualTo("0.16 GB");
|
||||
}
|
||||
@@ -79,7 +81,7 @@ public class FileSizeFormatterTest {
|
||||
FileSizeFormatter.formatFileSize(
|
||||
mContext,
|
||||
MEGABYTE_IN_BYTES * 1551 /* size */,
|
||||
com.android.internal.R.string.gigabyteShort,
|
||||
MeasureUnit.GIGABYTE,
|
||||
GIGABYTE_IN_BYTES))
|
||||
.isEqualTo("1.6 GB");
|
||||
}
|
||||
@@ -91,7 +93,7 @@ public class FileSizeFormatterTest {
|
||||
FileSizeFormatter.formatFileSize(
|
||||
mContext,
|
||||
GIGABYTE_IN_BYTES * 15 + MEGABYTE_IN_BYTES * 50 /* size */,
|
||||
com.android.internal.R.string.gigabyteShort,
|
||||
MeasureUnit.GIGABYTE,
|
||||
GIGABYTE_IN_BYTES))
|
||||
.isEqualTo("15 GB");
|
||||
}
|
||||
@@ -102,7 +104,7 @@ public class FileSizeFormatterTest {
|
||||
FileSizeFormatter.formatFileSize(
|
||||
mContext,
|
||||
MEGABYTE_IN_BYTES * -155 /* size */,
|
||||
com.android.internal.R.string.gigabyteShort,
|
||||
MeasureUnit.GIGABYTE,
|
||||
GIGABYTE_IN_BYTES))
|
||||
.isEqualTo("-0.16 GB");
|
||||
}
|
||||
|
Reference in New Issue
Block a user