Merge "Move ShadowXmlUtils to settingslib"

This commit is contained in:
TreeHugger Robot
2018-09-11 23:53:19 +00:00
committed by Android (Google) Code Review
2 changed files with 2 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
manifest=packages/apps/Settings/AndroidManifest.xml
sdk=NEWEST_SDK
shadows=\
com.android.settings.testutils.shadow.ShadowThreadUtils,\
com.android.settings.testutils.shadow.ShadowXmlUtils
com.android.settingslib.testutils.shadow.ShadowXmlUtils

View File

@@ -1,28 +0,0 @@
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;
}
}
}