Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e955df17 authored by Evan Laird's avatar Evan Laird
Browse files

Set bolt and plus colors together

Also test to make sure the colors stay the same.

Test: runtest -x frameworks/base/packages/SettingsLib/tests/integ/src/com/android/settingslib/graph/BatteryMeterDrawableBaseTest.java
Bug: 62668861
Change-Id: I7d01fd41aeedcb182dc05da8d7b0501a6b5b8539
parent 21c7490f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -281,6 +281,7 @@ public class BatteryMeterDrawableBase extends Drawable {
        mIconTint = fillColor;
        mFramePaint.setColor(backgroundColor);
        mBoltPaint.setColor(fillColor);
        mPlusPaint.setColor(fillColor);
        mChargeColor = fillColor;
        invalidateSelf();
    }
+14 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;

import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyFloat;
import static org.mockito.Matchers.anyString;
@@ -101,4 +102,17 @@ public class BatteryMeterDrawableBaseTest {
    private boolean isRectZero(Rect r) {
        return r.left == 0 && r.top == 0 && r.right == 0 && r.bottom == 0;
    }

    @Test
    public void testPlusPaint_isEqualToBoltPaint() {
        // Before setting color
        assertTrue(mBatteryDrawable.mPlusPaint.hasEqualAttributes(mBatteryDrawable.mBoltPaint));

        final int fakeFillColor = 123;
        final int fakeBackgrundColor = 456;

        // After
        mBatteryDrawable.setColors(fakeFillColor, fakeBackgrundColor);
        assertTrue(mBatteryDrawable.mPlusPaint.hasEqualAttributes(mBatteryDrawable.mBoltPaint));
    }
}