|
|
@@ -224,12 +224,12 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testGetPreferenceScreenResId_returnNewLayout() {
|
|
|
|
public void setPreferenceScreenResId_returnNewLayout() {
|
|
|
|
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.power_usage_detail);
|
|
|
|
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.power_usage_detail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_NoAppEntry_BuildByBundle() {
|
|
|
|
public void initHeader_NoAppEntry_BuildByBundle() {
|
|
|
|
mFragment.mAppEntry = null;
|
|
|
|
mFragment.mAppEntry = null;
|
|
|
|
mFragment.initHeader();
|
|
|
|
mFragment.initHeader();
|
|
|
|
|
|
|
|
|
|
|
@@ -238,7 +238,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_HasAppEntry_BuildByAppEntry() {
|
|
|
|
public void initHeader_HasAppEntry_BuildByAppEntry() {
|
|
|
|
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
|
|
|
|
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
|
|
|
|
new InstantAppDataProvider() {
|
|
|
|
new InstantAppDataProvider() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@@ -255,7 +255,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_HasAppEntry_InstantApp() {
|
|
|
|
public void initHeader_HasAppEntry_InstantApp() {
|
|
|
|
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
|
|
|
|
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
|
|
|
|
new InstantAppDataProvider() {
|
|
|
|
new InstantAppDataProvider() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@@ -272,7 +272,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_noUsageTimeAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_noUsageTimeAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
@@ -290,7 +290,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_bgTwoMinFgZeroAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_bgTwoMinFgZeroAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
@@ -310,7 +310,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_bgLessThanAMinFgZeroAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_bgLessThanAMinFgZeroAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
@@ -331,7 +331,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_totalUsageLessThanAMinAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_totalUsageLessThanAMinAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
@@ -353,7 +353,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_TotalAMinutesBgLessThanAMinAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_TotalAMinutesBgLessThanAMinAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
@@ -373,7 +373,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_TotalAMinBackgroundZeroAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_TotalAMinBackgroundZeroAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
final long backgroundTimeZero = 0;
|
|
|
|
final long backgroundTimeZero = 0;
|
|
|
@@ -392,7 +392,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_fgTwoMinBgFourMinAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
public void initHeader_fgTwoMinBgFourMinAndGraphDisabled_hasCorrectSummary() {
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext))
|
|
|
|
.thenReturn(false);
|
|
|
|
.thenReturn(false);
|
|
|
|
final long backgroundTimeFourMinute = 240000;
|
|
|
|
final long backgroundTimeFourMinute = 240000;
|
|
|
@@ -410,7 +410,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_noUsageTime_hasCorrectSummary() {
|
|
|
|
public void initHeader_noUsageTime_hasCorrectSummary() {
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
|
|
|
@@ -421,11 +421,11 @@ 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("No usage for past 24 hr");
|
|
|
|
.isEqualTo("No usage from last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_noUsageTimeButConsumedPower_hasEmptySummary() {
|
|
|
|
public void initHeader_noUsageTimeButConsumedPower_hasEmptySummary() {
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
|
|
|
@@ -440,7 +440,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_backgroundTwoMinForegroundZero_hasCorrectSummary() {
|
|
|
|
public void initHeader_backgroundTwoMinForegroundZero_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeTwoMinutes = 120000;
|
|
|
|
final long backgroundTimeTwoMinutes = 120000;
|
|
|
|
final long foregroundTimeZero = 0;
|
|
|
|
final long foregroundTimeZero = 0;
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
@@ -453,11 +453,11 @@ 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("2 min background for past 24 hr");
|
|
|
|
.isEqualTo("2 min background from last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_backgroundLessThanAMinForegroundZero_hasCorrectSummary() {
|
|
|
|
public void initHeader_backgroundLessThanAMinForegroundZero_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeLessThanAMinute = 59999;
|
|
|
|
final long backgroundTimeLessThanAMinute = 59999;
|
|
|
|
final long foregroundTimeZero = 0;
|
|
|
|
final long foregroundTimeZero = 0;
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
@@ -471,11 +471,11 @@ 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("Background less than a minute for past 24 hr");
|
|
|
|
.isEqualTo("Background less than a minute from last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_totalUsageLessThanAMin_hasCorrectSummary() {
|
|
|
|
public void initHeader_totalUsageLessThanAMin_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeLessThanHalfMinute = 20000;
|
|
|
|
final long backgroundTimeLessThanHalfMinute = 20000;
|
|
|
|
final long foregroundTimeLessThanHalfMinute = 20000;
|
|
|
|
final long foregroundTimeLessThanHalfMinute = 20000;
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
@@ -490,11 +490,11 @@ 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("Total less than a minute for past 24 hr");
|
|
|
|
.isEqualTo("Total less than a minute from last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_TotalAMinutesBackgroundLessThanAMin_hasCorrectSummary() {
|
|
|
|
public void initHeader_TotalAMinutesBackgroundLessThanAMin_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeZero = 59999;
|
|
|
|
final long backgroundTimeZero = 59999;
|
|
|
|
final long foregroundTimeTwoMinutes = 1;
|
|
|
|
final long foregroundTimeTwoMinutes = 1;
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
@@ -507,11 +507,11 @@ 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\nfor past 24 hr");
|
|
|
|
.isEqualTo("1 min total • background less than a minute\nfrom last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_TotalAMinBackgroundZero_hasCorrectSummary() {
|
|
|
|
public void initHeader_TotalAMinBackgroundZero_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeZero = 0;
|
|
|
|
final long backgroundTimeZero = 0;
|
|
|
|
final long foregroundTimeAMinutes = 60000;
|
|
|
|
final long foregroundTimeAMinutes = 60000;
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
@@ -524,11 +524,11 @@ 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 for past 24 hr");
|
|
|
|
.isEqualTo("1 min total from last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_foregroundTwoMinBackgroundFourMin_hasCorrectSummary() {
|
|
|
|
public void initHeader_foregroundTwoMinBackgroundFourMin_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeFourMinute = 240000;
|
|
|
|
final long backgroundTimeFourMinute = 240000;
|
|
|
|
final long foregroundTimeTwoMinutes = 120000;
|
|
|
|
final long foregroundTimeTwoMinutes = 120000;
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
|
Bundle bundle = new Bundle(2);
|
|
|
@@ -541,11 +541,11 @@ 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\nfor past 24 hr");
|
|
|
|
.isEqualTo("6 min total • 4 min background\nfrom last full charge");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_totalUsageLessThanAMinWithSlotTime_hasCorrectSummary() {
|
|
|
|
public void initHeader_totalUsageLessThanAMinWithSlotTime_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeLessThanHalfMinute = 20000;
|
|
|
|
final long backgroundTimeLessThanHalfMinute = 20000;
|
|
|
|
final long foregroundTimeLessThanHalfMinute = 20000;
|
|
|
|
final long foregroundTimeLessThanHalfMinute = 20000;
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
@@ -565,7 +565,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_TotalAMinBackgroundLessThanAMinWithSlotTime_hasCorrectSummary() {
|
|
|
|
public void initHeader_TotalAMinBackgroundLessThanAMinWithSlotTime_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeZero = 59999;
|
|
|
|
final long backgroundTimeZero = 59999;
|
|
|
|
final long foregroundTimeTwoMinutes = 1;
|
|
|
|
final long foregroundTimeTwoMinutes = 1;
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
@@ -583,7 +583,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_TotalAMinBackgroundZeroWithSlotTime_hasCorrectSummary() {
|
|
|
|
public void initHeader_TotalAMinBackgroundZeroWithSlotTime_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeZero = 0;
|
|
|
|
final long backgroundTimeZero = 0;
|
|
|
|
final long foregroundTimeAMinutes = 60000;
|
|
|
|
final long foregroundTimeAMinutes = 60000;
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
@@ -601,7 +601,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_foregroundTwoMinBackgroundFourMinWithSlotTime_hasCorrectSummary() {
|
|
|
|
public void initHeader_foregroundTwoMinBackgroundFourMinWithSlotTime_hasCorrectSummary() {
|
|
|
|
final long backgroundTimeFourMinute = 240000;
|
|
|
|
final long backgroundTimeFourMinute = 240000;
|
|
|
|
final long foregroundTimeTwoMinutes = 120000;
|
|
|
|
final long foregroundTimeTwoMinutes = 120000;
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
@@ -619,7 +619,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_systemUidWithChartIsDisabled_nullSummary() {
|
|
|
|
public void initHeader_systemUidWithChartIsDisabled_nullSummary() {
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, 240000);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, 240000);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, 120000);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, 120000);
|
|
|
@@ -636,7 +636,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitHeader_systemUidWithChartIsEnabled_notNullSummary() {
|
|
|
|
public void initHeader_systemUidWithChartIsEnabled_notNullSummary() {
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
Bundle bundle = new Bundle(3);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, 240000);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, 240000);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, 120000);
|
|
|
|
bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, 120000);
|
|
|
@@ -651,21 +651,21 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_hasBasicData() {
|
|
|
|
public void startBatteryDetailPage_hasBasicData() {
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
|
mBatteryEntry, USAGE_PERCENT, /*isValidToShowSummary=*/ true);
|
|
|
|
mBatteryEntry, USAGE_PERCENT, /*isValidToShowSummary=*/ true);
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_UID)).isEqualTo(UID);
|
|
|
|
assertThat(mBundle.getInt(AdvancedPowerUsageDetail.EXTRA_UID)).isEqualTo(UID);
|
|
|
|
assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME))
|
|
|
|
assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME))
|
|
|
|
.isEqualTo(BACKGROUND_TIME_MS);
|
|
|
|
.isEqualTo(BACKGROUND_TIME_MS);
|
|
|
|
assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME))
|
|
|
|
assertThat(mBundle.getLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME))
|
|
|
|
.isEqualTo(FOREGROUND_TIME_MS);
|
|
|
|
.isEqualTo(FOREGROUND_TIME_MS);
|
|
|
|
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT))
|
|
|
|
assertThat(mBundle.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT))
|
|
|
|
.isEqualTo(USAGE_PERCENT);
|
|
|
|
.isEqualTo(USAGE_PERCENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_invalidToShowSummary_noFGBDData() {
|
|
|
|
public void startBatteryDetailPage_invalidToShowSummary_noFGBDData() {
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
|
mBatteryEntry, USAGE_PERCENT, /*isValidToShowSummary=*/ false);
|
|
|
|
mBatteryEntry, USAGE_PERCENT, /*isValidToShowSummary=*/ false);
|
|
|
|
|
|
|
|
|
|
|
@@ -679,7 +679,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_NormalApp() {
|
|
|
|
public void startBatteryDetailPage_NormalApp() {
|
|
|
|
when(mBatteryEntry.getDefaultPackageName()).thenReturn(PACKAGE_NAME[0]);
|
|
|
|
when(mBatteryEntry.getDefaultPackageName()).thenReturn(PACKAGE_NAME[0]);
|
|
|
|
|
|
|
|
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
@@ -690,7 +690,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_SystemApp() {
|
|
|
|
public void startBatteryDetailPage_SystemApp() {
|
|
|
|
when(mBatteryEntry.getDefaultPackageName()).thenReturn(null);
|
|
|
|
when(mBatteryEntry.getDefaultPackageName()).thenReturn(null);
|
|
|
|
|
|
|
|
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
|
|
|
@@ -702,7 +702,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_WorkApp() {
|
|
|
|
public void startBatteryDetailPage_WorkApp() {
|
|
|
|
final int appUid = 1010019;
|
|
|
|
final int appUid = 1010019;
|
|
|
|
doReturn(appUid).when(mBatteryEntry).getUid();
|
|
|
|
doReturn(appUid).when(mBatteryEntry).getUid();
|
|
|
|
|
|
|
|
|
|
|
@@ -713,7 +713,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_typeUser_startByCurrentUser() {
|
|
|
|
public void startBatteryDetailPage_typeUser_startByCurrentUser() {
|
|
|
|
when(mBatteryEntry.isUserEntry()).thenReturn(true);
|
|
|
|
when(mBatteryEntry.isUserEntry()).thenReturn(true);
|
|
|
|
|
|
|
|
|
|
|
|
final int currentUser = 20;
|
|
|
|
final int currentUser = 20;
|
|
|
@@ -725,7 +725,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_noBatteryUsage_hasBasicData() {
|
|
|
|
public void startBatteryDetailPage_noBatteryUsage_hasBasicData() {
|
|
|
|
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
|
|
|
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
|
|
|
|
|
|
|
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment, PACKAGE_NAME[0]);
|
|
|
|
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment, PACKAGE_NAME[0]);
|
|
|
@@ -733,16 +733,16 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
verify(mActivity).startActivity(captor.capture());
|
|
|
|
verify(mActivity).startActivity(captor.capture());
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(captor.getValue().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
|
|
|
assertThat(captor.getValue().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
|
|
|
.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME))
|
|
|
|
.getString(AdvancedPowerUsageDetail.EXTRA_PACKAGE_NAME))
|
|
|
|
.isEqualTo(PACKAGE_NAME[0]);
|
|
|
|
.isEqualTo(PACKAGE_NAME[0]);
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(captor.getValue().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
|
|
|
assertThat(captor.getValue().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS)
|
|
|
|
.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT))
|
|
|
|
.getString(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_PERCENT))
|
|
|
|
.isEqualTo("0%");
|
|
|
|
.isEqualTo("0%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testStartBatteryDetailPage_batteryEntryNotExisted_extractUidFromPackageName() throws
|
|
|
|
public void startBatteryDetailPage_batteryEntryNotExisted_extractUidFromPackageName() throws
|
|
|
|
PackageManager.NameNotFoundException {
|
|
|
|
PackageManager.NameNotFoundException {
|
|
|
|
doReturn(UID).when(mPackageManager).getPackageUid(PACKAGE_NAME[0], 0 /* no flag */);
|
|
|
|
doReturn(UID).when(mPackageManager).getPackageUid(PACKAGE_NAME[0], 0 /* no flag */);
|
|
|
|
|
|
|
|
|
|
|
@@ -752,7 +752,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitPreferenceForTriState_isValidPackageName_hasCorrectString() {
|
|
|
|
public void initPreferenceForTriState_isValidPackageName_hasCorrectString() {
|
|
|
|
when(mBatteryOptimizeUtils.isValidPackageName()).thenReturn(false);
|
|
|
|
when(mBatteryOptimizeUtils.isValidPackageName()).thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
|
mFragment.initPreferenceForTriState(mContext);
|
|
|
|
mFragment.initPreferenceForTriState(mContext);
|
|
|
@@ -762,7 +762,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitPreferenceForTriState_isSystemOrDefaultApp_hasCorrectString() {
|
|
|
|
public void initPreferenceForTriState_isSystemOrDefaultApp_hasCorrectString() {
|
|
|
|
when(mBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
|
|
|
when(mBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
|
|
|
when(mBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true);
|
|
|
|
when(mBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true);
|
|
|
|
|
|
|
|
|
|
|
@@ -773,7 +773,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testInitPreferenceForTriState_hasCorrectString() {
|
|
|
|
public void initPreferenceForTriState_hasCorrectString() {
|
|
|
|
when(mBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
|
|
|
when(mBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
|
|
|
when(mBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(false);
|
|
|
|
when(mBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(false);
|
|
|
|
|
|
|
|
|
|
|
@@ -784,7 +784,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testOnRadioButtonClicked_clickOptimizePref_optimizePreferenceChecked() {
|
|
|
|
public void onRadioButtonClicked_clickOptimizePref_optimizePreferenceChecked() {
|
|
|
|
mOptimizePreference.setKey(KEY_PREF_OPTIMIZED);
|
|
|
|
mOptimizePreference.setKey(KEY_PREF_OPTIMIZED);
|
|
|
|
mRestrictedPreference.setKey(KEY_PREF_RESTRICTED);
|
|
|
|
mRestrictedPreference.setKey(KEY_PREF_RESTRICTED);
|
|
|
|
mUnrestrictedPreference.setKey(KEY_PREF_UNRESTRICTED);
|
|
|
|
mUnrestrictedPreference.setKey(KEY_PREF_UNRESTRICTED);
|
|
|
@@ -796,7 +796,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testOnPause_optimizationModeChanged_logPreference() {
|
|
|
|
public void onPause_optimizationModeChanged_logPreference() {
|
|
|
|
final int mode = BatteryOptimizeUtils.MODE_RESTRICTED;
|
|
|
|
final int mode = BatteryOptimizeUtils.MODE_RESTRICTED;
|
|
|
|
mFragment.mOptimizationMode = mode;
|
|
|
|
mFragment.mOptimizationMode = mode;
|
|
|
|
when(mBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn(mode);
|
|
|
|
when(mBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn(mode);
|
|
|
@@ -815,7 +815,7 @@ public class AdvancedPowerUsageDetailTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testOnPause_optimizationModeIsNotChanged_notInvokeLogging() {
|
|
|
|
public void onPause_optimizationModeIsNotChanged_notInvokeLogging() {
|
|
|
|
final int mode = BatteryOptimizeUtils.MODE_OPTIMIZED;
|
|
|
|
final int mode = BatteryOptimizeUtils.MODE_OPTIMIZED;
|
|
|
|
mFragment.mOptimizationMode = mode;
|
|
|
|
mFragment.mOptimizationMode = mode;
|
|
|
|
when(mBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn(mode);
|
|
|
|
when(mBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn(mode);
|
|
|
|