Chromium Code Reviews| 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 8ddc33dda917a49e76562999a2b197e673d6b552..49ab9e5d4813c74e8a39b13de7679f8bd853ea79 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 |
| @@ -274,4 +274,81 @@ public class PersonalDataManagerTest extends NativeLibraryTestBase { |
| expectedLabels.remove(idx); |
| } |
| } |
| + |
| + @SmallTest |
| + @Feature({"Autofill"}) |
| + public void testProfilesFrecency() throws InterruptedException, ExecutionException { |
| + // Create 3 profiles. |
| + AutofillProfile profile1 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "John Major", "Acme Inc.", "123 Main", "California", "Los Angeles", "", |
| + "90210", "", "US", "555 123-4567", "jm@example.com", ""); |
| + AutofillProfile profile2 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "John Major", "Acme Inc.", "123 Main", "California", "Los Angeles", "", |
| + "90210", "", "US", "555 123-4567", "jm-work@example.com", ""); |
| + AutofillProfile profile3 = |
| + new AutofillProfile("" /* guid */, "https://www.example.com" /* origin */, |
| + "Jasper Lundgren", "", "1500 Second Ave", "California", "Hollywood", "", |
| + "90068", "", "US", "555 123-9876", "jasperl@example.com", ""); |
| + |
| + String guid1 = mHelper.setProfile(profile1); |
| + String guid2 = mHelper.setProfile(profile2); |
| + String guid3 = mHelper.setProfile(profile3); |
| + |
| + // The first profile has a lower use count that the two other profiles. It also has an older |
|
please use gerrit instead
2016/05/16 15:57:46
s/that/than
sebsg
2016/05/19 17:52:03
Done.
|
| + // use date that the second profile and the same use date as the |
| + // third. It should be last. |
| + mHelper.setProfileUseStats(guid1, 3, 5000); |
| + // The second profile has the same use count as the third but a more recent use date. It |
| + // also has a bigger use count that the first profile. It should be first. |
| + mHelper.setProfileUseStats(guid2, 6, 5001); |
| + // The third profile has the same use count as the second but an older use date. It also has |
| + // a bigger use count that the first profile. It should be second. |
| + mHelper.setProfileUseStats(guid3, 6, 5000); |
| + |
| + List<AutofillProfile> profiles = mHelper.getProfiles(); |
| + assertEquals(3, profiles.size()); |
| + |
| + assertTrue("Profile2 should be ranked first", guid2.equals(profiles.get(0).getGUID())); |
| + assertTrue("Profile3 should be ranked second", guid3.equals(profiles.get(1).getGUID())); |
| + assertTrue("Profile1 should be ranked third", guid1.equals(profiles.get(2).getGUID())); |
| + } |
| + |
| + @SmallTest |
| + @Feature({"Autofill"}) |
| + public void testCreditCardsFrecency() throws InterruptedException, ExecutionException { |
| + // Create 3 credit cards. |
| + CreditCard card1 = new CreditCard("" /* guid */, "https://www.example.com" /* origin */, |
| + "Visa", "1234123412341234", "", "5", "2020"); |
| + |
| + CreditCard card2 = new CreditCard("" /* guid */, "http://www.example.com" /* origin */, |
| + "American Express", "1234123412341234", "", "8", "2020"); |
| + |
| + CreditCard card3 = new CreditCard("" /* guid */, "http://www.example.com" /* origin */, |
| + "Master Card", "1234123412341234", "", "11", "2020"); |
| + |
| + String guid1 = mHelper.setCreditCard(card1); |
| + String guid2 = mHelper.setCreditCard(card2); |
| + String guid3 = mHelper.setCreditCard(card3); |
| + |
| + // The first card has a lower use count that the two other cards. It also has an older |
|
please use gerrit instead
2016/05/16 15:57:46
s/that/than
sebsg
2016/05/19 17:52:03
Done.
|
| + // use date that the second card and the same use date as the |
| + // third. It should be last. |
| + mHelper.setCreditCardUseStats(guid1, 3, 5000); |
| + // The second card has the same use count as the third but a more recent use date. It also |
| + // has a bigger use count that the first card. It should be first. |
| + mHelper.setCreditCardUseStats(guid2, 6, 5001); |
| + // The third card has the same use count as the second but an older use date. It also has a |
| + // bigger use count that the first card. It should be second. |
| + mHelper.setCreditCardUseStats(guid3, 6, 5000); |
| + |
| + assertEquals(3, mHelper.getNumberOfCreditCards()); |
| + |
| + List<CreditCard> cards = mHelper.getCreditCards(); |
| + |
| + assertTrue("Card2 should be ranked first", guid2.equals(cards.get(0).getGUID())); |
| + assertTrue("Card3 should be ranked second", guid3.equals(cards.get(1).getGUID())); |
| + assertTrue("Card1 should be ranked third", guid1.equals(cards.get(2).getGUID())); |
| + } |
| } |