OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
6 | 6 |
7 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 7 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
8 | 8 |
9 import org.junit.Assert; | 9 import org.junit.Assert; |
10 import org.junit.Test; | 10 import org.junit.Test; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 mExpectedPayerEmail = expectedPayerEmail; | 50 mExpectedPayerEmail = expectedPayerEmail; |
51 mExpectedPayerPhone = expectedPayerPhone; | 51 mExpectedPayerPhone = expectedPayerPhone; |
52 } | 52 } |
53 | 53 |
54 @Test | 54 @Test |
55 public void test() { | 55 public void test() { |
56 AutofillProfile profile = new AutofillProfile(); | 56 AutofillProfile profile = new AutofillProfile(); |
57 AutofillContact contact = | 57 AutofillContact contact = |
58 new AutofillContact(profile, mPayerPhone, mPayerEmail, mIsComple
te); | 58 new AutofillContact(profile, mPayerPhone, mPayerEmail, mIsComple
te); |
59 | 59 |
60 Assert.assertEquals( | 60 Assert.assertEquals(mIsComplete, contact.isComplete()); |
61 mIsComplete ? "Contact should be complete" : "Contact should be
incomplete", | 61 Assert.assertEquals(profile, contact.getProfile()); |
62 mIsComplete, contact.isComplete()); | 62 Assert.assertEquals(profile.getGUID(), contact.getIdentifier()); |
63 Assert.assertEquals("Contact's profile should be the same as passed into
the constructor", | 63 assertPhoneEmailLabelSublabel(mExpectedPayerPhone, mExpectedPayerEmail,
mExpectedLabel, |
64 profile, contact.getProfile()); | 64 mExpectedSublabel, contact); |
65 assertIdPhoneEmailLabelSublabel(profile.getGUID(), mExpectedPayerPhone,
mExpectedPayerEmail, | |
66 mExpectedLabel, mExpectedSublabel, contact); | |
67 | 65 |
68 contact.completeContact("some-guid-here", "999-9999", "a@b.com"); | 66 contact.completeContact("999-9999", "a@b.com"); |
69 Assert.assertTrue("Contact should be complete", contact.isComplete()); | 67 Assert.assertTrue(contact.isComplete()); |
70 assertIdPhoneEmailLabelSublabel("some-guid-here", "999-9999", "a@b.com",
"999-9999", | 68 assertPhoneEmailLabelSublabel("999-9999", "a@b.com", "999-9999", "a@b.co
m", contact); |
71 "a@b.com", contact); | |
72 } | 69 } |
73 | 70 |
74 private void assertIdPhoneEmailLabelSublabel(String id, String expectedPhone
, | 71 private void assertPhoneEmailLabelSublabel(String expectedPhone, String expe
ctedEmail, |
75 String expectedEmail, String expectedLabel, String expectedSublabel, | 72 String expectedLabel, String expectedSublabel, AutofillContact actua
l) { |
76 AutofillContact actual) { | |
77 Assert.assertEquals("Identifier should be " + id, id, actual.getIdentifi
er()); | |
78 Assert.assertEquals( | 73 Assert.assertEquals( |
79 "Phone should be " + expectedPhone, expectedPhone, actual.getPay
erPhone()); | 74 "Phone should be " + expectedPhone, expectedPhone, actual.getPay
erPhone()); |
80 Assert.assertEquals( | 75 Assert.assertEquals( |
81 "Email should be " + expectedEmail, expectedEmail, actual.getPay
erEmail()); | 76 "Email should be " + expectedEmail, expectedEmail, actual.getPay
erEmail()); |
82 Assert.assertEquals("Label should be " + expectedLabel, expectedLabel, a
ctual.getLabel()); | 77 Assert.assertEquals("Label should be " + expectedLabel, expectedLabel, a
ctual.getLabel()); |
83 Assert.assertEquals( | 78 Assert.assertEquals( |
84 "Sublabel should be " + expectedSublabel, expectedSublabel, actu
al.getSublabel()); | 79 "Sublabel should be " + expectedSublabel, expectedSublabel, actu
al.getSublabel()); |
85 } | 80 } |
86 } | 81 } |
OLD | NEW |