| 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.support.v7.app.AlertDialog; | 7 import android.support.v7.app.AlertDialog; |
| 8 import android.view.View; | 8 import android.view.View; |
| 9 import android.widget.EditText; | 9 import android.widget.EditText; |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 mViewCoreRef.set(getActivity().getCurrentContentViewCore()); | 59 mViewCoreRef.set(getActivity().getCurrentContentViewCore()); |
| 60 mWebContentsRef.set(mViewCoreRef.get().getWebContents()); | 60 mWebContentsRef.set(mViewCoreRef.get().getWebContents()); |
| 61 } | 61 } |
| 62 }); | 62 }); |
| 63 assertWaitForPageScaleFactorMatch(1); | 63 assertWaitForPageScaleFactorMatch(1); |
| 64 DOMUtils.waitForNonZeroNodeBounds(mWebContentsRef.get(), "buy"); | 64 DOMUtils.waitForNonZeroNodeBounds(mWebContentsRef.get(), "buy"); |
| 65 DOMUtils.clickNode(this, mViewCoreRef.get(), "buy"); | 65 DOMUtils.clickNode(this, mViewCoreRef.get(), "buy"); |
| 66 } | 66 } |
| 67 | 67 |
| 68 protected void clickClosePaymentUIButton() throws InterruptedException { | 68 protected void clickClosePaymentUIButton() throws InterruptedException { |
| 69 clickPaymentUIButton("close", R.id.close_button); | 69 clickPaymentUIView("close button", R.id.close_button); |
| 70 } | 70 } |
| 71 | 71 |
| 72 protected void clickSecondaryPaymentUIButton() throws InterruptedException { | 72 protected void clickSecondaryPaymentUIButton() throws InterruptedException { |
| 73 clickPaymentUIButton("secondary", R.id.button_secondary); | 73 clickPaymentUIView("secondary button", R.id.button_secondary); |
| 74 } | 74 } |
| 75 | 75 |
| 76 protected void clickPrimaryPaymentUIButton() throws InterruptedException { | 76 protected void clickPrimaryPaymentUIButton() throws InterruptedException { |
| 77 clickPaymentUIButton("primary", R.id.button_primary); | 77 clickPaymentUIView("primary button", R.id.button_primary); |
| 78 } | 78 } |
| 79 | 79 |
| 80 private void clickPaymentUIButton(final String buttonName, final int resourc
eId) | 80 protected void expandShippingAddressSection() throws InterruptedException { |
| 81 clickPaymentUIView("shipping section", R.id.payments_shipping_section); |
| 82 } |
| 83 |
| 84 protected void selectAnyOptionInExpandedSection() throws InterruptedExceptio
n { |
| 85 clickPaymentUIView("option line", R.id.payments_selectable_option); |
| 86 } |
| 87 |
| 88 private void clickPaymentUIView(final String viewName, final int resourceId) |
| 81 throws InterruptedException { | 89 throws InterruptedException { |
| 82 CriteriaHelper.pollUiThread(new Criteria() { | 90 CriteriaHelper.pollUiThread(new Criteria() { |
| 83 @Override | 91 @Override |
| 84 public boolean isSatisfied() { | 92 public boolean isSatisfied() { |
| 85 PaymentRequestUI ui = PaymentRequestUI.getCurrentUIForTest(); | 93 PaymentRequestUI ui = PaymentRequestUI.getCurrentUIForTest(); |
| 86 if (ui == null) { | 94 if (ui == null) { |
| 87 updateFailureReason("Payment UI was not shown"); | 95 updateFailureReason("Payment UI was not shown"); |
| 88 return false; | 96 return false; |
| 89 } | 97 } |
| 90 | 98 |
| 91 View button = ui.getDialogForTest().findViewById(resourceId); | 99 View button = ui.getDialogForTest().findViewById(resourceId); |
| 92 if (button == null) { | 100 if (button == null) { |
| 93 updateFailureReason( | 101 updateFailureReason( |
| 94 String.format("Cannot find the %s button on payment
UI", buttonName)); | 102 String.format("Cannot find the %s on payment UI", vi
ewName)); |
| 95 return false; | 103 return false; |
| 96 } | 104 } |
| 97 | 105 |
| 98 if (!button.isEnabled()) { | 106 if (!button.isEnabled()) { |
| 99 updateFailureReason( | 107 updateFailureReason( |
| 100 String.format("The %s button on payment UI is disabl
ed", buttonName)); | 108 String.format("The %s on payment UI is disabled", vi
ewName)); |
| 101 return false; | 109 return false; |
| 102 } | 110 } |
| 103 | 111 |
| 104 ui.setShowResultDelayForTest(0); | 112 ui.setShowResultDelayForTest(0); |
| 105 button.performClick(); | 113 button.performClick(); |
| 106 return true; | 114 return true; |
| 107 } | 115 } |
| 108 }); | 116 }); |
| 109 } | 117 } |
| 110 | 118 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 updateFailureReason(e1.getMessage()); | 204 updateFailureReason(e1.getMessage()); |
| 197 return false; | 205 return false; |
| 198 } catch (TimeoutException e2) { | 206 } catch (TimeoutException e2) { |
| 199 updateFailureReason(e2.getMessage()); | 207 updateFailureReason(e2.getMessage()); |
| 200 return false; | 208 return false; |
| 201 } | 209 } |
| 202 } | 210 } |
| 203 }); | 211 }); |
| 204 } | 212 } |
| 205 } | 213 } |
| OLD | NEW |