Merge "Add ability to see both battery estimates on long press"
This commit is contained in:
committed by
Android (Google) Code Review
commit
90ef8cea69
@@ -83,6 +83,7 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
private BatteryMeterView mBatteryMeterView;
|
||||
private TextView mTimeText;
|
||||
private TextView mSummary;
|
||||
private TextView mSummary2;
|
||||
private LayoutPreference mBatteryLayoutPref;
|
||||
private Intent mBatteryIntent;
|
||||
private Lifecycle mLifecycle;
|
||||
@@ -97,6 +98,7 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
mTimeText = new TextView(mContext);
|
||||
mSummary = new TextView(mContext);
|
||||
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
|
||||
mSummary2 = new TextView(mContext);
|
||||
|
||||
mBatteryIntent = new Intent();
|
||||
mBatteryIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_LEVEL);
|
||||
@@ -113,7 +115,8 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
mContext, mActivity, mPreferenceFragment, mLifecycle);
|
||||
mController.mBatteryMeterView = mBatteryMeterView;
|
||||
mController.mTimeText = mTimeText;
|
||||
mController.mSummary = mSummary;
|
||||
mController.mSummary1 = mSummary;
|
||||
mController.mSummary2 = mSummary2;
|
||||
}
|
||||
|
||||
@After
|
||||
|
@@ -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