Merge "Reland "Don't use framework strings for formatting file sizes"" am: ba69fd0d3f am: d5ab7dc729 am: 5aada33242 am: 330934cfb5

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2096605

Change-Id: I51f6f771dd9a791c3dcc5465bff9e426d649f5ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Victor Chang
2022-05-24 11:38:30 +00:00
committed by Automerger Merge Worker
6 changed files with 106 additions and 41 deletions

View File

@@ -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");
}

View File

@@ -7,14 +7,14 @@ $ atest -c <YourClassName>
// The following instructions show how to run the test suite using make + adb //
To build the tests you can use the following command at the root of your android source tree
$ make SettingsUnitTests
$ make -j SettingsUnitTests
The test apk then needs to be installed onto your test device. The apk's location will vary
depending on your device model and architecture. At the end of the make command's output, there
should be a line similar to the following:
"Copy: out/target/product/shamu/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk"
"Copy: ${ANDROID_PRODUCT_OUT}/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk"
Install via the following command:
$ adb install -r out/target/product/shamu/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk
$ adb install -r ${ANDROID_PRODUCT_OUT}/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk
To run all tests:
$ adb shell am instrument -w com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner