Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
| 6 | 6 |
| 7 import org.chromium.base.ThreadUtils; | 7 import org.chromium.base.ThreadUtils; |
| 8 import org.chromium.base.test.util.CallbackHelper; | 8 import org.chromium.base.test.util.CallbackHelper; |
| 9 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 9 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 10 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 10 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| 11 import org.chromium.chrome.browser.autofill.PersonalDataManager.PersonalDataMana gerObserver; | 11 import org.chromium.chrome.browser.autofill.PersonalDataManager.PersonalDataMana gerObserver; |
| 12 | 12 |
| 13 import java.util.List; | 13 import java.util.List; |
| 14 import java.util.concurrent.Callable; | 14 import java.util.concurrent.Callable; |
| 15 import java.util.concurrent.ExecutionException; | 15 import java.util.concurrent.ExecutionException; |
| 16 import java.util.concurrent.TimeoutException; | 16 import java.util.concurrent.TimeoutException; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Helper class for testing AutofillProfiles. | 19 * Helper class for testing AutofillProfiles. |
| 20 */ | 20 */ |
| 21 public class AutofillTestHelper { | 21 public class AutofillTestHelper { |
| 22 | 22 |
| 23 private final CallbackHelper mOnPersonalDataChangedHelper = new CallbackHelp er(); | 23 private final CallbackHelper mOnPersonalDataChangedHelper = new CallbackHelp er(); |
| 24 | 24 |
| 25 public AutofillTestHelper() { | 25 public AutofillTestHelper() { |
| 26 registerDataObserver(); | 26 registerDataObserver(); |
| 27 setNormalizationTimeoutForTesting(); | 27 setNormalizationTimeoutForTesting(); |
|
Mathieu
2017/03/24 17:24:32
can we have a special value of normalization timeo
Parastoo
2017/03/24 22:42:23
Like checking what the timeout is set to, and base
Mathieu
2017/03/27 19:09:06
I find it weird to have two calls related to testi
Mathieu
2017/03/28 14:43:32
Still need to address this.
Parastoo
2017/03/29 19:33:55
Done.
Parastoo
2017/03/29 19:33:55
Done.
| |
| 28 setToTestingMode(); | |
| 28 } | 29 } |
| 29 | 30 |
| 30 void setNormalizationTimeoutForTesting() { | 31 void setNormalizationTimeoutForTesting() { |
| 31 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 32 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 32 @Override | 33 @Override |
| 33 public void run() { | 34 public void run() { |
| 34 PersonalDataManager.getInstance().setNormalizationTimeoutForTest ing(1); | 35 PersonalDataManager.getInstance().setNormalizationTimeoutForTest ing(1); |
| 35 } | 36 } |
| 36 }); | 37 }); |
| 37 } | 38 } |
| 38 | 39 |
| 40 void setToTestingMode() { | |
| 41 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
| 42 @Override | |
| 43 public void run() { | |
| 44 PersonalDataManager.getInstance().setToTestingMode(); | |
| 45 } | |
| 46 }); | |
| 47 } | |
| 48 | |
| 39 AutofillProfile getProfile(final String guid) throws ExecutionException { | 49 AutofillProfile getProfile(final String guid) throws ExecutionException { |
| 40 return ThreadUtils.runOnUiThreadBlocking(new Callable<AutofillProfile>() { | 50 return ThreadUtils.runOnUiThreadBlocking(new Callable<AutofillProfile>() { |
| 41 @Override | 51 @Override |
| 42 public AutofillProfile call() { | 52 public AutofillProfile call() { |
| 43 return PersonalDataManager.getInstance().getProfile(guid); | 53 return PersonalDataManager.getInstance().getProfile(guid); |
| 44 } | 54 } |
| 45 }); | 55 }); |
| 46 } | 56 } |
| 47 | 57 |
| 48 List<AutofillProfile> getProfilesToSuggest(final boolean includeNameInLabel) throws | 58 List<AutofillProfile> getProfilesToSuggest(final boolean includeNameInLabel) throws |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 }); | 360 }); |
| 351 } | 361 } |
| 352 }); | 362 }); |
| 353 if (isDataLoaded) return; | 363 if (isDataLoaded) return; |
| 354 mOnPersonalDataChangedHelper.waitForCallback(callCount); | 364 mOnPersonalDataChangedHelper.waitForCallback(callCount); |
| 355 } catch (TimeoutException | InterruptedException | ExecutionException e) { | 365 } catch (TimeoutException | InterruptedException | ExecutionException e) { |
| 356 throw new AssertionError(e); | 366 throw new AssertionError(e); |
| 357 } | 367 } |
| 358 } | 368 } |
| 359 } | 369 } |
| OLD | NEW |