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 android.content.DialogInterface; | 7 import android.content.DialogInterface; |
8 import android.support.test.filters.MediumTest; | 8 import android.support.test.filters.MediumTest; |
9 | 9 |
10 import org.chromium.base.metrics.RecordHistogram; | 10 import org.chromium.base.metrics.RecordHistogram; |
(...skipping 19 matching lines...) Expand all Loading... |
30 public void onMainActivityStarted() | 30 public void onMainActivityStarted() |
31 throws InterruptedException, ExecutionException, TimeoutException { | 31 throws InterruptedException, ExecutionException, TimeoutException { |
32 AutofillTestHelper helper = new AutofillTestHelper(); | 32 AutofillTestHelper helper = new AutofillTestHelper(); |
33 // The user has a valid payer name on disk. | 33 // The user has a valid payer name on disk. |
34 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt
ps://example.com", | 34 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt
ps://example.com", |
35 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", | 35 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "
", "90291", "", |
36 "US", "555-555-5555", "jon.doe@google.com", "en-US")); | 36 "US", "555-555-5555", "jon.doe@google.com", "en-US")); |
37 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 37 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
38 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, | 38 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa, |
39 billingAddressId, "" /* serverId */)); | 39 billingAddressId, "" /* serverId */)); |
| 40 |
| 41 // Add the same profile but with a different address. |
| 42 helper.setProfile(new AutofillProfile("", "https://example.com", true, "
", "Google", |
| 43 "999 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-
555-5555", |
| 44 "jon.doe@google.com", "en-US")); |
| 45 |
| 46 // Add the same profile but without a phone number. |
| 47 helper.setProfile(new AutofillProfile("", "https://example.com", true, "
Jon Doe", "Google", |
| 48 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "" /*
phone_number */, |
| 49 "jon.doe@google.com", "en-US")); |
| 50 |
| 51 // Add the same profile but without an email. |
| 52 helper.setProfile(new AutofillProfile("", "https://example.com", true, "
Jon Doe", "Google", |
| 53 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-
555-5555", |
| 54 "" /* emailAddress */, "en-US")); |
| 55 |
| 56 // Add the same profile but without a name. |
| 57 helper.setProfile(new AutofillProfile("" /* name */, "https://example.co
m", true, "", |
| 58 "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "", "
US", "555-555-5555", |
| 59 "jon.doe@google.com", "en-US")); |
40 } | 60 } |
41 | 61 |
42 /** Provide the existing valid payer name to the merchant. */ | 62 /** Provide the existing valid payer name to the merchant. */ |
43 @MediumTest | 63 @MediumTest |
44 @Feature({"Payments"}) | 64 @Feature({"Payments"}) |
45 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { | 65 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
46 triggerUIAndWait(mReadyToPay); | 66 triggerUIAndWait(mReadyToPay); |
47 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 67 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
48 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 68 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
49 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 69 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
(...skipping 25 matching lines...) Expand all Loading... |
75 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; | 95 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; |
76 setTextInEditorAndWait(new String[] {"Jane Jones"}, mEditorTextUpdate); | 96 setTextInEditorAndWait(new String[] {"Jane Jones"}, mEditorTextUpdate); |
77 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); | 97 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
78 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 98 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
79 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); | 99 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
80 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); | 100 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
81 expectResultContains(new String[] {"Jane Jones"}); | 101 expectResultContains(new String[] {"Jane Jones"}); |
82 } | 102 } |
83 | 103 |
84 /** | 104 /** |
| 105 * Makes sure that suggestions that are equal to or subsets of other suggest
ions are not shown |
| 106 * to the user. |
| 107 */ |
| 108 @MediumTest |
| 109 @Feature({"Payments"}) |
| 110 public void testSuggestionsDeduped() |
| 111 throws InterruptedException, ExecutionException, TimeoutException { |
| 112 triggerUIAndWait(mReadyToPay); |
| 113 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
| 114 assertEquals(1, getNumberOfContactDetailSuggestions()); |
| 115 } |
| 116 |
| 117 /** |
85 * Test that starting a payment request that requires only the user's payer
name results in | 118 * Test that starting a payment request that requires only the user's payer
name results in |
86 * the appropriate metric being logged in the PaymentRequest.RequestedInform
ation histogram. | 119 * the appropriate metric being logged in the PaymentRequest.RequestedInform
ation histogram. |
87 */ | 120 */ |
88 @MediumTest | 121 @MediumTest |
89 @Feature({"Payments"}) | 122 @Feature({"Payments"}) |
90 public void testRequestedInformationMetric() throws InterruptedException, Ex
ecutionException, | 123 public void testRequestedInformationMetric() throws InterruptedException, Ex
ecutionException, |
91 TimeoutException { | 124 TimeoutException { |
92 // Start the Payment Request. | 125 // Start the Payment Request. |
93 triggerUIAndWait(mReadyToPay); | 126 triggerUIAndWait(mReadyToPay); |
94 | 127 |
95 // Make sure that only the appropriate enum value was logged. | 128 // Make sure that only the appropriate enum value was logged. |
96 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { | 129 for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i
) { |
97 assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_NAME
? 1 : 0), | 130 assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_NAME
? 1 : 0), |
98 RecordHistogram.getHistogramValueCountForTesting( | 131 RecordHistogram.getHistogramValueCountForTesting( |
99 "PaymentRequest.RequestedInformation", i)); | 132 "PaymentRequest.RequestedInformation", i)); |
100 } | 133 } |
101 } | 134 } |
102 } | 135 } |
OLD | NEW |