Merge "Add dump log for BatteryTip." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
26b5b5b5db
@@ -68,6 +68,12 @@ public class AppInfo implements Comparable<AppInfo>, Parcelable {
|
||||
dest.writeInt(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "packageName=" + packageName + ",anomalyType=" + anomalyType + ",screenTime="
|
||||
+ screenOnTimeMs;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
|
||||
public AppInfo createFromParcel(Parcel in) {
|
||||
return new AppInfo(in);
|
||||
|
@@ -158,4 +158,9 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
||||
public int compareTo(BatteryTip o) {
|
||||
return TIP_ORDER.get(mType) - TIP_ORDER.get(o.mType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "type=" + mType + " state=" + mState;
|
||||
}
|
||||
}
|
||||
|
@@ -86,6 +86,19 @@ public class HighUsageTip extends BatteryTip {
|
||||
return mHighUsageAppList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder stringBuilder = new StringBuilder(super.toString());
|
||||
stringBuilder.append(" {");
|
||||
for (int i = 0, size = mHighUsageAppList.size(); i < size; i++) {
|
||||
final AppInfo appInfo = mHighUsageAppList.get(i);
|
||||
stringBuilder.append(" " + appInfo.toString() + " ");
|
||||
}
|
||||
stringBuilder.append('}');
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
|
||||
public BatteryTip createFromParcel(Parcel in) {
|
||||
return new HighUsageTip(in);
|
||||
|
@@ -97,6 +97,19 @@ public class RestrictAppTip extends BatteryTip {
|
||||
return mRestrictAppList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder stringBuilder = new StringBuilder(super.toString());
|
||||
stringBuilder.append(" {");
|
||||
for (int i = 0, size = mRestrictAppList.size(); i < size; i++) {
|
||||
final AppInfo appInfo = mRestrictAppList.get(i);
|
||||
stringBuilder.append(" " + appInfo.toString() + " ");
|
||||
}
|
||||
stringBuilder.append('}');
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
|
@@ -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