Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java |
| index a117f225ee5949f187331eee87f027620e040b90..c3902117ca03e5bf415d9ac239609be2b7f696e6 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestTestBase.java |
| @@ -60,6 +60,15 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA |
| private PaymentRequestUI mUI; |
| private CardUnmaskPrompt mCardUnmaskPrompt; |
| + /** An array mapping the index of a option label to its id. */ |
| + private final int[] mOptionLabelIds = { |
| + R.id.payments_first_option_label, |
| + R.id.payments_second_option_label, |
| + R.id.payments_third_option_label, |
| + R.id.payments_fourth_option_label, |
| + R.id.payments_fifth_option_label |
| + }; |
| + |
| protected PaymentRequestTestBase(String testFileName) { |
| super(ChromeActivity.class); |
| mReadyForInput = new PaymentsCallbackHelper<>(); |
| @@ -206,6 +215,44 @@ abstract class PaymentRequestTestBase extends ChromeActivityTestCaseBase<ChromeA |
| }); |
| } |
| + /** |
| + * Returns the label corresponding to the contact detail suggestion at the specified |
| + * |suggestionIndex|. Returns null if there is no suggestion at |suggestionIndex|. |
| + */ |
| + protected String getContactDetailsSuggestionLabel(final int suggestionIndex) |
| + throws ExecutionException { |
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() { |
| + @Override |
| + public String call() { |
| + if (mUI.getContactDetailsSectionForTest().findViewById( |
|
please use gerrit instead
2016/07/07 13:59:36
Don't call findByView() twice. Save the result and
sebsg
2016/07/08 07:54:52
Done.
|
| + mOptionLabelIds[suggestionIndex]) == null) { |
| + return null; |
| + } |
| + return ((TextView) mUI.getContactDetailsSectionForTest().findViewById( |
| + mOptionLabelIds[suggestionIndex])).getText().toString(); |
| + } |
| + }); |
| + } |
| + |
| + /** |
| + * Returns the label corresponding to the shipping address suggestion at the specified |
| + * |suggestionIndex|. Returns null if there is no suggestion at |suggestionIndex|. |
| + */ |
| + protected String getShippingAddressSuggestionLabel(final int suggestionIndex) |
| + throws ExecutionException { |
| + return ThreadUtils.runOnUiThreadBlocking(new Callable<String>() { |
| + @Override |
| + public String call() { |
| + if (mUI.getShippingAddressSectionForTest().findViewById( |
| + mOptionLabelIds[suggestionIndex]) == null) { |
| + return null; |
| + } |
| + return ((TextView) mUI.getShippingAddressSectionForTest().findViewById( |
| + mOptionLabelIds[suggestionIndex])).getText().toString(); |
| + } |
| + }); |
| + } |
| + |
| /** Selects the spinner value in the editor UI. */ |
| protected void setSpinnerSelectionInEditor(final int selection, CallbackHelper helper) |
| throws InterruptedException, TimeoutException { |