Add ability to see both battery estimates on long press

If the enhanced estimate is being used in battery settings
it is now possible to long press on the text to have it display
both instead of the string that is normally used.

Adds another loader to enable this since it needs both the old
and the new estimates simultaneously.

Feature is hidden behind a feature flag that only googlers will
have enabled.

Test: robotests
Bug: 38399275
Change-Id: I5caf26513baada27efd50ddb0e72d3868da47150
This commit is contained in:
Salvador Martinez
2017-05-22 17:26:39 -07:00
parent fe23da579d
commit f4727ea07f
10 changed files with 229 additions and 24 deletions

View File

@@ -15,7 +15,9 @@
*/
package com.android.settings.fuelgauge;
import android.view.View;
import java.util.List;
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import android.app.LoaderManager;
import android.content.Context;
@@ -106,6 +108,8 @@ public class PowerUsageSummaryTest {
private static final double POWER_USAGE_PERCENTAGE = 50;
private static final Intent ADDITIONAL_BATTERY_INFO_INTENT =
new Intent("com.example.app.ADDITIONAL_BATTERY_INFO");
public static final String NEW_ML_EST_SUFFIX = "(New ML est)";
public static final String OLD_EST_SUFFIX = "(Old est)";
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@@ -450,6 +454,18 @@ public class PowerUsageSummaryTest {
any());
}
@Test
public void testShowBothEstimates_summariesAreBothModified() {
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary1);
mFragment.onLongClick(new View(mRealContext));
TextView summary1 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary1);
TextView summary2 = mFragment.mBatteryLayoutPref.findViewById(R.id.summary2);
Robolectric.flushBackgroundThreadScheduler();
assertThat(summary2.getText().toString().contains(NEW_ML_EST_SUFFIX));
assertThat(summary1.getText().toString().contains(OLD_EST_SUFFIX));
}
public static class TestFragment extends PowerUsageSummary {
private Context mContext;