| 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 173fb565e50a8b01a6d0da5afe1fc824e4dc335a..1d5c687e555b66bd3844f3a7603f0d3586b080ce 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
|
| @@ -151,7 +151,25 @@ public class AutofillTestHelper {
|
| }
|
|
|
| /**
|
| + * Records the use of the profile associated with the specified |guid|. Effectively increments
|
| + * the use count of the profile and set its use date to the current time. Also logs usage
|
| + * metrics.
|
| + *
|
| + * @param guid The GUID of the profile.
|
| + */
|
| + void recordAndLogProfileUse(final String guid) throws InterruptedException {
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + PersonalDataManager.getInstance().recordAndLogProfileUse(guid);
|
| + }
|
| + });
|
| + waitForDataChanged();
|
| + }
|
| +
|
| + /**
|
| * Sets the use |count| and use |date| of the test profile associated with the |guid|.
|
| + *
|
| * @param guid The GUID of the profile to modify.
|
| * @param count The use count to assign to the profile. It should be non-negative.
|
| * @param date The use date to assign to the profile. It represents an absolute point in
|
| @@ -159,7 +177,7 @@ public class AutofillTestHelper {
|
| * epoch. For more details see the comment header in time.h. It should always be a
|
| * positive number.
|
| */
|
| - void setProfileUseStatsForTesting(final String guid, final int count, final long date)
|
| + public void setProfileUseStatsForTesting(final String guid, final int count, final long date)
|
| throws InterruptedException {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| @@ -171,7 +189,59 @@ public class AutofillTestHelper {
|
| }
|
|
|
| /**
|
| + * Get the use count of the test profile associated with the |guid|.
|
| + *
|
| + * @param guid The GUID of the profile to query.
|
| + * @return The non-negative use count of the profile.
|
| + */
|
| + public int getProfileUseCountForTesting(final String guid) throws InterruptedException,
|
| + ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
|
| + @Override
|
| + public Integer call() {
|
| + return PersonalDataManager.getInstance().getProfileUseCountForTesting(guid);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Get the use date of the test profile associated with the |guid|.
|
| + *
|
| + * @param guid The GUID of the profile to query.
|
| + * @return A non-negative long representing the last use date of the profile. It represents an
|
| + * absolute point in coordinated universal time (UTC) represented as microseconds since
|
| + * the Windows epoch. For more details see the comment header in time.h.
|
| + */
|
| + public long getProfileUseDateForTesting(final String guid) throws InterruptedException,
|
| + ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Long>() {
|
| + @Override
|
| + public Long call() {
|
| + return PersonalDataManager.getInstance().getProfileUseDateForTesting(guid);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Records the use of the credit card associated with the specified |guid|. Effectively
|
| + * increments the use count of the credit card and sets its use date to the current time. Also
|
| + * logs usage metrics.
|
| + *
|
| + * @param guid The GUID of the credit card.
|
| + */
|
| + public void recordAndLogCreditCardUse(final String guid) throws InterruptedException {
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + PersonalDataManager.getInstance().recordAndLogCreditCardUse(guid);
|
| + }
|
| + });
|
| + waitForDataChanged();
|
| + }
|
| +
|
| + /**
|
| * Sets the use |count| and use |date| of the test credit card associated with the |guid|.
|
| + *
|
| * @param guid The GUID of the credit card to modify.
|
| * @param count The use count to assign to the credit card. It should be non-negative.
|
| * @param date The use date to assign to the credit card. It represents an absolute point in
|
| @@ -179,7 +249,7 @@ public class AutofillTestHelper {
|
| * epoch. For more details see the comment header in time.h. It should always be a
|
| * positive number.
|
| */
|
| - void setCreditCardUseStatsForTesting(final String guid, final int count, final long date)
|
| + public void setCreditCardUseStatsForTesting(final String guid, final int count, final long date)
|
| throws InterruptedException {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| @@ -191,6 +261,56 @@ public class AutofillTestHelper {
|
| waitForDataChanged();
|
| }
|
|
|
| + /**
|
| + * Get the use count of the test credit card associated with the |guid|.
|
| + *
|
| + * @param guid The GUID of the credit card to query.
|
| + * @return The non-negative use count of the credit card.
|
| + */
|
| + public int getCreditCardUseCountForTesting(final String guid) throws InterruptedException,
|
| + ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
|
| + @Override
|
| + public Integer call() {
|
| + return PersonalDataManager.getInstance().getCreditCardUseCountForTesting(guid);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Get the use date of the test credit card associated with the |guid|.
|
| + *
|
| + * @param guid The GUID of the credit card to query.
|
| + * @return A non-negative long representing the last use date of the credit card. It represents
|
| + * an absolute point in coordinated universal time (UTC) represented as microseconds
|
| + * since the Windows epoch. For more details see the comment header in time.h.
|
| + */
|
| + public long getCreditCardUseDateForTesting(final String guid) throws InterruptedException,
|
| + ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Long>() {
|
| + @Override
|
| + public Long call() {
|
| + return PersonalDataManager.getInstance().getCreditCardUseDateForTesting(guid);
|
| + }
|
| + });
|
| + }
|
| +
|
| + /**
|
| + * Get the current use date to be used in test to compare with credit card or profile use dates.
|
| + *
|
| + * @return A non-negative long representing the current date. It represents an absolute point in
|
| + * coordinated universal time (UTC) represented as microseconds since the Windows epoch.
|
| + * For more details see the comment header in time.h.
|
| + */
|
| + public long getCurrentDateForTesting() throws InterruptedException, ExecutionException {
|
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<Long>() {
|
| + @Override
|
| + public Long call() {
|
| + return PersonalDataManager.getInstance().getCurrentDateForTesting();
|
| + }
|
| + });
|
| + }
|
| +
|
| private void registerDataObserver() {
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
|
|