Merge "Add dump log for BatteryTip." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
26b5b5b5db
@@ -52,7 +52,7 @@ public class BatteryTipTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildPreference() {
|
||||
public void buildPreference() {
|
||||
final Preference preference = mBatteryTip.buildPreference(mContext);
|
||||
|
||||
assertThat(preference.getTitle()).isEqualTo(TITLE);
|
||||
@@ -61,7 +61,7 @@ public class BatteryTipTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParcelable() {
|
||||
public void parcelable() {
|
||||
final BatteryTip batteryTip = new TestBatteryTip();
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
@@ -76,7 +76,7 @@ public class BatteryTipTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTipOrder_orderUnique() {
|
||||
public void tipOrder_orderUnique() {
|
||||
final List<Integer> orders = new ArrayList<>();
|
||||
for (int i = 0, size = BatteryTip.TIP_ORDER.size(); i < size; i++) {
|
||||
orders.add(BatteryTip.TIP_ORDER.valueAt(i));
|
||||
@@ -85,6 +85,11 @@ public class BatteryTipTest {
|
||||
assertThat(orders).containsNoDuplicates();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toString_containBatteryTipData() {
|
||||
assertThat(mBatteryTip.toString()).isEqualTo("type=6 state=0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to test the non abstract methods in {@link TestBatteryTip}
|
||||
*/
|
||||
|
@@ -73,4 +73,10 @@ public class HighUsageTipTest {
|
||||
assertThat(app.packageName).isEqualTo(PACKAGE_NAME);
|
||||
assertThat(app.screenOnTimeMs).isEqualTo(SCREEN_TIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toString_containsAppData() {
|
||||
assertThat(mBatteryTip.toString()).isEqualTo(
|
||||
"type=2 state=0 { packageName=com.android.app,anomalyType=0,screenTime=1800000 }");
|
||||
}
|
||||
}
|
||||
|
@@ -71,7 +71,7 @@ public class RestrictAppTipTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParcelable() {
|
||||
public void parcelable() {
|
||||
Parcel parcel = Parcel.obtain();
|
||||
mNewBatteryTip.writeToParcel(parcel, mNewBatteryTip.describeContents());
|
||||
parcel.setDataPosition(0);
|
||||
@@ -85,40 +85,46 @@ public class RestrictAppTipTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTitle_stateNew_showRestrictTitle() {
|
||||
public void getTitle_stateNew_showRestrictTitle() {
|
||||
assertThat(mNewBatteryTip.getTitle(mContext)).isEqualTo("Restrict 1 app");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTitle_stateHandled_showHandledTitle() {
|
||||
public void getTitle_stateHandled_showHandledTitle() {
|
||||
assertThat(mHandledBatteryTip.getTitle(mContext)).isEqualTo("1 recently restricted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSummary_stateNew_showRestrictSummary() {
|
||||
public void getSummary_stateNew_showRestrictSummary() {
|
||||
assertThat(mNewBatteryTip.getSummary(mContext))
|
||||
.isEqualTo("app has high battery usage");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSummary_stateHandled_showHandledSummary() {
|
||||
public void getSummary_stateHandled_showHandledSummary() {
|
||||
assertThat(mHandledBatteryTip.getSummary(mContext))
|
||||
.isEqualTo("App changes are in progress");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_anomalyBecomeInvisible_stateHandled() {
|
||||
public void update_anomalyBecomeInvisible_stateHandled() {
|
||||
mNewBatteryTip.updateState(mInvisibleBatteryTip);
|
||||
|
||||
assertThat(mNewBatteryTip.getState()).isEqualTo(BatteryTip.StateType.HANDLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_newAnomalyComes_stateNew() {
|
||||
public void update_newAnomalyComes_stateNew() {
|
||||
mInvisibleBatteryTip.updateState(mNewBatteryTip);
|
||||
assertThat(mInvisibleBatteryTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
||||
|
||||
mHandledBatteryTip.updateState(mNewBatteryTip);
|
||||
assertThat(mHandledBatteryTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toString_containsAppData() {
|
||||
assertThat(mNewBatteryTip.toString()).isEqualTo(
|
||||
"type=1 state=0 { packageName=com.android.app,anomalyType=0,screenTime=0 }");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user