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

Commit aadca0b5 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Reduce log spam from TestableResources" into udc-dev am: 9a7ce69d am: cb28ad9c"

parents 46fc8a13 bc1d7d5c
Loading
Loading
Loading
Loading
+22 −16
Original line number Original line Diff line number Diff line
@@ -59,6 +59,7 @@ public class TestableResources {
     * Since resource ids are unique there is a single addOverride that will override the value
     * Since resource ids are unique there is a single addOverride that will override the value
     * whenever it is gotten regardless of which method is used (i.e. getColor or getDrawable).
     * whenever it is gotten regardless of which method is used (i.e. getColor or getDrawable).
     * </p>
     * </p>
     *
     * @param id    The resource id to be overridden
     * @param id    The resource id to be overridden
     * @param value The value of the resource, null to cause a {@link Resources.NotFoundException}
     * @param value The value of the resource, null to cause a {@link Resources.NotFoundException}
     *              when gotten.
     *              when gotten.
@@ -74,15 +75,18 @@ public class TestableResources {
     * cause a {@link Resources.NotFoundException} whereas removing the override will actually
     * cause a {@link Resources.NotFoundException} whereas removing the override will actually
     * switch back to returning the default/real value of the resource.
     * switch back to returning the default/real value of the resource.
     * </p>
     * </p>
     * @param id
     */
     */
    public void removeOverride(int id) {
    public void removeOverride(int id) {
        mOverrides.remove(id);
        mOverrides.remove(id);
    }
    }


    private Object answer(InvocationOnMock invocationOnMock) throws Throwable {
    private Object answer(InvocationOnMock invocationOnMock) throws Throwable {
        // Only try to override methods with an integer first argument
        if (invocationOnMock.getArguments().length > 0) {
            Object argument = invocationOnMock.getArgument(0);
            if (argument instanceof Integer) {
                try {
                try {
            int id = invocationOnMock.getArgument(0);
                    int id = (Integer)argument;
                    int index = mOverrides.indexOfKey(id);
                    int index = mOverrides.indexOfKey(id);
                    if (index >= 0) {
                    if (index >= 0) {
                        Object value = mOverrides.valueAt(index);
                        Object value = mOverrides.valueAt(index);
@@ -97,6 +101,8 @@ public class TestableResources {
                    // the real implementation.
                    // the real implementation.
                    Log.i(TAG, "Falling back to default resources call " + t);
                    Log.i(TAG, "Falling back to default resources call " + t);
                }
                }
            }
        }
        return invocationOnMock.callRealMethod();
        return invocationOnMock.callRealMethod();
    }
    }
}
}