Merge changes from topic "BytesFormatter" into main
* changes: Migrate all data usage format use case Clean up unused DataUsageSummary.formatUsage Use BytesFormatter for data usage
This commit is contained in:
@@ -56,13 +56,10 @@ class AppDataUsageSummaryControllerTest {
|
||||
composeTestRule.onNode(hasTextExactly("Total", "6.75 kB")).assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Foreground", "5.54 kB")).assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Background", "1.21 kB")).assertIsDisplayed()
|
||||
composeTestRule.onNodeWithContentDescription("6.75 kB").assertIsDisplayed()
|
||||
composeTestRule.onNodeWithContentDescription("5.54 kB").assertIsDisplayed()
|
||||
composeTestRule.onNodeWithContentDescription("1.21 kB").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun summary_zero() {
|
||||
fun summary_smallByte() {
|
||||
val appUsage = NetworkUsageDetailsData(
|
||||
range = Range(1L, 2L),
|
||||
totalUsage = 3,
|
||||
@@ -75,12 +72,9 @@ class AppDataUsageSummaryControllerTest {
|
||||
controller.Content()
|
||||
}
|
||||
|
||||
composeTestRule.onNode(hasTextExactly("Total", "3 B")).assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Foreground", "1 B")).assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Background", "2 B")).assertIsDisplayed()
|
||||
composeTestRule.onNodeWithContentDescription("3 byte").assertIsDisplayed()
|
||||
composeTestRule.onNodeWithContentDescription("1 byte").assertIsDisplayed()
|
||||
composeTestRule.onNodeWithContentDescription("2 byte").assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Total", "3 byte")).assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Foreground", "1 byte")).assertIsDisplayed()
|
||||
composeTestRule.onNode(hasTextExactly("Background", "2 byte")).assertIsDisplayed()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
@@ -182,8 +182,8 @@ class DataUsageSummaryPreferenceControllerTest {
|
||||
val limitInfo = argumentCaptor {
|
||||
verify(preference).setLimitInfo(capture())
|
||||
}.firstValue.toString()
|
||||
assertThat(limitInfo).isEqualTo("1 B data warning")
|
||||
verify(preference).setLabels("0 B", "1 B")
|
||||
assertThat(limitInfo).isEqualTo("1 byte data warning")
|
||||
verify(preference).setLabels("0 byte", "1 byte")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -200,8 +200,8 @@ class DataUsageSummaryPreferenceControllerTest {
|
||||
val limitInfo = argumentCaptor {
|
||||
verify(preference).setLimitInfo(capture())
|
||||
}.firstValue.toString()
|
||||
assertThat(limitInfo).isEqualTo("1 B data limit")
|
||||
verify(preference).setLabels("0 B", "1 B")
|
||||
assertThat(limitInfo).isEqualTo("1 byte data limit")
|
||||
verify(preference).setLabels("0 byte", "1 byte")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,7 +219,7 @@ class DataUsageSummaryPreferenceControllerTest {
|
||||
verify(preference).setLimitInfo(capture())
|
||||
}.firstValue.toString()
|
||||
assertThat(limitInfo).isEqualTo("512 MB data warning / 1.00 GB data limit")
|
||||
verify(preference).setLabels("0 B", "1.00 GB")
|
||||
verify(preference).setLabels("0 byte", "1.00 GB")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -256,7 +256,7 @@ class DataUsageSummaryPreferenceControllerTest {
|
||||
POSITIVE_DATA_PLAN_INFO.dataPlanSize,
|
||||
)
|
||||
verify(preference).setChartEnabled(true)
|
||||
verify(preference).setLabels("0 B", "9 B")
|
||||
verify(preference).setLabels("0 byte", "9 byte")
|
||||
val progress = argumentCaptor {
|
||||
verify(preference).setProgress(capture())
|
||||
}.firstValue
|
||||
|
||||
@@ -21,7 +21,6 @@ import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.settings.datausage.lib.DataUsageFormatter.Companion.getBytesDisplayUnit
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -33,26 +32,23 @@ class DataUsageFormatterTest {
|
||||
|
||||
@Test
|
||||
fun formatDataUsage_0() {
|
||||
val (displayText, contentDescription) = dataUsageFormatter.formatDataUsage(0)
|
||||
val displayText = dataUsageFormatter.formatDataUsage(0)
|
||||
|
||||
assertThat(displayText).isEqualTo("0 B")
|
||||
assertThat(contentDescription).isEqualTo("0 byte")
|
||||
assertThat(displayText).isEqualTo("0 byte")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun formatDataUsage_1000() {
|
||||
val (displayText, contentDescription) = dataUsageFormatter.formatDataUsage(1000)
|
||||
val displayText = dataUsageFormatter.formatDataUsage(1000)
|
||||
|
||||
assertThat(displayText).isEqualTo("0.98 kB")
|
||||
assertThat(contentDescription).isEqualTo("0.98 kB")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun formatDataUsage_2000000() {
|
||||
val (displayText, contentDescription) = dataUsageFormatter.formatDataUsage(2000000)
|
||||
val displayText = dataUsageFormatter.formatDataUsage(2000000)
|
||||
|
||||
assertThat(displayText).isEqualTo("1.91 MB")
|
||||
assertThat(contentDescription).isEqualTo("1.91 MB")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -143,7 +143,7 @@ class DataUsagePreferenceControllerTest {
|
||||
controller.onViewCreated(TestLifecycleOwner())
|
||||
|
||||
waitUntil { preference.isEnabled }
|
||||
waitUntil { preference.summary?.contains("0 B used") == true }
|
||||
waitUntil { preference.summary?.contains("0 byte used") == true }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +159,7 @@ class DataUsagePreferenceControllerTest {
|
||||
controller.onViewCreated(TestLifecycleOwner())
|
||||
|
||||
waitUntil { !preference.isEnabled }
|
||||
waitUntil { preference.summary?.contains("0 B used") == true }
|
||||
waitUntil { preference.summary?.contains("0 byte used") == true }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -134,7 +134,7 @@ class AppDataUsagePreferenceTest {
|
||||
|
||||
setContent()
|
||||
|
||||
composeTestRule.waitUntilExists(hasText("123 B used since Oct 25, 2022"))
|
||||
composeTestRule.waitUntilExists(hasText("123 byte used since Oct 25, 2022"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user