Merge "Fix NPE in ComponentNameValidator" into pi-dev
am: b105913098
Change-Id: I9725217151634a66d7cd3dc0e80acb5f78f15c39
This commit is contained in:
@@ -79,7 +79,7 @@ public class SettingsValidators {
|
||||
public static final Validator COMPONENT_NAME_VALIDATOR = new Validator() {
|
||||
@Override
|
||||
public boolean validate(String value) {
|
||||
return ComponentName.unflattenFromString(value) != null;
|
||||
return value != null && ComponentName.unflattenFromString(value) != null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package android.provider;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.provider.SettingsValidators.Validator;
|
||||
@@ -62,6 +62,11 @@ public class SettingsValidatorsTest {
|
||||
assertFalse(SettingsValidators.COMPONENT_NAME_VALIDATOR.validate("rectangle"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentNameValidator_onNullValue_doesNotThrow() {
|
||||
assertFalse(SettingsValidators.COMPONENT_NAME_VALIDATOR.validate(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocaleValidator() {
|
||||
assertTrue(SettingsValidators.LOCALE_VALIDATOR.validate("en_US"));
|
||||
|
||||
Reference in New Issue
Block a user