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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user