Update restriciton page to support legacy string
- Update active time string with "last full charge" when new graph disabled Bug: 187666107 Test: make SettingsRoboTests Change-Id: Ie790600dcbe8b845ad63edd46b4a95a317c623a3
This commit is contained in:
@@ -6325,38 +6325,52 @@
|
|||||||
<!-- Title for the battery management group [CHAR LIMIT=40] -->
|
<!-- Title for the battery management group [CHAR LIMIT=40] -->
|
||||||
<string name ="battery_detail_manage_title">Manage battery usage</string>
|
<string name ="battery_detail_manage_title">Manage battery usage</string>
|
||||||
|
|
||||||
|
<!-- Description for battery total and background usage time for an app, i.e. 1 hr 15 min total • 39 min background from last full charge. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_total_and_bg_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background\nfrom last full charge</string>
|
||||||
<!-- Description for battery total and background usage time for an app, i.e. 1 hr 15 min total • 39 min background for past 24 hr. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery total and background usage time for an app, i.e. 1 hr 15 min total • 39 min background for past 24 hr. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_and_bg_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background\nfor past 24 hr</string>
|
<string name="battery_total_and_bg_usage_24hr"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background\nfor past 24 hr</string>
|
||||||
<!-- Description for battery total and background usage time in a time period for an app, i.e. 1 hr 15 min total • 39 min background for 12 am-2 am. Note: ^1, ^2 and ^3 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery total and background usage time in a time period for an app, i.e. 1 hr 15 min total • 39 min background for 12 am-2 am. Note: ^1, ^2 and ^3 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_and_bg_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background\nfor <xliff:g id="time_period" example="12 am-2 am">^3</xliff:g></string>
|
<string name="battery_total_and_bg_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • <xliff:g id="time" example="39 min">^2</xliff:g> background\nfor <xliff:g id="time_period" example="12 am-2 am">^3</xliff:g></string>
|
||||||
|
|
||||||
<!-- Description for battery total usage time is less than a minute for an app [CHAR LIMIT=120] -->
|
<!-- Description for battery total usage time is less than a minute for an app from last full charge [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_usage_less_minute">Total less than a minute for past 24 hr</string>
|
<string name="battery_total_usage_less_minute">Total less than a minute from last full charge</string>
|
||||||
|
<!-- Description for battery total usage time is less than a minute for an app for past 24 hr [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_total_usage_less_minute_24hr">Total less than a minute for past 24 hr</string>
|
||||||
<!-- Description for battery total usage time is less than a minute in a time period for an app, i.e. Total less than a minute for 12 am-2 am. Note: ^1 should be used in all translations[CHAR LIMIT=120] -->
|
<!-- Description for battery total usage time is less than a minute in a time period for an app, i.e. Total less than a minute for 12 am-2 am. Note: ^1 should be used in all translations[CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_usage_less_minute_with_period">Total less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
<string name="battery_total_usage_less_minute_with_period">Total less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
||||||
|
|
||||||
<!-- Description for battery background usage time is less than a minute for an app [CHAR LIMIT=120] -->
|
<!-- Description for battery background usage time is less than a minute for an app from last full charge [CHAR LIMIT=120] -->
|
||||||
<string name="battery_bg_usage_less_minute">Background less than a minute for past 24 hr</string>
|
<string name="battery_bg_usage_less_minute">Background less than a minute from last full charge</string>
|
||||||
|
<!-- Description for battery background usage time is less than a minute for an app for past 24 hr [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_bg_usage_less_minute_24hr">Background less than a minute for past 24 hr</string>
|
||||||
<!-- Description for battery background usage time is less than a minute in a time period for an app, i.e. Background less than a minute for 12 am-2 am. Note: ^1 should be used in all translations[CHAR LIMIT=120] -->
|
<!-- Description for battery background usage time is less than a minute in a time period for an app, i.e. Background less than a minute for 12 am-2 am. Note: ^1 should be used in all translations[CHAR LIMIT=120] -->
|
||||||
<string name="battery_bg_usage_less_minute_with_period">Background less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
<string name="battery_bg_usage_less_minute_with_period">Background less than a minute for <xliff:g id="time_period" example="12 am-2 am">^1</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Description for battery total usage time for an app, i.e. 1 hr 15 min total from last full charge. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_total_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total from last full charge</string>
|
||||||
<!-- Description for battery total usage time for an app, i.e. 1 hr 15 min total for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery total usage time for an app, i.e. 1 hr 15 min total for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total for past 24 hr</string>
|
<string name="battery_total_usage_24hr"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total for past 24 hr</string>
|
||||||
<!-- Description for battery total usage time in a time period for an app, i.e. 1 hr 15 min total for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery total usage time in a time period for an app, i.e. 1 hr 15 min total for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
<string name="battery_total_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Description for battery background usage time for an app, i.e. 1 hr 15 min background from last full charge. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_bg_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background from last full charge</string>
|
||||||
<!-- Description for battery background usage time for an app, i.e. 1 hr 15 min background for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery background usage time for an app, i.e. 1 hr 15 min background for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_bg_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for past 24 hr</string>
|
<string name="battery_bg_usage_24hr"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for past 24 hr</string>
|
||||||
<!-- Description for battery background usage time in a time period for an app, i.e. 1 hr 15 min background for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery background usage time in a time period for an app, i.e. 1 hr 15 min background for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_bg_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
<string name="battery_bg_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> background for <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Description for battery total usage with background usage time less than a minute for an app, i.e. 1 hr 15 min total • background less than a minute from last full charge. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_total_usage_and_bg_less_minute_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute\nfrom last full charge</string>
|
||||||
<!-- Description for battery total usage with background usage time less than a minute for an app, i.e. 1 hr 15 min total • background less than a minute for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery total usage with background usage time less than a minute for an app, i.e. 1 hr 15 min total • background less than a minute for past 24 hr. Note: ^1 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_usage_and_bg_less_minute_usage"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute\nfor past 24 hr</string>
|
<string name="battery_total_usage_and_bg_less_minute_usage_24hr"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute\nfor past 24 hr</string>
|
||||||
<!-- Description for battery total usage with background usage time less than a minute in a time period for an app, i.e. 1 hr 15 min total • background less than a minute for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
<!-- Description for battery total usage with background usage time less than a minute in a time period for an app, i.e. 1 hr 15 min total • background less than a minute for 12 am-2 am. Note: ^1 and ^2 should be used in all translations [CHAR LIMIT=120] -->
|
||||||
<string name="battery_total_usage_and_bg_less_minute_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute\nfor <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
<string name="battery_total_usage_and_bg_less_minute_usage_with_period"><xliff:g id="time" example="1 hr 15 min">^1</xliff:g> total • background less than a minute\nfor <xliff:g id="time_period" example="12 am-2 am">^2</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Description for no any battery usage from last full charge [CHAR LIMIT=120] -->
|
||||||
|
<string name="battery_not_usage">No usage from last full charge</string>
|
||||||
<!-- Description for no any battery usage for past 24 hr [CHAR LIMIT=120] -->
|
<!-- Description for no any battery usage for past 24 hr [CHAR LIMIT=120] -->
|
||||||
<string name="battery_not_usage">No usage for past 24 hr</string>
|
<string name="battery_not_usage_24hr">No usage for past 24 hr</string>
|
||||||
|
|
||||||
<!-- Graph subtext displayed to user when enhanced battery estimate is being used [CHAR LIMIT=120] -->
|
<!-- Graph subtext displayed to user when enhanced battery estimate is being used [CHAR LIMIT=120] -->
|
||||||
<string name="advanced_battery_graph_subtext">Battery left estimate is based on your device usage</string>
|
<string name="advanced_battery_graph_subtext">Battery left estimate is based on your device usage</string>
|
||||||
|
@@ -44,6 +44,7 @@ import com.android.settings.core.SubSettingLauncher;
|
|||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.widget.EntityHeaderController;
|
import com.android.settings.widget.EntityHeaderController;
|
||||||
import com.android.settingslib.applications.AppUtils;
|
import com.android.settingslib.applications.AppUtils;
|
||||||
import com.android.settingslib.applications.ApplicationsState;
|
import com.android.settingslib.applications.ApplicationsState;
|
||||||
@@ -436,13 +437,18 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
|||||||
long foregroundTimeMs, long backgroundTimeMs, String slotTime) {
|
long foregroundTimeMs, long backgroundTimeMs, String slotTime) {
|
||||||
final long totalTimeMs = foregroundTimeMs + backgroundTimeMs;
|
final long totalTimeMs = foregroundTimeMs + backgroundTimeMs;
|
||||||
final CharSequence usageTimeSummary;
|
final CharSequence usageTimeSummary;
|
||||||
|
final PowerUsageFeatureProvider powerFeatureProvider =
|
||||||
|
FeatureFactory.getFactory(getContext()).getPowerUsageFeatureProvider(getContext());
|
||||||
|
|
||||||
if (totalTimeMs == 0) {
|
if (totalTimeMs == 0) {
|
||||||
usageTimeSummary = getText(R.string.battery_not_usage);
|
usageTimeSummary = getText(powerFeatureProvider.isChartGraphEnabled(getContext())
|
||||||
|
? R.string.battery_not_usage_24hr : R.string.battery_not_usage);
|
||||||
} else if (slotTime == null) {
|
} else if (slotTime == null) {
|
||||||
// Shows summary text with past 24 hr if slot time is null.
|
// Shows summary text with past 24 hr or full charge if slot time is null.
|
||||||
usageTimeSummary =
|
usageTimeSummary = powerFeatureProvider.isChartGraphEnabled(getContext())
|
||||||
getAppPast24HrActiveSummary(foregroundTimeMs, backgroundTimeMs, totalTimeMs);
|
? getAppPast24HrActiveSummary(foregroundTimeMs, backgroundTimeMs, totalTimeMs)
|
||||||
|
: getAppFullChargeActiveSummary(
|
||||||
|
foregroundTimeMs, backgroundTimeMs, totalTimeMs);
|
||||||
} else {
|
} else {
|
||||||
// Shows summary text with slot time.
|
// Shows summary text with slot time.
|
||||||
usageTimeSummary = getAppActiveSummaryWithSlotTime(
|
usageTimeSummary = getAppActiveSummaryWithSlotTime(
|
||||||
@@ -451,7 +457,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
|||||||
return usageTimeSummary;
|
return usageTimeSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence getAppPast24HrActiveSummary(
|
private CharSequence getAppFullChargeActiveSummary(
|
||||||
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs) {
|
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs) {
|
||||||
// Shows background summary only if we don't have foreground usage time.
|
// Shows background summary only if we don't have foreground usage time.
|
||||||
if (foregroundTimeMs == 0 && backgroundTimeMs != 0) {
|
if (foregroundTimeMs == 0 && backgroundTimeMs != 0) {
|
||||||
@@ -494,6 +500,49 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CharSequence getAppPast24HrActiveSummary(
|
||||||
|
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs) {
|
||||||
|
// Shows background summary only if we don't have foreground usage time.
|
||||||
|
if (foregroundTimeMs == 0 && backgroundTimeMs != 0) {
|
||||||
|
return backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS
|
||||||
|
? getText(R.string.battery_bg_usage_less_minute_24hr)
|
||||||
|
: TextUtils.expandTemplate(getText(R.string.battery_bg_usage_24hr),
|
||||||
|
StringUtil.formatElapsedTime(
|
||||||
|
getContext(),
|
||||||
|
backgroundTimeMs,
|
||||||
|
/* withSeconds */ false,
|
||||||
|
/* collapseTimeUnit */ false));
|
||||||
|
// Shows total usage summary only if total usage time is small.
|
||||||
|
} else if (totalTimeMs < DateUtils.MINUTE_IN_MILLIS) {
|
||||||
|
return getText(R.string.battery_total_usage_less_minute_24hr);
|
||||||
|
// Shows different total usage summary when background usage time is small.
|
||||||
|
} else if (backgroundTimeMs < DateUtils.MINUTE_IN_MILLIS) {
|
||||||
|
return TextUtils.expandTemplate(
|
||||||
|
getText(backgroundTimeMs == 0
|
||||||
|
? R.string.battery_total_usage_24hr
|
||||||
|
: R.string.battery_total_usage_and_bg_less_minute_usage_24hr),
|
||||||
|
StringUtil.formatElapsedTime(
|
||||||
|
getContext(),
|
||||||
|
totalTimeMs,
|
||||||
|
/* withSeconds */ false,
|
||||||
|
/* collapseTimeUnit */ false));
|
||||||
|
// Shows default summary.
|
||||||
|
} else {
|
||||||
|
return TextUtils.expandTemplate(
|
||||||
|
getText(R.string.battery_total_and_bg_usage_24hr),
|
||||||
|
StringUtil.formatElapsedTime(
|
||||||
|
getContext(),
|
||||||
|
totalTimeMs,
|
||||||
|
/* withSeconds */ false,
|
||||||
|
/* collapseTimeUnit */ false),
|
||||||
|
StringUtil.formatElapsedTime(
|
||||||
|
getContext(),
|
||||||
|
backgroundTimeMs,
|
||||||
|
/* withSeconds */ false,
|
||||||
|
/* collapseTimeUnit */ false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CharSequence getAppActiveSummaryWithSlotTime(
|
private CharSequence getAppActiveSummaryWithSlotTime(
|
||||||
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs, String slotTime) {
|
long foregroundTimeMs, long backgroundTimeMs, long totalTimeMs, String slotTime) {
|
||||||
// Shows background summary only if we don't have foreground usage time.
|
// Shows background summary only if we don't have foreground usage time.
|
||||||
|
@@ -128,6 +128,7 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
private RadioButtonPreference mUnrestrictedPreference;
|
private RadioButtonPreference mUnrestrictedPreference;
|
||||||
private AdvancedPowerUsageDetail mFragment;
|
private AdvancedPowerUsageDetail mFragment;
|
||||||
private SettingsActivity mTestActivity;
|
private SettingsActivity mTestActivity;
|
||||||
|
private FakeFeatureFactory mFeatureFactory;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -135,7 +136,7 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getPackageName()).thenReturn("foo");
|
when(mContext.getPackageName()).thenReturn("foo");
|
||||||
FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
|
|
||||||
mFragment = spy(new AdvancedPowerUsageDetail());
|
mFragment = spy(new AdvancedPowerUsageDetail());
|
||||||
doReturn(mContext).when(mFragment).getContext();
|
doReturn(mContext).when(mFragment).getContext();
|
||||||
@@ -144,6 +145,8 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
doReturn(APP_LABEL).when(mBundle).getString(nullable(String.class));
|
doReturn(APP_LABEL).when(mBundle).getString(nullable(String.class));
|
||||||
when(mFragment.getArguments()).thenReturn(mBundle);
|
when(mFragment.getArguments()).thenReturn(mBundle);
|
||||||
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(true);
|
||||||
|
|
||||||
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
|
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
|
||||||
doReturn(mEntityHeaderController).when(mEntityHeaderController)
|
doReturn(mEntityHeaderController).when(mEntityHeaderController)
|
||||||
@@ -269,6 +272,144 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
verify(mEntityHeaderController).setIsInstantApp(true);
|
verify(mEntityHeaderController).setIsInstantApp(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_noUsageTimeAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("No usage from last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_bgTwoMinFgZeroAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
final long backgroundTimeTwoMinutes = 120000;
|
||||||
|
final long foregroundTimeZero = 0;
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeZero);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("2 min background from last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_bgLessThanAMinFgZeroAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
final long backgroundTimeLessThanAMinute = 59999;
|
||||||
|
final long foregroundTimeZero = 0;
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(
|
||||||
|
AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeZero);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("Background less than a minute from last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_totalUsageLessThanAMinAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
final long backgroundTimeLessThanHalfMinute = 20000;
|
||||||
|
final long foregroundTimeLessThanHalfMinute = 20000;
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(
|
||||||
|
AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanHalfMinute);
|
||||||
|
bundle.putLong(
|
||||||
|
AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeLessThanHalfMinute);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("Total less than a minute from last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_TotalAMinutesBgLessThanAMinAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
|
||||||
|
final long backgroundTimeZero = 59999;
|
||||||
|
final long foregroundTimeTwoMinutes = 1;
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeZero);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("1 min total • background less than a minute\nfrom last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_TotalAMinBackgroundZeroAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
final long backgroundTimeZero = 0;
|
||||||
|
final long foregroundTimeAMinutes = 60000;
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeZero);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeAMinutes);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("1 min total from last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitHeader_fgTwoMinBgFourMinAndGraphDisabled_hasCorrectSummary() {
|
||||||
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
||||||
|
.thenReturn(false);
|
||||||
|
final long backgroundTimeFourMinute = 240000;
|
||||||
|
final long foregroundTimeTwoMinutes = 120000;
|
||||||
|
Bundle bundle = new Bundle(2);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeFourMinute);
|
||||||
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
|
||||||
|
when(mFragment.getArguments()).thenReturn(bundle);
|
||||||
|
mFragment.initHeader();
|
||||||
|
|
||||||
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
|
assertThat(captor.getValue().toString())
|
||||||
|
.isEqualTo("6 min total • 4 min background\nfrom last full charge");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInitHeader_noUsageTime_hasCorrectSummary() {
|
public void testInitHeader_noUsageTime_hasCorrectSummary() {
|
||||||
Bundle bundle = new Bundle(2);
|
Bundle bundle = new Bundle(2);
|
||||||
@@ -352,7 +493,7 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
assertThat(captor.getValue().toString())
|
assertThat(captor.getValue().toString())
|
||||||
.isEqualTo("1 min total • background less than a minute for past 24 hr");
|
.isEqualTo("1 min total • background less than a minute\nfor past 24 hr");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -385,7 +526,7 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
assertThat(captor.getValue().toString())
|
assertThat(captor.getValue().toString())
|
||||||
.isEqualTo("6 min total • 4 min background for past 24 hr");
|
.isEqualTo("6 min total • 4 min background\nfor past 24 hr");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -423,7 +564,7 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
assertThat(captor.getValue().toString())
|
assertThat(captor.getValue().toString())
|
||||||
.isEqualTo("1 min total • background less than a minute for 12 am-2 am");
|
.isEqualTo("1 min total • background less than a minute\nfor 12 am-2 am");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -458,7 +599,7 @@ public class AdvancedPowerUsageDetailTest {
|
|||||||
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
|
||||||
verify(mEntityHeaderController).setSummary(captor.capture());
|
verify(mEntityHeaderController).setSummary(captor.capture());
|
||||||
assertThat(captor.getValue().toString())
|
assertThat(captor.getValue().toString())
|
||||||
.isEqualTo("6 min total • 4 min background for 12 am-2 am");
|
.isEqualTo("6 min total • 4 min background\nfor 12 am-2 am");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user