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

Commit cd03bdd9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move ShadowXmlUtils to settingslib"

parents acb31abf 2ee4a484
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
manifest=packages/apps/Settings/AndroidManifest.xml
sdk=NEWEST_SDK

shadows=\
   com.android.settings.testutils.shadow.ShadowThreadUtils,\
   com.android.settings.testutils.shadow.ShadowXmlUtils
 No newline at end of file
   com.android.settingslib.testutils.shadow.ShadowXmlUtils
+0 −28
Original line number Diff line number Diff line
package com.android.settings.testutils.shadow;

import static org.robolectric.shadow.api.Shadow.directlyOn;

import com.android.internal.util.XmlUtils;

import org.robolectric.Robolectric;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;

@Implements(XmlUtils.class)
public class ShadowXmlUtils {

    @Implementation
    public static final int convertValueToInt(CharSequence charSeq, int defaultValue) {
        final Class<?> xmlUtilsClass = ReflectionHelpers.loadClass(
                Robolectric.class.getClassLoader(), "com.android.internal.util.XmlUtils");
        try {
            return directlyOn(xmlUtilsClass, "convertValueToInt",
                    ClassParameter.from(CharSequence.class, charSeq),
                    ClassParameter.from(int.class, new Integer(defaultValue)));
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
}