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