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 static java.util.Arrays.asList; | 7 import static java.util.Arrays.asList; |
8 | 8 |
9 import android.os.Handler; | 9 import android.os.Handler; |
10 import android.view.KeyEvent; | 10 import android.view.KeyEvent; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 mEditorValidationError = new CallbackHelper(); | 121 mEditorValidationError = new CallbackHelper(); |
122 mEditorTextUpdate = new CallbackHelper(); | 122 mEditorTextUpdate = new CallbackHelper(); |
123 mDismissed = new CallbackHelper(); | 123 mDismissed = new CallbackHelper(); |
124 mUnableToAbort = new CallbackHelper(); | 124 mUnableToAbort = new CallbackHelper(); |
125 mBillingAddressChangeProcessed = new CallbackHelper(); | 125 mBillingAddressChangeProcessed = new CallbackHelper(); |
126 mExpirationMonthChange = new CallbackHelper(); | 126 mExpirationMonthChange = new CallbackHelper(); |
127 mShowFailed = new CallbackHelper(); | 127 mShowFailed = new CallbackHelper(); |
128 mCanMakePaymentQueryResponded = new CallbackHelper(); | 128 mCanMakePaymentQueryResponded = new CallbackHelper(); |
129 mViewCoreRef = new AtomicReference<>(); | 129 mViewCoreRef = new AtomicReference<>(); |
130 mWebContentsRef = new AtomicReference<>(); | 130 mWebContentsRef = new AtomicReference<>(); |
131 mTestFilePath = UrlUtils.getIsolatedTestFilePath( | 131 mTestFilePath = testFileName.startsWith("data:") |
132 String.format("chrome/test/data/payments/%s", testFileName)); | 132 ? testFileName |
| 133 : UrlUtils.getIsolatedTestFilePath( |
| 134 String.format("chrome/test/data/payments/%s", testFile
Name)); |
133 } | 135 } |
134 | 136 |
135 @Override | 137 @Override |
136 public void startMainActivity() throws InterruptedException { | 138 public void startMainActivity() throws InterruptedException { |
137 startMainActivityWithURL(mTestFilePath); | 139 startMainActivityWithURL(mTestFilePath); |
138 } | 140 } |
139 | 141 |
140 protected abstract void onMainActivityStarted() | 142 protected abstract void onMainActivityStarted() |
141 throws InterruptedException, ExecutionException, TimeoutException; | 143 throws InterruptedException, ExecutionException, TimeoutException; |
142 | 144 |
143 protected void triggerUIAndWait(PaymentsCallbackHelper<PaymentRequestUI> hel
per) | 145 protected void triggerUIAndWait(PaymentsCallbackHelper<PaymentRequestUI> hel
per) |
144 throws InterruptedException, ExecutionException, TimeoutException { | 146 throws InterruptedException, ExecutionException, TimeoutException { |
145 openPageAndClickNodeAndWait("buy", helper); | 147 openPageAndClickNodeAndWait("buy", helper); |
146 mUI = helper.getTarget(); | 148 mUI = helper.getTarget(); |
147 } | 149 } |
148 | 150 |
149 protected void openPageAndClickBuyAndWait(CallbackHelper helper) | 151 protected void openPageAndClickBuyAndWait(CallbackHelper helper) |
150 throws InterruptedException, ExecutionException, TimeoutException { | 152 throws InterruptedException, ExecutionException, TimeoutException { |
151 openPageAndClickNodeAndWait("buy", helper); | 153 openPageAndClickNodeAndWait("buy", helper); |
152 } | 154 } |
153 | 155 |
154 protected void triggerUIAndWait(String nodeId, PaymentsCallbackHelper<Paymen
tRequestUI> helper) | 156 protected void triggerUIAndWait(String nodeId, PaymentsCallbackHelper<Paymen
tRequestUI> helper) |
155 throws InterruptedException, ExecutionException, TimeoutException { | 157 throws InterruptedException, ExecutionException, TimeoutException { |
156 openPageAndClickNodeAndWait(nodeId, helper); | 158 openPageAndClickNodeAndWait(nodeId, helper); |
157 mUI = helper.getTarget(); | 159 mUI = helper.getTarget(); |
158 } | 160 } |
159 | 161 |
160 protected void openPageAndClickNodeAndWait(String nodeId, CallbackHelper hel
per) | 162 protected void openPageAndClickNodeAndWait(String nodeId, CallbackHelper hel
per) |
161 throws InterruptedException, ExecutionException, TimeoutException { | 163 throws InterruptedException, ExecutionException, TimeoutException { |
| 164 openPage(); |
| 165 clickNodeAndWait(nodeId, helper); |
| 166 } |
| 167 |
| 168 protected void openPageAndClickNode(String nodeId) |
| 169 throws InterruptedException, ExecutionException, TimeoutException { |
| 170 openPage(); |
| 171 DOMUtils.clickNode(mViewCoreRef.get(), nodeId); |
| 172 } |
| 173 |
| 174 private void openPage() throws InterruptedException, ExecutionException, Tim
eoutException { |
162 onMainActivityStarted(); | 175 onMainActivityStarted(); |
163 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 176 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
164 @Override | 177 @Override |
165 public void run() { | 178 public void run() { |
166 mViewCoreRef.set(getActivity().getCurrentContentViewCore()); | 179 mViewCoreRef.set(getActivity().getCurrentContentViewCore()); |
167 mWebContentsRef.set(mViewCoreRef.get().getWebContents()); | 180 mWebContentsRef.set(mViewCoreRef.get().getWebContents()); |
168 PaymentRequestUI.setObserverForTest(PaymentRequestTestBase.this)
; | 181 PaymentRequestUI.setObserverForTest(PaymentRequestTestBase.this)
; |
169 PaymentRequestImpl.setObserverForTest(PaymentRequestTestBase.thi
s); | 182 PaymentRequestImpl.setObserverForTest(PaymentRequestTestBase.thi
s); |
170 CardUnmaskPrompt.setObserverForTest(PaymentRequestTestBase.this)
; | 183 CardUnmaskPrompt.setObserverForTest(PaymentRequestTestBase.this)
; |
171 } | 184 } |
172 }); | 185 }); |
173 assertWaitForPageScaleFactorMatch(1); | 186 assertWaitForPageScaleFactorMatch(1); |
174 clickNodeAndWait(nodeId, helper); | |
175 } | 187 } |
176 | 188 |
177 protected void reTriggerUIAndWait( | 189 protected void reTriggerUIAndWait( |
178 String nodeId, PaymentsCallbackHelper<PaymentRequestUI> helper) | 190 String nodeId, PaymentsCallbackHelper<PaymentRequestUI> helper) |
179 throws InterruptedException, ExecutionException, TimeoutException { | 191 throws InterruptedException, ExecutionException, TimeoutException { |
180 clickNodeAndWait(nodeId, helper); | 192 clickNodeAndWait(nodeId, helper); |
181 mUI = helper.getTarget(); | 193 mUI = helper.getTarget(); |
182 } | 194 } |
183 | 195 |
184 /** Clicks on an HTML node. */ | 196 /** Clicks on an HTML node. */ |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 List<PaymentItem> displayItems, Map<String, PaymentDetailsModifi
er> modifiers, | 1031 List<PaymentItem> displayItems, Map<String, PaymentDetailsModifi
er> modifiers, |
1020 InstrumentDetailsCallback detailsCallback) { | 1032 InstrumentDetailsCallback detailsCallback) { |
1021 detailsCallback.onInstrumentDetailsReady( | 1033 detailsCallback.onInstrumentDetailsReady( |
1022 mMethodName, "{\"transaction\": 1337}"); | 1034 mMethodName, "{\"transaction\": 1337}"); |
1023 } | 1035 } |
1024 | 1036 |
1025 @Override | 1037 @Override |
1026 public void dismissInstrument() {} | 1038 public void dismissInstrument() {} |
1027 } | 1039 } |
1028 } | 1040 } |
OLD | NEW |