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

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

Issue 2126213002: [Payments] Record use of profiles and credit cards in Payment Request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 173fb565e50a8b01a6d0da5afe1fc824e4dc335a..5603a0011ee1c9d78e1ff1d4c6c0fb76133a12a5 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,6 +151,22 @@ 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.
please use gerrit instead 2016/07/12 15:41:58 newline before @param
sebsg 2016/07/13 18:49:19 Done.
+ */
+ 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.
@@ -159,7 +175,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,15 +187,64 @@ public class AutofillTestHelper {
}
/**
+ * Get the use count of the test profile associated with the |guid|.
+ * @param guid The GUID of the profile to modify.
please use gerrit instead 2016/07/12 15:41:58 1) newline before @param 2) s/to modify/to query/
sebsg 2016/07/13 18:49:19 Done.
+ * @return count The use count to assign to the profile. It should be non-negative.
please use gerrit instead 2016/07/12 15:41:58 1) Remove "count". @return The use count to ass
sebsg 2016/07/13 18:49:20 Done.
+ */
+ 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 modify.
please use gerrit instead 2016/07/12 15:41:58 1) newline before @param 2) s/to modify/to query/
sebsg 2016/07/13 18:49:19 Done.
+ * @return date The use date to assign to the profile. It represents an absolute point in
please use gerrit instead 2016/07/12 15:41:58 Remove "date" after "@return".
sebsg 2016/07/13 18:49:19 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.
+ */
+ 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 set its use date to the current time. Also
please use gerrit instead 2016/07/12 15:41:58 s/set/sets/
sebsg 2016/07/13 18:49:20 Done.
+ * logs usage metrics.
+ * @param guid The GUID of the credit card.
please use gerrit instead 2016/07/12 15:41:58 newline before @param
sebsg 2016/07/13 18:49:20 Done.
+ */
+ 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
- * 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.
+ * @return date The use date to assign to the credit card. It represents an absolute point in
please use gerrit instead 2016/07/12 15:41:58 Remove "date" after "@return".
sebsg 2016/07/13 18:49:19 Actually it should still be a param, my bad...
+ * 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 long date)
+ public void setCreditCardUseStatsForTesting(final String guid, final int count, final long date)
throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
@@ -191,6 +256,54 @@ 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 modify.
please use gerrit instead 2016/07/12 15:41:58 1) newline before @param 2) s/modify/query/
sebsg 2016/07/13 18:49:19 Done.
+ * @return count The use count to assign to the credit card. It should be non-negative.
please use gerrit instead 2016/07/12 15:41:58 1) Remove "count". 2) Remove "It should be".
sebsg 2016/07/13 18:49:19 Done.
+ */
+ 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 modify.
please use gerrit instead 2016/07/12 15:41:58 Ditto
sebsg 2016/07/13 18:49:19 Done.
+ * @return 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.
+ */
+ 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 date The current use date. It represents an absolute point in coordinated universal
please use gerrit instead 2016/07/12 15:41:58 Ditto
sebsg 2016/07/13 18:49:19 Done.
+ * 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.
+ */
+ 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

Powered by Google App Engine
This is Rietveld 408576698