| Index: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java
|
| index 2df7a4496523ac4405e40cae8b9abd3a0e3bf4d2..b8f47b807e31fe48d4c4b1a3944a6b924899e12d 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java
|
| @@ -325,6 +325,90 @@ public class AutofillTestHelper {
|
| });
|
| }
|
|
|
| + /**
|
| + * Starts loading the address validation rules for the specified {@code regionCode}.
|
| + *
|
| + * @param regionCode The code of the region for which to load the rules.
|
| + */
|
| + public void loadRulesForRegion(final String regionCode) throws InterruptedException {
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + PersonalDataManager.getInstance().loadRulesForRegion(regionCode);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Return whether the validation rules have finished loading for the specified
|
| + * {@code regionCode}.
|
| + *
|
| + * @param regionCode The code of the region of the rules.
|
| + */
|
| + public boolean areRulesDoneLoadingForRegion(final String regionCode)
|
| + throws InterruptedException, ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
|
| + @Override
|
| + public Boolean call() {
|
| + return PersonalDataManager.getInstance().areRulesDoneLoadingForRegion(regionCode);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Return whether the validation rules have been successfully loaded for the specified
|
| + * {@code regionCode}.
|
| + *
|
| + * @param regionCode The code of the region of the rules.
|
| + */
|
| + public boolean areRulesSuccessfullyLoadedForRegion(final String regionCode)
|
| + throws InterruptedException, ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
|
| + @Override
|
| + public Boolean call() {
|
| + return PersonalDataManager.getInstance().areRulesSuccessfullyLoadedForRegion(
|
| + regionCode);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Returns the normalized profile associated with the specified {@code guid}. The profile fields
|
| + * are normalized with the rules associated with the {@code regionCode}.
|
| + *
|
| + * This method will wait a certain amount of time for the rules to load if they are not done
|
| + * loading.
|
| + *
|
| + * @param guid The GUID of the profile.
|
| + * @param regionCode The code of the region to use for normalization.
|
| + */
|
| + public AutofillProfile getNormalizedProfile(final String guid, final String regionCode)
|
| + throws InterruptedException, ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<AutofillProfile>() {
|
| + @Override
|
| + public AutofillProfile call() {
|
| + return PersonalDataManager.getInstance().getNormalizedProfile(guid, regionCode);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Sets up a mock address validator for testing. The validator will return
|
| + * {@code rulesLoadedResponse} when asked if rules are done loading.
|
| + *
|
| + * @param rulesLoadedResponse The value to return when asked if rules are done loading.
|
| + */
|
| + public void setMockAddressValidatorForTesting(final boolean rulesLoadedResponse)
|
| + throws InterruptedException {
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + PersonalDataManager.getInstance().setMockAddressValidatorForTesting(
|
| + rulesLoadedResponse);
|
| + }
|
| + });
|
| + }
|
| +
|
| private void registerDataObserver() {
|
| try {
|
| int callCount = mOnPersonalDataChangedHelper.getCallCount();
|
|
|