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.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
8 | 8 |
9 import org.chromium.base.test.util.CommandLineFlags; | 9 import org.chromium.base.test.util.CommandLineFlags; |
10 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
11 import org.chromium.chrome.R; | 11 import org.chromium.chrome.R; |
12 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 12 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
13 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
14 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 14 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
15 | 15 |
16 import java.util.concurrent.ExecutionException; | 16 import java.util.concurrent.ExecutionException; |
17 import java.util.concurrent.TimeoutException; | 17 import java.util.concurrent.TimeoutException; |
18 | 18 |
19 /** | 19 /** |
20 * A payment integration test for checking whether user can make active payment
via a credit card. | 20 * A payment integration test for checking whether user can make a payment via a
credit card. |
21 * This user has a complete credit card on file. | 21 * This user has a complete credit card on file. |
22 */ | 22 */ |
23 @CommandLineFlags.Add("enable-blink-features=CanMakeActivePayment") | 23 @CommandLineFlags.Add("enable-blink-features=CanMakePayment") |
24 public class PaymentRequestCcActivePaymentQueryTest extends PaymentRequestTestBa
se { | 24 public class PaymentRequestCcCanMakePaymentQueryTest extends PaymentRequestTestB
ase { |
25 public PaymentRequestCcActivePaymentQueryTest() { | 25 public PaymentRequestCcCanMakePaymentQueryTest() { |
26 super("payment_request_active_payment_query_cc_test.html"); | 26 super("payment_request_can_make_payment_query_cc_test.html"); |
27 } | 27 } |
28 | 28 |
29 @Override | 29 @Override |
30 public void onMainActivityStarted() throws InterruptedException, ExecutionEx
ception, | 30 public void onMainActivityStarted() throws InterruptedException, ExecutionEx
ception, |
31 TimeoutException { | 31 TimeoutException { |
32 // The user has a complete credit card on file. This is sufficient for | 32 // The user has a complete credit card on file. This is sufficient for |
33 // canMakeActivePayment() to return true. | 33 // canMakePayment() to return true. |
34 AutofillTestHelper helper = new AutofillTestHelper(); | 34 AutofillTestHelper helper = new AutofillTestHelper(); |
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", "", "en-US")); | 37 "US", "555-555-5555", "", "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 } | 41 } |
42 | 42 |
43 @MediumTest | 43 @MediumTest |
44 @Feature({"Payments"}) | 44 @Feature({"Payments"}) |
45 public void testCanMakeActivePayment() throws InterruptedException, Executio
nException, | 45 public void testCanMakePayment() throws InterruptedException, ExecutionExcep
tion, |
46 TimeoutException { | 46 TimeoutException { |
47 openPageAndClickBuyAndWait(mActivePaymentQueryResponded); | 47 openPageAndClickBuyAndWait(mCanMakePaymentQueryResponded); |
48 expectResultContains(new String[]{"true"}); | 48 expectResultContains(new String[]{"true"}); |
49 | 49 |
50 // Repeating a query does not count against the quota. | 50 // Repeating a query does not count against the quota. |
51 clickNodeAndWait("buy", mActivePaymentQueryResponded); | 51 clickNodeAndWait("buy", mCanMakePaymentQueryResponded); |
52 expectResultContains(new String[]{"true"}); | 52 expectResultContains(new String[]{"true"}); |
53 | 53 |
54 clickNodeAndWait("buy", mActivePaymentQueryResponded); | 54 clickNodeAndWait("buy", mCanMakePaymentQueryResponded); |
55 expectResultContains(new String[]{"true"}); | 55 expectResultContains(new String[]{"true"}); |
56 | 56 |
57 // Different queries are throttled for a period of time. | 57 // Different queries are throttled for a period of time. |
58 clickNodeAndWait("other-buy", mActivePaymentQueryResponded); | 58 clickNodeAndWait("other-buy", mCanMakePaymentQueryResponded); |
59 expectResultContains(new String[]{"Query quota exceeded"}); | 59 expectResultContains(new String[]{"Query quota exceeded"}); |
60 | 60 |
61 // Repeating the same query again does not count against the quota. | 61 // Repeating the same query again does not count against the quota. |
62 clickNodeAndWait("buy", mActivePaymentQueryResponded); | 62 clickNodeAndWait("buy", mCanMakePaymentQueryResponded); |
63 expectResultContains(new String[]{"true"}); | 63 expectResultContains(new String[]{"true"}); |
64 } | 64 } |
65 } | 65 } |
OLD | NEW |