| Index: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/PersonalDataManagerTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/PersonalDataManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/PersonalDataManagerTest.java
|
| index 47e381409546b3601a9833caac88b6840fcbfc0d..86d625175771627b83de36d53f7d513f92498a73 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/PersonalDataManagerTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/PersonalDataManagerTest.java
|
| @@ -370,4 +370,101 @@ public class PersonalDataManagerTest extends NativeLibraryTestBase {
|
| // Both cards should be seen in the settings even if they are identical.
|
| assertEquals(2, mHelper.getNumberOfCreditCardsForSettings());
|
| }
|
| +
|
| + @SmallTest
|
| + @Feature({"Autofill"})
|
| + public void testProfileUseStatsSettingAndGetting() throws InterruptedException,
|
| + ExecutionException {
|
| + String guid = mHelper.setProfile(
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "Jasper Lundgren", "", "1500 Second Ave", "California", "Hollywood", "",
|
| + "90068", "", "US", "555 123-9876", "jasperl@example.com", ""));
|
| +
|
| + // Make sure the profile does not have the specific use stats form the start.
|
| + assertTrue(1234 != mHelper.getProfileUseCountForTesting(guid));
|
| + assertTrue(1234 != mHelper.getProfileUseDateForTesting(guid));
|
| +
|
| + // Set specific use stats for the profile.
|
| + mHelper.setProfileUseStatsForTesting(guid, 1234, 1234);
|
| +
|
| + // Make sure the specific use stats were set for the profile.
|
| + assertEquals(1234, mHelper.getProfileUseCountForTesting(guid));
|
| + assertEquals(1234, mHelper.getProfileUseDateForTesting(guid));
|
| + }
|
| +
|
| +
|
| + @SmallTest
|
| + @Feature({"Autofill"})
|
| + public void testCreditCardUseStatsSettingAndGetting() throws InterruptedException,
|
| + ExecutionException {
|
| + String guid = mHelper.setCreditCard(
|
| + new CreditCard("" /* guid */, "https://www.example.com" /* origin */,
|
| + true /* isLocal */, false /* isCached */, "John Doe", "1234123412341234", "",
|
| + "5", "2020", "Visa", 0 /* issuerIconDrawableId */, "" /* billingAddressId */));
|
| +
|
| + // Make sure the credit card does not have the specific use stats form the start.
|
| + assertTrue(1234 != mHelper.getCreditCardUseCountForTesting(guid));
|
| + assertTrue(1234 != mHelper.getCreditCardUseDateForTesting(guid));
|
| +
|
| + // Set specific use stats for the credit card.
|
| + mHelper.setCreditCardUseStatsForTesting(guid, 1234, 1234);
|
| +
|
| + // Make sure the specific use stats were set for the credit card.
|
| + assertEquals(1234, mHelper.getCreditCardUseCountForTesting(guid));
|
| + assertEquals(1234, mHelper.getCreditCardUseDateForTesting(guid));
|
| + }
|
| +
|
| + @SmallTest
|
| + @Feature({"Autofill"})
|
| + public void testRecordAndLogProfileUse() throws InterruptedException, ExecutionException {
|
| + String guid = mHelper.setProfile(
|
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */,
|
| + "Jasper Lundgren", "", "1500 Second Ave", "California", "Hollywood", "",
|
| + "90068", "", "US", "555 123-9876", "jasperl@example.com", ""));
|
| +
|
| + // Set specific use stats for the profile.
|
| + mHelper.setProfileUseStatsForTesting(guid, 1234, 1234);
|
| +
|
| + // Get the current date value just before the call to record and log.
|
| + long timeBeforeRecord = mHelper.getCurrentDateForTesting();
|
| +
|
| + // Record and log use of the profile.
|
| + mHelper.recordAndLogProfileUse(guid);
|
| +
|
| + // Get the current date value just after the call to record and log.
|
| + long timeAfterRecord = mHelper.getCurrentDateForTesting();
|
| +
|
| + // Make sure the use stats of the profile were updated.
|
| + assertEquals(1235, mHelper.getProfileUseCountForTesting(guid));
|
| + assertTrue(timeBeforeRecord <= mHelper.getProfileUseDateForTesting(guid));
|
| + assertTrue(timeAfterRecord >= mHelper.getProfileUseDateForTesting(guid));
|
| + }
|
| +
|
| +
|
| + @SmallTest
|
| + @Feature({"Autofill"})
|
| + public void testRecordAndLogCreditCardUse() throws InterruptedException, ExecutionException {
|
| + String guid = mHelper.setCreditCard(
|
| + new CreditCard("" /* guid */, "https://www.example.com" /* origin */,
|
| + true /* isLocal */, false /* isCached */, "John Doe",
|
| + "1234123412341234", "", "5", "2020", "Visa",
|
| + 0 /* issuerIconDrawableId */, "" /* billingAddressId */));
|
| +
|
| + // Set specific use stats for the credit card.
|
| + mHelper.setCreditCardUseStatsForTesting(guid, 1234, 1234);
|
| +
|
| + // Get the current date value just before the call to record and log.
|
| + long timeBeforeRecord = mHelper.getCurrentDateForTesting();
|
| +
|
| + // Record and log use of the credit card.
|
| + mHelper.recordAndLogCreditCardUse(guid);
|
| +
|
| + // Get the current date value just after the call to record and log.
|
| + long timeAfterRecord = mHelper.getCurrentDateForTesting();
|
| +
|
| + // Make sure the use stats of the credit card were updated.
|
| + assertEquals(1235, mHelper.getCreditCardUseCountForTesting(guid));
|
| + assertTrue(timeBeforeRecord <= mHelper.getCreditCardUseDateForTesting(guid));
|
| + assertTrue(timeAfterRecord >= mHelper.getCreditCardUseDateForTesting(guid));
|
| + }
|
| }
|
|
|