Merge "Don't use framework strings for formatting file sizes"

This commit is contained in:
TreeHugger Robot
2017-07-13 23:11:42 +00:00
committed by Android (Google) Code Review
11 changed files with 116 additions and 55 deletions

View File

@@ -22,6 +22,7 @@ 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 android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@@ -46,7 +47,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 +58,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 +69,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 +80,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 +92,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 +103,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");
}