Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTestHelper.java

Issue 1982623002: [Autofill] Sort profiles and credit cards by frecency in PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 20467b77401de6cd607e7c92c81633012ed8abfd..fa8d2e6442ed4de353364841ce98f764ef7bf33a 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
@@ -34,22 +34,44 @@ public class AutofillTestHelper {
});
}
- List<AutofillProfile> getProfiles() throws ExecutionException {
+ List<AutofillProfile> getProfilesToSuggest() throws ExecutionException {
return ThreadUtils.runOnUiThreadBlocking(new Callable<List<AutofillProfile>>() {
@Override
public List<AutofillProfile> call() {
- return PersonalDataManager.getInstance().getProfiles();
+ return PersonalDataManager.getInstance().getProfilesToSuggest();
}
});
}
- int getNumberOfProfiles() throws ExecutionException {
- return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
+ List<AutofillProfile> getProfilesForSettings() throws ExecutionException {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<List<AutofillProfile>>() {
@Override
- public Integer call() {
- return PersonalDataManager.getInstance().getProfiles().size();
+ public List<AutofillProfile> call() {
+ return PersonalDataManager.getInstance().getProfilesForSettings();
}
- }).intValue();
+ });
+ }
+
+ int getNumberOfProfilesToSuggest() throws ExecutionException {
gone 2016/05/31 22:39:42 Does it make sense to factor out the bit that fire
sebsg 2016/06/01 20:58:24 Done.
+ return ThreadUtils
+ .runOnUiThreadBlocking(new Callable<Integer>() {
+ @Override
+ public Integer call() {
+ return PersonalDataManager.getInstance().getProfilesToSuggest().size();
+ }
+ })
+ .intValue();
+ }
+
+ int getNumberOfProfilesForSettings() throws ExecutionException {
+ return ThreadUtils
+ .runOnUiThreadBlocking(new Callable<Integer>() {
+ @Override
+ public Integer call() {
+ return PersonalDataManager.getInstance().getProfilesForSettings().size();
+ }
+ })
+ .intValue();
}
public String setProfile(final AutofillProfile profile) throws InterruptedException,
@@ -83,11 +105,40 @@ public class AutofillTestHelper {
});
}
- int getNumberOfCreditCards() throws ExecutionException {
+ List<CreditCard> getCreditCardsToSuggest() throws ExecutionException {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<List<CreditCard>>() {
+ @Override
+ public List<CreditCard> call() {
+ return PersonalDataManager.getInstance().getCreditCardsToSuggest();
+ }
+ });
+ }
+
+ List<CreditCard> getCreditCardsForSettings() throws ExecutionException {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<List<CreditCard>>() {
+ @Override
+ public List<CreditCard> call() {
+ return PersonalDataManager.getInstance().getCreditCardsForSettings();
+ }
+ });
+ }
+
+ int getNumberOfCreditCardsToSuggest() throws ExecutionException {
+ return ThreadUtils
+ .runOnUiThreadBlocking(new Callable<Integer>() {
+ @Override
+ public Integer call() {
+ return PersonalDataManager.getInstance().getCreditCardsToSuggest().size();
+ }
+ })
+ .intValue();
+ }
+
+ int getNumberOfCreditCardsForSettings() throws ExecutionException {
return ThreadUtils.runOnUiThreadBlocking(new Callable<Integer>() {
@Override
public Integer call() {
- return PersonalDataManager.getInstance().getCreditCards().size();
+ return PersonalDataManager.getInstance().getCreditCardsForSettings().size();
}
}).intValue();
}
@@ -104,6 +155,17 @@ public class AutofillTestHelper {
return guid;
}
+ public void addServerCreditCard(final CreditCard card)
+ throws InterruptedException, ExecutionException {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ PersonalDataManager.getInstance().addServerCreditCardForTest(card);
+ }
+ });
+ waitForDataChanged();
+ }
+
void deleteCreditCard(final String guid) throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -114,6 +176,45 @@ public class AutofillTestHelper {
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
gone 2016/05/31 22:39:42 For multiline javadocs, it's preferable to indent
sebsg 2016/06/01 20:58:24 Done.
+ * coordinated universal time (UTC) represented as microseconds since the Windows 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 int date)
+ throws InterruptedException {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ PersonalDataManager.getInstance().setProfileUseStatsForTesting(guid, count, date);
+ }
+ });
+ 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
+ * coordinated universal time (UTC) represented as microseconds since the Windows 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 int date)
+ throws InterruptedException {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ PersonalDataManager.getInstance().setCreditCardUseStatsForTesting(
+ guid, count, date);
+ }
+ });
+ waitForDataChanged();
+ }
+
private void registerDataObserver() {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override

Powered by Google App Engine
This is Rietveld 408576698