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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/payments/AutofillContactTest.java

Issue 2583593002: [Payments] Dedupe subsets in contact detail suggestions. (Closed)
Patch Set: Addressed Comments Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 static org.mockito.ArgumentMatchers.anyInt; 7 import static org.mockito.ArgumentMatchers.anyInt;
8 import static org.mockito.Mockito.doReturn; 8 import static org.mockito.Mockito.doReturn;
9 import static org.mockito.Mockito.spy; 9 import static org.mockito.Mockito.spy;
10 10
11 import android.content.Context; 11 import android.content.Context;
12 12
13 import org.junit.Assert; 13 import org.junit.Assert;
14 import org.junit.Test; 14 import org.junit.Test;
15 import org.junit.runner.RunWith; 15 import org.junit.runner.RunWith;
16 import org.robolectric.ParameterizedRobolectricTestRunner; 16 import org.robolectric.ParameterizedRobolectricTestRunner;
17 import org.robolectric.ParameterizedRobolectricTestRunner.Parameters; 17 import org.robolectric.ParameterizedRobolectricTestRunner.Parameters;
18 import org.robolectric.RuntimeEnvironment; 18 import org.robolectric.RuntimeEnvironment;
19 import org.robolectric.annotation.Config; 19 import org.robolectric.annotation.Config;
20 20
21 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; 21 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
22 22
23 import java.util.Arrays; 23 import java.util.Arrays;
24 import java.util.Collection; 24 import java.util.Collection;
25 25
26 /** 26 /**
27 * Unit tests for the AutofillContact class. 27 * Parametrized unit tests for the AutofillContact class.
28 */ 28 */
29 @RunWith(ParameterizedRobolectricTestRunner.class) 29 @RunWith(ParameterizedRobolectricTestRunner.class)
30 @Config(sdk = 21, manifest = Config.NONE) 30 @Config(sdk = 21, manifest = Config.NONE)
31 public class AutofillContactTest { 31 public class AutofillContactTest {
32 @Parameters 32 @Parameters
33 public static Collection<Object[]> data() { 33 public static Collection<Object[]> data() {
34 return Arrays.asList(new Object[][] { 34 return Arrays.asList(new Object[][] {
35 {"Jon Doe", "555-5555", "j@d.co", true, 35 {"Jon Doe", "555-5555", "j@d.co", true,
36 "Jon Doe", "555-5555", "j@d.co", 36 "Jon Doe", "555-5555", "j@d.co",
37 "Jon Doe", "555-5555", "j@d.co"}, 37 "Jon Doe", "555-5555", "j@d.co"},
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 mExpectedTertiaryLabel = expectedTertiaryLabel; 100 mExpectedTertiaryLabel = expectedTertiaryLabel;
101 mExpectedPayerName = expectedPayerName; 101 mExpectedPayerName = expectedPayerName;
102 mExpectedPayerPhone = expectedPayerPhone; 102 mExpectedPayerPhone = expectedPayerPhone;
103 mExpectedPayerEmail = expectedPayerEmail; 103 mExpectedPayerEmail = expectedPayerEmail;
104 } 104 }
105 105
106 @Test 106 @Test
107 public void test() { 107 public void test() {
108 AutofillProfile profile = new AutofillProfile(); 108 AutofillProfile profile = new AutofillProfile();
109 AutofillContact contact = new AutofillContact(mContext, profile, mPayerN ame, mPayerPhone, 109 AutofillContact contact = new AutofillContact(mContext, profile, mPayerN ame, mPayerPhone,
110 mPayerEmail, 110 mPayerEmail, mIsComplete ? ContactEditor.COMPLETE
111 mIsComplete ? ContactEditor.COMPLETE : ContactEditor.INVALID_MUL TIPLE_FIELDS); 111 : ContactEditor.INVALID_NAME | ContactE ditor.INVALID_EMAIL,
112 true, true, true);
112 113
113 Assert.assertEquals( 114 Assert.assertEquals(
114 mIsComplete ? "Contact should be complete" : "Contact should be incomplete", 115 mIsComplete ? "Contact should be complete" : "Contact should be incomplete",
115 mIsComplete, contact.isComplete()); 116 mIsComplete, contact.isComplete());
116 Assert.assertEquals("Contact's profile should be the same as passed into the constructor", 117 Assert.assertEquals("Contact's profile should be the same as passed into the constructor",
117 profile, contact.getProfile()); 118 profile, contact.getProfile());
118 assertContact(profile.getGUID(), mExpectedPayerName, mExpectedPayerPhone , 119 assertContact(profile.getGUID(), mExpectedPayerName, mExpectedPayerPhone ,
119 mExpectedPayerEmail, mExpectedLabel, mExpectedSublabel, mExpecte dTertiaryLabel, 120 mExpectedPayerEmail, mExpectedLabel, mExpectedSublabel, mExpecte dTertiaryLabel,
120 contact); 121 contact);
121 122
(...skipping 18 matching lines...) Expand all
140 Assert.assertEquals("TertiaryLabel should be " + expectedTertiaryLabel, 141 Assert.assertEquals("TertiaryLabel should be " + expectedTertiaryLabel,
141 expectedTertiaryLabel, actual.getTertiaryLabel()); 142 expectedTertiaryLabel, actual.getTertiaryLabel());
142 143
143 Assert.assertEquals("EditTitle should be " + INCOMPLETE_MESSAGE, INCOMPL ETE_MESSAGE, 144 Assert.assertEquals("EditTitle should be " + INCOMPLETE_MESSAGE, INCOMPL ETE_MESSAGE,
144 actual.getEditTitle()); 145 actual.getEditTitle());
145 String editMessage = actual.isComplete() ? null : INCOMPLETE_MESSAGE; 146 String editMessage = actual.isComplete() ? null : INCOMPLETE_MESSAGE;
146 Assert.assertEquals( 147 Assert.assertEquals(
147 "EditMessage should be " + editMessage, editMessage, actual.getE ditMessage()); 148 "EditMessage should be " + editMessage, editMessage, actual.getE ditMessage());
148 } 149 }
149 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698